/* ============================================
   Mobile Header & Hamburger Menu Styles
   ============================================ */

/* Hamburger Button Styling */
#menuBtn {
    display: none; /* Hidden by default, shown on mobile via media query */
    background: transparent;
    border: 1.5px solid #9ca3af; /* gray-400 */
    border-radius: 4px;
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1001;
    position: relative;
    color: #374151; /* gray-700 */
    font-size: 16px;
    line-height: 1;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#menuBtn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.18);
}

#menuBtn:active {
    background: #D0E8FF;
    transform: scale(0.95);
}

#menuBtn:focus {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

/* SVG icon sizing (FontAwesome removed) */
#menuBtn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease, opacity 0.2s ease;
}

/* Swap hamburger/close SVG based on button state */
#menuBtn .ep-icon--close { display: none; }
#menuBtn.active .ep-icon--bars { display: none; }
#menuBtn.active .ep-icon--close { display: inline-flex; }

/* Mobile Menu Container - Fixed overlay */
#mobileMenu {
    position: fixed;
    top: 70px; /* Adjust based on header height */
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 999;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

#mobileMenu:not(.hidden) {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

#mobileMenu.hidden {
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
}

/* Backdrop overlay when menu is open */
#mobileMenuBackdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#mobileMenuBackdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Menu Navigation */
#mobileMenu nav {
    padding: 20px;
}

#mobileMenu nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#mobileMenu nav ul li {
    margin: 0;
    padding: 0;
    width: 100%;
    border-bottom: 1px solid #eee;
}

#mobileMenu nav ul li:last-child {
    border-bottom: none;
}

#mobileMenu nav ul li a {
    display: block;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    width: 100%;
    text-align: right;
    box-sizing: border-box;
    white-space: normal; /* Allow text wrapping */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#mobileMenu nav ul li a:hover,
#mobileMenu nav ul li a:focus {
    background: #eff6ff;
    color: #2563eb;
}

/* Ensure regular links don't overlap with padding */
#mobileMenu nav ul li:not(.menu-item-has-children) > a {
    padding-right: 20px;
}

/* Dropdown Menu Items in Mobile */
#mobileMenu .menu-item-has-children > a {
    position: relative;
    padding-right: 50px !important; /* Increased padding to prevent overlap */
    padding-left: 20px;
    min-height: 48px; /* Ensure consistent height */
    display: block;
    line-height: 1.5; /* Better line height for wrapping text */
    padding-top: 15px;
    padding-bottom: 15px;
    white-space: normal; /* Allow text to wrap */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#mobileMenu .menu-item-has-children > a::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    pointer-events: none;
    z-index: 1;
    line-height: 1;
    font-size: 14px;
    color: #666;
}

#mobileMenu .menu-item-has-children.active > a::after {
    transform: translateY(-50%) rotate(180deg);
}

#mobileMenu .menu-item-has-children > ul {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease, opacity 0.3s ease;
    background: #f9f9f9;
    padding-left: 0;
    opacity: 0;
    visibility: hidden;
}

#mobileMenu .menu-item-has-children.active > ul {
    max-height: 2000px; /* Large enough to show all items */
    opacity: 1;
    visibility: visible;
    overflow: visible; /* Allow all items to be visible */
}

#mobileMenu .menu-item-has-children > ul li {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #e0e0e0;
}

#mobileMenu .menu-item-has-children > ul li:last-child {
    border-bottom: none;
}

#mobileMenu .menu-item-has-children > ul li a {
    padding-right: 20px;
    padding-left: 40px; /* Indent submenu items */
    font-size: 14px;
    font-weight: 500;
    display: block;
    width: 100%;
    white-space: normal; /* Allow text to wrap if needed */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Desktop Menu - Hidden on Mobile */
@media (max-width: 767px) {
    header nav.hidden.md\\:flex {
        display: none !important;
    }
    
    /* Show hamburger button on mobile */
    #menuBtn {
        display: flex !important;
    }
    
    /* Header is sticky via Tailwind classes on .site-header */
    .site-header {
        z-index: 1000;
    }
    
    header.fixed {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        z-index: 1000;
    }
    
    /* Calculate header height dynamically */
    header {
        height: auto;
        min-height: 70px;
    }
    
    /* Adjust mobile menu top based on actual header height */
    #mobileMenu {
        top: var(--header-height, 70px);
        max-height: calc(100vh - var(--header-height, 70px));
    }
}

/* Tablet and Desktop - Hide Mobile Menu */
@media (min-width: 768px) {
    #menuBtn {
        display: none !important;
    }
    
    #mobileMenu {
        display: none !important;
    }
}

/* Small Mobile Adjustments */
@media (max-width: 480px) {
    #menuBtn {
        padding: 5px 7px;
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 14px;
    }
    
    #menuBtn i {
        font-size: 16px;
    }
    
    #mobileMenu nav {
        padding: 15px;
    }
    
    #mobileMenu nav ul li a {
        padding: 12px 15px;
        font-size: 15px;
    }
    
    #mobileMenu .menu-item-has-children > a {
        padding-right: 45px !important; /* More space on small screens */
    }
    
    #mobileMenu .menu-item-has-children > a::after {
        right: 12px;
        width: 18px;
        height: 18px;
        font-size: 14px;
    }
    
    #mobileMenu .menu-item-has-children > ul li a {
        padding-left: 30px;
    }
    
    /* Ensure submenu shows all items on small screens */
    #mobileMenu .menu-item-has-children.active > ul {
        max-height: 2000px !important;
        overflow: visible !important;
    }
}

/* Ensure header container doesn't overflow */
header .max-w-7xl {
    position: relative;
    width: 100%;
}

/* Fix for Tailwind conflicts */
header.fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

/* Header spacer adjustment for mobile */
.header-spacer {
    height: 90px;
}

@media (max-width: 768px) {
    .header-spacer {
        height: 70px;
    }
    
    /* Adjust mobile menu top position based on header height */
    #mobileMenu {
        top: 70px;
        max-height: calc(100vh - 70px);
    }
}

@media (max-width: 480px) {
    .header-spacer {
        height: 65px;
    }
    
    #mobileMenu {
        top: 65px;
        max-height: calc(100vh - 65px);
    }
}

/* Logo adjustments on mobile */
@media (max-width: 768px) {
    header .flex.items-center.gap-3 {
        flex: 1;
    }
    
    header .flex.items-center.gap-3 img {
        max-height: 40px;
        width: auto;
    }
    
    header .text-2xl {
        font-size: 1.25rem;
    }
}

