/* ===== 头部样式 ===== */

/* 全站：防止页面宽高溢出，避免导航随横向滚动错位（固定/粘性导航相对视口） */
html {
    overflow-x: hidden !important;
}
body {
    overflow-x: hidden !important;
    max-width: 100%;
}

/* 头部按钮容器 */
.header1-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

/* 搜索按钮 - 圆形 */
.search-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #e9ecef;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.search-icon-btn:hover {
    border-color: #2f318b;
    background: #f8f9fa;
}

/* 语言选择器容器 */
.language-selector {
    position: relative;
}

/* 语言选择按钮 */
.lang-select-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.lang-select-btn:hover {
    border-color: #2f318b;
    background: #f8f9fa;
}

/* 语言选择器图标 */
.lang-globe-icon {
    color: #666;
}

.lang-arrow-icon {
    color: #666;
}

/* 语言国旗图片 */
.lang-flag-img {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
}

/* 语言文本 */
.lang-text {
    font-size: 14px;
    color: #333;
}

/* 语言下拉菜单 */
.lang-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 5px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    display: none;
    z-index: 1000;
}

/* 语言选项 */
.lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    text-decoration: none;
    color: #333;
    font-size: 14px;
    transition: background 0.3s;
}

.lang-option:hover {
    background: #f8f9fa;
}

.lang-option-border {
    border-top: 1px solid #f0f0f0;
}

/* 搜索框弹出层 */
.search-box-popup {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px;
    display: none;
    z-index: 1000;
    min-width: 180px;
}

/* 搜索表单 */
#searchForm {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border-radius: 16px;
    padding: 2px 6px;
    border: 1px solid #e9ecef;
    transition: all 0.3s;
}

#searchForm:focus-within {
    border-color: #2f318b;
    box-shadow: 0 0 0 3px rgba(47, 49, 139, 0.1);
    background: #fff;
}

/* 搜索输入框 */
.search-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 12px;
    color: #333;
    width: 160px;
    padding: 2px 6px;
}

/* 搜索按钮 */
.search-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    min-width: 20px;
}

.search-btn:hover {
    color: #2f318b;
}

/* 顶部主导航下拉菜单（桌面端） */
.main-menu-ex1 > ul > li {
    position: relative;
}
.main-menu-ex1 .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    width: auto;               /* Width will be adjusted via JS (except for product dropdown) */
    padding: 8px 0;
    margin-top: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    list-style: none;
    display: none;
    z-index: 1000;
}
.main-menu-ex1 .dropdown-menu li a {
    display: block;
    padding: 8px 16px;
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}
.main-menu-ex1 .dropdown-menu-products li a {
    padding: 8px 28px; /* extra horizontal space for product items */
}

/* Product dropdown: width follows its content (longest item), not fixed */
.main-menu-ex1 .dropdown-menu-products {
    width: max-content;
    min-width: 0;
}
.main-menu-ex1 .dropdown-menu li a:hover {
    background: #f5f6fa;
    color: #2f318b;
}
/* 通过 JS 控制 .nav-open 类，支持延迟关闭 */
.main-menu-ex1 li.dropdown-menu-parrent.nav-open > .dropdown-menu {
    display: block;
}

/* 有二级菜单的右侧小箭头（仅桌面端显示） */
.nav-arrow {
    display: inline-block;
    margin-left: 4px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    vertical-align: middle;
}

/* ===== 1450px 断点：小屏导航在 1450 以下出现 ===== */
@media (max-width: 1449px) {
    .header-desktop-only {
        display: none !important;
    }
    .header-mobile-only {
        display: block !important;
    }
}
@media (min-width: 1450px) {
    .header-desktop-only {
        display: block !important;
    }
    .header-mobile-only {
        display: none !important;
    }
}

/* 共用弹层容器：固定定位，供桌面/小屏按钮共用 */
.header-shared-popups {
    position: fixed;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    z-index: 10000;
    pointer-events: none;
}
.header-shared-popups .search-box-popup,
.header-shared-popups .lang-dropdown {
    pointer-events: auto;
}
/* 搜索框由 JS 动态定位到触发按钮下方，此处仅做占位样式 */
.header-shared-popups .search-box-popup {
    position: fixed;
    left: auto;
    margin-top: 0;
    /* Let the search box keep its designed width but clamp within viewport */
    width: auto;
    max-width: calc(100% - 32px);
}
@media (max-width: 768px) {
    .header-shared-popups .search-box-popup {
        width: auto;
        max-width: calc(100% - 24px);
    }
}
.header-shared-popups .language-selector-dropdown {
    position: absolute;
    right: 24px;
    top: 70px;
}
.header-shared-popups .lang-dropdown {
    position: absolute;
    right: 0;
    left: auto;
    top: 0;
    margin-top: 0;
    min-width: 130px;
}
@media (max-width: 1449px) {
    .header-shared-popups .language-selector-dropdown {
        right: 20px;
        top: 58px;
    }
    .header-shared-popups .lang-dropdown {
        right: 0;
        top: 0;
    }
}

/* 1450–768 小屏导航条统一样式（避免 770–1449 区间错乱） */
@media (max-width: 1449px) {
    .mobile-header.header-mobile-only {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        padding: 12px 0;
        z-index: 999;
        background: #fff;
        box-shadow: 0 1px 0 rgba(0,0,0,0.06);
    }
    .mobile-header .container-fluid {
        width: 100%;
        padding-left: 20px;
        padding-right: 20px;
    }
    .mobile-header .container-fluid .col-12 {
        padding: 0;
    }
    .mobile-header-elements {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 16px;
    }
    .mobile-header-elements .mobile-logo {
        flex-shrink: 0;
        max-width: 200px;
    }
    .mobile-header-elements .mobile-logo a {
        display: block;
        line-height: 0;
    }
    .mobile-header-elements .mobile-logo img {
        max-height: 44px;
        width: auto;
        max-width: 100%;
        object-fit: contain;
        vertical-align: middle;
    }
    .mobile-header-buttons {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
    }
    .mobile-header-buttons .mobile-nav-icon {
        font-size: 20px;
        border: 1px solid #e9ecef;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        color: #333;
        flex-shrink: 0;
    }
}

/* 小屏头部按钮组：搜索 + 语言 + 菜单图标 */
.mobile-header-buttons .search-icon-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}
.mobile-header-buttons .lang-select-btn {
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
}
.mobile-header-buttons .lang-select-btn .lang-text {
    font-size: 13px;
}
.mobile-header-buttons .lang-select-btn .lang-flag-img {
    width: 18px;
    height: 14px;
}

@media (max-width: 400px)  {
    .mobile-header.header-mobile-only{
        padding: 10px 0;
    }
    
}
/* 400px 以下：头部只保留汉堡菜单，搜索和语言移入侧栏 */
@media (max-width: 400px) {
    .mobile-header-buttons .search-icon-btn,
    .mobile-header-buttons .language-selector {
        display: none !important;
    }
}
/* 401px 以上：侧栏内不显示搜索/语言（在头部显示） */
@media (min-width: 401px) {
    .mobile-sidebar .sidebar-tools {
        display: none !important;
    }
}

/* 侧栏内的搜索 + 语言（仅 400px 以下显示） */
.mobile-sidebar .sidebar-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid #eee;
}
.mobile-sidebar .sidebar-tools .sidebar-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 15px;
    color: #333;
    background: #f5f7fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.mobile-sidebar .sidebar-tools .sidebar-tool-btn:hover {
    background: #edf1f8;
    border-color: #2f318b;
    color: #2f318b;
}
.mobile-sidebar .sidebar-tools .search-icon-btn span {
    font-weight: 500;
}
/* 侧栏内搜索、语言两个框高度一致 */
.mobile-sidebar .sidebar-tools .search-icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    flex-shrink: 0;
}
.mobile-sidebar .sidebar-tools .lang-select-btn {
    height: 40px;
    min-height: 40px;
    padding: 0 14px;
    font-size: 15px;
    box-sizing: border-box;
    line-height: 1;
}

/* 小屏侧栏：1450 以下默认隐藏，点击汉堡菜单后才显示；样式与小屏(769以下)一致 */
@media (max-width: 1449px) {
    .mobile-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 100%;
        height: 100%;
        background: #fff;
        z-index: 9999;
        padding: 40px 30px;
        visibility: hidden;
        opacity: 0;
        transition: left 0.3s, visibility 0.3s, opacity 0.3s;
        overflow-y: auto;
    }
    .mobile-sidebar.mobile-menu-active {
        left: 0;
        visibility: visible;
        opacity: 1;
        padding-top: 55px;
    }
    /* 关闭按钮：与小屏一致 */
    .mobile-sidebar .menu-close {
        position: absolute;
        right: 20px;
        top: 20px;
        font-size: 25px;
        color: #000;
        cursor: pointer;
        z-index: 10;
    }
    /* 主导航链接：与小屏一致 */
    .mobile-sidebar .mobile-nav li a {
        font-size: 18px;
        line-height: 24px;
        color: #000;
        padding: 10px 0;
        display: block;
        font-weight: 500;
    }
    .mobile-sidebar .mobile-nav li a:hover {
        color: #2f318b;
    }
    /* 小屏侧栏：有下拉的项在右侧显示下拉箭头 */
    .mobile-sidebar .mobile-nav li.has-dropdown > a,
    .mobile-sidebar .mobile-nav li.has-sub > a {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .mobile-sidebar .nav-arrow {
        display: inline-block !important;
        margin-left: 8px;
        flex-shrink: 0;
        transition: transform 0.2s ease;
    }
    .mobile-sidebar li.has-dropdown.open-sub > a .nav-arrow,
    .mobile-sidebar li.has-sub.open-sub > a .nav-arrow {
        transform: rotate(180deg);
    }
    .mobile-sidebar .submenu-button,
    .mobile-sidebar span.submenu-button::before,
    .mobile-sidebar span.submenu-button::after {
        display: none !important;
    }
    .mobile-sidebar .sub-menu {
        display: none;
        padding-left: 15px;
        list-style: none;
        margin: 0;
    }
    .mobile-sidebar li.has-dropdown.open-sub > .sub-menu,
    .mobile-sidebar li.has-sub.open-sub > .sub-menu {
        display: block;
    }
    /* 二级菜单链接：与小屏风格统一 */
    .mobile-sidebar .sub-menu li a {
        padding: 8px 0;
        font-size: 15px;
        color: #2f318b;
        display: block;
    }
    .mobile-sidebar .sub-menu li a:hover {
        color: #1e2068;
    }
}
