/* ==========================================================================
   HEADER & NAVIGATION STYLES
   ========================================================================== */

/* Header Container */
.site-header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.site-header.scrolled {
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.header-container {
    max-width: var(--layout-content-width, 1400px);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--header-height, 80px);
}

/* Site Branding */
.site-branding {
    display: flex;
    align-items: center;
    z-index: 10;
}

/* Logo Styles - Force override WP defaults */
.site-logo .custom-logo-link img,
.site-logo img,
.custom-logo {
    max-height: var(--header-logo-height, 60px) !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
}

.site-title-link {
    text-decoration: none;
}

.site-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    transition: color 0.3s ease;
}

.site-title-link:hover .site-title {
    color: #667eea;
}

.site-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 5px 0 0 0;
    font-weight: 400;
}

/* Primary Navigation */
.primary-navigation {
    display: flex;
    align-items: center;
}

/* Desktop Menu */
.desktop-menu {
    display: block;
}

.primary-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px;
}

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

.primary-menu .menu-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px var(--header-menu-padding, 18px);
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    font-size: var(--header-menu-font-size, 15px);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.primary-menu > li > .menu-link:hover,
.primary-menu > li.active > .menu-link,
.primary-menu > li.current-menu-item > .menu-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.dropdown-arrow {
    font-size: 0.7em;
    transition: transform 0.3s ease;
}

.has-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu (Desktop Only) */
@media (min-width: 769px) {
    .sub-menu,
    .primary-menu .sub-menu,
    ul.sub-menu {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 220px;
        width: max-content;
        max-width: 350px;
        height: auto;
        min-height: auto;
        max-height: none;
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
        padding: 8px;
        margin: 5px 0 0 0;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.25s ease;
        list-style: none;
        z-index: 99999;
        overflow: visible;
        display: block;
        clip: auto;
    }

    .has-dropdown:hover > .sub-menu,
    .primary-menu li:hover > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .sub-menu li,
    .primary-menu .sub-menu li {
        margin: 0;
        padding: 0;
        display: block;
        width: 100%;
        height: auto;
        background: #ffffff;
        list-style: none;
        position: relative;
    }

    .sub-menu .menu-link,
    .sub-menu a,
    .primary-menu .sub-menu .menu-link,
    .primary-menu .sub-menu a {
        display: block;
        padding: 12px 16px;
        color: #374151;
        text-decoration: none;
        font-size: 14px;
        font-weight: 500;
        border-radius: 8px;
        background: transparent;
        transition: all 0.2s ease;
        white-space: normal;
        line-height: 1.4;
    }

    .sub-menu .menu-link:hover,
    .sub-menu a:hover,
    .primary-menu .sub-menu .menu-link:hover,
    .primary-menu .sub-menu a:hover {
        background: #f3f4f6;
        color: #667eea;
    }

    /* Fix Dropdown Overflow: Align last 2 items to the right */
    .primary-menu > li:last-child > .sub-menu,
    .primary-menu > li:nth-last-child(2) > .sub-menu {
        left: auto;
        right: 0;
    }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}

.hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 28px;
}

.hamburger .line {
    width: 100%;
    height: 3px;
    background: #374151;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active .line:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.mobile-menu-toggle.active .line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .line:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Hide hamburger when menu is open - the close button inside sidebar is enough */
.mobile-menu-toggle.active {
    display: none !important;
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile Menu Sidebar */
.mobile-menu-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 320px;
    max-width: 85%;
    height: 100vh;
    background: #fff;
    z-index: 1000;
    transition: right 0.3s ease;
    box-shadow: -5px 0 30px rgba(0,0,0,0.2);
    overflow-y: auto;
}

.mobile-menu-sidebar.active {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.mobile-logo img,
.mobile-logo .custom-logo {
    max-height: 40px;
    width: auto;
}

.mobile-site-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
}

.mobile-menu-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: #6b7280;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    transition: color 0.3s ease;
}

.mobile-menu-close:hover {
    color: #667eea;
}

.mobile-menu-content {
    padding: 15px 0;
}

.mobile-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-menu li {
    border-bottom: 1px solid #f3f4f6;
}

.mobile-menu a {
    display: block;
    padding: 15px 20px;
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mobile-menu a:hover,
.mobile-menu .active > a,
.mobile-menu .current-menu-item > a {
    background: linear-gradient(135deg, #667eea10 0%, #764ba210 100%);
    color: #667eea;
    padding-left: 30px;
}

.mobile-menu .sub-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    background: #f9fafb;
    width: 100%;
    flex-basis: 100%;
    display: none; /* Let JS handle display toggle */
    border: none;
    max-width: none;
    min-width: 0;
    top: auto;
    left: auto;
}

.mobile-menu .sub-menu a {
    padding-left: 40px;
    font-size: 0.9em;
}

/* No Menu Notice */
.no-menu-notice {
    padding: 15px 20px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
}

.no-menu-notice p {
    margin: 0;
    color: #92400e;
}

/* Responsive */
@media (max-width: 768px) {
    .header-container {
        min-height: 70px;
        padding: 0 15px;
    }

    .desktop-menu {
        display: none;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .site-description {
        display: none;
    }

    .site-logo .custom-logo-link img,
    .site-logo img,
    .custom-logo {
        max-height: 45px !important;
    }

    .site-title {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .mobile-menu-sidebar {
        width: 280px;
    }
}

/* Mobile Menu Submenu Styles (Accordion) */
.mobile-menu li {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 1px solid #f3f4f6;
}

.mobile-menu a {
    flex-grow: 1;
    display: block;
    padding: 15px 20px;
    padding-right: 60px; /* Make room for toggle */
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.submenu-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 50px;
    height: 52px;
    background: transparent;
    border: none;
    border-left: 1px solid #f3f4f6;
    color: #6b7280;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.submenu-toggle:hover {
    color: #667eea;
    background: #f9fafb;
}

.submenu-toggle.active {
    background: #f3f4f6;
    color: #667eea;
}

.submenu-toggle span {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* Mobile Submenu Default State */
.mobile-menu .sub-menu {
    width: 100%;
    flex-basis: 100%;
    /* Display is handled by JS (block/none) */
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    background: #f9fafb;
    border-radius: 0;
    /* Reset desktop properties just in case */
    top: auto;
    left: auto;
}

/* Indent submenu items nicely */
.mobile-menu .sub-menu a {
    padding-left: 40px;
    font-size: 0.95em;
    color: #6b7280;
    border-left: 3px solid transparent;
}

.mobile-menu .sub-menu a:hover {
    background: #f3f4f6;
    color: #667eea;
    border-left-color: #667eea;
}
