/**
 * BTR Pest Control - Responsive Styles
 */

/* ============================================
   MOBILE (768px and below)
   ============================================ */
@media (max-width: 768px) {
    :root {
        --container-padding: 1rem;
        --spacing-3xl: 4rem;
    }

    /* Header Top Bar */
    .header-top {
        font-size: 0.8125rem;
        position: relative;
        z-index: 10001;
    }

    .header-top-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .header-contact .divider {
        display: none;
    }

    /* Header Main - MUST stay visible above nav */
    .header-main {
        padding: 0.75rem 0;
        position: relative;
        z-index: 10001;
        background: #fff;
    }

    .header-main-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    /* Logo */
    .logo img,
    .logo-image {
        height: 45px;
        width: auto;
    }

    .logo span,
    .logo-text {
        font-size: 1rem;
        line-height: 1.2;
    }

    /* Hide desktop CTA */
    .header-cta {
        display: none;
    }

    /* Navigation wrapper - MUST be relative for absolute nav-menu */
    .main-nav {
        display: flex;
        align-items: center;
        position: relative;
    }

    /* ========== HAMBURGER MENU ========== */
    .mobile-menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 44px;
        height: 44px;
        padding: 10px;
        background: transparent;
        border: none;
        cursor: pointer;
        position: relative;
        z-index: 10002;
    }

    .mobile-menu-toggle span {
        display: block;
        width: 24px;
        height: 3px;
        background-color: #1A1A2E;
        border-radius: 2px;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .mobile-menu-toggle[aria-expanded="true"] span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .mobile-menu-toggle[aria-expanded="true"] span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle[aria-expanded="true"] span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* ========== MOBILE NAV MENU ========== */
    /* Hidden by default - absolutely positioned BELOW header */
    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        background: #ffffff;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
        transition: max-height 0.35s ease-in-out;
        z-index: 10000;
    }

    /* NAV MENU OPEN STATE */
    .nav-menu.active {
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Nav menu items */
    .nav-menu > li {
        border-bottom: 1px solid #e5e7eb;
    }

    .nav-menu > li > a {
        display: block;
        padding: 1rem 1.5rem;
        font-size: 1rem;
        font-weight: 600;
        color: #1A1A2E;
        text-decoration: none;
    }

    .nav-menu > li > a:hover,
    .nav-menu > li > a.active {
        background: #f5f7fa;
        color: #FF6B35;
    }

    /* Section active state on mobile */
    .nav-menu > li.section-active > a {
        color: #FF6B35;
        background: #fff5f0;
        border-left: 3px solid #FF6B35;
    }

    .nav-menu > li.section-active > a::after {
        display: none; /* Hide underline on mobile, use left border instead */
    }

    /* Active dropdown items on mobile */
    .dropdown li a.active {
        color: #FF6B35 !important;
        background: #d1d5db !important;
        font-weight: 600 !important;
    }

    /* ========== DROPDOWN SUBMENUS ========== */
    .has-dropdown {
        position: relative;
    }

    /* Disable hover on mobile - only use click/tap */
    /* But allow .active state to override hover */
    .has-dropdown:hover:not(.active) .dropdown {
        opacity: 0 !important;
        visibility: hidden !important;
        max-height: 0 !important;
    }

    /* CRITICAL: Active state MUST override hover state */
    .has-dropdown.active .dropdown,
    .has-dropdown.active:hover .dropdown,
    .nav-menu .has-dropdown.active .dropdown,
    .nav-menu .has-dropdown.active:hover .dropdown {
        opacity: 1 !important;
        visibility: visible !important;
        max-height: 500px !important;
        display: block !important;
    }

    /* Add arrow indicator after dropdown links */
    .has-dropdown > a {
        padding-right: 1.5rem !important;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
    }

    .has-dropdown > a::after {
        content: '▼';
        font-size: 0.75rem;
        margin-left: 0.5rem;
        transition: transform 0.3s ease;
    }

    .has-dropdown.active > a::after {
        transform: rotate(180deg);
    }

    /* Hide any JS-created toggle buttons */
    .dropdown-toggle {
        display: none !important;
    }

    /* Dropdown submenu - hidden by default */
    .dropdown {
        position: static !important;
        max-height: 0 !important;
        overflow: hidden !important;
        background: #e5e7eb !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        box-shadow: none !important;
        transition: max-height 0.35s ease-out !important;
        display: block !important;
    }

    /* When parent has .active class, expand dropdown - highest specificity */
    .nav-menu .has-dropdown.active > .dropdown {
        max-height: 500px !important;
        overflow-y: auto !important;
    }

    .dropdown li a,
    .nav-menu .dropdown li a,
    .nav-menu .has-dropdown .dropdown li a {
        display: block !important;
        padding: 0.875rem 1.5rem 0.875rem 2.5rem !important;
        font-size: 0.9375rem !important;
        color: #1A1A2E !important;
        background: #e5e7eb !important;
        border-bottom: 1px solid #d1d5db !important;
        text-decoration: none !important;
    }

    .dropdown li:last-child a,
    .nav-menu .dropdown li:last-child a {
        border-bottom: none !important;
    }

    .dropdown li a:hover,
    .dropdown li a:active,
    .nav-menu .dropdown li a:hover,
    .nav-menu .dropdown li a:active {
        background: #d1d5db !important;
        color: #FF6B35 !important;
    }

    /* ========== OTHER MOBILE STYLES ========== */
    .hero {
        min-height: 500px;
    }

    .hero h1 {
        font-size: 2rem;
    }

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

    .btn {
        width: 100%;
    }

    .services-grid {
        grid-template-columns: 1fr;
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }

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

    .floating-call-btn {
        bottom: 1rem;
        right: 1rem;
        width: 50px;
        height: 50px;
    }
}

/* ============================================
   SMALL PHONES (480px and below)
   ============================================ */
@media (max-width: 480px) {
    .logo img,
    .logo-image {
        height: 40px;
    }

    .logo-text {
        font-size: 0.9rem;
    }

    .section-title {
        font-size: 1.75rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }
}

/* ============================================
   TABLET LANDSCAPE / SMALL DESKTOP
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .nav-menu {
        gap: 1rem;
    }

    .nav-menu > li > a {
        font-size: 0.875rem;
    }
}

/* ============================================
   LARGE SCREENS
   ============================================ */
@media (min-width: 1400px) {
    :root {
        --container-max-width: 1320px;
    }
}

/* ============================================
   VIDEO GRID FIX
   ============================================ */
@media (max-width: 768px) {
    .city-page .container > div > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}
