/* 改进的Header样式 - 美化版 */

/* ============================================
   第一部分：清理原有header元素
   ============================================ */

/* 隐藏原有的导航元素 */
.nav-top,
.nav-top-m,
.btn-nav,
.btn-nav-m,
.btn-search-m,
.j-btn-nav-m {
  display: none !important;
}

/* 隐藏原有header中的搜索表单 */
.header .search-form:not(.search-box form) {
  display: none !important;
}

/* 隐藏原有的top-links */
.top-links {
  display: none !important;
}

/* 清理原有header样式 */
.header {
  all: unset !important;
  display: block !important;
}

/* 清理原有header的背景色（针对嵌套的header元素） */
.header:not(.main-header) {
  background: transparent !important;
  height: auto !important;
  position: static !important;
}

/* 重置body和container */
body {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

.container-index {
  margin-top: 35px !important;
}

/* ============================================
   第二部分：美化Header样式
   ============================================ */

/* 主Header容器 */
.main-header {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  z-index: 100 !important;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  width: 100% !important;
  margin: 0 !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* 顶部导航栏 */
.header-top {
  height: 70px;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  position: relative;
  overflow: hidden;
}

/* 背景装饰元素 */
.header-top::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
}

.header-top::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 150px;
  height: 150px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
  animation: float 8s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(180deg); }
}

.header-top .container,
.category-nav .container {
  display: flex !important;
  align-items: center !important;
  height: 100% !important;
  gap: 30px;
  padding: 0 20px !important;
  max-width: 1400px !important;
  margin: 0 auto !important;
  min-height: auto !important;
  grid-template-columns: none !important;
  position: relative;
  z-index: 2;
}

/* Logo区域 */
.header-top .logo {
  flex-shrink: 0;
  margin: 0;
  position: relative;
}

.header-top .logo a {
  display: flex;
  align-items: center;
  text-decoration: none;
  position: relative;
  gap: 12px; /* logo图片和网站名之间的间距 */
}

/* 移动端移除gap间距和预留空间 */
@media (max-width: 767px) {
  .header-top .logo a {
    gap: 0;
  }
  
  .header-top .logo {
    width: auto;
    min-width: auto;
  }
  
  .header-top .logo-img {
    margin-right: 0;
    padding-right: 0;
  }
}

.header-top .logo-text {
  font-size: 28px;
  font-weight: 800;
  color: #2c2c2c;
  text-shadow: none;
  letter-spacing: 1px;
  display: inline; /* 默认显示网站名 */
}

/* desktop-only类在移动端完全隐藏 */
.desktop-only {
  display: inline;
}

@media (max-width: 767px) {
  .desktop-only {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
}

.header-top .logo-img {
  max-height: 48px;
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  flex-shrink: 0; /* 防止logo图片被压缩 */
}

/* 搜索区域 - 占据主要空间 */
.search-area {
  flex: 1;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  padding: 0 15px;
  display: flex;
  align-items: center;
  height: 100%;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box form {
  display: flex;
  align-items: center;
}

.search-box input[type="search"] {
  flex: 1;
  width: 100%;
  padding: 8px 50px 8px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  background: #fff;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.search-box input[type="search"]:focus {
  outline: none;
  background: #fff;
  border-color: rgba(255,255,255,0.8);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15), 0 0 0 4px rgba(255,255,255,0.3);
  transform: translateY(-2px);
}

.search-box input[type="search"]::placeholder {
  color: #999;
  font-weight: 400;
}

.search-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 12px;
  background: #007cba;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.search-btn:hover {
  background: #4a4a4a;
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

/* 热搜标签样式优化 */
.hot-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.hot-search span {
  color: #666;
  font-size: 13px;
  white-space: nowrap;
}

.hot-search a {
  display: inline-block;
  padding: 4px 10px;
  background: #f5f5f5;
  border-radius: 15px;
  color: #333;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.hot-search a:hover {
  background: var(--primary-color, #2196F3);
  color: white;
  transform: translateY(-2px);
}

/* 用户区 */
.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.login-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: rgba(44,44,44,0.1);
  color: #2c2c2c;
  text-decoration: none;
  border-radius: 26px;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.login-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  background: rgba(44,44,44,0.1);
  border-radius: 25px;
  text-decoration: none;
  color: #2c2c2c;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.user-info:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.user-info img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* 分类导航 */
.category-nav {
  background: transparent;
  border-bottom: none;
  overflow-x: auto;
  position: relative;
  padding: 2px 0;
}

.category-nav::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(0,0,0,0.05);
}

/* category-nav的container样式已在上面合并定义 */
.category-nav .container {
  gap: 8px !important; /* 覆盖上面的50px gap */
}

/* 分类项容器 */
.category-item {
  position: relative;
  display: inline-block;
}

.category-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  color: #333;
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
  position: relative;
}

.category-nav a:hover {
  color: #007cba;
}

.category-nav a.active {
  color: #007cba;
  font-weight: 500;
}

/* 子分类箭头图标 */
.subcategory-arrow {
  font-size: 10px;
  margin-left: 4px;
  transition: transform 0.3s ease;
}

/* 子分类下拉容器 */
.subcategory-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 150px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  padding: 5px 0;
}

/* 鼠标悬停时显示子分类 */
.category-item:hover .subcategory-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 当前分类页面时始终显示子分类（固定显示） */
.category-item .category-nav a.active ~ .subcategory-dropdown,
.category-item:has(.active) .subcategory-dropdown {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
  position: static;
  box-shadow: none;
  border: none;
  background: #f8f9fa;
  margin-top: 5px;
  border-radius: 0;
  padding: 0;
}

/* 箭头旋转动画 */
.category-item:hover .subcategory-arrow,
.category-item:has(.active) .subcategory-arrow {
  transform: rotate(180deg);
}

/* 子分类链接样式 */
.subcategory-dropdown a {
  display: block;
  padding: 8px 15px;
  color: #555;
  font-size: 13px;
  border-radius: 0;
  transition: all 0.2s ease;
  border-bottom: 1px solid #f0f0f0;
}

.subcategory-dropdown a:hover {
  background: #f5f5f5;
  color: #007cba;
  padding-left: 20px;
}

.subcategory-dropdown a.active {
  background: #e3f2fd;
  color: #1976d2;
  font-weight: 500;
}

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

/* 更多分类下拉 */
.dropdown {
  position: relative;
}

.dropdown-toggle {
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 200px;
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  z-index: 100;
  max-height: 400px;
  overflow-y: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 0;
}

.dropdown:hover .dropdown-content {
  display: block;
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-content a {
  display: block;
  padding: 14px 24px;
  color: #495057;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.3s;
  font-weight: 400;
  margin: 2px 8px;
}

.dropdown-content a:hover {
  background: #f0f0f0;
  color: #1976d2;
  transform: none;
  padding-left: 25px;
}

.dropdown-content a:first-child {
  border-radius: 12px 12px 0 0;
}

.dropdown-content a:last-child {
  border-radius: 0 0 12px 12px;
}

/* 响应式设计 */

/* PC端 (>1024px) - 显示完整logo信息 */
@media (min-width: 1025px) {
  .header-top .logo-text {
    display: inline !important;
    font-size: 28px;
  }
  
  .header-top .logo-img {
    max-height: 48px;
  }
}

/* 平板端 (768px-1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
  .header-top .container {
    gap: 30px;
  }
  
  .search-area {
    max-width: 500px;
    padding: 0 15px;
  }
  
  /* PC端显示完整logo信息 */
  .header-top .logo-text {
    display: inline;
    font-size: 24px;
  }
  
  .category-nav a {
    padding: 12px 18px;
    font-size: 14px;
  }
  
  /* 隐藏部分分类 */
  .category-nav a:nth-child(n+7) {
    display: none;
  }
  
  .dropdown {
    display: flex !important;
  }
}

/* 移动端 (<768px) */
@media (max-width: 767px) {
  .header-top {
    height: auto;
    padding: 20px 0;
  }
  
  .header-top .container {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    padding: 0 25px;
    width: 100%;
    box-sizing: border-box;
  }
  
  .header-top .logo {
    flex-shrink: 0;
    order: 1;
    max-width: 120px;
    width: auto;
    min-width: auto;
  }
  
  .search-area {
    flex: 1;
    max-width: none;
    padding: 0;
    margin: 0 10px;
    order: 2;
    text-align: center;
    min-width: 0;
  }
  
  /* 移动端汉堡菜单显示 */
  .mobile-menu-btn {
    display: block !important;
    flex-shrink: 0;
    order: 3;
    max-width: 60px;
  }
  
  .search-box input[type="search"] {
    padding: 14px 60px 14px 22px;
    font-size: 16px;
    border-radius: 25px;
  }
  
  .search-btn {
    padding: 8px 16px;
    font-size: 16px;
  }
  
  /* 移动端logo优化 */
  .header-top .logo-img {
    max-height: 28px;
    width: auto;
    max-width: 100%;
  }
  
  .header-top .logo a {
    gap: 0 !important; /* 移动端不需要logo和文字之间的间距，强制覆盖基础样式 */
  }
  
  /* 移动端隐藏网站名 */
  .header-top .logo-text {
    display: none !important;
  }
}

/* 超小屏幕 (<480px) */
@media (max-width: 479px) {
  .header-top .container {
    padding: 0 15px;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
  }
  
  .header-top .logo-img {
    max-height: 28px;
  }
  
  .header-top .logo-text {
    display: none !important;
  }
  
  .search-area {
    margin: 0 6px;
  }
  
  .header-top .logo {
    order: 1;
    max-width: 100px;
    width: auto;
    min-width: auto;
  }
  
  .search-area {
    order: 2;
    min-width: 0;
  }
  
  .mobile-menu-btn {
    order: 3;
    max-width: 50px;
  }
  
  .search-box input[type="search"] {
    padding: 12px 55px 12px 20px;
    font-size: 15px;
  }
  
  .search-btn {
    padding: 6px 14px;
    font-size: 14px;
  }
  
  .mobile-menu-btn {
    font-size: 22px;
    padding: 6px;
  }
}

  .category-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .category-nav .container {
    padding: 0 20px;
    gap: 8px;
  }
  
  .category-nav a {
    padding: 12px 18px;
    font-size: 18px;
  }
  
  /* 分类导航横向滚动 */
  .category-nav::-webkit-scrollbar {
    height: 4px;
  }
  
  .category-nav::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
  }
  
  .category-nav::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
  }
  
  .category-nav::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
  }

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  .main-header {
    background: #1a1a1a;
  }
  
  .header-top {
    background: #2a2a2a;
    border-bottom-color: rgba(255,255,255,0.1);
  }
  
  .category-nav {
    background: #1f1f1f;
    border-bottom-color: #333;
  }
  
  .category-nav a {
    color: #ccc;
  }
  
  .category-nav a:hover {
    background: #e0e0e0;
    color: #2c2c2c;
  }
  
  .dropdown-content {
    background: #2a2a2a;
    border-color: #333;
  }
  
  .dropdown-content a {
    color: #ccc;
  }
  
  .dropdown-content a:hover {
    background: #333;
  }
}

/* 动画效果 */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 平滑滚动 */
.category-nav {
  scroll-behavior: smooth;
}

/* 焦点样式改进 */
.search-box input[type="search"]:focus,
.login-btn:focus,
.category-nav a:focus {
  outline: 2px solid rgba(102, 126, 234, 0.5);
  outline-offset: 2px;
}

/* 滚动时的header样式 */
.main-header.scrolled {
  box-shadow: 0 6px 25px rgba(0,0,0,0.12);
}

/* Header隐藏动画 */
.main-header {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-header.header-hidden {
  transform: translateY(-100%);
}

/* 移动端汉堡菜单按钮 */
.mobile-menu-btn {
  display: none;
  position: relative;
  z-index: 1001;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.3s ease;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.mobile-menu-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.hamburger-line {
  display: block;
  height: 2px;
  width: 20px;
  background-color: #fff;
  margin: 2px 0;
  transition: all 0.3s ease;
  border-radius: 1px;
}

.mobile-menu-btn.active .hamburger-line:nth-child(1) {
  transform: rotate(-45deg) translate(-3px, 4px);
}

.mobile-menu-btn.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn.active .hamburger-line:nth-child(3) {
  transform: rotate(45deg) translate(-3px, -4px);
}

@media (max-width: 767px) {
  .mobile-menu-btn {
    display: flex !important;
  }
  
  .category-nav {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow-y: auto;
  }
  
  .category-nav.mobile-open {
    left: 0;
  }
  
  .category-nav .container {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    padding: 70px 25px 25px;
    gap: 0;
  }
  
  .category-nav a {
    width: 100%;
    border-radius: 0;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
  }
  
  .dropdown-content {
    position: static;
    display: block !important;
    box-shadow: none;
    border: none;
    background: #f8f9fa;
    margin-left: 25px;
    border-radius: 0;
  }
  
  /* 遮罩层 */
  .category-nav.mobile-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
  }
}

/* 搜索框聚焦状态 */
.search-box.focused {
  position: relative;
  z-index: 100;
}

/* 优化容器宽度 - 移除全局.container样式，避免冲突 */
.main-header .container {
  width: 100% !important;
  max-width: 1400px !important;
  margin: 0 auto !important;
  padding: 0 40px !important;
}

@media (max-width: 1440px) {
  .main-header .container {
    max-width: 1400px !important;
  }
}

@media (max-width: 1200px) {
  .main-header .container {
    max-width: 992px !important;
  }
}

@media (max-width: 992px) {
  .main-header .container {
    max-width: 768px !important;
  }
}

@media (max-width: 768px) {
  .main-header .container {
    padding: 0 25px !important;
  }
}

/* 加载动画 */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.search-box.loading input[type="search"] {
  background: #e8e8e8;
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* 悬停效果增强 */
.search-box:hover input[type="search"] {
  border-color: rgba(255,255,255,0.4);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

/* 图标动画 */
.category-nav a:hover {
  transform: translateY(-2px) scale(1.02);
}

/* 渐变文字效果 */
.header-top .logo strong {
  background: #f8f8f8;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}