/* ================================================
   MOBILE & TABLET PERFECTION FIXES
   iOS & Android Optimization
   ================================================ */

/* ==========================================
   1. iOS-SPECIFIC FIXES
   ========================================== */

/* Prevent zoom on input focus (iOS) */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
textarea,
select {
    font-size: 16px !important; /* Prevents iOS zoom */
}

/* Fix iOS Safari bottom bar issues */
@supports (-webkit-touch-callout: none) {
    .property-hero {
        min-height: -webkit-fill-available;
    }
}

/* Smooth momentum scrolling for iOS */
body {
    -webkit-overflow-scrolling: touch;
}

/* Fix iOS button appearance */
button,
input[type="submit"],
.btn {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ==========================================
   2. ANDROID-SPECIFIC FIXES
   ========================================== */

/* Fix Android Chrome address bar */
.property-hero {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for better mobile support */
}

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* ==========================================
   3. TOUCH TARGET OPTIMIZATION
   ========================================== */

/* Ensure all interactive elements meet 48x48px minimum */
.nav-link,
.btn,
.property-buttons a,
.booking-buttons a,
.gallery-item,
.nav-toggle {
    min-height: 48px;
    min-width: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Better tap feedback */
.nav-link,
.btn,
a[class*="btn"] {
    -webkit-tap-highlight-color: rgba(27, 160, 152, 0.2);
    tap-highlight-color: rgba(27, 160, 152, 0.2);
}

/* ==========================================
   4. MOBILE NAVIGATION ENHANCEMENTS
   ========================================== */

@media (max-width: 768px) {
    /* Ensure nav menu doesn't cover content */
    .nav-menu.active {
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better spacing for mobile nav items */
    .nav-link {
        padding: 1rem 0;
        font-size: 1.1rem;
    }
    
    /* Fix dropdown visibility on mobile */
    .nav-dropdown .dropdown-menu {
        position: static;
        display: block;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .nav-dropdown.active .dropdown-menu {
        max-height: 500px;
    }
}

/* ==========================================
   5. HERO SECTION MOBILE OPTIMIZATION
   ========================================== */

@media (max-width: 768px) {
    .property-hero {
        height: 70vh;
        min-height: 500px;
    }
    
    .property-hero-content {
        padding: 1.5rem;
    }
    
    .property-hero-title {
        font-size: clamp(2rem, 6vw, 3rem);
        line-height: 1.2;
        margin-bottom: 0.75rem;
    }
    
    .property-tagline {
        font-size: clamp(1rem, 4vw, 1.25rem);
    }
    
    .property-location-badge {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
}

/* ==========================================
   6. GALLERY OPTIMIZATION
   ========================================== */

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .gallery-item {
        height: 250px;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* Lightbox mobile optimization */
    #lightbox {
        padding: 1rem;
    }
    
    #lightboxImage {
        max-height: 70vh;
        width: auto;
        max-width: 100%;
    }
    
    .lightbox-nav {
        bottom: 20px;
        padding: 0 1rem;
    }
}

/* ==========================================
   7. FORM INPUT OPTIMIZATION
   ========================================== */

@media (max-width: 768px) {
    input,
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 1rem;
        border-radius: 8px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* ==========================================
   8. BUTTON OPTIMIZATION
   ========================================== */

@media (max-width: 768px) {
    .btn,
    .property-buttons a {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        text-align: center;
    }
    
    .booking-buttons {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .booking-buttons a {
        width: 100%;
    }
}

/* ==========================================
   9. CARD LAYOUT OPTIMIZATION
   ========================================== */

@media (max-width: 768px) {
    .property-card,
    .area-card {
        margin-bottom: 1.5rem;
    }
    
    .area-highlights {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }
    
    .area-card-image {
        height: 200px;
    }
}

/* ==========================================
   10. TABLET-SPECIFIC OPTIMIZATIONS (768px - 1024px)
   ========================================== */

@media (min-width: 769px) and (max-width: 1024px) {
    .property-hero {
        height: 60vh;
        min-height: 500px;
    }
    
    .property-hero-title {
        font-size: 3rem;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem;
    }
    
    .area-highlights {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .overview-specs {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================
   11. LANDSCAPE ORIENTATION FIX
   ========================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .property-hero {
        height: 100vh;
        min-height: 400px;
    }
    
    .property-hero-content {
        padding: 1rem;
    }
    
    .property-hero-title {
        font-size: 2rem;
    }
}

/* ==========================================
   12. SAFE AREA INSETS (iPhone X+, Android notch)
   ========================================== */

@supports (padding: max(0px)) {
    .nav,
    .property-hero-content,
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .nav-menu {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ==========================================
   13. IMAGE LOADING OPTIMIZATION
   ========================================== */

img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

@media (max-width: 768px) {
    img[loading="lazy"] {
        content-visibility: auto;
    }
}

/* ==========================================
   14. PREVENT HORIZONTAL SCROLL
   ========================================== */

html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

.container {
    max-width: 100%;
    overflow-x: hidden;
}

/* ==========================================
   15. ACCESSIBILITY ENHANCEMENTS
   ========================================== */

/* Larger tap targets for better accessibility */
@media (max-width: 768px) {
    .nav-toggle {
        padding: 1rem;
        min-width: 60px;
        min-height: 60px;
    }
    
    .nav-toggle span {
        width: 28px;
        height: 3px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn,
    .nav-link {
        border: 2px solid currentColor;
    }
}

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