/* 移动端抽屉导航样式 - 使用ID选择器避免冲突 */

/* 遮罩层 */
#mobile-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#mobile-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 抽屉主体 */
#mobile-drawer-nav {
  position: fixed;
  top: 0;
  left: -320px;
  width: 320px;
  height: 100%;
  background: #ffffff;
  z-index: 9999;
  overflow-y: auto;
  transition: left 0.3s ease;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

#mobile-drawer-nav.active {
  left: 0;
}

/* 抽屉头部 */
#mobile-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
}

#mobile-drawer-header img {
  max-width: 180px;
  height: auto;
}

#mobile-drawer-close {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 32px;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

#mobile-drawer-close:hover {
  color: #005523;
}

/* 移动端搜索框 */
#mobile-drawer-search {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
}

#mobile-drawer-search form {
  display: flex;
  align-items: stretch; /* 改为stretch确保高度一致 */
  background: #f5f5f5;
  border-radius: 8px;
  overflow: hidden; /* 隐藏内部元素溢出 */
  border: 1px solid #ddd;
  height: 45px; /* 固定高度 */
}

#mobile-search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0 15px; /* 上下padding改为0 */
  font-size: 15px;
  outline: none;
  color: #333;
  border-radius: 0; /* 移除圆角，由form控制 */
  margin: 0; /* 确保没有margin */
}

#mobile-search-input::placeholder {
  color: #999;
}

#mobile-drawer-search button {
  width: 45px;
  height: 100%; /* 使用100%高度 */
  border: none;
  background: #005523;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
  border-radius: 0; /* 移除圆角，由form控制 */
  flex-shrink: 0;
  margin: 0; /* 确保没有margin */
  padding: 0; /* 确保没有额外padding */
}

#mobile-drawer-search button:hover {
  background: #003d19;
}

/* 移动端语言切换 */
#mobile-drawer-language {
  display: flex;
  gap: 8px;
  padding: 15px 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #fafafa;
}

.mobile-lang-btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  background: #ffffff;
  color: #666;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.mobile-lang-btn:hover {
  border-color: #005523;
  color: #005523;
}

.mobile-lang-btn.active {
  background: #005523;
  color: #ffffff;
  border-color: #005523;
}

/* 移动端菜单 */
#mobile-drawer-menu {
  padding: 10px 0;
}

#mobile-drawer-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#mobile-drawer-menu > ul > li {
  border-bottom: 1px solid #f0f0f0;
}

#mobile-drawer-menu > ul > li:last-child {
  border-bottom: none;
}

/* 菜单项包装器 */
.menu-item-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.menu-item-wrapper > a {
  flex: 1;
  padding: 15px 20px;
  color: #333;
  text-decoration: none;
  font-size: 16px;
  display: block;
  transition: background 0.3s ease, color 0.3s ease;
}

.menu-item-wrapper > a:hover {
  background: #f5f5f5;
  color: #005523;
}

/* 没有子菜单的链接 */
#mobile-drawer-menu > ul > li:not(.has-submenu) > a {
  padding: 15px 20px;
  color: #333;
  text-decoration: none;
  font-size: 16px;
  display: block;
  transition: background 0.3s ease, color 0.3s ease;
}

#mobile-drawer-menu > ul > li:not(.has-submenu) > a:hover {
  background: #f5f5f5;
  color: #005523;
}

/* 子菜单切换按钮 */
.submenu-toggle {
  width: 50px;
  height: 50px;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, color 0.3s ease;
  flex-shrink: 0;
}

.submenu-toggle:hover {
  color: #005523;
}

.has-submenu.open .submenu-toggle {
  transform: rotate(180deg);
}

.has-submenu.open .submenu-toggle svg {
  color: #005523;
}

/* 子菜单 */
.submenu {
  max-height: 0;
  overflow: hidden;
  background: #f8f9fa;
  transition: max-height 0.3s ease;
}

.has-submenu.open .submenu {
  max-height: 800px;
}

.submenu li {
  border-top: 1px solid #e8e8e8;
}

.submenu li:first-child {
  border-top: none;
}

.submenu a {
  padding: 12px 20px 12px 40px;
  color: #555;
  text-decoration: none;
  font-size: 15px;
  display: block;
  transition: background 0.3s ease, color 0.3s ease;
}

.submenu a:hover {
  background: #e8f5e9;
  color: #005523;
}

/* 移动端超级菜单 */
#mobile-megamenu {
  /* 不设置固定高度，使用和其他submenu一样的展开逻辑 */
  overflow-y: auto;
}

/* 当展开时允许滚动并设置最大高度 */
.has-submenu.open #mobile-megamenu {
  max-height: 600px;
}

/* 自定义滚动条 */
#mobile-drawer-nav::-webkit-scrollbar,
#mobile-megamenu::-webkit-scrollbar {
  width: 6px;
}

#mobile-drawer-nav::-webkit-scrollbar-track,
#mobile-megamenu::-webkit-scrollbar-track {
  background: #f1f1f1;
}

#mobile-drawer-nav::-webkit-scrollbar-thumb,
#mobile-megamenu::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

#mobile-drawer-nav::-webkit-scrollbar-thumb:hover,
#mobile-megamenu::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* 只在移动端显示抽屉导航 */
@media (min-width: 992px) {
  /* PC端完全隐藏移动端抽屉导航 */
  #mobile-drawer-overlay,
  #mobile-drawer-nav {
    display: none !important;
  }
  
  /* PC端恢复导航元素显示，使用原有的display值 */
  .rd-navbar-nav-wrap {
    display: flex !important;
  }
  
  .rd-navbar-nav {
    display: flex !important;
  }
  
  .rd-navbar-main {
    display: flex !important;
  }
  
  .rd-navbar-main-outer {
    display: block !important;
  }
  
  .rd-navbar-content-outer {
    display: flex !important;
  }
  
  .rd-navbar-content {
    display: flex !important;
  }
  
  .language-switcher-container {
    display: block !important;
  }
  
  /* 确保PC端搜索按钮可见 */
  .rd-navbar-search-toggle {
    display: inline-block !important;
  }
}

/* 在移动端隐藏PC端导航的某些元素 */
@media (max-width: 991px) {
  /* 隐藏PC端的搜索按钮 */
  .rd-navbar-search-toggle {
    display: none !important;
  }
  
  /* 强制隐藏PC端搜索覆盖层 */
  .rd-navbar-search-toggled .rd-search,
  .rd-navbar-search-toggled.active .rd-search {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
  }
  
  /* 隐藏旧的移动端导航菜单（橙色背景部分） */
  .rd-navbar-nav-wrap {
    display: none !important;
  }
  
  /* 隐藏移动端展开的导航 */
  .rd-navbar-nav-wrap.active {
    display: none !important;
  }
  
  /* 确保导航主体在移动端隐藏 */
  .rd-navbar-main {
    display: none !important;
  }
  
  /* 隐藏导航外层容器 */
  .rd-navbar-main-outer {
    display: none !important;
    height: auto !important;
  }
  
  /* 隐藏右上角的语言切换按钮（桌面端版本） */
  .rd-navbar-content-outer,
  .rd-navbar-content,
  .language-switcher-container {
    display: none !important;
  }
  
  /* 隐藏aside区域的语言切换 */
  .rd-navbar-aside .rd-navbar-content-outer {
    display: none !important;
  }
}

