/* ===========================
   灵秫科技 - 导航栏专属样式
   替换旧版 .navbar 相关样式
   =========================== */

/* ---- 基础重置 ---- */
*, *::before, *::after { box-sizing: border-box; }

/* ---- 导航栏外壳 ---- */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 2000;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  transition: box-shadow 0.2s;
}
.navbar.scrolled { box-shadow: 0 2px 20px rgba(0,0,0,0.1); }

.nav-inner {
  display: flex;
  align-items: center;
  height: 68px;
  gap: 8px;
}

/* ---- LOGO ---- */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  margin-right: 24px;
}
.logo-img {
  height: 40px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
}
.logo-icon {
  width: 38px; height: 38px;
  background: #0f3460;
  color: white;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700;
  flex-shrink: 0;
}
.logo-text {
  font-size: 17px; font-weight: 700;
  color: #1a1a2e;
  white-space: nowrap;
}

/* ---- 导航链接列表 ---- */
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0; padding: 0;
  flex: 1;
}

.nav-item { position: relative; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #2d3748;
  text-decoration: none;
  border-radius: 7px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.nav-link:hover,
.nav-item.open > .nav-link,
.nav-link.active { color: #0f3460; background: #e8effe; }

.nav-arrow {
  font-size: 11px;
  color: #9aabb8;
  transition: transform 0.2s;
  line-height: 1;
}
.nav-item.open > .nav-link .nav-arrow { transform: rotate(180deg); }

/* ---- 右侧操作区 ---- */
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-cta {
  padding: 8px 20px;
  background: #0f3460;
  color: white;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s;
}
.nav-cta:hover { background: #1a1a2e; }
.nav-admin-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: #f1f5f9;
  border-radius: 7px;
  font-size: 16px;
  color: #64748b;
  text-decoration: none;
  transition: background 0.15s;
  border: 1px solid #e2e8f0;
}
.nav-admin-btn:hover { background: #e2e8f0; color: #0f3460; }

/* ---- 汉堡按钮 ---- */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
  cursor: pointer;
  background: none;
  border: none;
  margin-left: auto;
}
.menu-toggle span {
  display: block; width: 22px; height: 2px;
  background: #1a1a2e; border-radius: 2px;
  transition: all 0.3s;
}
.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* =============================
   MEGA DROPDOWN - 大菜单
   ============================= */

.mega-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 260px;
  background: white;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  transform: translateX(-50%) translateY(6px);
  z-index: 2100;
}

/* 向左修正以防超出右边界 */
.nav-item:last-child .mega-dropdown,
.nav-item:nth-last-child(2) .mega-dropdown {
  left: auto;
  right: 0;
  transform: translateY(6px);
}
.nav-item:last-child.open .mega-dropdown,
.nav-item:nth-last-child(2).open .mega-dropdown {
  transform: translateY(0);
}

.nav-item.open .mega-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* 小箭头 */
.mega-dropdown::before {
  content: '';
  position: absolute;
  top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 12px; height: 12px;
  background: white;
  border-left: 1px solid rgba(0,0,0,0.08);
  border-top: 1px solid rgba(0,0,0,0.08);
  transform: translateX(-50%) rotate(45deg);
}
.nav-item:last-child .mega-dropdown::before,
.nav-item:nth-last-child(2) .mega-dropdown::before {
  left: auto; right: 24px; transform: rotate(45deg);
}

.mega-inner { padding: 8px; }

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

/* ---- 每个子项行 ---- */
.mega-item {
  position: relative;
}

.mega-item-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s;
  cursor: pointer;
}
.mega-item-link:hover,
.mega-item.hovered .mega-item-link {
  background: #f0f4ff;
}
.mega-item-title {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a2e;
  white-space: nowrap;
}
.mega-item-arrow {
  font-size: 16px;
  color: #9aabb8;
  transition: transform 0.15s, color 0.15s;
}
.mega-item.hovered .mega-item-arrow { color: #0f3460; transform: translateX(3px); }

/* =============================
   PREVIEW PANEL - 多产品展示
   ============================= */
.mega-preview {
  position: absolute;
  top: 0;
  left: calc(100% + 12px);
  width: 480px;
  max-height: 480px;
  overflow-y: auto;
  background: white;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(8px);
  transition: opacity 0.18s, transform 0.18s;
  z-index: 2200;
  padding: 16px;
}
.mega-preview::-webkit-scrollbar { width: 4px; }
.mega-preview::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.mega-item.hovered .mega-preview {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

/* 防止 preview 超出右侧视口 */
.nav-item:last-child .mega-preview,
.nav-item:nth-last-child(2) .mega-preview {
  left: auto;
  right: calc(100% + 12px);
  transform: translateX(-8px);
}
.nav-item:last-child .mega-item.hovered .mega-preview,
.nav-item:nth-last-child(2) .mega-item.hovered .mega-preview {
  transform: translateX(0);
}

/* ---- 产品网格 ---- */
.mega-products-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.mega-product-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s;
  border: 1px solid transparent;
}
.mega-product-card:hover {
  background: #eef2ff;
  border-color: rgba(15, 52, 96, 0.12);
  transform: translateY(-1px);
}

.mega-product-img {
  width: 90px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #e2e8f0;
}
.mega-product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mega-product-info {
  flex: 1;
  min-width: 0;
}
.mega-product-name {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mega-product-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.6;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mega-product-link {
  font-size: 12px;
  font-weight: 500;
  color: #0f3460;
  white-space: nowrap;
}
.mega-product-card:hover .mega-product-link { text-decoration: underline; }

.mega-products-empty {
  padding: 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

/* ---- 旧版兼容：单一 preview 样式（有 products 后不再使用，但保留） ---- */
.preview-img-wrap {
  width: 100%;
  height: 170px;
  overflow: hidden;
  background: #f8fafc;
  border-radius: 10px;
}
.preview-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s;
}
.mega-item.hovered .preview-img-wrap img { transform: scale(1.04); }

.preview-body {
  padding: 14px 16px 16px;
}
.preview-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a2e;
  margin: 0 0 8px;
}
.preview-desc {
  font-size: 13px;
  color: #4a5568;
  line-height: 1.7;
  margin: 0 0 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.preview-more {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: #0f3460;
  text-decoration: none;
  transition: gap 0.15s;
  gap: 4px;
}
.preview-more:hover { gap: 8px; }

/* ===========================
   响应式 - 移动端
   =========================== */
@media (max-width: 900px) {
  .nav-right { display: none; }
  .menu-toggle {
    display: flex;
    position: relative;
    z-index: 2100;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: 68px; left: 0; right: 0;
    background: white;
    padding: 12px 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    max-height: calc(100vh - 68px);
    overflow-y: auto;
    z-index: 1999;
    gap: 4px;
  }
  .nav-links.open { display: flex; }

  .nav-link { padding: 11px 14px; font-size: 15px; border-radius: 8px; }

  .mega-dropdown {
    position: static;
    transform: none !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    box-shadow: none;
    border: none;
    border-radius: 0;
    display: none;
    padding: 0 0 0 16px;
  }
  .mega-dropdown::before { display: none; }
  .nav-item.open .mega-dropdown { display: block; }

  /* 移动端：mega-preview 改为手风琴式展开 */
  .mega-preview {
    display: none;
    position: static !important;
    transform: none !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    width: 100%;
    max-height: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    margin: 0;
    overflow: hidden;
    overflow-y: visible;
    padding: 8px 0;
  }
  .mega-item.sub-open .mega-preview {
    display: block;
  }
  .mega-item.sub-open .mega-item-arrow {
    transform: rotate(90deg);
    color: #0f3460;
  }

  /* 移动端产品卡片 */
  .mega-products-grid { gap: 8px; }
  .mega-product-card {
    padding: 10px;
    gap: 10px;
  }
  .mega-product-img { width: 90px; height: auto; }
  .mega-product-name { font-size: 13px; }
  .mega-product-desc { font-size: 11px; -webkit-line-clamp: 2; }
  .mega-product-link { font-size: 11px; }

  .preview-img-wrap { height: 140px; border-radius: 8px; }
  .preview-body { padding: 10px 4px 6px; }
  .preview-title { font-size: 14px; margin: 0 0 4px; }
  .preview-desc { font-size: 12px; line-height: 1.6; -webkit-line-clamp: 4; }
  .preview-more { font-size: 12px; }

  .mega-item-link { padding: 9px 12px; }
  .mega-item-title { font-size: 13px; color: #4a5568; }
}
