/* 导航栏样式 - 添加子菜单功能 */
nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: #1a1a1a;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 5px 20px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.logo img {
  height: 50px;
  width: auto;
  margin-top: 2px; /* 微调垂直位置 */
  transition: transform 0.3s ease;
}

.logo:hover img {
  transform: scale(1.05);
}

#nav-list {
  list-style-type: none;
  margin: 0;
  padding: 0;
  display: flex;
}

#nav-list li {
  margin: 0 15px;
  position: relative;
}

#nav-list li a {
  color: white;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: color 0.3s ease;
  padding: 4px 10px;
  position: relative;
  white-space: nowrap;
  z-index: 1;
}

#nav-list li a::after {
  content: "";
  position: absolute;
  width: 0;
  height: 100%;
  top: 0;
  left: 0;
  background: #ffffff;
  border-radius: 4px;
  transition: width 0.3s ease;
  z-index: -1;
}

#nav-list li a:hover {
  color: #000000;
}

#nav-list li a:hover::after {
  width: 100%;
}

.search-bar {
  display: flex;
  margin-left: auto;
  max-width: 220px;
}

.search-bar input {
  padding: 6px 12px;
  border: none;
  border-radius: 4px 0 0 4px;
  width: 150px;
  font-size: 14px;
  background-color: #333;
  color: white;
  transition: all 0.3s ease;
}

.search-bar input:focus {
  outline: none;
  background-color: #444;
  width: 180px;
}

.search-bar input::placeholder {
  color: #999;
}

.search-bar button {
  padding: 6px 12px;
  background: linear-gradient(45deg, #6a11cb, #2575fc);
  color: white;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.search-bar button:hover {
  background: linear-gradient(45deg, #5910b0, #1e65da);
}

.hamburger-menu {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 25px;
  height: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-left: 10px;
}

.hamburger-menu span {
  display: block;
  width: 100%;
  height: 2px;
  background-color: white;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* 汉堡菜单转换为X的动画 */
.hamburger-menu.active span:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}

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

.hamburger-menu.active span:nth-child(3) {
  transform: translateY(-9px) rotate(-45deg);
}

/* ========== 子菜单样式 ========== */

/* 子菜单指示器 */
.submenu-indicator {
  margin-left: 6px;
  font-size: 12px;
  transition: all 0.3s ease;
  display: inline-block;
}

/* 桌面端和移动端指示器显示控制 */
.desktop-only {
  display: inline-block;
}

.mobile-only {
  display: none;
}

/* 有子菜单的导航项 */
.nav-item-with-submenu {
  position: relative;
}

/* 子菜单基础样式 */
.submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1001;
}

/* 桌面端子菜单样式 - 现代化设计 */
.desktop-submenu {
  top: 100%;
  left: -27px;
  background: #2a2a2a;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  min-width: 130px;
  transform: translateY(-10px);
  overflow: hidden;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  margin-top: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.desktop-submenu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.desktop-submenu li {
  margin: 0;
}

.desktop-submenu li a {
  display: block;
  padding: 4px 6px 4px 6px !important;
  color: white !important;
  font-weight: 500;
  transition: all 0.2s ease;
  font-size: 15px;
  border-radius: 12px;
  margin: 4px 12px 4px 4px;
  position: relative;
}

.desktop-submenu li:last-child a {
  margin-bottom: 4px;
}

.desktop-submenu li a:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(4px);
}

.desktop-submenu li a:hover::after {
  width: 0 !important; /* 移除原有的下划线效果 */
}

/* 移动端子菜单样式 */
.mobile-submenu {
  position: static;
  background: #333;
  border-radius: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transform: none;
  transition: max-height 0.4s ease, opacity 0.3s ease;
}

.mobile-submenu.show {
  max-height: 200px;
  opacity: 1;
  visibility: visible;
}

.mobile-submenu li {
  margin: 0;
}

.mobile-submenu li a {
  display: block;
  padding: 12px 30px;
  color: #fff !important;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  animation: slideInLeft 0.3s ease;
}

.mobile-submenu li:last-child a {
  border-bottom: none;
}

.mobile-submenu li a:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  padding-left: 40px;
}

.mobile-submenu li a:hover::after {
  width: 0 !important; /* 移除原有的下划线效果 */
}

/* 移动端指示器旋转动画 */
.mobile-only.rotated {
  transform: rotate(120deg);
  transform-origin: center center; 
}

/* 滑入动画 */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* PC端导航栏布局 */
@media (min-width: 769px) {
  .submenu-indicator.desktop-only {
    margin-left: 0.5px;
    vertical-align: middle;
    position: relative;
    top: -2.5px;
  }
  nav {
    padding: 0 50px;
    height: 55px;
    justify-content: space-between;
  }

  .logo {
    margin-right: 25px;
  }

  #nav-list {
    margin-right: auto;
    flex-wrap: nowrap;
  }

  .search-bar {
    order: 3;
    flex-shrink: 0;
  }

  /* 桌面端显示桌面端指示器和子菜单 */
  .desktop-only {
    display: inline-block;
  }

  .mobile-only {
    display: none;
  }

  .mobile-submenu {
    display: none;
  }
}

/* 平板电脑的导航栏布局 */
@media (max-width: 991px) and (min-width: 769px) {
  .search-bar input {
    width: 120px;
  }

  .search-bar input:focus {
    width: 150px;
  }

  #nav-list li {
    margin: 0 8px;
  }

  nav {
    padding: 0 30px;
  }
}

/* 手机端导航栏布局 */
@media (max-width: 768px) {
        .submenu-indicator.mobile-only {
        margin-left: 0.5px !important;
        vertical-align: middle !important;
        position: relative !important;
        top: -2px !important;
    }
  nav {
    padding: 8px 15px;
    justify-content: space-between;
  }

  .logo {
    order: 1;
    margin-right: 0;
    flex-shrink: 1;
  }

  .logo img {
    height: 30px;
  }

  .search-bar {
    order: 2;
    flex-grow: 1;
    margin: 0 10px;
    max-width: 60%;
  }

  .search-bar input {
    width: 100%;
    font-size: 14px;
    padding: 6px 10px;
  }

  .search-bar input:focus {
    width: 100%;
  }

  .search-bar button {
    padding: 6px 10px;
    font-size: 14px;
  }

  .hamburger-menu {
    display: flex;
    order: 3;
    flex-shrink: 0;
    margin-left: 10px;
  }

  #nav-list {
    order: 4;
    width: 100%;
    flex-direction: column;
    background-color: #222;
    border-radius: 0 0 8px 8px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
    margin-top: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    padding: 0;
  }

  #nav-list.show {
    max-height: 400px; /* 增加高度以容纳子菜单 */
    padding: 8px 0;
  }

  #nav-list li {
    margin: 0;
    width: 100%;
    text-align: center;
  }

  #nav-list li a {
    display: block;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  #nav-list li:last-child a {
    border-bottom: none;
  }

  /* 移动端显示移动端指示器和子菜单 */
  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: inline-block;
  }

  .desktop-submenu {
    display: none;
  }

  /* 移动端子菜单项样式调整 */
  .nav-item-with-submenu {
    position: relative;
  }

  .nav-item-with-submenu > a {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
  }
}

/* 极小屏幕设备的调整 */
@media (max-width: 480px) {
  .search-bar {
    max-width: 50%;
  }

  .search-bar input {
    width: 100%;
    font-size: 12px;
    padding: 6px 8px;
  }

  .search-bar button {
    padding: 6px 8px;
    font-size: 12px;
  }

  .logo img {
    height: 28px;
  }

  nav {
    padding: 8px 10px;
  }

  #nav-list.show {
    max-height: 450px; /* 为极小屏幕提供更多空间 */
  }
}