/**
 * Header Styles
 * Logo, layout, navigation menu, and My Account dropdown
 */

/* Ensure page-container doesn't clip the dropdown when search header is present */
body:has(.wf-search-header) #page-container,
#page-container:has(.wf-search-header) {
    overflow: visible !important;
}

.wf-search-header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    width: 100%;
}

body.admin-bar .wf-search-header {
    top: 32px;
}

/* Top Row: Logo, Search, My Account */
.wf-search-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    padding: 0px 25px;
    border-bottom: 1px solid #e0e0e0;
}

.wf-search-header-logo {
    flex-shrink: 0;
}

.wf-search-header-logo img {
    width: 168px;
}

.wf-search-header-search-container {
    flex: 1;
    display: flex;
    justify-content: end;
}

.wf-search-header-search {
    flex: 1;
    max-width: 688px;
}

/* Mobile Menu Wrapper - Hidden on desktop */
.wf-search-mobile-menu-wrapper {
    display: none;
    flex-shrink: 0;
    align-items: center;
}

/* Hide the mobile menu source nav (we clone it into mobile_nav) */
.wf-search-mobile-menu-wrapper #top-menu-nav-mobile {
    display: none;
}

/* My Account Dropdown - Uses same structure as bottom nav to inherit styles */
.wf-search-account-wrapper {
    position: relative;
    flex-shrink: 0;
}

/* Apply the exact same styles as #top-menu-nav ul.nav li .sub-menu */
.wf-search-account-wrapper #top-menu-nav-account {
    line-height: 0;
}

/* Style the parent menu item (My Account) to look like a button */
.wf-search-account-wrapper #top-menu-nav-account ul.nav > li > a {
    display: flex;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Acumin Variable Concept', sans-serif;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.2;
    color: #000000;
    border-radius: 200px;
    transition: background-color 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
}

/* Override Divi's dropdown arrow with custom chevron icon */
.wf-search-account-wrapper #top-menu-nav-account ul.nav > li.menu-item-has-children > a {
    padding-top: 30px;
    padding-bottom: 30px;
}

.wf-search-account-wrapper #top-menu-nav-account ul.nav > li.menu-item-has-children > a:first-child:after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 2px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6L8 10L12 6' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
    position: static;
    font-size: inherit;
    font-weight: inherit;
    top: auto;
    right: auto;
}

/* Apply exact same styles as #top-menu-nav ul.nav li .sub-menu from old-styles.css */
.wf-search-account-wrapper #top-menu-nav-account ul.nav li .sub-menu {
    border-color: #010101;
    box-shadow: 0 0 20px 0 rgba(222, 222, 222, 0.5);
    padding-top: 10px;
    padding-left: 20px;
    right: 0;
    left: auto;
}

.wf-search-account-wrapper #top-menu-nav-account ul.nav li.et-show-dropdown .sub-menu,
.wf-search-account-wrapper #top-menu-nav-account ul.nav li:hover .sub-menu,
.wf-search-account-wrapper #top-menu-nav-account ul.nav li.et-hover .sub-menu {
    display: block;
}

.wf-search-account-wrapper #top-menu-nav-account ul.nav li .sub-menu li {
    padding: 0;
    width: 100%;
}

.wf-search-account-wrapper #top-menu-nav-account ul.nav li .sub-menu li a {
    background: none;
    font-size: 16px;
    line-height: 1.2;
    color: #000000;
    text-decoration: none;
}


/* Bottom Row: Navigation Menu */
.wf-search-header-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    /* min-height: 56px; */
}

/* Ensure menu aligns properly with existing header */
.wf-search-header-bottom #top-menu-nav {
    line-height: 0;
}

.wf-search-header-bottom #top-menu {
    line-height: 0;
}

.wf-search-header-bottom #top-menu-nav ul.nav li {
    padding-right: 50px;
}

.wf-search-header-bottom #top-menu-nav ul.nav > li > a {
    padding-top: 20px;
    padding-bottom: 20px;
}

.wf-search-header-bottom #top-menu .menu-item-has-children>a:first-child:after {
    top: 20px;
}

/* Navigation menu uses existing Divi CSS - no custom styles needed */
/* Override Divi's default mobile menu breakpoint for search header */
/* Keep bottom navigation visible between 768px and 980px */
@media (min-width: 769px) and (max-width: 980px) {
    .wf-search-header-bottom #top-menu {
        display: block !important;
    }
    .wf-search-header-bottom #top-menu-nav ul.nav li {
        padding-right: 25px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .wf-search-header-top {
        gap: 14px;
        padding: 15px 20px;
        border-bottom: none;
    }

    .wf-search-header-logo {
        width: auto;
        text-align: left;
        padding: 0;
    }

    .wf-search-header-logo img {
        width: 158px;
    }

    .wf-search-header-search-container {
        max-width: none;
        margin: 0;
        justify-content: flex-end;
        align-items: center;
        position: relative;
    }

    .wf-search-header-search {
        max-width: none;
        display: flex;
        justify-content: flex-end;
    }
    
    /* Show mobile menu wrapper on mobile */
    .wf-search-mobile-menu-wrapper {
        display: flex !important;
        align-items: center;
        justify-content: center;
        margin-left: 14px; /* Space between search icon and hamburger */
        position: relative;
        z-index: 1001;
    }
    
    /* Ensure the mobile nav menu container is visible and positioned */
    .wf-search-mobile-menu-wrapper .et_mobile_nav_menu {
        display: block !important;
        visibility: visible !important;
        position: relative;
    }
    
    /* Style the hamburger menu button */
    .wf-search-mobile-menu-wrapper .mobile_menu_bar,
    .wf-search-mobile-menu-wrapper .mobile_nav .mobile_menu_bar {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        line-height: 0;
        cursor: pointer;
        width: 32px;
        height: 32px;
        position: relative;
    }
    
    .wf-search-mobile-menu-wrapper .mobile_menu_bar:before,
    .wf-search-mobile-menu-wrapper .mobile_nav .mobile_menu_bar:before {
        content: "\61";
        font-family: 'ETmodules' !important;
        font-size: 32px;
        position: relative;
        left: 0;
        top: 0;
        cursor: pointer;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        line-height: 1;
        color: #000;
    }
    
    /* Ensure mobile menu structure is accessible for Divi's JavaScript */
    .wf-search-mobile-menu-wrapper #et-top-navigation-mobile {
        position: relative;
    }
    
    .wf-search-mobile-menu-wrapper .et_mobile_nav_menu {
        display: block !important;
        position: relative;
    }
    
    /* Ensure mobile_nav is visible */
    .wf-search-mobile-menu-wrapper .mobile_nav {
        display: block !important;
        visibility: visible !important;
    }
    
    /* Ensure the hamburger button is visible */
    .wf-search-mobile-menu-wrapper .mobile_nav .mobile_menu_bar {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Mobile menu base styles */
    .wf-search-mobile-menu-wrapper #mobile_menu {
        display: block !important;
        visibility: visible !important;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: #fff;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        z-index: 99999;
        padding: 0 20px;
        margin: 0;
        list-style: none;
        overflow: hidden;
        max-height: 345px;
        overflow-x: scroll;
        opacity: 0;
        transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out, padding 0.3s ease-in-out;
    }
    
    /* Adjust mobile menu position when admin bar is present */
    body.admin-bar .wf-search-mobile-menu-wrapper #mobile_menu {
        top: 93px; /* 106px header height + 32px admin bar */
    }
    
    /* Hidden by default when mobile_nav has 'closed' class - height animation */
    .wf-search-mobile-menu-wrapper .mobile_nav.closed #mobile_menu {
        max-height: 0;
        opacity: 0;
        padding-top: 0;
        padding-bottom: 0;
        pointer-events: none;
    }
    
    /* Show menu with height expansion animation when mobile_nav doesn't have 'closed' class */
    .wf-search-mobile-menu-wrapper .mobile_nav:not(.closed) #mobile_menu {
        opacity: 1;
        padding-top: 20px;
        padding-bottom: 20px;
        pointer-events: auto;
        overflow-y: auto;
    }
    
    /* Mobile menu items styling */
    .wf-search-mobile-menu-wrapper #mobile_menu li {
        margin: 0;
        padding: 0;
    }
    
    .wf-search-mobile-menu-wrapper #mobile_menu li a {
        display: block;
        padding: 10px 20px;
        color: #666;
        text-decoration: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    }
    
    .wf-search-mobile-menu-wrapper #mobile_menu li.menu-item-has-children > a {
        font-weight: bold;
        background-color: rgba(0, 0, 0, 0.03);
        position: relative;
        padding-right: 40px;
    }
    
    /* Submenu toggle icon (plus sign) */
    .wf-search-mobile-menu-wrapper #mobile_menu li.menu-item-has-children > a::after {
        content: '+';
        position: absolute;
        right: 20px;
        font-size: 20px;
        font-weight: normal;
        line-height: 1;
    }
    
    /* Hide submenus by default */
    .wf-search-mobile-menu-wrapper #mobile_menu li.menu-item-has-children > ul {
        display: none !important;
        padding-left: 20px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
    }
    
    /* Show submenus when parent has 'visible' class */
    .wf-search-mobile-menu-wrapper #mobile_menu li.menu-item-has-children.visible > ul {
        display: block !important;
        max-height: 1000px;
    }
    
    /* Change plus to minus when expanded */
    .wf-search-mobile-menu-wrapper #mobile_menu li.menu-item-has-children.visible > a::after {
        content: '−';
    }
    
    /* Submenu items styling */
    .wf-search-mobile-menu-wrapper #mobile_menu li.menu-item-has-children > ul li a {
        font-weight: normal;
        background-color: transparent;
        padding-left: 20px;
    }

    /* Hide My Account on mobile */
    .wf-search-account-wrapper {
        display: none;
    }
}
