/* ============================================
   LudhianaCab — Responsive & Mobile Optimization
   ============================================ */

/* Global Overflow & Grid Containment */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

*, *::before, *::after {
    box-sizing: border-box;
}

h1, h2, h3, h4, h5, h6, p, span, a, li, td, th, div {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* CRITICAL CSS GRID FIX: Prevent Grid Children from Expanding Beyond Viewport */
.content-sidebar-layout > *,
.grid > *,
.grid-2 > *,
.grid-3 > *,
.grid-4 > *,
.travel-needs-grid > *,
.locality-grid > * {
    min-width: 0 !important;
    max-width: 100% !important;
}

/* Content-Sidebar Grid Layout */
.content-sidebar-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-10);
    width: 100%;
    max-width: 100%;
}

/* Mobile Nav Overlay Backdrop */
.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    z-index: 998;
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

body.menu-open {
    overflow: hidden !important;
}

/* Table scroll wrapper */
.fare-table-wrapper {
    position: relative;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-xl);
    width: 100% !important;
    max-width: 100% !important;
    display: block;
}

/* Touch friendly form inputs */
@media (max-width: 768px) {
    .form-input,
    .form-select {
        font-size: 16px !important; /* Prevents auto-zoom on iOS */
        min-height: 48px;
    }
}

/* === Mobile Sticky CTA display control === */
@media (max-width: 768px) {
    .mobile-cta {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1001;
        background: rgba(15, 25, 35, 0.98);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }
    
    body {
        padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
    }
}

/* === Large Screens (<= 1200px) === */
@media (max-width: 1200px) {
    .hero-content {
        gap: var(--space-8);
    }
    .footer-grid {
        grid-template-columns: 1.5fr 1fr 1fr 1fr;
        gap: var(--space-6);
    }
}

/* === Medium Screens & Tablets (<= 992px) === */
@media (max-width: 992px) {
    :root {
        --header-height: 70px;
    }

    .content-sidebar-layout {
        grid-template-columns: 1fr !important;
        gap: var(--space-8);
    }

    .hero-content {
        grid-template-columns: 1fr;
        gap: var(--space-10);
        padding: var(--space-10) 0;
    }

    .hero-text {
        text-align: center;
    }

    .hero-badge {
        margin-left: auto;
        margin-right: auto;
    }

    .hero-buttons {
        justify-content: center;
    }

    .hero-stats {
        justify-content: center;
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-8);
    }

    .nav-menu {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        max-height: calc(100vh - var(--header-height));
        overflow-y: auto;
        background: #0F1923;
        flex-direction: column;
        padding: var(--space-6);
        gap: var(--space-2);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
        transform: translateY(-150%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-menu.active {
        transform: translateY(0);
    }

    .nav-menu a {
        width: 100%;
        padding: var(--space-4);
        font-size: var(--text-base);
        border-radius: var(--radius-lg);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .nav-menu a:last-child {
        border-bottom: none;
    }

    .mobile-toggle {
        display: flex;
    }

    .nav-phone span {
        display: none;
    }
}

/* === Mobile Devices (<= 768px) === */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--space-4) !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Mobile Typography Scale */
    h1 { font-size: 1.65rem !important; line-height: 1.25 !important; }
    h2 { font-size: 1.35rem !important; line-height: 1.3 !important; }
    h3 { font-size: 1.15rem !important; line-height: 1.35 !important; }
    h4 { font-size: 1.0rem !important; }

    .section {
        padding: var(--space-8) 0 !important;
    }

    .section-header {
        margin-bottom: var(--space-6);
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .travel-needs-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-4);
    }

    .page-content {
        padding: var(--space-4) 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .page-content ul {
        padding-left: var(--space-4) !important;
    }

    .page-content li {
        font-size: 0.9rem !important;
        line-height: 1.6 !important;
    }

    /* Fare table touch scrolling */
    .fare-table-wrapper {
        border-radius: var(--radius-lg);
        box-shadow: none;
        border: 1px solid var(--gray-200);
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
    }

    .fare-table {
        min-width: 460px !important; /* Touch swipe table on mobile */
    }

    .fare-table th, 
    .fare-table td {
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
    }

    .fare-table .btn--sm {
        padding: 5px 10px !important;
        font-size: 0.72rem !important;
    }

    /* Package cards vertical stack */
    .package-card {
        flex-direction: column;
        padding: var(--space-5);
        text-align: center;
        align-items: center;
    }

    .package-specs {
        justify-content: center;
    }

    /* Locality grid: 2 columns on mobile */
    .locality-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--space-3) !important;
    }

    .locality-card {
        padding: var(--space-3) var(--space-4) !important;
        font-size: 0.82rem !important;
    }

    .trust-items {
        gap: var(--space-3);
    }

    .trust-item {
        width: 48%;
    }

    .cta-buttons {
        flex-direction: column;
    }

    .cta-buttons .btn {
        width: 100%;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }

    .inline-booking-grid {
        grid-template-columns: 1fr;
    }

    .booking-form {
        padding: var(--space-4) !important;
    }

    .intro-content-block {
        padding: var(--space-5);
    }

    .transport-card {
        padding: var(--space-5);
    }

    .route-hero {
        padding: calc(var(--header-height) + var(--space-4)) 0 var(--space-4);
        text-align: center;
    }

    .route-hero .hero-buttons {
        justify-content: center;
    }

    .card,
    .service-card,
    .vehicle-card,
    .testimonial-card,
    .route-card,
    .feature-card {
        padding: var(--space-4);
    }
}

/* === Small Phones (<= 576px) === */
@media (max-width: 576px) {
    .hero h1 {
        font-size: 1.55rem !important;
    }

    .hero-subtitle {
        font-size: 0.9rem !important;
    }

    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }

    .hero-buttons .btn {
        width: 100%;
    }

    .hero-stats {
        flex-direction: row;
        justify-content: space-around;
        gap: var(--space-2);
        padding-top: var(--space-4);
    }

    .hero-stat-number {
        font-size: 1.2rem;
    }

    .hero-stat-label {
        font-size: 0.7rem;
    }

    .route-hero h1 {
        font-size: 1.35rem !important;
    }

    .route-quick-info {
        flex-direction: column;
        gap: var(--space-2);
    }

    .route-quick-item {
        width: 100%;
        justify-content: center;
    }

    .locality-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
}

/* === Extra Small Mobile (<= 480px) === */
@media (max-width: 480px) {
    .trust-items {
        flex-direction: column;
        align-items: stretch;
    }

    .trust-item {
        width: 100%;
        justify-content: center;
    }

    .nav-cta {
        gap: var(--space-2);
    }

    .nav-cta .btn--whatsapp {
        padding: var(--space-2) var(--space-3);
        font-size: 0.8rem;
    }

    .fare-table th,
    .fare-table td {
        padding: 6px 8px !important;
        font-size: 0.75rem !important;
    }

    .fare-table .btn--sm {
        padding: 4px 6px !important;
        font-size: 0.68rem !important;
    }
}
