/* ============================================
   MOBILE OPTIMIZATION STYLESHEET
   Priority: Load AFTER all other stylesheets
   ============================================ */

/* CORE MOBILE RESETS */
@media (max-width: 1024px) {

    /* Prevent horizontal scroll */
    html,
    body {
        overflow-x: hidden;
        max-width: 100vw;
        position: relative;
    }

    /* Force all containers to respect viewport */
    * {
        max-width: 100%;
    }

    /* Fix navigation on mobile */
    .nav-compact-container {
        padding: 0 1rem;
        height: 70px;
    }

    .logo-compact-premium img {
        height: 40px;
    }

    /* Ensure mobile menu button is visible and clickable */
    .mobile-menu-btn-compact {
        display: flex !important;
        z-index: 100;
        position: relative;
    }

    /* Hide desktop navigation */
    .nav-links-compact,
    .cta-compact-premium {
        display: none !important;
    }

    /* Mobile Menu Overlay - CRITICAL FIX */
    #mobile-menu-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.7);
        z-index: 60;
        backdrop-filter: blur(4px);
        transition: opacity 0.3s ease;
    }

    #mobile-menu-overlay.hidden {
        opacity: 0;
        pointer-events: none;
    }

    /* Mobile Menu Content - CRITICAL FIX */
    #mobile-menu-content {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 85%;
        max-width: 320px;
        background: #ffffff;
        z-index: 70;
        transform: translateX(0);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
    }

    #mobile-menu-content.translate-x-full {
        transform: translateX(100%);
    }

    /* Mobile menu links styling */
    .mobile-sublink-elite {
        display: block;
        padding: 0.75rem 1rem;
        color: #64748b;
        font-size: 0.875rem;
        transition: all 0.2s;
        border-left: 3px solid transparent;
    }

    .mobile-sublink-elite:hover,
    .mobile-sublink-elite:active {
        background: rgba(69, 205, 211, 0.1);
        border-left-color: #45CDD3;
        color: #0a1e2e;
    }

    /* HERO SECTION - MOBILE */
    .hero-compact-premium {
        min-height: 90vh;
        /* Increased height for mobile */
        padding-top: 100px;
        /* Reset padding */
    }

    .hero-compact-content {
        padding: 45vh 1rem 3rem 1rem;
        /* Push content down to reveal image */
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        height: 100%;
        background: linear-gradient(to top, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0.8) 40%, rgba(15, 23, 42, 0) 100%);
        /* distinct gradient for text readability */
    }

    /* Ensure image focuses on faces/top-center */
    .hero-slide {
        object-position: top center !important;
    }

    .hero-compact-inner {
        max-width: 100%;
        gap: 1.25rem;
    }

    .hero-badge-compact {
        font-size: 0.625rem;
        padding: 0.4rem 0.875rem;
        align-self: flex-start;
    }

    /* Hide the default desktop overlay on mobile since we use content gradient */
    .hero-compact-overlay {
        display: none;
    }

    .hero-heading-compact {
        font-size: 2rem !important;
        line-height: 1.2;
    }

    .hero-description-compact {
        font-size: 1rem;
        line-height: 1.6;
    }

    .hero-cta-group {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }

    .hero-cta-primary,
    .hero-cta-secondary {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1.5rem;
        font-size: 0.875rem;
    }

    .hero-stats-compact {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1.5rem;
        margin-top: 1.5rem;
        padding-top: 1.5rem;
    }

    .hero-stat-item {
        flex: 0 0 calc(50% - 0.75rem);
    }

    .hero-stat-number {
        font-size: 1.25rem;
    }

    .hero-stat-label {
        font-size: 0.7rem;
    }

    /* SECTIONS - MOBILE */
    .section-compact-premium,
    .section-premium {
        padding: 2.5rem 1rem;
    }

    .section-title-compact {
        font-size: 1.75rem !important;
    }

    .section-description-compact {
        font-size: 0.9rem;
    }

    /* GRIDS - MOBILE */
    .grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    /* Services grid */
    .service-card-compact {
        margin-bottom: 1rem;
    }

    /* IMAGES - MOBILE */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Content blocks */
    .content-block-compact {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    /* FOOTER - MOBILE */
    .footer-compact-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem;
    }

    .footer-compact-premium {
        padding: 2rem 0 1rem;
    }

    .footer-compact-container {
        padding: 0 1rem;
    }

    .footer-bottom-compact {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-legal-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* INSURANCE SECTION - MOBILE */
    .insurance-grid-compact {
        gap: 1rem;
    }

    .insurance-card-compact {
        min-width: 140px;
        padding: 1rem 1.5rem;
        height: 80px;
    }

    .insurance-logo-compact {
        max-height: 35px;
        max-width: 110px;
    }

    /* TEXT SIZING - MOBILE */
    h1 {
        font-size: 1.875rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.25rem !important;
    }

    p {
        font-size: 0.938rem;
    }

    /* BLOG CARDS - MOBILE */
    .blog-card {
        margin-bottom: 1.5rem;
    }

    /* WELLNESS BOT - MOBILE ADJUSTMENT */
    #wb-float-btn {
        bottom: 1.5rem;
        right: 1.5rem;
        padding: 1rem;
    }

    #wb-window {
        width: calc(100vw - 2rem) !important;
        height: calc(100vh - 4rem) !important;
        bottom: 1rem;
        right: 1rem;
    }
}

/* SMALL MOBILE (phones) */
@media (max-width: 640px) {
    .hero-heading-compact {
        font-size: 1.75rem !important;
    }

    .hero-stats-compact {
        flex-direction: column;
        align-items: flex-start;
    }

    .hero-stat-item {
        flex: none;
        width: 100%;
    }

    .nav-compact-container {
        height: 65px;
        padding: 0 0.875rem;
    }

    .logo-compact-premium img {
        height: 36px;
    }

    #mobile-menu-content {
        width: 90%;
    }

    /* Stack all grid items on very small screens */
    [class*="grid-cols"] {
        grid-template-columns: 1fr !important;
    }

    /* Reduce padding everywhere */
    .section-compact-premium,
    .section-premium {
        padding: 2rem 0.875rem;
    }

    /* Smaller typography */
    .section-title-compact {
        font-size: 1.5rem !important;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }
}

/* MEDIUM TO LARGE TABLETS */
@media (min-width: 768px) and (max-width: 1024px) {
    .hero-heading-compact {
        font-size: 2.5rem !important;
    }

    #mobile-menu-content {
        width: 400px;
    }

    .hero-stats-compact {
        flex-direction: row;
        justify-content: flex-start;
    }

    .hero-stat-item {
        flex: none;
    }

    /* 2-column grid for tablets */
    .grid.md\:grid-cols-2,
    .grid.lg\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ENSURE Z-INDEX HIERARCHY */
.top-bar-premium {
    z-index: 60;
}

.nav-compact-premium {
    z-index: 50;
}

#mobile-menu-overlay {
    z-index: 60;
}

#mobile-menu-content {
    z-index: 70;
}

#wellness-bot-container {
    z-index: 9999;
}