/**
 * Dream Property Search - Responsive Mobile-First Styles
 * 
 * Sprint 13: Mobile Responsive UI
 * 
 * Mobile-first approach with progressive enhancement.
 * All base styles target mobile (320px+), then scale up for larger screens.
 */

/* ========== BREAKPOINTS ========== */
/* 
 * Mobile: 320px - 767px (base styles, no media query needed)
 * Tablet: 768px - 1023px
 * Desktop: 1024px+
 */

/* ========== MOBILE-FIRST BASE STYLES (320px+) ========== */

/* Container - tighter padding on mobile */
.container {
    padding: 0 12px;
    max-width: 100%;
}

/* Typography - slightly smaller on mobile */
html {
    font-size: 14px; /* 14px base on mobile vs 16px desktop */
}

h1 { font-size: 1.75rem; } /* ~25px */
h2 { font-size: 1.5rem; }  /* ~21px */
h3 { font-size: 1.25rem; } /* ~17px */

/* Touch-friendly minimum sizes (WCAG AAA: 44x44px) */
.btn {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 16px; /* Prevents iOS zoom on focus */
}

.form-input,
.form-select,
.form-textarea {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 16px; /* Prevents iOS zoom on focus */
}

/* Range slider - larger thumb for touch */
.range-slider::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
}

.range-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
}

/* Checkboxes and radio buttons - larger for touch */
input[type="checkbox"],
input[type="radio"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* ========== NAVIGATION ========== */

/* Hide desktop nav on mobile */
.navbar-nav.desktop-nav {
    display: none;
}

/* Mobile hamburger button */
.mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-color);
}

.hamburger-icon {
    display: block;
    width: 24px;
    height: 2px;
    background: currentColor;
    position: relative;
}

.hamburger-icon::before,
.hamburger-icon::after {
    content: '';
    display: block;
    width: 24px;
    height: 2px;
    background: currentColor;
    position: absolute;
    left: 0;
    transition: transform 0.3s ease;
}

.hamburger-icon::before {
    top: -7px;
}

.hamburger-icon::after {
    top: 7px;
}

/* Animate hamburger to X when open */
.mobile-menu-toggle.active .hamburger-icon {
    background: transparent;
}

.mobile-menu-toggle.active .hamburger-icon::before {
    transform: rotate(45deg);
    top: 0;
}

.mobile-menu-toggle.active .hamburger-icon::after {
    transform: rotate(-45deg);
    top: 0;
}

/* Mobile menu overlay */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: var(--background-color);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: var(--z-index-modal);
    transition: right 0.3s ease;
    overflow-y: auto;
}

.mobile-menu.open {
    right: 0;
}

/* Mobile menu backdrop */
.mobile-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-index-modal) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

/* Mobile menu close button */
.mobile-menu-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Mobile nav links */
.mobile-nav-links {
    list-style: none;
    padding: 60px 20px 20px;
    margin: 0;
}

.mobile-nav-links li {
    margin-bottom: 8px;
}

.mobile-nav-links a {
    display: block;
    padding: 12px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 18px;
    font-weight: var(--font-weight-medium);
    border-radius: var(--border-radius-md);
    transition: background-color 0.2s ease;
}

.mobile-nav-links a:hover {
    background-color: var(--background-secondary);
    text-decoration: none;
}

/* ========== GRIDS ========== */

/* All grids stack to single column on mobile */
.grid-cols-2,
.grid-cols-3,
.grid-cols-4,
.filter-grid {
    grid-template-columns: 1fr;
    gap: 12px;
}

/* Results grid - single column on mobile */
.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* ========== PROPERTY CARDS ========== */

.property-card {
    width: 100%;
}

.property-image {
    height: 220px; /* Slightly taller on mobile for better viewing */
}

.property-details {
    flex-wrap: wrap;
}

/* ========== FILTER SECTIONS ========== */

.filter-section {
    padding: 16px;
    margin-bottom: 16px;
}

/* Collapsible filter sections on mobile */
.filter-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.filter-section-header .chevron {
    font-size: 12px;
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.filter-section.collapsed .filter-grid {
    display: none;
    margin-top: 0;
}

.filter-section.collapsed .chevron {
    transform: rotate(-90deg);
}

.filter-section-title {
    margin-bottom: 12px;
}

/* ========== STICKY SEARCH BUTTON ========== */

.search-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--background-color);
    border-top: 1px solid var(--border-color);
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)); /* iPhone notch */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: var(--z-index-sticky);
}

.btn-block {
    display: block;
    width: 100%;
    margin-bottom: 8px;
}

.btn-block:last-child {
    margin-bottom: 0;
}

/* Add bottom padding to form to prevent overlap with sticky button */
#search-form {
    padding-bottom: 160px;
}

/* ========== ALERTS & MESSAGES ========== */

.alert {
    padding: 12px;
    font-size: 14px;
}

/* ========== NAVBAR ========== */

.navbar {
    padding: 12px 0;
}

.navbar-brand {
    font-size: 18px;
}

/* ========== CARDS ========== */

.card {
    padding: 16px;
}

/* ========== FOOTER ========== */

footer {
    padding: 24px 0;
    font-size: 13px;
}

/* ========== UTILITY CLASSES ========== */

/* Show/hide on mobile */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

/* ========== TABLET (768px - 1023px) ========== */

@media (min-width: 768px) {
    /* Container - more padding on tablet */
    .container {
        padding: 0 24px;
    }
    
    /* Typography - back to normal size */
    html {
        font-size: 16px;
    }
    
    h1 { font-size: var(--font-size-4xl); }
    h2 { font-size: var(--font-size-3xl); }
    h3 { font-size: var(--font-size-2xl); }
    
    /* Grids - 2 columns on tablet */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    /* Filter sections - no longer collapsible */
    .filter-section-header {
        cursor: default;
    }
    
    .filter-section-header .chevron {
        display: none;
    }
    
    .filter-section.collapsed .filter-grid {
        display: grid;
    }
    
    /* Sticky button - not sticky on tablet */
    .search-actions {
        position: static;
        padding: 20px 0;
        box-shadow: none;
        border-top: none;
        display: flex;
        justify-content: center;
        gap: 16px;
    }
    
    .btn-block {
        width: auto;
        min-width: 200px;
        margin-bottom: 0;
    }
    
    #search-form {
        padding-bottom: 0;
    }
    
    /* Property image - back to normal height */
    .property-image {
        height: 200px;
    }
}

/* ========== DESKTOP (1024px+) ========== */

@media (min-width: 1024px) {
    /* Container - full width with max */
    .container {
        max-width: 1200px;
        padding: 0 32px;
        margin: 0 auto;
    }
    
    /* Show desktop nav, hide mobile */
    .navbar-nav.desktop-nav {
        display: flex;
    }
    
    .mobile-menu-toggle {
        display: none;
    }
    
    /* Grids - full column count on desktop */
    .grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .filter-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 20px;
    }
    
    .results-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
    
    /* Utility classes */
    .mobile-only {
        display: none;
    }
    
    .desktop-only {
        display: block;
    }
    
    /* Filter sections - larger padding */
    .filter-section {
        padding: 24px;
    }
    
    /* Cards - larger padding */
    .card {
        padding: 24px;
    }
    
    /* Navbar */
    .navbar {
        padding: 16px 0;
    }
    
    .navbar-brand {
        font-size: 24px;
    }
}

/* ========== LARGE DESKTOP (1280px+) ========== */

@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
    }
}

/* ========== PRINT STYLES ========== */

@media print {
    .navbar,
    .search-actions,
    .mobile-menu,
    .mobile-menu-backdrop {
        display: none;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
}

/* ========== REDUCED MOTION ========== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========== HIGH CONTRAST MODE ========== */

@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        border: 2px solid var(--text-color);
    }
}


