/* =================== Navbar Container =================== */
#mainNav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background-color: var(--color-secondary-blue);
    border-bottom: 1px solid var(--color-secondary-blue);
    color: white;
}

/* =================== Desktop Menu =================== */
#desktopMenu {
    margin-left: 0.5rem;
}

@media (max-width: 1024px) {
    #desktopMenu { display: none; }
}

/* =================== Hamburger Toggle (Mobile) =================== */
.hamburger-checkbox {
    display: none;
}

.hamburger-button {
    width: 40px;
    height: 40px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.hamburger-line {
    position: absolute;
    width: 30px;
    height: 3px;
    background-color: var(--color-secondary-light);
    box-shadow: 1px 1px 2px var(--color-secondary-blue);
    border-radius: 2px;
    transition: transform 0.3s ease-in-out, top 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.hamburger-line:nth-child(1) { top: 10px; }
.hamburger-line:nth-child(2) { top: 18px; }
.hamburger-line:nth-child(3) { top: 26px; }

.hamburger-checkbox:checked + .hamburger-button .hamburger-line:nth-child(1) {
    transform: rotate(45deg);
    top: 18px;
}

.hamburger-checkbox:checked + .hamburger-button .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-checkbox:checked + .hamburger-button .hamburger-line:nth-child(3) {
    transform: rotate(-45deg);
    top: 18px;
}

@media (min-width: 1025px) {
    .hamburger-button { display: none; }
}

/* =================== Mobile Menu Panel =================== */
#mobileMenu {
    z-index: 9999;
    position: fixed;
    top: 75px;
    left: 0;
    right: 0;
    transition: transform 0.4s ease, opacity 0.4s ease;
    transform: translateY(0);
}
#mobileMenu.opacity-0 {
    pointer-events: none;
}

/* =================== Dropdown Menu =================== */
.menu-item-has-children {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.menu-item-has-children > a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    position: relative;
    z-index: 20;
}

.menu-item-has-children > .menu-item-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu-item-has-children .dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

.dropdown-arrow {
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
    pointer-events: auto;
}

.dropdown-arrow svg {
    width: 1em;
    height: 1em;
    transition: transform 0.3s ease;
}

/* =================== Submenu (Shared Defaults) =================== */
.sub-menu {
    display: none;
    min-width: max-content;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition: opacity 0.8s ease, visibility 0.8s ease, transform 0.8s ease;
    z-index: 10;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0;
}

.sub-menu.visible {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}


/* =================== Search Bar Styles =================== */
.search-icon-button {
    background: transparent;
    border: none;
    cursor: pointer;
    color: white;
    font-size: 1.25rem;
    padding: 0.5rem;
}

#navbarSearch {
    position: absolute;
    top: 100%; 
    right: 0;
    margin-top: 0.5rem;
    width: 18rem;
    background: white;
    padding: 1rem;
    border: 1px solid #ccc;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    z-index: 999;
    pointer-events: none;
    transition: opacity 0.2s ease-out, visibility 0.2s ease-out;}

#navbarSearch.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#navbarSearch input[type="search"] {
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-secondary-blue);
    border-radius: 4px 0 0 4px;
    width: 200px;
    font-size: 1rem;
}

#navbarSearch button[type="submit"] {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: black;
    cursor: pointer;
    transition: color 0.2s ease;
}

#navbarSearch button[type="submit"]:hover,
#navbarSearch:hover button[type="submit"],
#toggleSearch:hover + #navbarSearch button[type="submit"] {
    color: var(--color-accent-gold);
}

.search-icon-button {
    order: 3;
    margin-left: 0.5rem;
}

#header-buttons {
    padding: 0;
    margin: 0;
    max-width: 220px;
    width: auto;
    min-width: 0;
    display: flex;
    gap: 0.5rem;
    overflow: visible;
    justify-content: flex-end;
}

#toggleSearch.hovered svg,
#searchIcon.hovered {
    color: var(--color-accent-gold);
    stroke: var(--color-accent-gold);
}

#searchInput:focus,
#search:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* =================== Desktop Media =================== */
@media (min-width: 1025px) {
    .menu-item-has-children:hover > .sub-menu {
        display: block;
        pointer-events: auto;
    }

    .menu-item-has-children:hover .dropdown-arrow svg {
        transition: transform 0.3s ease, color 0.3s ease;
        color: var(--color-accent-gold);
        transform: rotate(180deg);
    }

    #mobileMenu .menu-item-link {
        display: none;
    }

    .menu-item-has-children:hover > .sub-menu,
    .sub-menu:hover {
        opacity: 1;
        visibility: visible;
    }

    .dropdown-arrow {
        color: white;
    }

    #mobileSearch {
        display: none !important;
    }
}

/* =================== Mobile Media =================== */
@media (max-width: 1024px) {
    .sub-menu {
        display: none;
        position: relative;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0.5rem 0;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.5s ease, transform 0.5s ease;
    }

    .sub-menu.visible {
        display: block;
        opacity: 1;
        visibility: visible;
        color: black;
    }

    .menu-item-has-children {
        flex-direction: column;
        align-items: stretch;
        flex-shrink: 0;
    }

    .menu-item-has-children > .menu-item-link {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        padding: 0.75rem 1rem;
        flex-shrink: 0;
        align-items: center;
    }

    #mobileMenu .menu-item-link {
        display: flex;
        align-items: center;
        justify-content: start;
        padding: 0.75rem 1rem;
        width: 100%;
        text-align: center;
        position: relative;
        color: var(--color-primary-dark);
    }

    #mobileMenu .menu-item-link:hover {
        color: var(--color-accent-gold);
    }

    #mobileMenu:not(.open) .menu-item-link {
        display: none;
    }

    .menu-item-has-children .dropdown-toggle {
        flex-shrink: 0;
        margin-left: 8px;
    }

    .menu-item-has-children > a {
        flex-grow: 1;
    }

    .dropdown-toggle svg {
        transition: transform 0.3s ease, color 0.3s ease;
    }

    .dropdown-toggle:hover svg {
        color: var(--color-accent-gold);
    }

    .menu-item-has-children.open > .menu-item-link {
        justify-content: space-between;
        margin-left: 0 !important;
    }

    .menu-item-link-wrapper {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 0.75rem 1rem;
    }

    .menu-item-has-children:hover .dropdown-arrow svg {
        transform: none !important;
    }

    #mobileMenu {
        display: block !important;
    }

    #desktopMenu {
        display: none;
    }

    #navbarSearch {
        width: 100%;
        padding: 0.5rem 1rem;
        order: -1;
        background: var(--color-secondary-blue);
        margin-bottom: 0.5rem;
    }

    #navbarSearch input[type="search"] {
        width: 100%;
        border-radius: 4px;
        border-right: none;
    }

    #navbarSearch button[type="submit"] {
        border-radius: 4px;
        width: 100%;
        margin-top: 0.5rem;
    }

    .search-icon-button {
        order: 0;
    }

    #toggleSearch, #navbarSearch {
        display: none;
    }

    #searchGhost {
        pointer-events: none;
        transition: opacity 0.2s ease;
        user-select: none;
    }
}

/* =================== Active Menu Item Highlight =================== */
.current-menu-item > a,
.current-menu-parent > a,
.current-menu-ancestor > a {
    color: var(--color-accent-gold);
    font-weight: bold;
}

/* =================== Submenu Links =================== */
.sub-menu li a {
    display: block;
    padding: 0.5rem 1rem;
    white-space: nowrap;
    transition: background-color 0.3s, color 0.3s;
}

.sub-menu li a:hover,
.sub-menu.visible li a:hover {
    color: var(--color-accent-gold) !important;
    background-color: transparent;
}
