/**
 * Header 样式文件
 * 
 * @package WorthRanker
 */

/* 头部样式 */
.site-header {
    background-color: #fff;
    position: relative;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 22px 0;
    position: relative;
}

/* 网站标志样式 */
.site-branding {
    flex: 0 0 auto;
    z-index: 10;
    position: relative;
}

.site-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    position: relative;
    display: inline-block;
}

.site-title a {
    text-decoration: none;
    color: #337ab7;
    display: inline-block;
    position: relative;
}

.site-title img {
    display: block;
    height: 30px;
    width: auto;
    max-width: 100%;
}

/* 导航菜单 */
.main-navigation {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
    pointer-events: auto;
}

.category-nav-menu {
    list-style: none;
    display: flex;
    gap: 2rem;
    margin: 0;
    padding: 0;
    align-items: center;
}

.category-nav-menu .menu-item {
    margin: 0;
}

.category-nav-menu a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.category-nav-menu .current-menu-item a {
    color: #337ab7;
}

.category-nav-menu a:hover {
    color: #337ab7;
}

/* 头部右侧包装器 */
.header-right-wrapper {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 20;
}

/* 头部右侧功能图标 */
.header-actions {
    display: flex;
    /* gap: 1.5rem; */
    align-items: center;
    position: relative;
    z-index: 20;
}

.header-icon {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
    /* min-width: 44px; */
    /* min-height: 44px; */
    border-radius: 4px;
    position: relative;
    z-index: 21;
}

.header-icon:hover {
    color: #337ab7;
    background-color: rgba(51, 122, 183, 0.1);
}

.header-icon:active {
    background-color: rgba(51, 122, 183, 0.2);
}

.header-icon svg {
    display: block;
}

.header-icon:focus {
    outline: 2px solid #337ab7;
    outline-offset: 2px;
}

/* 语言切换器样式 - 与 header-icon 保持一致 */
.header-actions .language-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #333;
    transition: color 0.3s;
    border-radius: 4px;
    margin: 0;
    float: none;
    padding-top: 8px;
    font-size: inherit;
    line-height: normal;
}

.header-actions .language-switcher i {
    font-size: 20px;
    color: currentColor;
    transition: color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-actions .language-switcher:hover {
    color: #337ab7;
    background-color: rgba(51, 122, 183, 0.1);
}

.header-actions .language-switcher:active {
    background-color: rgba(51, 122, 183, 0.2);
}

.header-actions .language-switcher:focus {
    outline: 2px solid #337ab7;
    outline-offset: 2px;
}

/* 语言下拉菜单样式优化 */
.header-actions .language-switcher .language-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    min-width: 140px;
    z-index: 1001;
    display: none;
    margin-top: 0;
    padding: 8px 0;
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #337ab7 #f1f1f1;
}

.header-actions .language-switcher .language-dropdown.show {
    display: block;
}

/* 自定义滚动条样式 */
.header-actions .language-switcher .language-dropdown::-webkit-scrollbar {
    width: 6px;
}

.header-actions .language-switcher .language-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.header-actions .language-switcher .language-dropdown::-webkit-scrollbar-thumb {
    background: #337ab7;
    border-radius: 3px;
}

.header-actions .language-switcher .language-dropdown::-webkit-scrollbar-thumb:hover {
    background: #2868a5;
}

/* 语言选项样式 */
.header-actions .language-switcher .language-option {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-weight: 500;
}

.header-actions .language-switcher .language-option:hover {
    background-color: rgba(51, 122, 183, 0.08);
    color: #337ab7;
}

.header-actions .language-switcher .language-option.active {
    background-color: rgba(51, 122, 183, 0.1);
    color: #337ab7;
    font-weight: 600;
}

/* 汉堡菜单按钮 */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    color: #333;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    align-items: center;
    transition: color 0.3s;
    border-radius: 4px;
    position: relative;
    z-index: 21;
}

.menu-toggle:hover {
    color: #337ab7;
    background-color: rgba(51, 122, 183, 0.1);
}

.menu-toggle:focus {
    outline: 2px solid #337ab7;
    outline-offset: 2px;
}

.menu-toggle-icon {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 24px;
    height: 18px;
}

.menu-toggle-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: currentColor;
    transition: all 0.3s;
    border-radius: 2px;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(2) {
    opacity: 0;
}

.menu-toggle[aria-expanded="true"] .menu-toggle-icon span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* 搜索框覆盖层 */
.search-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #fff;
    z-index: 9999;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, transform 0.3s ease-out, opacity 0.3s ease-out;
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.search-overlay.active {
    max-height: 100%;
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* PC端：确保header布局正常 */
@media (min-width: 1025px) {
    .site-header .container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
        position: relative;
    }
    
    .site-branding {
        flex: 0 0 auto;
    }
    
    .main-navigation {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 5;
    }
    
    .header-right-wrapper {
        flex: 0 0 auto;
    }
    
    /* 搜索框激活时隐藏导航菜单 */
    .main-navigation.search-hidden {
        display: none !important;
    }
    
    /* 确保右侧图标区域有足够的z-index */
    .header-right-wrapper {
        position: relative;
        z-index: 10;
    }
    
    /* PC端搜索框覆盖层完全覆盖header */
    .search-overlay {
        height: 100%;
    }
    
    .search-overlay.active {
        height: 100%;
    }
    
    /* PC端菜单项字体样式 */
    .category-nav-menu a {
        font-family: 'Open Sans', sans-serif;
        font-weight: 600;
        font-size: 20px;
        color: #000000;
        line-height: 27px;
    }
}

.search-form-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 4px;
    display: none;
    align-items: center;
    justify-content: center;
    height: 100%;
    /* min-height: 80px; */
}

.search-overlay.active .search-form-wrapper {
    display: flex;
}

.search-form {
    width: 100%;
    /* max-width: 600px; */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.search-field {
    flex: 1;
    padding: 12px 20px;
    font-size: 1rem;
    background-color: #FFFFFF;
    border: none;
    border-radius: 8px;
    outline: none;
    transition: background-color 0.3s;
    font-family: inherit;
    text-align: center;
    color: #333;
    /* 隐藏浏览器默认的清除按钮 */
    appearance: none;
    -webkit-appearance: none;
}

/* 隐藏WebKit浏览器的清除按钮 */
.search-field::-webkit-search-cancel-button {
    display: none;
    -webkit-appearance: none;
}

/* 隐藏IE/Edge的清除按钮 */
.search-field::-ms-clear {
    display: none;
}

.search-field::placeholder {
    color: #999;
    text-align: center;
}

.search-field:focus {
    background-color: #FFFFFF;
}

.search-field:focus::placeholder {
    color: #bbb;
}

.search-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.search-close:hover {
    opacity: 0.7;
}

.search-close:focus {
    outline: 2px solid #337ab7;
    outline-offset: 2px;
    border-radius: 2px;
}

.search-close svg {
    display: block;
    width: 16px;
    height: 16px;
}

/* 响应式设计 */
@media (max-width: 1240px) {
    .site-header .container {
        padding: 20px 0px;
    }

    .category-nav-menu {
        gap: 1.5rem;
    }

    /* 菜单项字体样式 */
    .category-nav-menu a {
        font-family: 'Open Sans', sans-serif;
        font-weight: 600;
        font-size: 18px;
        color: #000000;
        line-height: 24px;
    }

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

    .site-title img {
        height: 28px;
    }
}

@media (max-width: 1024px) {
    .site-header .container {
        padding: 20px 20px;
        flex-wrap: wrap;
    }

    .site-branding {
        flex: 1 1 auto;
        min-width: 0;
    }

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

    .site-title img {
        height: 26px;
    }

    .header-right-wrapper {
        flex: 0 0 auto;
        gap: 0.5rem;
    }

    /* 平板端显示汉堡菜单 */
    .menu-toggle {
        display: flex;
    }

    /* 平板端导航菜单隐藏默认显示 */
    .main-navigation {
        position: static;
        transform: none;
        flex: 1 1 100%;
        order: 3;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
        margin-top: 0;
    }

    .main-navigation.toggled {
        max-height: 1000px;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid #e0e0e0;
    }

    .category-nav-menu {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
        width: 100%;
    }

    .category-nav-menu .menu-item {
        width: 100%;
        border-bottom: 1px solid #f0f0f0;
    }

    .category-nav-menu .menu-item:last-child {
        border-bottom: none;
    }

    /* 平板端菜单项字体样式 */
    .category-nav-menu a {
        display: block;
        padding: 1rem 0;
        font-family: 'Open Sans', sans-serif;
        font-weight: 600;
        font-size: 16px;
        color: #000000;
        line-height: 22px;
        text-align: left;
        width: 100%;
        text-transform: none;
        letter-spacing: 0;
    }

    .category-nav-menu a:hover {
        padding-left: 10px;
        transition: padding-left 0.3s;
    }

    .search-form-wrapper {
        padding: 0 20px;
    }
}

@media (max-width: 768px) {
    /* 移动端头部布局 */
    .site-header .container {
        padding: 15 0;
    }

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

    .site-title img {
        height: 24px;
    }

    .header-icon {
        padding: 6px;
        min-width: 40px;
        min-height: 40px;
    }

    .header-icon svg {
        width: 18px;
        height: 18px;
    }

    /* 移动端语言切换器样式 */
    .header-actions .language-switcher {
        padding: 6px;
        min-width: 40px;
        min-height: 40px;
    }

    .header-actions .language-switcher i {
        font-size: 18px;
    }

    .header-actions .language-switcher .language-dropdown {
        right: 0;
        min-width: 130px;
    }

    /* 移动端搜索框 */
    .search-form-wrapper {
        padding: 0 15px;
        height: 70px;
    }

    .search-form {
        max-width: 100%;
    }

    .search-field {
        font-size: 16px; /* 防止 iOS 自动缩放 */
        padding: 10px 16px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .site-title {
        font-size: 1.3rem;
    }

    .site-title img {
        height: 22px;
    }

    .header-icon {
        min-width: 36px;
        min-height: 36px;
        padding: 5px;
    }

    .header-icon svg {
        width: 16px;
        height: 16px;
    }

    /* 超小屏幕语言切换器样式 */
    .header-actions .language-switcher {
        min-width: 36px;
        min-height: 36px;
        padding: 5px;
    }

    .header-actions .language-switcher i {
        font-size: 16px;
    }

    .header-actions .language-switcher .language-dropdown {
        min-width: 120px;
    }

    .site-header .container {
        padding: 6px 12px;
    }

    /* 超小屏幕菜单项字体样式 */
    .category-nav-menu a {
        font-family: 'Open Sans', sans-serif;
        font-weight: 600;
        font-size: 14px;
        color: #000000;
        line-height: 20px;
        padding: 0.85rem 0;
    }

    .search-form-wrapper {
        padding: 0 12px;
        height: 60px;
    }

    .search-field {
        font-size: 16px;
        padding: 8px 14px;
    }
}

