/* Header navigation and global nav bar styles */

.site-header {
    background-color: #fff;
    padding: 0;
    position: relative;
    z-index: 100;
    align-items: center;
}

.site-header .nav-flex {
    display: flex;
    align-items: center;
    gap: 40px;
    padding: 0 30px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.site-header .site-branding-nav {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    /* 防止logo容器被压缩 */
}

.site-header .site-branding-nav .logo {
    display: flex;
    align-items: center;
}

.site-header .site-branding-nav .logo-img {
    width: auto !important;
    /* 覆盖全局的 width: 100% */
    max-width: 100%;
    object-fit: contain !important;
    /* 保持logo比例 */
}

.site-header nav.nav-links {
    margin-left: 30px;
    flex: 1;
    display: flex;
    justify-content: center;
}

.site-header nav.nav-links>ul {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 0;
    margin: 0;
}

.site-header nav.nav-links>ul>li {
    list-style: none;
}

/* Capitalize menu items in English mode */
html[lang^="en"] .site-header nav.nav-links>ul>li>a,
html[lang^="en"] .mobile-nav-menu li a {
    text-transform: capitalize;
}

/* Header Actions */
.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 40px;
}

/* Header Search Form */
.header-search {
    /* margin-left: auto; Removed, handled by header-actions */
    display: flex;
    align-items: center;
}

/* Language Switcher Desktop */
.language-switcher-container {
    position: relative;
    z-index: 101;
}

.language-switcher {
    position: relative;
    font-size: 14px;
    color: #333;
}

.language-switcher .current-lang {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    font-weight: 500;
    padding: 0 16px;
    /* Match dropdown item padding for alignment */
}

.language-switcher .current-lang:after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid #666;
    margin-left: 4px;
    transition: transform 0.2s;
}

.language-switcher:hover .current-lang:after {
    transform: rotate(180deg);
}

.language-switcher .lang-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    /* Align left edge with trigger */
    background: #fff;
    border: 1px solid #eee;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 8px 0;
    margin: 10px 0 0;
    list-style: none;
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

/* Invisible bridge to prevent hover loss during mouse transition */
.language-switcher .lang-dropdown::before {
    content: '';
    position: absolute;
    top: -12px;
    /* Covers the 10px margin plus a little buffer */
    left: 0;
    width: 100%;
    height: 12px;
    background: transparent;
}

.language-switcher:hover .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-switcher .lang-dropdown li {
    display: block;
    margin: 0;
}

.language-switcher .lang-dropdown li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
    white-space: nowrap;
}

.language-switcher .lang-dropdown li a:hover {
    background: #f5f5f5;
    color: var(--primary-color);
}

.language-switcher .lang-flag {
    font-size: 16px;
    line-height: 1;
    position: relative;
    top: 1px;
    /* Visual correction for vertical alignment */
}

.header-search .search-form {
    display: flex;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    background-color: #fff;
    height: 36px;
}

.header-search .search-form label {
    display: flex;
    align-items: center;
    height: 100%;
}

.header-search .search-field {
    border: none;
    padding: 0 12px;
    font-size: 14px;
    color: #333;
    width: 160px;
    background-color: transparent;
    height: 100%;
}

.header-search .search-field:focus {
    outline: none;
}

.header-search .search-submit {
    background-color: var(--primary-color);
    border: none;
    color: #fff;
    padding: 0 12px;
    min-width: 80px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
    height: 100%;
}

.header-search .search-submit:hover {
    background-color: var(--primary-color);
    filter: brightness(90%);
}

.menu-toggle {
    display: none;
    /* margin-left: auto; Removed to allow grouping with header-actions */
    width: 42px;
    height: 42px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    color: #1f2937;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.menu-toggle i {
    font-size: 22px;
}

.menu-toggle:hover {
    background: #f4f5f7;
}

.mobile-menu-container {
    display: none;
    background: transparent;
    border: none;
    box-shadow: none;
    width: 100%;
}

.mobile-nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-nav-menu li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    text-align: left;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #eee;
    font-weight: 500;
}

.mobile-nav-menu li:last-child a {
    border-bottom: none;
}

.mobile-nav-menu .current-menu-item>a {
    color: var(--primary-color, #004aad);
    font-weight: 600;
}

.mobile-nav-menu li.mobile-highlight-reset>a {
    color: #333;
    font-weight: 500;
    background: none;
    border-left: none;
    padding-left: 20px;
}

/* Prevent parent items such as "产品中心" from inheriting highlight when a child is active */
.mobile-nav-menu .current-menu-ancestor:not(.current-menu-item)>a,
.mobile-nav-menu .current-menu-parent:not(.current-menu-item)>a,
.mobile-nav-menu .current_page_parent:not(.current-menu-item)>a,
.mobile-nav-menu .current_page_ancestor:not(.current-menu-item)>a {
    color: #333;
    font-weight: 500;
}

.mobile-nav-menu .language-switcher>a {
    position: relative;
}

.mobile-nav-menu .language-switcher>a::after {
    content: '\25BE';
    font-size: 12px;
    color: inherit;
    margin-left: 8px;
    transition: transform 0.2s ease-in-out;
}

.mobile-nav-menu .language-switcher .sub-menu {
    list-style: none;
    padding-left: 0;
    margin: 0;
    display: none;
    background: #f8fafc;
}

.mobile-nav-menu .language-switcher .sub-menu li a {
    padding-left: 32px;
    font-size: 14px;
    border-bottom: 1px solid #e5e7eb;
}

.mobile-nav-menu .language-switcher.lang-switcher-open .sub-menu {
    display: block;
}

.mobile-nav-menu .language-switcher.lang-switcher-open>a::after {
    transform: rotate(180deg);
}

@media (min-width: 769px) {
    #mobile-menu-container {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .site-header .nav-flex {
        gap: 20px;
    }

    .site-header nav.nav-links,
    .header-actions .language-switcher {
        display: none;
    }

    .menu-toggle {
        display: flex;
    }

    .mobile-menu-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 999999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s;
        display: block !important;
    }

    body.mobile-menu-active .mobile-menu-container {
        opacity: 1;
        visibility: visible;
    }

    .mobile-drawer {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #f7f9fc;
        display: flex;
        flex-direction: column;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 12px rgba(15, 23, 42, 0.12);
    }

    body.mobile-menu-active .mobile-drawer {
        transform: translateX(0);
    }

    .drawer-header {
        width: 100%;
        padding: 20px;
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
    }

    body.admin-bar .mobile-menu-container .drawer-header {
        padding-top: calc(20px + 46px);
    }

    .drawer-search-toggle {
        width: 36px;
        height: 36px;
        border: none;
        border-radius: 999px;
        background: rgba(15, 23, 42, 0.08);
        color: #1f2937;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background-color 0.2s ease, color 0.2s ease;
    }

    .drawer-search-toggle i {
        font-size: 18px;
        line-height: 1;
    }

    .drawer-search-toggle:hover {
        background: rgba(15, 23, 42, 0.15);
    }

    .close-drawer-toggle {
        width: 30px;
        height: 30px;
        border: none;
        background: transparent;
        color: #1f2937;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border-radius: 8px;
        transition: background-color 0.2s ease;
    }

    .close-drawer-toggle i {
        font-size: 18px;
        line-height: 1;
    }

    .close-drawer-toggle:hover {
        background: rgba(15, 23, 42, 0.08);
    }

    .drawer-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .mobile-nav-menu {
        list-style: none;
        margin: 0;
        padding: 0 0 calc(80px + env(safe-area-inset-bottom)) 0;
    }

    .mobile-nav-menu li {
        display: block;
        opacity: 0;
        transform: translateY(10px);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    body.mobile-menu-active .mobile-nav-menu li {
        opacity: 1;
        transform: translateY(0);
    }

    /* Staggered animation for list items */
    body.mobile-menu-active .mobile-nav-menu li:nth-child(1) {
        transition-delay: 0.05s;
    }

    body.mobile-menu-active .mobile-nav-menu li:nth-child(2) {
        transition-delay: 0.1s;
    }

    body.mobile-menu-active .mobile-nav-menu li:nth-child(3) {
        transition-delay: 0.15s;
    }

    body.mobile-menu-active .mobile-nav-menu li:nth-child(4) {
        transition-delay: 0.2s;
    }

    body.mobile-menu-active .mobile-nav-menu li:nth-child(5) {
        transition-delay: 0.25s;
    }

    body.mobile-menu-active .mobile-nav-menu li:nth-child(6) {
        transition-delay: 0.3s;
    }

    body.mobile-menu-active .mobile-nav-menu li:nth-child(7) {
        transition-delay: 0.35s;
    }

    body.mobile-menu-active .mobile-nav-menu li:nth-child(8) {
        transition-delay: 0.4s;
    }

    .mobile-nav-menu li a {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 18px 30px;
        font-size: 15px;
        font-weight: 500;
        color: #1f2937;
        text-decoration: none;
        border-bottom: 1px solid #e5e7eb;
        transition: all 0.2s ease;
    }

    .mobile-nav-menu li:first-child a {
        border-top: 1px solid #e5e7eb;
    }

    .mobile-nav-menu li:last-child a {
        border-bottom: none;
    }

    .mobile-nav-menu li a:active {
        background-color: rgba(15, 23, 42, 0.05);
    }

    .mobile-nav-menu .current-menu-item>a {
        color: var(--primary-color, #0d6efd);
        font-weight: 600;
        background-color: rgba(13, 110, 253, 0.12);
        border-left: 4px solid var(--primary-color, #0d6efd);
        padding-left: 26px;
    }

    .mobile-nav-menu li.mobile-highlight-reset>a {
        color: #1f2937;
        font-weight: 500;
        background: none;
        border-left: none;
        padding-left: 30px;
    }

    .mobile-nav-menu .current-menu-ancestor:not(.current-menu-item)>a,
    .mobile-nav-menu .current-menu-parent:not(.current-menu-item)>a,
    .mobile-nav-menu .current_page_parent:not(.current-menu-item)>a,
    .mobile-nav-menu .current_page_ancestor:not(.current-menu-item)>a {
        color: #1f2937;
        font-weight: 500;
        background: none;
        border-left: none;
        padding-left: 30px;
    }

    /* Language Switcher Specifics */
    .mobile-drawer-lang-switcher {
        margin: 0 auto;
        /* Center it */
        position: relative;
    }

    .mobile-drawer-lang-switcher .language-switcher {
        font-size: 15px;
    }

    .mobile-drawer-lang-switcher .current-lang {
        display: flex;
        align-items: center;
        gap: 6px;
        color: #1f2937;
        font-weight: 500;
        padding: 8px 12px;
        background: rgba(15, 23, 42, 0.05);
        border-radius: 6px;
    }

    .mobile-drawer-lang-switcher .current-lang::after {
        content: '\25BE';
        font-size: 12px;
        color: inherit;
        margin-left: 4px;
        transition: transform 0.2s ease-in-out;
        border: none;
        width: auto;
        height: auto;
    }

    .mobile-drawer-lang-switcher .lang-dropdown {
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%) translateY(10px);
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        padding: 6px 0;
        margin-top: 8px;
        list-style: none;
        min-width: 140px;
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s ease;
        z-index: 100;
    }

    .mobile-drawer-lang-switcher .language-switcher.lang-switcher-open .lang-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
        display: block;
    }

    .mobile-drawer-lang-switcher .language-switcher.lang-switcher-open .current-lang::after {
        transform: rotate(180deg);
    }

    .mobile-drawer-lang-switcher .lang-dropdown li a {
        padding: 10px 16px;
        display: flex;
        align-items: center;
        gap: 8px;
        color: #4b5563;
        white-space: nowrap;
        text-decoration: none;
        transition: background 0.2s;
    }

    .mobile-drawer-lang-switcher .lang-dropdown li a:hover {
        background: #f3f4f6;
        color: var(--primary-color);
    }

    .mobile-drawer-lang-switcher .lang-dropdown li:last-child a {
        border-bottom: none;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-5px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

@media (max-width: 767px) {
    .header-search {
        display: none;
    }
}

body.mobile-search-visible {
    overflow: hidden;
}

.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-search-modal {
    background: transparent;
    width: 100%;
    max-width: 600px;
    border-radius: 0;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: visible;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.mobile-search-overlay.active .mobile-search-modal {
    transform: scale(1);
}

.mobile-search-form {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.mobile-search-form input {
    width: 100%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 0;
    padding: 18px 60px 18px 20px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    margin: 0;
}

.mobile-search-form input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.mobile-search-form input:focus {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.08);
}

.mobile-search-form button {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    padding: 0 20px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-search-form button:hover {
    color: #fff;
}

.mobile-search-form button:active {
    transform: scale(0.95);
}