/* ==========================================================================
   1. 基础布局与顶部 Header (Site Header)
   ========================================================================== */
.site-header {
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid #eeeeee;
  padding: 10px 0;
  position: relative;
  z-index: 1100;
}

.site-header.is-sticky {
  position: fixed;
  left: 0;
  top: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-inner {
  max-width: none;
  width: 100%;
  padding: 0 30px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
}

.logo img {
  display: block;
  height: 64px;
  width: auto;
  margin-right: 20px;
  border: 0;
}

.header-right-tools {
  display: flex;
  align-items: center;
  gap: 15px;
  height: 100%;
}

.mobile-lang-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.lang-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #1e6cbf;
}

.lang-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  min-width: 100px;
  z-index: 2100;
  border: 1px solid #eee;
}

.lang-dropdown-menu a {
  padding: 10px 15px;
  color: #333;
  text-decoration: none;
  font-size: 14px;
  border-bottom: 1px solid #f5f5f5;
}

.lang-dropdown-menu a:last-child {
  border-bottom: none;
}

.lang-dropdown-menu a:hover {
  background-color: #f8f9fa;
  color: #1e6cbf;
}

.lang-dropdown-menu.show {
  display: flex;
  flex-direction: column;
}

.lang-trigger svg {
  stroke: #1e6cbf !important;
  display: block;
}

/* 搜索框 */
.header-search {
  position: relative;
}

.search-wrapper {
  display: flex;
  align-items: center;
  width: 300px;
  height: 34px;
  background: #f5f5f5;
  border: 1px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.search-wrapper:focus-within {
  background: #ffffff;
  border-color: #1e6cbf;
}

.header-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  font-size: 14px;
  background: transparent !important;
  border: none !important;
  outline: none;
}

.search-icon-static {
  width: 40px;
  flex-shrink: 0;
  height: 100%;
  background-color: #1e6cbf;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

#searchResults {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 500px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  z-index: 1200;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  max-height: 450px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  display: none;
}

/* ==========================================================================
   2. 主导航栏 (PC端) - 1139px 以上
   ========================================================================== */
@media (min-width: 1139px) {
  .header-nav {
    display: block !important;
  }

  .header-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
  }

  .header-nav ul li {
    margin-left: 25px;
    position: relative;
  }

  .header-nav ul li a {
    text-decoration: none;
    color: #333333;
    font-size: 14px;
    font-weight: 500;
    display: block;
    padding: 10px 0;
  }

  .header-nav ul li a:hover {
    color: #1e6cbf;
  }

  .header-nav .nav-submenu {
    display: none;
    position: absolute;
    min-width: 160px;
    background: #ffffff;
    z-index: 1000;
    top: 100%;
    right: 0;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #dddddd;
  }

  .header-nav .nav-dropdown:hover>.nav-submenu {
    display: block !important;
  }

  .menu-toggle {
    display: none !important;
  }
}

/* ==========================================================================
   3. 产品分类导航栏 (蓝色条) - 通用与大屏
   ========================================================================== */
.product-nav-container {
  background: #1e6cbf;
  width: 100%;
  position: relative;
  z-index: 999;
}

.product-nav-inner {
  width: 100%;
  box-sizing: border-box;
}

.prod-nav-list {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item-wrap {
  position: relative !important;
}

.nav-link-main {
  color: #ffffff;
  text-decoration: none;
  padding: 15px 20px;
  display: block;
  font-size: 14px;
  white-space: nowrap;
}

/* Mega Menu 桌面端行为 (769px以上) */
@media (min-width: 769px) {

  .nav-item-wrap:hover>.sub-menu-mega,
  .more-nav-wrap:hover>.more-dropdown {
    display: block !important;
  }

  .prod-mobile-bar {
    display: none;
  }
}

/* ==========================================================================
   4. Mega Menu 核心样式
   ========================================================================== */
.sub-menu-mega {
  display: none;
  position: absolute;
  top: calc(100% + 0px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500 !important;
  width: max-content !important;
  min-width: 180px;
  max-width: calc(100vw - 40px);
  background: #ffffff !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  padding: 20px;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
}

.nav-item-wrap:first-child .sub-menu-mega {
  left: 0;
  transform: none;
}

.nav-item-wrap:last-child .sub-menu-mega {
  left: auto;
  right: 0;
  transform: none;
}

.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: flex-start;
  max-width: 605px;
}

.sub-card {
  width: 140px;
  flex: 0 0 140px;
  text-align: center;
  text-decoration: none;
  color: #444;
}

.card-img {
  width: 100%;
  height: 110px;
  background: #f9f9f9;
  border: 1px solid #eee;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  border-radius: 4px;
}

.card-img img {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
}

/* ==========================================================================
   5. More (更多) 下拉菜单
   ========================================================================== */
.more-dropdown {
  display: none;
  position: absolute;
  right: 0;
  background: #ffffff !important;
  z-index: 1501 !important;
  border: 1px solid #ddd;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 220px;
}

#more-items-container .nav-link-main {
  color: #333 !important;
  padding: 12px 20px;
  border-bottom: 1px solid #f5f5f5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#more-items-container .sub-menu-mega {
  left: auto !important;
  right: 100% !important;
  top: -1px !important;
  transform: none !important;
  min-height: calc(100% + 2px);
}

/* ==========================================================================
   6. 响应式断点 A: 1138px (主导航折叠)
   ========================================================================== */
@media (max-width: 1138px) {
  .menu-toggle {
    display: flex !important;
  }

  .header-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    z-index: 2000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border-top: 1px solid #eee;
  }

  .header-nav.show {
    display: block;
  }

  .header-nav ul {
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
  }

  .header-nav ul li {
    width: 100%;
    margin: 0;
    padding: 14px 0;
    border-bottom: 1px solid #eee;
  }

  .header-nav ul li a {
    padding: 15px 20px;
  }

  .nav-lang-item {
    display: none !important;
  }

  .search-wrapper {
    width: 200px;
  }

  .search-icon-static {
    width: 32px;
  }

  .header-search input {
    font-size: 12px;
  }

  /* 1. 确保子菜单在移动端是静态定位，这样它展开时会撑开父级容器 */
  .header-nav .nav-submenu {
    position: static !important;
    display: none;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    background: #fdfdfd !important;
    padding-left: 8px !important;
    list-style: none;
  }

  /* 2. 修正子菜单项的样式 */
  .header-nav .nav-submenu li {
    border-bottom: 1px solid #f9f9f9 !important;
  }

  .header-nav .nav-submenu li a {
    padding: 12px 20px !important;
    color: #666 !important;
    font-size: 14px !important;
  }
}

/* ==========================================================================
   7. 响应式断点 B: 768px (产品菜单折叠 & 移动端微调)
   ========================================================================== */
@media (max-width: 768px) {
  .logo img {
    height: 44px;
    margin-right: 10px;
  }

  .header-inner {
    padding: 0 15px;
  }

  .prod-mobile-bar {
    display: block;
    background: #1e6cbf;
    padding: 15px;
    color: #ffffff;
    text-align: center;
    cursor: pointer;
  }

  .prod-nav-list {
    display: none;
    flex-direction: column;
    background: #ffffff;
  }

  .prod-nav-list.show {
    display: block;
  }

  .nav-link-main {
    color: #333;
    border-bottom: 1px solid #eee;
  }

  .sub-menu-mega {
    display: none;
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    transform: none !important;
    box-shadow: none;
    background: #f9f9f9 !important;
    border: 0;
    padding: 15px;
  }

  .sub-card {
    width: calc(50% - 8px);
    flex: 0 0 calc(50% - 8px);
  }

  .more-nav-wrap {
    display: none !important;
  }

  .mobile-lang-wrap {
    display: flex;
  }
}

/* 汉堡包按钮图标 */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 22px;
  height: 18px;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 3px;
  background-color: #1e6cbf;
  border-radius: 3px;
}

@media (min-width: 1139px) {
  .mobile-lang-wrap {
    display: none;
  }
}

/* SVG 强制颜色 */
.site-header svg {
  stroke: currentColor;
  display: inline-block;
  vertical-align: middle;
}

/* ==========================================================================
   8. 针对 IE 10/11 的专用补丁 (修复 Flex 失效与折叠失效)
   ========================================================================== */
/* IE10/11 PC 端基础样式 (清除 Flex, 强制单行横向排列) */
@media all and (-ms-high-contrast: none),
(-ms-high-contrast: active) {
  .header-inner {
    display: -ms-flexbox !important;
    -ms-flex-pack: justify;
    -ms-flex-align: center;
  }

  .header-search {
    min-width: 300px;
  }

  .site-header svg {
    height: 24px;
    width: 24px;
  }

  /* 修复：强制横向单行排列，消除 inline-block 产生的 HTML 空白间距 */
  .prod-nav-list {
    display: block !important;
    text-align: center;
    white-space: nowrap !important;
    /* 强制不换行 */
    font-size: 0;
    /* 消除节点间隙 */
  }

  .nav-item-wrap {
    display: inline-block !important;
    vertical-align: top;
    font-size: 14px;
    /* 恢复字体大小 */
    white-space: normal;
    /* 恢复子菜单内部文字正常换行 */
  }
}

/* 修复：将移动端媒体查询拆分出来，避免 IE 嵌套解析失败 */
@media all and (-ms-high-contrast: none) and (max-width: 768px),
(-ms-high-contrast: active) and (max-width: 768px) {

  /* 初始隐藏列表，防止默认展开 */
  .prod-nav-list {
    display: none !important;
    width: 100% !important;
    background: #ffffff !important;
    border: 1px solid #ddd;
    white-space: normal !important;
    /* 移动端恢复纵向换行 */
  }

  /* 点击后通过 JS 添加 show 类名显示 */
  .prod-nav-list.show {
    display: block !important;
  }

  /* 强制菜单项占满整行 */
  .nav-item-wrap {
    display: block !important;
    width: 100% !important;
    border-bottom: 1px solid #eee;
  }

  .nav-link-main {
    color: #333 !important;
    padding: 10px !important;
    display: block !important;
  }

  /* 二级菜单改为纵向展开 */
  .sub-menu-mega {
    position: static !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    padding: 10px !important;
    background: #f9f9f9 !important;
  }
}

/* 建议添加到 CSS 末尾 */
@media (max-width: 768px) {

  /* 当 JS 给链接加上 .active 类时，旋转右侧箭头 */
  .nav-link-main.active .caret {
    display: inline-block;
    transform: rotate(180deg);
    transition: transform 0.3s ease;
  }

  /* 调整二级菜单内的卡片布局，防止在手机上排成一团 */
  .sub-menu-mega .card-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    max-width: none !important;
  }

  .sub-card {
    width: calc(50% - 5px) !important;
    /* 手机上一行显示两个 */
    flex: 0 0 calc(50% - 5px) !important;
    margin-bottom: 10px;
  }
}