/**
 * ENTROTERRA - Mobile Responsiveness Polish
 * Optimized for phones (320px+), tablets (768px+), and desktops (1024px+)
 */

/* ==========================================
   MOBILE-FIRST BASE STYLES
   ========================================== */

/* Prevent horizontal overflow */
body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Better text rendering on all devices */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Touch-friendly tap targets ONLY on mobile/tablet (< 1024px) */
@media (max-width: 1023px) {
    button:not(.gallery-dot):not(.gallery-prev):not(.gallery-next):not(.contact-modal-close),
    a:not(.gallery-dot) {
        min-height: 44px;
    }
    
    input, select, textarea {
        min-height: 44px;
    }
}

/* ==========================================
   MOBILE NAVIGATION (< 768px)
   ========================================== */

@media (max-width: 767px) {
    /* Hide desktop nav, show mobile nav */
    nav[style*="display: none"] {
        display: none !important;
    }
    
    .mobile-nav {
        display: flex !important;
    }
    
    /* Mobile hamburger menu */
    .mobile-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        padding: 1rem;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        z-index: 999;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .mobile-menu.active {
        max-height: 500px;
    }
    
    .mobile-menu a {
        display: flex;
        align-items: center;
        padding: 1rem;
        font-size: 1.1rem;
        gap: 1rem;
        border-radius: 8px;
        transition: background 0.2s;
    }
    
    .mobile-menu a:hover {
        background: rgba(107, 159, 92, 0.1);
    }
}

/* ==========================================
   PROPERTY CARDS - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .property-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
        padding: 1rem !important;
    }
    
    .property-card {
        max-width: 100%;
    }
    
    .property-gallery {
        height: 250px !important;
    }
    
    .gallery-prev,
    .gallery-next {
        width: 36px !important;
        height: 36px !important;
        font-size: 1rem !important;
    }
    
    .gallery-dots {
        gap: 0.5rem !important;
    }
    
    .gallery-dot {
        width: 8px !important;
        height: 8px !important;
    }
}

/* ==========================================
   EXPERIENCES PAGE - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .hero-section {
        padding: 2rem 1rem !important;
    }
    
    .hero-section h1 {
        font-size: 2.5rem !important;
        line-height: 1.2 !important;
    }
    
    .hero-section p {
        font-size: 1rem !important;
    }
    
    /* Filter buttons stack on mobile */
    .filter-btn {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Experiences grid - TWO columns, COMPACT */
    #experiences-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
        padding: 0 1rem !important;
    }
    
    .experience-card {
        margin: 0 !important;
        max-height: 300px !important;
    }
    
    .experience-card img {
        height: 140px !important;
        object-fit: cover !important;
    }
    
    .experience-card > div:last-child {
        padding: 0.75rem !important;
    }
    
    .experience-card h3 {
        font-size: 1rem !important;
        margin-bottom: 0.35rem !important;
    }
    
    .experience-card p {
        font-size: 0.75rem !important;
        line-height: 1.4 !important;
        margin-bottom: 0.75rem !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .experience-card a {
        font-size: 0.8rem !important;
    }
    
    .experience-image {
        height: 160px !important;
    }
    
    /* Extended Stays - Stack vertically on mobile */
    .extended-stays-card-horizontal {
        grid-template-columns: 1fr !important;
        min-height: auto !important;
        max-height: none !important;
    }
    
    .extended-stays-image-horizontal {
        height: 180px !important;
        min-height: 180px !important;
    }
    
    .extended-stays-content {
        padding: 1.5rem !important;
        gap: 1rem !important;
    }
    
    .extended-stays-title {
        font-size: 1.5rem !important;
    }
    
    .extended-stays-subtitle {
        font-size: 0.85rem !important;
    }
    
    .extended-stays-description {
        font-size: 0.85rem !important;
        line-height: 1.6 !important;
    }
    
    .extended-stays-features {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    .extended-feature {
        font-size: 0.85rem !important;
    }
}

/* ==========================================
   BOOKING CALENDAR - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .booking-calendar {
        max-width: 100% !important;
        padding: 1rem !important;
        margin: 0 !important;
    }
    
    .calendar-header {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }
    
    .calendar-header h3 {
        font-size: 1.25rem !important;
    }
    
    .calendar-nav button {
        width: 36px !important;
        height: 36px !important;
    }
    
    .days-grid {
        gap: 0.25rem !important;
    }
    
    .day {
        font-size: 0.875rem !important;
        padding: 0.5rem !important;
        min-height: 40px !important;
    }
    
    .weekday {
        font-size: 0.75rem !important;
    }
    
    /* Booking summary sidebar becomes bottom card */
    .booking-summary {
        position: relative !important;
        width: 100% !important;
        margin-top: 2rem !important;
    }
}

/* ==========================================
   CHECKOUT PAGE - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .checkout-container {
        flex-direction: column !important;
        padding: 1rem !important;
    }
    
    .checkout-form,
    .checkout-summary {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }
    
    .payment-method {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .summary-row {
        font-size: 0.9rem !important;
    }
    
    .deposit-highlight {
        font-size: 1.25rem !important;
    }
    
    .submit-button {
        padding: 1rem !important;
        font-size: 1.125rem !important;
    }
}

/* ==========================================
   ADMIN DASHBOARD - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .sidebar {
        position: fixed;
        left: -280px;
        transition: left 0.3s ease;
        z-index: 2000;
    }
    
    .sidebar.mobile-open {
        left: 0;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 1rem !important;
    }
    
    .page-header h2 {
        font-size: 2rem !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .stat-card {
        padding: 1rem !important;
    }
    
    .stat-value {
        font-size: 1.5rem !important;
    }
    
    /* Table scrolls horizontally */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
        font-size: 0.875rem;
    }
    
    th, td {
        padding: 0.75rem 0.5rem !important;
        white-space: nowrap;
    }
}

/* ==========================================
   TYPOGRAPHY - MOBILE SCALING
   ========================================== */

@media (max-width: 767px) {
    h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    h2 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    h3 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    p, li, a {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }
    
    .btn-primary,
    .contact-btn {
        padding: 0.875rem 1.25rem !important;
        font-size: 1rem !important;
    }
}

/* ==========================================
   HOMEPAGE HERO - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .hero-section {
        height: 70vh !important;
        margin-top: 60px !important;
    }
    
    /* Fix trailing bar - ensure hero fills properly */
    section[style*="margin-top: 100px"] {
        margin-top: 60px !important;
    }
    
    .hero-title {
        font-size: 2.5rem !important;
        line-height: 1.1 !important;
    }
    
    .hero-subtitle {
        font-size: 1.75rem !important;
    }
    
    .hero-content {
        padding: 1.5rem !important;
    }
    
    .hero-content p {
        font-size: 1rem !important;
    }
}

/* ==========================================
   PROPERTY PAGE - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .property-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }
    
    .property-title {
        font-size: 2rem !important;
    }
    
    .property-price {
        font-size: 1.25rem !important;
    }
    
    .photo-gallery-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    .photo-gallery-grid > div:first-child {
        grid-row: 1 !important;
        height: 300px !important;
    }
    
    .photo-gallery-grid > div {
        height: 200px !important;
    }
    
    .amenities-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
}

/* ==========================================
   MODAL & OVERLAY - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .photo-modal {
        padding: 0 !important;
    }
    
    .photo-modal-content {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
    }
    
    .photo-modal-nav {
        width: 44px !important;
        height: 44px !important;
    }
    
    .photo-modal-close {
        top: 1rem !important;
        right: 1rem !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 1.5rem !important;
    }
}

/* ==========================================
   TOAST NOTIFICATIONS - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .toast-notification {
        left: 1rem !important;
        right: 1rem !important;
        width: auto !important;
        font-size: 0.9rem !important;
        padding: 1rem !important;
    }
}

/* ==========================================
   FORM INPUTS - MOBILE OPTIMIZATION
   ========================================== */

@media (max-width: 767px) {
    /* Prevent iOS zoom on input focus */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    /* Better date picker on mobile */
    input[type="date"] {
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Better select on mobile */
    select {
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B9F5C' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 1rem center;
        padding-right: 3rem !important;
    }
}

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

@media (min-width: 768px) and (max-width: 1023px) {
    .property-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 2rem !important;
    }
    
    #experiences-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .main-content {
        padding: 1.5rem !important;
    }
}

/* ==========================================
   LANDSCAPE MOBILE (480px+)
   ========================================== */

@media (min-width: 480px) and (max-width: 767px) {
    .property-grid {
        padding: 1.5rem !important;
    }
    
    .hero-title {
        font-size: 3rem !important;
    }
    
    .filter-btn {
        padding: 0.75rem 1.25rem !important;
    }
}

/* ==========================================
   LOADING STATES - MOBILE
   ========================================== */

@media (max-width: 767px) {
    .skeleton-card {
        margin-bottom: 1.5rem;
    }
    
    .loading-overlay {
        padding: 2rem;
    }
    
    .spinner-large {
        width: 36px !important;
        height: 36px !important;
    }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .property-card,
    .experience-card,
    .stat-card {
        border: 2px solid #000 !important;
    }
    
    button,
    .btn-primary {
        border: 2px solid #000 !important;
    }
}

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

/* ==========================================
   PRINT STYLES (Bonus)
   ========================================== */

@media print {
    .mobile-nav,
    .mobile-menu,
    nav,
    .gallery-prev,
    .gallery-next,
    .btn-primary,
    .contact-btn,
    footer {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .property-card,
    .experience-card {
        page-break-inside: avoid;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }
}
