/* 1️⃣ 全局变量 */
:root {
  --nav-height: 60px;
  --gap: 22px;
  --mobile-gap: 16px;  /* 新增：移动端间距 */
}

/* 2️⃣ 整个导航条的主容器 */
.nav {
  display: flex;
  align-items: center;
  height: var(--nav-height);
  padding: 0 24px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
  font-size: 14px;
}

/* 3️⃣ 左侧 logo 区域 - 修改为flex布局 */
.nav__left {
  display: flex;          /* 新增：flex布局 */
  align-items: center;    /* 新增：垂直居中 */
  flex-shrink: 0;
  margin-right: auto;
  gap: 8px;              /* 改用gap代替margin */
}

.logo-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;        /* 新增：防止图片被压缩 */
}

/* 4️⃣ logo 文字 - 添加移动端适配 */
.logo {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  text-decoration: none;
  white-space: nowrap;   /* 新增：防止换行 */
}

/* 5️⃣ 中间菜单容器 */
.nav__center {
  display: flex;
  gap: var(--gap);
  justify-content: center;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* 6️⃣ 菜单项 - 改为flex子项 */
.nav__center li {
  display: flex;          /* 新增：让li也成为flex容器 */
  align-items: center;    /* 新增：垂直居中 */
}

.nav__center a {
  text-decoration: none;
  font-size: 16px;        /* 调整：17px改为16px更合适 */
  color: #333;
  white-space: nowrap;
  padding: 8px 4px;       /* 新增：增加可点击区域 */
}

/* 7️⃣ 右侧搜索框区域 */
.nav__right {
  margin-left: auto;
  display: flex;          /* 新增：flex布局 */
  align-items: center;    /* 新增：垂直居中 */
}

/* 8️⃣ 搜索框 - 添加过渡效果 */
.search {
  width: 140px;
  padding: 8px 12px;      /* 调整：增加padding更好点击 */
  border: 1px solid #ddd; /* 调整：更浅的边框色 */
  border-radius: 20px;    /* 调整：更圆的边框 */
  transition: all 0.3s ease;
}

.search:focus {
  width: 160px;           /* 新增：聚焦时变宽 */
  border-color: #333;
  outline: none;
}

/* ========== 移动端适配 ========== */

/* 9️⃣ 汉堡按钮 - 优化移动端体验 */
#hamburger {
  display: none;          /* 桌面端隐藏 */
  margin-left: 16px;      /* 调整：增加左边距 */
  cursor: pointer;
  padding: 12px 8px;      /* 调整：更大的点击区域 */
  background: none;
  border: none;
  z-index: 201;
}

#hamburger span {
  display: block;
  width: 24px;            /* 调整：稍微加宽 */
  height: 2px;
  margin: 4px 0;          /* 调整：间距减小 */
  background: #333;
  transition: 0.3s;
  border-radius: 2px;     /* 新增：圆角端点 */
}

/* 汉堡按钮悬停效果 */
#hamburger:hover span {
  background: #666;
}

/* 🔟 移动端样式 (≤768px) */
@media (max-width: 768px) {
  /* 导航容器调整 */
  .nav {
    padding: 0 16px;      /* 减少左右padding */
    height: 56px;         /* 稍微降低高度 */
  }
  
  /* logo文字缩小 */
  .logo {
    font-size: 18px;      /* 移动端减小字号 */
  }
  
  .logo-icon {
    width: 22px;          /* 移动端图标也缩小 */
    height: 22px;
  }
  
  /* 隐藏桌面菜单和搜索框 */
  .nav__center,
  .nav__right {
    display: none;
  }
  
  /* 显示汉堡按钮 */
  #hamburger {
    display: block;
  }
  
  /* 搜索框在移动端样式 */
  .search {
    width: 100%;          /* 抽屉内搜索框占满宽度 */
    margin-top: 16px;
    padding: 12px 16px;   /* 移动端更大padding */
    border-radius: 25px;  /* 更圆的边框 */
  }
  
  /* 导航左侧区域自适应 */
  .nav__left {
    gap: 6px;             /* 移动端缩小间距 */
  }
}

/* 1️⃣1️⃣ 小手机特殊适配 (≤480px) */
@media (max-width: 480px) {
  .nav {
    padding: 0 12px;
  }
  
  .logo {
    font-size: 16px;      /* 超小屏幕进一步缩小 */
  }
  
  .logo-icon {
    width: 20px;
    height: 20px;
  }
  
  #hamburger {
    padding: 10px 6px;
  }
  
  #hamburger span {
    width: 22px;
  }
}

/* 1️⃣2️⃣ 抽屉菜单样式 */
#navDrawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: 280px;           /* 调整为更合适的宽度 */
  height: 100vh;
  background: #fff;
  box-shadow: -2px 0 20px rgba(0, 0, 0, 0.15); /* 加深阴影 */
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1); /* 贝塞尔曲线动画 */
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 80px 24px 24px; /* 顶部留更多空间 */
  overflow-y: auto;       /* 内容过多时可滚动 */
}

/* 抽屉打开状态 */
#navDrawer.open { 
  transform: translateX(0); 
}

/* 抽屉内菜单样式 */
#navDrawer .nav__center {
  display: flex !important;
  flex-direction: column;
  gap: 12px;              /* 减少间距 */
  margin: 0 0 24px;
  padding: 0;
  width: 100%;
}

/* 抽屉内菜单项 */
#navDrawer .nav__center li {
  width: 100%;
  border-bottom: 1px solid #f0f0f0; /* 添加分隔线 */
}

/* 抽屉内菜单链接 */
#navDrawer .nav__center a {
  display: block;
  width: 100%;
  padding: 16px 8px;      /* 更大的可点击区域 */
  font-size: 17px;        /* 移动端稍大字号 */
  color: #333;
  text-decoration: none;
  transition: background-color 0.2s;
}

/* 抽屉内链接悬停/点击效果 */
#navDrawer .nav__center a:hover,
#navDrawer .nav__center a:active {
  background-color: #f8f8f8;
  border-radius: 8px;
}

/* 抽屉内搜索框区域 */
#navDrawer .nav__right {
  display: block !important;
  width: 100%;
  margin: 0;
}

/* 1️⃣3️⃣ 遮罩层 */
#drawerMask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5); /* 加深遮罩 */
  opacity: 0;
  visibility: hidden;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 199;
}

#navDrawer.open ~ #drawerMask {
  opacity: 1;
  visibility: visible;
}

/* 1️⃣4️⃣ 关闭按钮（可选，在抽屉内添加） */
.drawer-close {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  z-index: 202;
}

.drawer-close:hover {
  color: #333;
}

/*下拉*/
/* ========== 桌面端下拉菜单 ========== */

.has-dropdown {
    position: relative;
}

/* 下拉箭头 */
.dropdown-arrow {
    margin-left: 6px;
    transition: transform 0.3s ease;
}

.has-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg); /* 悬停时箭头翻转 */
}

/* 下拉菜单容器 */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: auto;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px 0;
    margin-top: 8px;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.has-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 下拉菜单项 */
.dropdown-menu li {
    width: 100%;
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s;
}

.dropdown-menu a:hover {
    background-color: #f5f5f5;
    color: #000;
}

/* 桌面端链接添加箭头后的样式调整 */
.nav__center .has-dropdown > a {
    display: flex;
    align-items: center;
    gap: 4px;
}

