/**
 * Navigation Styles - Wisdom English
 * Dropdown menu with "text = link, caret = toggle" pattern
 * @version 1.0
 */

/* ==========================================================================
   Primary Navigation Container
   ========================================================================== */

.we-primary-nav {
    position: relative;
}

.we-primary-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   Menu Items (Top Level)
   ========================================================================== */

.we-primary-menu>li {
    position: relative;
}

.we-primary-menu>li>a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: #374151;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
}

.we-primary-menu>li>a:hover,
.we-primary-menu>li>a:focus {
    background: #F3F4F6;
    color: #111827;
}

.we-primary-menu>li.current-menu-item>a,
.we-primary-menu>li.current-menu-parent>a {
    background: #FEF3C7;
    color: #92400E;
}

/* ==========================================================================
   Dropdown Toggle (Caret Button)
   ========================================================================== */

.we-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 2px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.we-dropdown-toggle:hover,
.we-dropdown-toggle:focus {
    background: #E5E7EB;
}

.we-dropdown-toggle:focus {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

.we-dropdown-toggle svg {
    width: 16px;
    height: 16px;
    color: #6B7280;
    transition: transform 0.2s;
}

.we-dropdown-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* ==========================================================================
   Dropdown Submenu
   ========================================================================== */

.we-primary-menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 220px;
    margin: 0;
    padding: 8px 0;
    list-style: none;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}

.we-primary-menu>li.is-dropdown-open>.sub-menu,
.we-primary-menu>li:focus-within>.sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Desktop hover behavior */
@media (hover: hover) and (min-width: 769px) {
    .we-primary-menu>li.menu-item-has-children:hover>.sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

.we-primary-menu .sub-menu li {
    margin: 0;
}

.we-primary-menu .sub-menu a {
    display: block;
    padding: 10px 16px;
    font-size: 0.9rem;
    color: #374151;
    text-decoration: none;
    transition: background-color 0.15s;
}

.we-primary-menu .sub-menu a:hover,
.we-primary-menu .sub-menu a:focus {
    background: #F9FAFB;
    color: #111827;
}

.we-primary-menu .sub-menu .current-menu-item a {
    background: #FEF3C7;
    color: #92400E;
}

/* ==========================================================================
   Mobile Navigation
   ========================================================================== */

.we-mobile-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
}

.we-mobile-menu-toggle:hover {
    background: #F3F4F6;
}

.we-mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
    color: #374151;
}

/* Hide mobile close button on desktop */
.we-mobile-nav-close {
    display: none;
}

@media (max-width: 768px) {
    .we-mobile-menu-toggle {
        display: flex;
    }

    .we-primary-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: #FFFFFF;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        z-index: 9999;
        overflow-y: auto;
        padding: 60px 0 20px;
    }

    .we-primary-nav.is-open {
        right: 0;
    }

    .we-primary-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .we-primary-menu>li {
        border-bottom: 1px solid #F3F4F6;
    }

    .we-primary-menu>li>a {
        display: flex;
        justify-content: space-between;
        padding: 14px 20px;
        border-radius: 0;
    }

    .we-dropdown-toggle {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 32px;
        height: 32px;
    }

    .we-primary-menu .sub-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: #F9FAFB;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .we-primary-menu>li.is-dropdown-open>.sub-menu {
        max-height: 500px;
    }

    .we-primary-menu .sub-menu a {
        padding-left: 36px;
    }

    /* Mobile menu close button */
    .we-mobile-nav-close {
        position: absolute;
        top: 12px;
        right: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: none;
        background: #F3F4F6;
        border-radius: 8px;
        cursor: pointer;
    }

    .we-mobile-nav-close svg {
        width: 20px;
        height: 20px;
        color: #374151;
    }

    /* Overlay */
    .we-nav-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 9998;
    }

    .we-nav-overlay.is-visible {
        display: block;
    }
}

/* ==========================================================================
   Header Layout Adjustments
   ========================================================================== */

.we-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

/* Ensure menu items with dropdowns have proper display */
.we-primary-menu>li.menu-item-has-children {
    display: flex;
    align-items: center;
}