/* =========================================
   Header & Navigation Refactoring (Two-Row Layout)
   ========================================= */

/* 1. Top Bar (First Row) - Minimal & Sleek */
.header-top-bar {
    background-color: #0f172a; /* Deep Dark Blue */
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.top-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar-left, .top-bar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.top-contact-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    text-decoration: none;
    transition: color 0.3s;
    line-height: 1;
}

.top-contact-item svg {
    display: block;
}

.top-contact-item:hover {
    color: #fff;
}

.top-contact-item i {
    color: var(--accent-color);
}

/* 2. Main Header (Second Row) - Logo + Menu + Action */
.main-header {
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 80px; /* Fixed height for consistency */
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.header-logo {
    flex-shrink: 0;
    margin-right: 40px;
    display: flex;
    align-items: center;
}

.logo-img {
    height: 45px; /* Adjusted logo height */
    width: auto;
    display: block;
}

/* 3. Navigation Menu (Centered) */
.main-nav {
    flex: 1;
    height: 100%;
}

.nav-menu {
    display: flex;
    align-items: center;
    justify-content: center; /* 菜单整体水平居中 */
    gap: 5px;
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none;
}

.nav-item {
    height: 100%;
    display: flex;
    align-items: center;
    position: relative;
    margin: 0 !important;
    padding: 0 !important;
}

.nav-link {
    padding: 0 25px !important; /* 增加水平内边距，让菜单更舒展 */
    color: var(--primary-color);
    font-weight: 500;
    font-size: 15px;
    text-decoration: none;
    transition: all 0.3s;
    height: 100% !important;
    display: flex !important;
    flex-direction: row !important; /* 强制水平排列 */
    align-items: center !important; /* 强制垂直居中 */
    justify-content: center !important;
    position: relative;
    line-height: 1 !important; /* 设置行高为1，确保文字紧凑 */
    white-space: nowrap; /* 强制不换行 */
    gap: 5px; /* 使用 gap 控制文字和图标间距 */
    margin: 0 !important;
    vertical-align: middle !important;
}

.nav-link svg {
    display: inline-block; /* 恢复 inline-block */
    margin: 0 !important; /* 移除内联样式的 margin，由 gap 接管 */
    flex-shrink: 0; /* 防止图标被压缩 */
    vertical-align: middle; /* 垂直居中对齐 */
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background: var(--accent-color);
    transition: width 0.3s;
}

.nav-link:hover, .nav-link.active {
    color: var(--accent-color);
}

.nav-link:hover::after, .nav-link.active::after {
    width: 100%;
}

/* Mega Menu & Dropdown Base Styles */
.has-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    min-width: 220px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-radius: 0 0 8px 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s;
    z-index: 100;
    padding: 10px 0;
}

.has-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 10px 20px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background: #f8fafc;
    color: var(--accent-color);
    padding-left: 25px;
}

/* 4. Header Actions (Right Side) */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    margin-left: 20px;
}

.search-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.search-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.action-btn {
    padding: 10px 24px;
    background: var(--accent-color);
    color: white;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(52, 112, 255, 0.2);
    white-space: nowrap;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.action-btn:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(52, 112, 255, 0.3);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    font-size: 24px;
    color: var(--primary-color);
    background: none;
    border: none;
    cursor: pointer;
}

/* Language Switcher */
.top-language-switcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.2s;
}

.top-language-switcher:hover {
    background: rgba(255,255,255,0.1);
}

.top-language-switcher.active .lang-dropdown {
    display: block !important;
}

.lang-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0;
    background: #fff;
    min-width: 160px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 6px 0;
    z-index: 9999;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* 在按钮和下拉菜单之间添加不可见的桥接区域 */
.lang-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
}

.lang-option:hover {
    background: #f1f5f9;
    color: var(--accent-color);
}

.lang-flag {
    font-size: 16px;
}

.lang-arrow {
    transition: transform 0.3s;
}

.top-language-switcher.active .lang-arrow {
    transform: rotate(180deg);
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .nav-link { padding: 0 12px; font-size: 14px; }
}

@media (max-width: 991px) {
    .mobile-menu-toggle { display: block; }
    .main-nav {
        display: none; /* Hidden on mobile by default */
        position: absolute;
        top: 80px;
        left: 0;
        right: 0;
        background: #fff;
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        padding: 20px;
    }
    
    .main-nav.active { display: block; }
    
    .nav-menu {
        flex-direction: column;
        align-items: flex-start;
        height: auto;
    }
    
    .nav-item {
        width: 100%;
        height: auto;
        border-bottom: 1px solid #f1f5f9;
    }
    
    .nav-link {
        width: 100%;
        padding: 15px 0;
    }
    
    .nav-link::after { display: none; }
    
    .header-actions { display: none; /* Simplify header on mobile */ }
}
