/**
 * Mobile Optimized Styles
 * Enhanced responsive design for small screens and touch devices
 */

/* Touch-friendly interface */
@media (max-width: 768px) {
    /* Increase touch target size to minimum 44x44px */
    button, a.btn, input[type="button"], input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }

    /* Large touch targets for navigation */
    .navbar button, .nav-links a {
        padding: 12px 16px;
        min-height: 44px;
    }

    /* Spacing for mobile lists */
    .listings-grid > * {
        margin-bottom: 12px;
    }

    /* Optimized form inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        padding: 12px;
    }

    /* Prevent double-tap zoom on inputs */
    input:focus, textarea:focus, select:focus {
        font-size: 16px;
    }
}

/* Small phones (320px - 375px) */
@media (max-width: 375px) {
    body {
        font-size: 14px;
    }

    .navbar-container {
        padding: 0.5rem 0.25rem;
        padding-left: max(0.5rem, var(--safe-area-inset-left));
        padding-right: max(0.5rem, var(--safe-area-inset-right));
        padding-top: max(0.5rem, var(--safe-area-inset-top));
    }

    .logo {
        font-size: 1.1rem;
    }

    .nav-links {
        width: 100%;
        max-width: 100%;
    }

    .hero {
        min-height: 250px;
        padding: 1rem 0.5rem;
        padding-top: max(1rem, var(--safe-area-inset-top));
    }

    .hero-title {
        font-size: 1.2rem;
        line-height: 1.3;
    }

    .hero-subtitle {
        font-size: 0.8rem;
    }

    .cta-button {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .search-section {
        margin: -0.75rem 0.5rem 1rem;
        padding: 0.75rem;
    }

    .search-box {
        padding: 0.5rem;
        font-size: 14px;
    }

    .listings-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .card {
        border-radius: 8px;
    }

    .card-image {
        height: 150px;
    }

    .card-content {
        padding: 0.5rem;
    }

    .card-title {
        font-size: 0.9rem;
    }

    .card-price {
        font-size: 1rem;
    }

    /* Modal optimizations */
    .modal-content {
        width: 95vw;
        max-width: 100%;
        margin: 40% auto;
        max-height: 90vh;
        border-radius: 12px 12px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        transform: translateY(0);
    }

    .modal-body {
        padding: 0.75rem;
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-body h2 {
        font-size: 1rem;
    }

    .modal-body p {
        font-size: 0.8rem;
    }

    .main-image {
        height: 180px;
    }

    .book-btn,
    .payment-btn,
    .confirm-btn,
    .view-details-btn,
    .access-btn {
        width: 100%;
        padding: 0.5rem;
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }

    /* Gallery optimization */
    .gallery-thumbnails {
        gap: 0.25rem;
    }

    .gallery-thumbnails img {
        height: 40px;
        width: 40px;
    }
}

/* Medium phones (376px - 480px) */
@media (min-width: 376px) and (max-width: 480px) {
    .navbar-container {
        padding-left: max(1rem, var(--safe-area-inset-left));
        padding-right: max(1rem, var(--safe-area-inset-right));
        padding-top: max(0.75rem, var(--safe-area-inset-top));
    }

    .logo {
        font-size: 1.2rem;
    }

    .hero {
        min-height: 270px;
        padding: 1.25rem 1rem;
    }

    .hero-title {
        font-size: 1.3rem;
    }

    .listings-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .modal-content {
        width: 96vw;
        bottom: 0;
    }

    .card-image {
        height: 160px;
    }

    .main-image {
        height: 200px;
    }
}

/* Tablets and above (481px+) */
@media (min-width: 481px) {
    .navbar-container {
        padding-left: max(2rem, var(--safe-area-inset-left));
        padding-right: max(2rem, var(--safe-area-inset-right));
    }
}

/* Performance: Reduce animations on reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .nav-links {
        transition: none;
    }

    .card {
        transform: none !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-light: #1a1a1a;
        --bg-white: #2d2d2d;
        --text-dark: #e0e0e0;
        --text-light: #b0b0b0;
        --border-color: #404040;
    }

    body {
        background-color: var(--bg-light);
        color: var(--text-dark);
    }
}

/* Landscape orientation optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 1rem;
    }

    .hero-title {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }

    .hero-animation {
        display: none;
    }

    .navbar {
        position: relative;
    }

    .nav-links {
        flex-direction: row !important;
        position: static !important;
        background: transparent !important;
        width: auto !important;
        padding: 0 !important;
    }

    .nav-links li {
        border-bottom: none !important;
        padding: 0 0.75rem !important;
    }
}

/* High DPI screen optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .card {
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    }

    button, a.btn {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

/* Safe area support for notch and rounded corners */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, var(--safe-area-inset-left));
        padding-right: max(0px, var(--safe-area-inset-right));
        padding-bottom: max(0px, var(--safe-area-inset-bottom));
    }

    .navbar-container {
        padding-left: max(1rem, var(--safe-area-inset-left));
        padding-right: max(1rem, var(--safe-area-inset-right));
    }

    .modal-content {
        padding-bottom: max(1rem, var(--safe-area-inset-bottom));
    }
}

/* Smooth scrolling with touch devices */
@supports (scroll-behavior: smooth) {
    html {
        scroll-behavior: smooth;
    }
}

/* Optimized images for mobile */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }

    .card-image, .main-image {
        object-fit: cover;
        object-position: center;
    }

    /* Lazy loading hint */
    img[loading="lazy"] {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
    }

    @keyframes loading {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }
}

/* Text optimization */
@media (max-width: 480px) {
    p, li, span {
        word-break: break-word;
        hyphens: auto;
        -webkit-hyphens: auto;
        -moz-hyphens: auto;
    }

    h1, h2, h3, h4, h5, h6 {
        word-break: break-word;
        line-height: 1.3;
    }
}

/* Bottom navigation safe area */
@supports (padding: max(0px)) {
    .footer {
        padding-bottom: max(1rem, var(--safe-area-inset-bottom));
    }
}

/* Link focus states for accessibility */
@media (hover: none) and (pointer: coarse) {
    a:focus-visible, button:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
}
