﻿/* ========== 顶栏 ========== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.site-header.is-scrolled {
  background: #fff;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
}

/* 顶部联系条 */
.header-topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid transparent;
  transition: border-color 0.35s ease;
}

.site-header.is-scrolled .header-topbar {
  border-bottom-color: var(--color-border);
}

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

.header-contacts {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 12px;
}

.header-contacts a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.92);
  transition: color 0.3s;
}

.site-header.is-scrolled .header-contacts a {
  color: var(--color-text-light);
}

.header-contacts a:hover {
  color: var(--color-accent);
}

.header-contacts svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.header-utils {
  display: flex;
  align-items: center;
  gap: 18px;
}

.util-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.92);
  transition: color 0.3s;
}

.site-header.is-scrolled .util-btn {
  color: var(--color-text);
}

.util-btn:hover {
  color: var(--color-accent);
}

.util-btn svg {
  width: 18px;
  height: 18px;
}

/* 中英文切换 */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  font-size: 12px;
  line-height: 1;
  user-select: none;
}

.lang-switch a,
.lang-switch span {
  padding: 4px 6px;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  transition: color 0.3s;
}

.site-header.is-scrolled .lang-switch a,
.site-header.is-scrolled .lang-switch span {
  color: var(--color-text-light);
}

.lang-switch a.is-active,
.lang-switch span.is-active {
  color: #fff;
  font-weight: 400;
}

.site-header.is-scrolled .lang-switch a.is-active,
.site-header.is-scrolled .lang-switch span.is-active {
  color: var(--color-accent);
}

.lang-switch .lang-divider {
  color: rgba(255, 255, 255, 0.45);
  padding: 0 2px;
  cursor: default;
}

.site-header.is-scrolled .lang-switch .lang-divider {
  color: #ccc;
}

/* 主导航 */
.header-nav {
  height: var(--nav-height);
}

.header-nav .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.site-logo {
  flex: 0 0 auto;
}

.site-logo__img {
  display: block;
  width: auto;
  object-fit: contain;
}

/* 未滚动：透明顶栏，Logo 更大 */
.site-logo__img--default {
  height: 96px;
  max-width: 440px;
}

/* 滚动后 / 内页：保持原尺寸 */
.site-logo__img--active {
  display: none;
  height: 72px;
  max-width: 360px;
}

.site-header.is-scrolled .site-logo__img--default,
body.page-inner .site-header .site-logo__img--default {
  display: none;
}

.site-header.is-scrolled .site-logo__img--active,
body.page-inner .site-header .site-logo__img--active {
  display: block;
}

.site-logo .logo-cn {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  line-height: 1.2;
  transition: color 0.35s;
}

.site-header.is-scrolled .site-logo .logo-cn {
  color: var(--color-header-title);
}

.site-logo .logo-en {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.5px;
  line-height: 1.2;
  margin-top: 2px;
  transition: color 0.35s;
}

.site-header.is-scrolled .site-logo .logo-en {
  color: var(--color-text-light);
}

.nav-menu {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.nav-item {
  position: relative;
}

.nav-item__link {
  position: relative;
  display: flex;
  align-items: center;
  height: var(--nav-height);
  padding: 0 22px;
  font-size: 15px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.95);
  border-bottom: none;
  transition: color 0.3s;
  white-space: nowrap;
}

.nav-item__link::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(84%, 108px);
  height: 4px;
  background: rgb(89, 87, 87);
  opacity: 0;
  transition: opacity 0.3s, background 0.3s, height 0.3s;
}

/* 下滑出现白底后再显示下划线 */
.site-header.is-scrolled .nav-item__link::after {
  opacity: 1;
}

.site-header.is-scrolled .nav-item__link {
  color: var(--color-header-title);
}

.site-header.is-scrolled .nav-item__link:hover,
.site-header.is-scrolled .nav-item__link.is-active {
  color: var(--color-accent);
}

.site-header.is-scrolled .nav-item__link:hover::after,
.site-header.is-scrolled .nav-item__link.is-active::after {
  background: var(--color-accent);
}

.site-header.is-scrolled .nav-item__link.is-active::after {
  height: 8px;
}

.site-header:not(.is-scrolled) .nav-item__link.is-active {
  color: #fff;
}

/* 二级下拉菜单 */
:root {
  --nav-dd-link-py: 11px;
  --nav-dd-link-fs: 14px;
  --nav-dd-link-lh: 1.4;
  --nav-dd-first-center: calc(var(--nav-dd-link-py) + var(--nav-dd-link-fs) * var(--nav-dd-link-lh) / 2);
}

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  transform: none;
  padding-top: 0;
  margin-top: 0;
  z-index: 1100;
}

.nav-dropdown::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 6px;
}

.nav-item.has-dropdown:hover .nav-dropdown,
.nav-item.has-dropdown:focus-within .nav-dropdown {
  display: block;
}

.nav-dropdown__list {
  position: relative;
  min-width: 148px;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #ececec;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.nav-dropdown__list::before {
  content: "";
  position: absolute;
  left: -7px;
  top: var(--nav-dd-first-center);
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 7px solid #ececec;
}

.nav-dropdown__link {
  display: block;
  padding: var(--nav-dd-link-py) 18px;
  font-size: var(--nav-dd-link-fs);
  font-weight: 400;
  line-height: var(--nav-dd-link-lh);
  color: #444;
  text-align: center;
  white-space: nowrap;
  transition: background 0.25s, color 0.25s;
}

.nav-dropdown__link:hover {
  background: #4a5d6b;
  color: #fff;
}

/* 移动端菜单按钮 */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: background 0.3s;
}

.site-header.is-scrolled .nav-toggle span {
  background: var(--color-text);
}

/* PC 端：顶栏与页面版心同宽，Logo 与菜单分列两侧 */
@media (min-width: 1025px) {
  :root {
    --topbar-height: 56px;
    --topbar-pad-top: 14px;
    --nav-height: 88px;
    --header-height: calc(var(--topbar-pad-top) + var(--topbar-height) + var(--nav-height));
    --nav-dd-link-fs: 17px;
    --nav-dd-link-py: 11px;
  }

  .header-topbar {
    padding-top: var(--topbar-pad-top);
    height: auto;
    min-height: calc(var(--topbar-pad-top) + var(--topbar-height));
    box-sizing: border-box;
  }

  .header-topbar .container {
    min-height: var(--topbar-height);
  }

  .header-nav {
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  body.page-inner .site-main,
  body.page-product-list .site-main {
    padding-top: var(--header-height);
  }

  .header-contacts {
    font-size: 18.5px;
    gap: 32px;
  }

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

  .lang-switch {
    font-size: 18.5px;
  }

  .util-btn {
    width: 32px;
    height: 32px;
  }

  .util-btn svg {
    width: 20px;
    height: 20px;
  }

  .site-logo .logo-cn {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
  }

  .site-logo .logo-en {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 2px;
  }

  .nav-item__link {
    font-size: 18.5px;
    padding: 0 24px;
  }

  .header-topbar .container,
  .header-nav .container {
    width: min(85%, calc(100% - 2 * var(--container-gutter)));
    max-width: var(--container-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
  }

  .header-nav .container {
    height: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
  }

  .site-logo {
    flex: 0 0 auto;
    max-width: 42%;
    overflow: visible;
  }

  .nav-menu {
    flex: 0 0 auto;
    margin-left: 0;
    position: static;
    flex-direction: row;
    max-height: none !important;
    overflow: visible;
    background: transparent;
    box-shadow: none;
  }

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

  /* 一级项宽度随文字 */
  .nav-item.has-dropdown {
    position: relative;
    width: max-content;
    max-width: 100%;
  }

  /*
   * 垂直位置不变；水平：二级标题左缘对齐一级项垂直中线
   * left:50% 且不平移 → 下拉框从一级项水平中心线向右展开
   */
  .nav-item.has-dropdown .nav-dropdown {
    top: 100%;
    left: 50%;
    right: auto;
    transform: none;
    padding-top: 0;
    margin-top: 0;
    width: max-content;
    max-width: none;
  }

  .nav-item.has-dropdown .nav-dropdown__list {
    min-width: 148px;
  }

  /* 小箭头：面板左侧，对齐第一个二级项垂直中心 */
  .nav-item.has-dropdown .nav-dropdown__list::before {
    left: -7px;
    top: var(--nav-dd-first-center);
    transform: translateY(-50%);
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-right: 7px solid #ececec;
    border-left: none;
  }
}

/* ========== 搜索弹窗 ========== */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 140px;
}

.search-modal.is-open {
  display: flex;
}

.search-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

.search-modal__dialog {
  position: relative;
  width: 560px;
  max-width: calc(100% - 32px);
  max-height: 70vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.search-modal__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #888;
  cursor: pointer;
  z-index: 2;
}

.search-modal__close svg {
  width: 18px;
  height: 18px;
}

.search-modal__close:hover {
  color: var(--color-accent);
}

.search-modal__input-wrap {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  gap: 10px;
}

.search-modal__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #999;
}

.search-modal__icon svg {
  width: 18px;
  height: 18px;
}

.search-modal__input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  background: transparent;
  color: #333;
  padding: 4px 6px;
}

.search-modal__results {
  overflow-y: auto;
  max-height: calc(70vh - 60px);
  padding: 8px 0;
}

.search-modal__empty {
  padding: 28px 18px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.search-modal__meta {
  padding: 8px 18px;
  font-size: 12px;
  color: #999;
}

.search-modal__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-modal__item {
  padding: 0;
  border-bottom: 1px solid #f3f3f3;
}

.search-modal__item:last-child {
  border-bottom: none;
}

.search-modal__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: #333;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.search-modal__link:hover {
  background: #fafafa;
  color: var(--color-accent);
}

.search-modal__thumb {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f3f3f3;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.search-modal__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.search-modal__title {
  flex: 1;
  font-size: 15px;
  line-height: 1.4;
  color: inherit;
}

@media (max-width: 768px) {
  .search-modal {
    padding-top: 96px;
  }

  .search-modal__dialog {
    width: calc(100% - 24px);
    border-radius: 10px;
  }

  .search-modal__input {
    font-size: 15px;
  }
}