/* ===================================================================== */
/* === 01. 导航栏样式 (Header) - 最终修正版 (解决移动端选项消失问题) === */
/* ===================================================================== */

/* 估算主图标宽度 + 间距，用于偏移下拉菜单 */
:root {
    /* 图标宽度 (20px) + 间距 (5px) = 25px */
    --lang-icon-offset: 30px; 
}

/* 注意：Header 所需的全局变量 (:root) 已移至 index.css */

#main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--color-bg-light);
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    padding: 15px 0;
    /* AUTO-REPLACE: replaced 'transition: all' with property-specific transitions */
    transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease;
    height: var(--header-height);
    /* 设定高度 */
    display: flex;
    /* 确保内容居中 */
    align-items: center;
    /* 确保内容居中 */
}

#main-header.scrolled {
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.15);
}

#main-header .logo img {
    height: 80px;
    /* 调整高度与导航栏匹配 */
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    /* 添加间距 */
}

.header-inner-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* 主菜单 */
#main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
}

#main-nav li {
    margin: 0 15px;
}

#main-nav a {
    color: var(--color-text-dark);
    text-decoration: none;
    font-size: 1rem;
    padding: 5px 0;
    transition: color 0.3s ease;
    position: relative;

    /* 确保 nav-link 可以包含图标 */
    display: flex;
    align-items: center;
}

/* 消除所有可点击元素（链接和按钮）在聚焦或点击时出现的默认“框” */
#main-header a:focus,
#main-header a:focus-visible,
#main-header button:focus,
#main-header button:focus-visible {
    /* outline: none 是主要解决办法 */
    outline: none !important;
    /* box-shadow: none 防止某些浏览器使用阴影作为焦点指示 */
    box-shadow: none !important;
}

/* 确保您的 Logo 链接也没有任何轮廓 */
.logo a:focus,
.logo a:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* 导航链接 Hover 效果：渐变色下划线 */
#main-nav a:hover {
    color: var(--color-primary);
}

#main-nav a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--brand-gradient);
    transition: width 0.3s ease;
}

#main-nav a:hover::after {
    width: 100%;
}

.action-link {
    color: var(--color-text-dark);
    text-decoration: none;
    margin-right: 20px;
    transition: color 0.3s;
}

.action-link:hover {
    color: var(--color-text-subtle);
}

/* 下拉箭头图标样式 */
.nav-link i.fa-chevron-down {
    font-size: 0.7em;
    margin-left: 5px;
    transition: transform 0.3s;
}

.menu-item:hover .nav-link i.fa-chevron-down {
    transform: rotate(180deg);
}


/* ===================================================================== */
/* === Mega Menu 基础样式 (产品, 解决方案, 文档, 定价, 关于我们) === */
/* ===================================================================== */
.menu-item.has-mega-menu {
    position: relative;
}

.mega-menu-content {
    position: absolute;
    left: 50%;
    top: 100%;

    width: max-content;
    min-width: 650px;
    max-width: 90vw;

    padding: 30px;
    background-color: var(--color-bg-light);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 1000;

    display: flex;
    justify-content: space-between;
    gap: 30px;

    /* 默认隐藏和过渡 */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, 10px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

.menu-item.has-mega-menu:hover .mega-menu-content {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
}

/* Mega Menu 内容样式 */
.product-column {
    /* 允许产品列灵活适应内容，并提供足够的最小基础宽度 */
    flex: 1 1 280px;
    padding-right: 20px;
    border-right: 1px solid var(--color-border-light);
}

/* 热门地区列 (产品菜单的第三列) */
.hot-regions-column {
    flex: 0 0 150px;
    /* 固定热门地区列的宽度 */
    padding-left: 20px;
    border-left: none;
}

/* 移除产品菜单最后一列的分隔线 */
.menu-item:not(.has-pricing-menu):not(.has-about-menu) .product-column:last-of-type {
    border-right: none;
    padding-right: 0;
}

.menu-item.has-solutions-menu .product-column:nth-child(2) {
    border-right: none;
}


/* 标题和文字样式 */
.category-title {
    font-size: 0.9em;
    font-weight: 700;
    color: var(--color-text-subtle);
    margin-bottom: 15px;
    padding-bottom: 5px;
}

/* 单个产品项 (Product Item) 样式 */
.product-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 10px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--color-text-dark);
    border-radius: 8px;
    transition: background-color 0.2s, transform 0.2s;
}

.product-item:hover {
    background-color: var(--color-bg-secondary);
    transform: translateX(3px);
}

.product-item i {
    font-size: 20px;
    color: var(--color-primary);
    margin-right: 15px;
    margin-top: 2px;
    flex-shrink: 0;
}

/* 【优化项】：小标题颜色调淡 */
.product-item h6 {
    margin: 0;
    font-size: 1em;
    font-weight: bold;
    color: #495057;
}

.product-item p {
    margin: 0;
    font-size: 0.8em;
    color: var(--color-text-subtle);
    line-height: 1.3;
    margin-top: 2px;
}

/* --- 热门地区列表样式 --- */
.region-list,
.region-list-vertical {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.region-list li,
.region-list-vertical li {
    font-size: 0.9em;
    color: var(--color-text-dark);
    padding: 6px 0;
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    width: 100% !important;
    text-align: left;
}

.region-list li img,
.region-list-vertical li img {
    width: 20px;
    height: auto;
    margin-right: 10px;
    border-radius: 3px;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);
    display: block;
}

.region-list li .region-name,
.region-list-vertical li .region-name {
    display: block;
    flex-shrink: 0;
    white-space: nowrap;
}




/* ===================================================================== */
/* === Mega Menu 变体样式 (Solutions, Docs, Pricing, About) - 最终优化 === */
/* ===================================================================== */

/* --- 1. 解决方案 (Solutions) 菜单: 三列 --- */
.menu-item.has-solutions-menu .mega-menu-content {
    min-width: 800px;
    max-width: 850px;
}

/* --- 2. 文档 (Docs) 菜单: 两列 --- */
.menu-item.has-docs-menu .mega-menu-content {
    min-width: 600px;
    max-width: 700px;
    gap: 20px;
}

.menu-item.has-docs-menu .product-column {
    flex: 1 1 250px;
    padding-right: 20px;
}

.menu-item.has-docs-menu .product-column:last-child {
    border-right: none;
    padding-right: 0;
}

/* --- 3. 定价 (Pricing) 菜单: 【修正】双列横向布局 --- */
.menu-item.has-pricing-menu .mega-menu-content {
    /* 恢复默认的 flex-direction: row (横向排列) */
    width: max-content;
    min-width: 600px; /* 增大最小宽度以容纳两列 */
    max-width: 800px;
    
    flex-direction: row; /* 显式设置横向排列 */
    gap: 30px; /* 恢复列之间的间距 */
}

/* 修正：让定价菜单的产品列恢复双列样式 */
.menu-item.has-pricing-menu .product-column {
    /* 允许列占据 flex-content 的一部分，让它们并排 */
    flex: 1 1 280px; 
    padding-right: 20px;
    border-right: 1px solid var(--color-border-light); /* 添加分隔线 */
}

/* 移除定价菜单最后一列的分隔线 */
.menu-item.has-pricing-menu .product-column:last-of-type {
    border-right: none;
    padding-right: 0;
}

/* ===================================================================== */
/* === 专属：定价菜单 (Pricing Menu) 的产品列表样式 (名称左对齐，价格右对齐) === */
/* ===================================================================== */

/* 1. 确保 .product-text 占据图标右侧的全部宽度 (横着排的关键) */
.has-pricing-menu .product-item .product-text {
    flex-grow: 1; /* 占据图标右侧的所有剩余空间 */
    display: block; /* 保持描述P标签在下一行 */
}

/* 2. product-header 负责 H6 和 Price 的横向对齐 */
.has-pricing-menu .product-header {
    display: flex;
    align-items: center; 
    width: 100%; 
    margin-bottom: 2px;
}

/* 3. 价格样式 (核心：右对齐) */
.has-pricing-menu .product-price {
    margin-left: auto; /* ** 关键：将价格推到最右边 ** */
    
    /* 样式继承 */
    flex-shrink: 0;
    font-size: 1em;
    font-weight: 700;
    color: var(--color-primary); 
    white-space: nowrap; 
    text-align: right; 
}

/* 4. H6 和 P 的微调 */
.has-pricing-menu .product-item h6 {
    margin: 0; 
    flex-shrink: 0;
}
.has-pricing-menu .product-item p {
    margin: 0; 
    margin-top: 2px;
}

/* 移动端优化 */
@media (max-width: 768px) {
    /* 移动端，Mega Menu content 会被其他规则强制垂直堆叠 (这是正确的) */

    /* 确保 H6/Price 在移动端仍然左右对齐 */
    .has-pricing-menu .product-header {
        display: flex;
    }
    
    .has-pricing-menu .product-price {
        font-size: 0.9em;
        text-align: right;
    }
}

/* --- 4. 关于我们 (About Us) 菜单: 保持单列 (如果需要) --- */
.menu-item.has-about-menu .mega-menu-content {
    /* 保持单列垂直堆叠 */
    width: max-content;
    min-width: 200px;
    max-width: 90vw;
    flex-direction: column;
    gap: 0;
}
.menu-item.has-about-menu .product-column {
    flex: none;
    width: 100%;
    border-right: none;
    padding-right: 0;
    padding-left: 0;
}


/* 移动端优化和汉堡菜单控制 (保持原样) */
.menu-toggle {
    display: none;
    /* 默认隐藏 */
}


/* --- 媒体查询：小屏幕 (Max-Width: 768px) --- */
@media (max-width: 768px) {

    /* 1. 按钮和汉堡菜单控制 */
    .menu-toggle {
        display: block;
        /* ⬅️ 显示汉堡按钮 */
        order: 3;
        font-size: 24px;
        cursor: pointer;
    }

    /* 隐藏登录按钮，保留注册按钮 (假设注册按钮有 .btn-primary 类) */
    .header-actions .action-link:not(.btn-primary) {
        display: none;
        /* ⬅️ 隐藏登录按钮 */
    }

    /* 2. 主菜单结构调整 */
    #main-nav {
        /* HIDE: 确保在小屏上默认隐藏 */
        display: none !important;
        /* ⬅️ 必须使用 !important 确保隐藏 */
        position: absolute;
        top: 80px;
        left: 0;
        width: 100%;
        background-color: var(--color-bg-light);
        box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
        padding: 0;
        z-index: 999;
    }

    #main-nav.active {
        /* SHOW: 确保在 active 时显示 */
        display: block !important;
        /* ⬅️ 必须使用 !important 确保显示 */
    }

    #main-nav ul {
        /* ⬅️ 【核心修正】：强制菜单列表显示，防止被其他规则隐藏 */
        display: flex !important;
        flex-direction: column;
        /* ⬅️ 菜单垂直堆叠 */
        align-items: flex-start;
        width: 100%;
    }

    #main-nav li {
        margin: 0;
        width: 100%;
        border-bottom: 1px solid var(--color-border-light);
    }

    #main-nav a {
        padding: 15px 20px;
        /* 增大点击区域 */
        width: 100%;
        display: block;
        border-bottom: none;
    }

    #main-nav a::after {
        display: none;
    }

    /* 3. Mega Menu 结构和内容简化 */

    .mega-menu-content,
    .menu-item.has-solutions-menu .mega-menu-content,
    .menu-item.has-docs-menu .mega-menu-content,
    .menu-item.has-pricing-menu .mega-menu-content,
    .menu-item.has-about-menu .mega-menu-content {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        flex-direction: column;
        gap: 0;
        padding-left: 0;
        padding-right: 0;
        position: static;
        transform: none;
        box-shadow: none;
        display: none;
    }

    .menu-item.active .mega-menu-content {
        display: flex;
    }

    .product-column {
        border-right: none;
        padding: 15px 20px;
        flex: 1 1 100%;
    }

    .hot-regions-column {
        border-left: none;
        padding: 15px 20px;
        width: 100%;
    }

    /* 隐藏图标 */
    .product-item i {
        display: none;
        /* ⬅️ 隐藏产品图标 */
    }

    /* 隐藏地区旗帜图标 */
    .region-list li img,
    .region-list-vertical li img {
        display: none;
        /* ⬅️ 隐藏地区旗帜 */
    }

    .product-item {
        padding: 10px 5px;
        border-bottom: 1px solid var(--color-border-light);
        margin-bottom: 0;
    }

    .region-list li .region-name {
        display: block;
        white-space: normal;
    }
    
    /* 移动端隐藏语言切换器 */
    .language-switcher {
        display: none; 
    }
}

/* 确保桌面端（> 1025px）的主导航始终可见，汉堡按钮隐藏 */
@media (min-width: 1025px) {
    #main-nav {
        display: block !important;
    }

    .menu-toggle {
        display: none !important;
    }
}

/* ===================================================================== */
/* === 新增：多语言切换样式 (Language Switcher) - 优化和图标放大版 === */
/* ===================================================================== */

.language-switcher {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.language-switcher .lang-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-dark);
    font-size: 1rem;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;

    display: flex;
    align-items: center;
    gap: 5px; 
}

.language-switcher .lang-toggle:hover {
    color: var(--color-primary);
    background-color: var(--color-bg-secondary);
}

.language-switcher .lang-toggle:focus,
.language-switcher .lang-toggle:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* 调大地球图标尺寸 */
.language-switcher .lang-toggle .lang-icon-main {
    font-size: 20px; /* 图标放大 */
    color: var(--color-primary); /* 使用主色调突出显示 */
}

.language-switcher .lang-toggle .fas.fa-chevron-down {
    font-size: 0.7em;
    transition: transform 0.3s;
}

/* 下拉菜单容器样式 */
.lang-dropdown {
    list-style: none;
    margin: 0;
    padding: 20px 0;

    position: absolute;
    top: 100%;
    
    min-width: 160px;
    background-color: var(--color-bg-light);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    z-index: 1001;

    opacity: 0;
    visibility: hidden;
    
    /* 关键对齐调整：X轴偏移等于 --lang-icon-offset 的负值 */
    right: -50px; 
    
    /* Y 轴的微调保持不变 */
    transform: translateY(0px);
    transition: opacity 0.3s, transform 0.3s;
}

/* 悬停/展开时，移除 Y 轴偏移，但保留 X 轴偏移 */
.language-switcher:hover .lang-dropdown,
.lang-toggle[aria-expanded="true"] + .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translate(calc(var(--lang-icon-offset) * -1), 0);
}


/* 语言选项样式 */
.lang-option a {
    text-decoration: none;
    color: var(--color-text-dark);
    font-size: 0.95rem;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.lang-option a:hover,
.lang-option.active a {
    background-color: var(--color-bg-secondary);
    color: var(--color-primary);
}

/* 旗帜图标样式 */
.lang-option .flag-icon {
    width: 20px;
    height: 15px;
    border: 1px solid var(--color-border-light);
    border-radius: 2px;
    object-fit: cover;
    flex-shrink: 0;
}