/* === 全局基础样式 === */
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background-color: #fff;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

/* === 顶部菜单 === */
.header-top {
  background-color: #f4f4f4;
  border-bottom: 1px solid #e5e5e5;
  font-size: 14px;
  height: 36px;
  line-height: 36px;
}

.top-menu .menu {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.top-menu .menu li a {
  color: #333;
  padding: 0 10px;
  text-decoration: none;
  transition: color 0.2s ease;
}

.top-menu .menu li a:hover {
  color: #007aff;
}

/* === 中部区域：LOGO + 空白 + 购物车 === */
.header-middle {
  width: 100%;
  background-color: #fff;
  height: 100px;
  border-bottom: 1px solid #eaeaea;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.header-middle .container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.header-middle .site-logo {
  flex: 0 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
}

/* 新增：电脑版显示电脑logo，隐藏手机logo */
.site-logo .logo-pc {
  display: block;
}
.site-logo .logo-mobile {
  display: none;
}

.header-middle .site-logo img {
  max-height: 80px;
  display: block;
}

/* === 购物车 === */
.header-middle .site-cart {
  flex: 0 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
}

.site-cart .cart-button {
  background: #ff4d4f;
  color: #fff;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  display: inline-block;
  transition: background-color 0.3s ease;
}

.site-cart .cart-button:hover {
  background-color: #e33c3f;
}

/* === 底部菜单 === */
.header-bottom {
  background-color: #20232a;
  color: #fff;
}

.bottom-flex {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 分类菜单 */
.category-menu {
  position: relative;
  font-size: 16px;
}

/* 切换按钮 */
#category-toggle {
  background: #007aff;
  color: #fff;
  border: none;
  padding: 10px 10px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#category-toggle:hover {
  background-color: #005bb5;
}

/* 一级分类列表 */
.category-list {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 999;
  background: #f7f7f7; /* 浅灰色背景 */
  color: #333;
  list-style: none;
  margin: 0;
  padding: 8px 0;
  width: 180px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* 显示菜单 */
.category-list.show {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* 一级分类项 */
.category-list li {
  position: relative;
  border-bottom: 1px solid #e0e0e0; /* 更浅的分隔线 */
}

.category-list li:last-child {
  border-bottom: none;
}

/* 一级分类链接 + 箭头布局 */
.category-list li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  text-decoration: none;
  color: #333;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* hover 效果 */
.category-list li a:hover {
  background-color: #e6f7ff; /* 更友好的背景色 */
  color: #007aff;
}

/* 有子分类的箭头 */
.category-list li.has-sub > a::after {
  content: ">";
  font-size: 14px;
  color: #999;
  margin-left: 8px;
}

/* 子分类列表 */
.sub-cat-list {
  display: none;
  position: absolute;
  top: 0;
  left: 100%;
  width: 160px;
  background: #fcfcfc;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
  border-left: 3px solid #007aff;
  border-radius: 4px;
  padding: 6px 0;
  z-index: 1000;
}

/* 悬停显示子分类 */
.category-list li:hover > .sub-cat-list {
  display: block;
}

/* 子分类链接样式 */
.sub-cat-list li a {
  display: block;
  padding: 10px 16px;
  font-size: 13px;
  color: #444;
  font-weight: 400;
  text-decoration: none;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.sub-cat-list li a:hover {
  background-color: #e6f7ff;
  color: #007aff;
}
/* 主菜单 */
.main-menu .menu {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 24px;
  font-size: 15px;
}

.main-menu .menu li a {
  color: #fff;
  text-decoration: none;
  padding: 8px 10px;
  transition: background 0.3s, color 0.3s;
  border-radius: 4px;
}

.main-menu .menu li a:hover {
  background: #007aff;
  color: #fff;
}

/* === 响应式样式 === */
@media screen and (max-width: 768px) {
  .header-top {
    display: none;
  }
  
  .header-bottom {
    display: none;
  }

  .header-middle {
    background-color: #fff;
    height: auto;
    padding: 10px 0;
  }

  .header-middle .container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    height: auto;
  }

  .header-middle .site-logo {
    justify-content: flex-start;
    height: auto;
  }

  /* 手机端只显示手机logo，隐藏电脑版logo */
  .site-logo .logo-pc {
    display: none;
  }
  .site-logo .logo-mobile {
    display: block;
    text-align: center;
  }
  .site-logo .logo-mobile img {
    max-width: 120px;
    width: 100%;
    max-height: 60px;
    object-fit: contain;
  }

  .header-middle .site-cart {
    display: none;
  }

  .header-middle .middle-space {
    flex: 0 0 auto;
    padding-right: 0;
    justify-content: flex-end;
  }

  .header-middle .search-toggle {
    display: block;
  }

  .header-middle .search-form {
    display: none;
    position: absolute;
    top: 60px;
    right: 10px;
    margin-top: 6px;
    z-index: 999;
    width: 90vw;
    max-width: 300px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  }

  .header-middle .search-form.active {
    display: flex;
  }

  .header-middle input[type="search"] {
    font-size: 13px;
    padding: 8px 12px;
  }

  .header-middle button[type="submit"] {
    padding: 8px 14px;
    font-size: 13px;
  }

  .bottom-flex {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-menu .menu {
    flex-direction: column;
    gap: 10px;
  }

  .category-list, 
  .sub-cat-list {
    position: relative;
    width: 100%;
    box-shadow: none;
    border: none;
  }
}


#backToTop {
  display: none; /* 初始隐藏 */
  position: fixed;
  bottom: 150px;
  right: 40px;
  z-index: 999;
  border: none;
  outline: none;
  background-color: #333;
  color: white;
  cursor: pointer;
  padding: 10px 15px;
  border-radius: 4px;
  font-size: 16px;
  opacity: 0.7;
  transition: opacity 0.3s;
}

#backToTop:hover {
  opacity: 1;
}
