/* =============================================
   Modern Header Styles
   ============================================= */

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #fff;
    transition: box-shadow 0.3s ease, background 0.3s ease;
}

/* Logo Styling */
.custom-logo-link {
    display: inline-block;
    line-height: 0;
}

.custom-logo {
    display: block;
    width: var(--logo-width, 150px);
    height: auto;
    max-height: 60px;
    object-fit: contain;
}

.site-header.is-scrolled {
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    min-height: 70px;
    overflow: visible;
}

/* Branding */
.branding .site-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--theme-primary);
    letter-spacing: -0.025em;
    transition: color 0.2s ease;
}

.branding .site-title:hover {
    color: var(--theme-secondary);
}

/* Header Actions (Search + Menu) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Icon Buttons Base Styles */
.header-search-toggle,
.header-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #374151;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.header-search-toggle:hover,
.header-menu-toggle:hover {
    background: #f3f4f6;
    color: var(--theme-primary);
}

.header-search-toggle:active,
.header-menu-toggle:active {
    transform: scale(0.95);
}

/* Search Toggle Active State */
.header-search-toggle[aria-expanded="true"] {
    background: #f3f4f6;
    color: var(--theme-primary);
}

/* Hamburger Menu */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 22px;
    height: 18px;
    position: relative;
}

.hamburger-line {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    position: absolute;
}

.hamburger-line:nth-child(1) {
    top: 0;
}

.hamburger-line:nth-child(2) {
    top: 50%;
    transform: translateY(-50%);
}

.hamburger-line:nth-child(3) {
    bottom: 0;
}

/* Hamburger Active State */
.header-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.header-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.header-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
    bottom: 50%;
    transform: translateY(50%) rotate(-45deg);
}

/* Search Modal */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    overflow-y: auto;
}

.search-modal[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

.search-modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.search-modal__content {
    position: relative;
    width: 100%;
    max-width: 720px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    margin: auto;
}

.search-modal[aria-hidden="false"] .search-modal__content {
    transform: scale(1);
    opacity: 1;
}

.search-modal__close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    cursor: pointer;
    color: #6b7280;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.search-modal__close:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #111827;
}

.search-modal__inner {
    padding: 3rem 2.5rem;
}

.search-modal__title {
    margin: 0 0 2rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: #111827;
    text-align: center;
    letter-spacing: -0.025em;
}

.search-modal .search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-modal .search-field {
    width: 100%;
    padding: 1.125rem 1.5rem;
    font-size: 1.125rem;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-modal .search-field::placeholder {
    color: #9ca3af;
}

.search-modal .search-field:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 4px rgba(15, 76, 129, 0.1);
}

.search-modal .search-submit {
    width: 100%;
    padding: 1.125rem 2rem;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #fff;
    background: var(--theme-primary);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.search-modal .search-submit:hover {
    background: var(--theme-secondary);
}

.search-modal .search-submit:active {
    transform: scale(0.98);
}

.search-modal__hint {
    margin: 1.75rem 0 0;
    padding-top: 1.5rem;
    font-size: 0.8125rem;
    color: #9ca3af;
    text-align: center;
    border-top: 1px solid #f3f4f6;
}

.search-modal__hint kbd {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    background: #f3f4f6;
    border-radius: 4px;
    margin: 0 0.15rem;
}

/* =============================================
   MOBILE RESPONSIVE STYLES
   ============================================= */
@media (max-width: 768px) {
    /* Header container gets same padding as main container */
    .site-header .container {
        width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .header-inner {
        padding: 0.75rem 0;
        min-height: 60px;
    }

    /* Adjust logo size on mobile */
    .custom-logo {
        max-height: 45px;
        width: auto;
        max-width: 120px;
    }

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

@media (max-width: 768px) {
    .search-modal {
        padding: 1rem;
    }

    .search-modal__close {
        width: 36px;
        height: 36px;
        top: 1rem;
        right: 1rem;
    }

    .search-modal__close svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .search-modal__inner {
        padding: 2.5rem 1.5rem;
    }

    .search-modal__title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .search-modal .search-field,
    .search-modal .search-submit {
        padding: 1rem 1.25rem;
    }
}

/* Desktop Navigation */
.desktop-nav {
    display: none;
}

.desktop-nav > .menu {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.desktop-nav .menu li {
    margin: 0;
    position: relative;
}

.desktop-nav > .menu > li > a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #4b5563;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
}

.desktop-nav > .menu > li > a:hover {
    color: var(--theme-primary);
    background: rgba(15, 76, 129, 0.06);
}

.desktop-nav > .menu > .current-menu-item > a,
.desktop-nav > .menu > .current-menu-ancestor > a {
    color: var(--theme-primary);
    background: rgba(15, 76, 129, 0.08);
}

/* Desktop Submenus */
.desktop-nav .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    padding: 0.5rem;
    margin: 0;
    list-style: none;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1),
                0 4px 6px -2px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    z-index: 100;
    transform: translateY(10px);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
}

/* Bridge gap to prevent hover loss */
.desktop-nav .menu-item-has-children::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 12px;
}

.desktop-nav .menu-item-has-children:hover > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.desktop-nav .sub-menu li {
    margin: 0;
}

.desktop-nav .sub-menu li + li {
    margin-top: 2px;
}

.desktop-nav .sub-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    border-radius: 10px;
    transition: all 0.15s ease;
}

.desktop-nav .sub-menu a:hover {
    background: linear-gradient(135deg, rgba(15, 76, 129, 0.08) 0%, rgba(15, 76, 129, 0.04) 100%);
    color: var(--theme-primary);
    padding-left: 1.25rem;
}

.desktop-nav .sub-menu .current-menu-item > a {
    color: var(--theme-primary);
    background: rgba(15, 76, 129, 0.06);
    font-weight: 600;
}

/* Nested submenus */
.desktop-nav .sub-menu .sub-menu {
    top: -0.5rem;
    left: calc(100% + 0.5rem);
    transform: translateX(10px);
}

.desktop-nav .sub-menu .menu-item-has-children:hover > .sub-menu {
    transform: translateX(0);
}

/* Nested submenu indicator */
.desktop-nav .sub-menu .menu-item-has-children > a::after {
    content: '';
    margin-left: auto;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid currentColor;
    border-top: 1.5px solid currentColor;
    transform: rotate(45deg);
    opacity: 0.5;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.desktop-nav .sub-menu .menu-item-has-children:hover > a::after {
    opacity: 1;
    transform: rotate(45deg) translate(2px, -2px);
}

/* Dropdown indicator */
.desktop-nav .menu-item-has-children > a svg.dropdown-icon {
    width: 14px;
    height: 14px;
    opacity: 0.4;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.desktop-nav .menu-item-has-children:hover > a svg.dropdown-icon {
    opacity: 0.7;
    transform: rotate(180deg);
}

/* Mobile Navigation */
.mobile-nav {
    max-height: 0;
    overflow: hidden;
    background: #fff;
    border-top: 1px solid transparent;
    transition: max-height 0.4s ease, border-color 0.3s ease;
}

.mobile-nav[aria-hidden="false"] {
    max-height: 80vh;
    overflow-y: auto;
    border-top-color: #e5e7eb;
}

.mobile-nav .container {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.mobile-nav .menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-nav .menu li {
    margin: 0;
}

.mobile-nav > .container > .menu > li > a {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    color: #374151;
    border-radius: 10px;
    transition: background 0.15s ease, color 0.15s ease;
}

.mobile-nav > .container > .menu > li > a:hover {
    background: #f3f4f6;
}

.mobile-nav > .container > .menu > .current-menu-item > a,
.mobile-nav > .container > .menu > .current-menu-ancestor > a {
    color: var(--theme-primary);
    background: rgba(15, 76, 129, 0.08);
}

/* Mobile Submenus */
.mobile-nav .sub-menu {
    list-style: none;
    margin: 0.25rem 0 0;
    padding: 0 0 0 1.25rem;
    display: none;
}

.mobile-nav .menu-item-has-children.is-open > .sub-menu {
    display: block;
    animation: mobileSubSlide 0.2s ease;
}

.mobile-nav .sub-menu a {
    display: block;
    padding: 0.7rem 1rem;
    font-size: 0.9375rem;
    font-weight: 450;
    color: #6b7280;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.mobile-nav .sub-menu a:hover {
    background: #f3f4f6;
    color: #374151;
}

.mobile-nav .sub-menu .current-menu-item > a {
    color: var(--theme-primary);
    background: rgba(15, 76, 129, 0.06);
}

/* Mobile submenu toggle button */
.mobile-nav .submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: auto;
    padding: 0;
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #6b7280;
    transition: background 0.15s ease, color 0.15s ease, transform 0.2s ease;
}

.mobile-nav .submenu-toggle:hover {
    background: #e5e7eb;
    color: #374151;
}

.mobile-nav .menu-item-has-children.is-open > a .submenu-toggle {
    background: rgba(15, 76, 129, 0.1);
    color: var(--theme-primary);
    transform: rotate(180deg);
}

.mobile-nav .submenu-toggle svg {
    width: 18px;
    height: 18px;
}

@keyframes mobileSubSlide {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Desktop Styles */
@media (min-width: 901px) {
    .header-inner {
        padding: 0.75rem 0;
        gap: 2rem;
    }

    .branding {
        flex-shrink: 0;
    }

    .desktop-nav {
        display: flex;
        flex: 1;
        justify-content: center;
    }

    .header-menu-toggle {
        display: none;
    }

    .mobile-nav {
        display: none;
    }
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
