/*
 * HomeMate Africa - Comprehensive Responsive Fixes
 * Applies to ALL pages - Desktop, Tablet, and Mobile
 * Bootstrap-compatible responsive enhancements
 */

/* ============================================
   GLOBAL RESPONSIVE FOUNDATION
   ============================================ */

/* Ensure proper viewport behavior */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    min-width: 320px;
}

/* Container responsiveness */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .container { max-width: 540px; }
}

@media (min-width: 768px) {
    .container { max-width: 720px; }
}

@media (min-width: 992px) {
    .container { max-width: 960px; }
}

@media (min-width: 1200px) {
    .container { max-width: 1140px; }
}

@media (min-width: 1400px) {
    .container { max-width: 1320px; }
}

/* ============================================
   NAVIGATION - FULLY RESPONSIVE
   ============================================ */

/* Logo - Keep Horizontal on All Devices */
.navbar-brand {
    white-space: nowrap !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
}

.navbar-brand span {
    white-space: nowrap !important;
}

/* Desktop: Horizontal Navigation (992px and above) */
@media (min-width: 992px) {
    .navbar-expand-lg .navbar-nav {
        flex-direction: row !important;
    }
    
    .navbar-expand-lg .navbar-nav .nav-item {
        display: inline-block;
    }
    
    .navbar-expand-lg .navbar-collapse {
        display: flex !important;
        flex-basis: auto;
    }
    
    .navbar .d-flex {
        flex-direction: row !important;
        align-items: center;
    }
}

/* Tablet and Mobile: Vertical Navigation (below 992px) */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background: white;
        border-radius: 8px;
        margin-top: 1rem;
        padding: 1rem;
        box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    }
    
    .navbar-nav {
        flex-direction: column !important;
        width: 100%;
    }
    
    .navbar-nav .nav-item {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        width: 100%;
        display: block;
    }
    
    .navbar .d-flex {
        flex-direction: column !important;
        width: 100%;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .navbar .d-flex .btn,
    .navbar .d-flex .dropdown {
        width: 100%;
    }
    
    .navbar .d-flex .dropdown-toggle {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   PROPERTIES GRID - ADAPTIVE COLUMNS
   ============================================ */

/* Desktop: 3 columns */
@media (min-width: 1200px) {
    .properties-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 2rem;
    }
}

/* Laptop/Tablet Landscape: 2 columns */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .properties-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem;
    }
}

/* Tablet Portrait and Mobile: 1 column */
@media (max-width: 767.98px) {
    .properties-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1.25rem;
    }
}

/* ============================================
   SEARCH FILTERS - RESPONSIVE LAYOUT
   ============================================ */

/* Desktop: Horizontal filters */
@media (min-width: 992px) {
    .main-search-bar {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-end;
        gap: 0.75rem;
        flex-wrap: wrap;
    }
    
    .search-input-group {
        flex: 1 1 300px;
        min-width: 250px;
    }
    
    .inline-filter-group {
        display: flex;
        align-items: flex-end;
        gap: 0.5rem;
    }
    
    .top-filters {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}

/* Tablet: 2-column filter layout */
@media (min-width: 576px) and (max-width: 991.98px) {
    .main-search-bar {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    
    .search-input-group {
        width: 100%;
    }
    
    .inline-filter-group {
        display: flex;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .inline-filter-select {
        flex: 1 1 calc(50% - 0.375rem);
        min-width: 150px;
    }
    
    .top-filters {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

/* Mobile: Stacked filters */
@media (max-width: 575.98px) {
    .main-search-bar {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .search-input-group {
        width: 100%;
    }
    
    .inline-filter-group {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .inline-filter-select,
    .inline-reset-btn {
        width: 100%;
    }
    
    .top-filters {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .top-filter-group {
        width: 100%;
    }
}

/* ============================================
   PROPERTY CARDS - RESPONSIVE
   ============================================ */

.property-listing-card {
    width: 100%;
    max-width: 100%;
}

/* Desktop */
@media (min-width: 992px) {
    .property-image-container {
        height: 280px;
    }
    
    .property-content {
        padding: 1.5rem;
    }
    
    .property-price {
        font-size: 1.5rem;
    }
    
    .property-title {
        font-size: 1.25rem;
    }
}

/* Tablet */
@media (min-width: 576px) and (max-width: 991.98px) {
    .property-image-container {
        height: 250px;
    }
    
    .property-content {
        padding: 1.25rem;
    }
    
    .property-price {
        font-size: 1.35rem;
    }
    
    .property-title {
        font-size: 1.15rem;
    }
}

/* Mobile */
@media (max-width: 575.98px) {
    .property-image-container {
        height: 220px;
    }
    
    .property-content {
        padding: 1rem;
    }
    
    .property-price {
        font-size: 1.25rem;
    }
    
    .property-title {
        font-size: 1.1rem;
    }
    
    .property-meta {
        font-size: 0.85rem;
    }
}

/* ============================================
   BUTTONS AND FORMS - MOBILE FRIENDLY
   ============================================ */

@media (max-width: 575.98px) {
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .btn-sm {
        padding: 0.35rem 0.75rem;
        font-size: 0.8rem;
    }
    
    /* Form inputs full width on mobile */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    select,
    textarea {
        width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ============================================
   HERO SECTION - RESPONSIVE
   ============================================ */

/* Desktop */
@media (min-width: 992px) {
    .hero-section {
        padding: 6rem 0;
    }
    
    .hero-section h1 {
        font-size: 3rem;
    }
    
    .hero-section p {
        font-size: 1.25rem;
    }
}

/* Tablet */
@media (min-width: 576px) and (max-width: 991.98px) {
    .hero-section {
        padding: 4rem 0;
    }
    
    .hero-section h1 {
        font-size: 2.25rem;
    }
    
    .hero-section p {
        font-size: 1.1rem;
    }
}

/* Mobile */
@media (max-width: 575.98px) {
    .hero-section {
        padding: 2.5rem 0;
    }
    
    .hero-section h1 {
        font-size: 1.75rem;
    }
    
    .hero-section p {
        font-size: 1rem;
    }
}

/* ============================================
   FOOTER - RESPONSIVE
   ============================================ */

/* Desktop: 4 columns */
@media (min-width: 992px) {
    footer .row > div {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

/* Tablet: 2 columns */
@media (min-width: 576px) and (max-width: 991.98px) {
    footer .row > div {
        flex: 0 0 50%;
        max-width: 50%;
        margin-bottom: 2rem;
    }
}

/* Mobile: 1 column */
@media (max-width: 575.98px) {
    footer .row > div {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 2rem;
    }
    
    footer {
        text-align: center;
    }
    
    footer ul {
        padding-left: 0;
        list-style: none;
    }
}

/* ============================================
   TABLES - RESPONSIVE
   ============================================ */

@media (max-width: 767.98px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    table th,
    table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
}

/* ============================================
   MODALS - MOBILE ADJUSTMENTS
   ============================================ */

@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
    }
}

/* ============================================
   DASHBOARD/ADMIN SECTIONS
   ============================================ */

@media (max-width: 767.98px) {
    .dashboard-card {
        margin-bottom: 1rem;
    }
    
    .stats-card {
        margin-bottom: 1rem;
    }
    
    /* Stack action buttons vertically on mobile */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
}

/* ============================================
   UTILITY CLASSES - RESPONSIVE SPACING
   ============================================ */

/* Reduce spacing on mobile */
@media (max-width: 575.98px) {
    .py-5 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
    .my-5 { margin-top: 2rem !important; margin-bottom: 2rem !important; }
    .py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
    .my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }
}

/* ============================================
   IMAGE OPTIMIZATION
   ============================================ */

img {
    max-width: 100%;
    height: auto;
}

/* Prevent layout shift */
.property-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   TOUCH-FRIENDLY INTERACTIONS
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    /* Mobile touch targets should be at least 44px */
    .btn,
    .nav-link,
    a.card {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    .property-listing-card:hover {
        transform: none;
    }
}

/* ============================================
   ACCESSIBILITY - HIGH CONTRAST
   ============================================ */

@media (prefers-contrast: high) {
    .btn {
        border-width: 2px;
    }
    
    .card {
        border-width: 2px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .navbar,
    .footer,
    .btn,
    .search-form,
    .filters {
        display: none !important;
    }
    
    .container {
        max-width: none !important;
    }
    
    .property-listing-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ============================================
   PROPERTY DETAILS PAGE - RESPONSIVE
   ============================================ */

@media (max-width: 767.98px) {
    .property-details-gallery {
        height: 300px;
    }
    
    .property-details-info {
        padding: 1rem;
    }
    
    .property-details-sidebar {
        margin-top: 2rem;
    }
}

/* ============================================
   FORM PAGES - RESPONSIVE
   ============================================ */

@media (max-width: 575.98px) {
    .form-container {
        padding: 1rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .multi-step-form .step-indicator {
        font-size: 0.85rem;
    }
}
