/* 基础布局结构 */
.main-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

#sidebar-placeholder {
  flex-shrink: 0;
  z-index: 1000;
}

/* 侧边栏整体过渡 */
.sidebar-nav {
  width: 200px;
  min-width: 200px;
  max-width: 320px;
  background: radial-gradient(circle at top left, #0b1120, #020617);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100vh;
  position: sticky;
  top: 0;
}

.mobile-menu-toggle {
  display: none;
}

/* 展开状态下的文案容器：强制不换行并平滑缩放 */
.sidebar-nav .category-option,
.sidebar-nav .sidebar-footer button,
.sidebar-nav .sidebar-footer .lang-btn {
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav .nav-brand {
  white-space: nowrap;
  overflow: visible;
}

.sidebar-main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-main-content::-webkit-scrollbar {
  width: 4px;
}

.sidebar-main-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.sidebar-nav * {
  white-space: nowrap;
}

.sidebar-footer {
  padding: 12px 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: inherit;
  /* overflow: hidden; */ /* 移除 overflow: hidden 以允许语言菜单弹出 */
}

.sidebar-collapsed .sidebar-footer {
  padding: 12px 0 20px;
  align-items: center;
  /* overflow: hidden; */ /* 移除 overflow: hidden */
}

.sidebar-footer .lang-selector {
  width: 100%;
  display: flex;
  justify-content: center;
}

.sidebar-footer .lang-btn,
.sidebar-footer .theme-btn {
  width: 100%;
  justify-content: center;
}

.sidebar-collapsed .sidebar-footer .lang-btn,
.sidebar-collapsed .sidebar-footer .theme-btn {
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  justify-content: center; /* 确保图标居中 */
}

.sidebar-collapsed .sidebar-footer .lang-btn span:first-child {
  margin: 0; /* 移除可能的边距 */
}

.sidebar-collapsed .nav-section-title {
  display: none;
}

.sidebar-collapsed .sidebar-nav {
  width: 72px;
  min-width: 72px;
  overflow: visible !important; /* 允许悬浮气泡溢出显示 */
}

.nav-header {
  padding: 0 12px;
  height: 64px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  overflow: visible;
}

.nav-brand-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
  overflow: visible;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 700;
  color: #e5e7eb;
  text-decoration: none;
  white-space: nowrap;
  overflow: visible;
  padding: 2px 0;
}

.nav-brand .logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: #0b1120;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.nav-section {
  padding: 16px 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4b5563;
  margin: 0 0 12px 4px;
  font-weight: 700;
}

.sidebar-nav .category-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  flex-direction: column;
}

/* 移除一级菜单选中样式，仅保留 hover 效果 */
.sidebar-nav .category-option:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

/* 亮色模式 hover */
.light-theme .sidebar-nav .category-option:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* 确保 active 类在一级菜单上生效 */
.sidebar-nav .category-option.active {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  font-weight: 600;
}

.sub-menu {
  display: none; /* 默认隐藏 */
  flex-direction: column;
  gap: 2px;
  margin-left: 28px; /* 图标对齐对齐 */
  margin-bottom: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
  width: fit-content;
  min-width: 100px;
}

.nav-item.open .sub-menu {
  display: flex; /* 展开时显示 */
}

/* 一级菜单样式 */
.category-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  margin: 2px 0;
}

.category-option:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

.category-option.active {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  font-weight: 600;
}

.category-option .option-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.category-option .arrow {
  font-size: 10px;
  transition: transform 0.3s ease;
  opacity: 0.6;
}

.nav-item.open > .category-option .arrow {
  transform: rotate(180deg);
  opacity: 1;
}

.sidebar-collapsed .category-option .arrow {
  display: none; /* 折叠侧栏时隐藏箭头 */
}

.sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 12px; /* 比一级菜单小一点 */
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-item .sub-icon {
  font-size: 12px;
  width: 16px;
  display: flex;
  justify-content: center;
}

.sub-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

.sub-item.active {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  font-weight: 600;
}

.light-theme .sub-item {
  color: #64748b;
}

.light-theme .sub-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.light-theme .sub-item.active {
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}

.sidebar-collapsed .sub-menu {
  display: none !important; /* 强制折叠时隐藏二级菜单 */
}

.sidebar-collapsed .nav-item.open .sub-menu {
  display: none !important; /* 强制折叠时隐藏展开的二级菜单 */
}

.sidebar-nav .category-option span:first-child {
  font-size: 18px;
  display: inline-flex;
  width: 24px;
  justify-content: center;
}

/* 折叠时隐藏标题 */
.sidebar-collapsed .nav-section {
  padding: 16px 0;
  overflow: visible;
}

.sidebar-collapsed .category-options {
  align-items: center;
}

.sidebar-collapsed .nav-item {
  width: 100%;
  align-items: center;
}

.sidebar-collapsed .category-option {
  width: 48px;
  height: 48px;
  padding: 0;
  justify-content: center;
  border-radius: 12px;
}

.sidebar-collapsed .category-option .option-content {
  gap: 0;
}

.sidebar-collapsed .sidebar-nav {
  overflow-y: auto;
  overflow-x: hidden; /* 禁止横向滚动 */
}

.sidebar-collapsed .sidebar-main-content {
  overflow-x: hidden; /* 禁止横向滚动 */
  overflow-y: auto;
}

/* 默认文案样式 */
.sidebar-nav .nav-brand span:not(.logo),
.sidebar-nav .category-option span:last-child,
.sidebar-nav .sidebar-footer .lang-label,
.sidebar-nav .sidebar-footer .theme-btn span:last-child,
.sidebar-nav .sidebar-footer .sidebar-toggle span:last-child {
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* 折叠状态：立即隐藏文案，防止 fixed 定位切换时的闪烁 */
.sidebar-collapsed .sidebar-nav .nav-brand span:not(.logo),
.sidebar-collapsed .sidebar-nav .category-option .option-content span:last-child,
.sidebar-collapsed .sidebar-nav .sidebar-footer .lang-label,
.sidebar-collapsed .sidebar-nav .sidebar-footer .theme-btn span:last-child,
.sidebar-collapsed .sidebar-nav .sidebar-footer .sidebar-toggle span:last-child {
  position: fixed;
  left: 72px; /* 紧贴侧边栏边缘 (72px) */
  background: #1e293b;
  color: #f1f5f9;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* 关键：使用 translateY(-50%) 配合 JS 设置的 top 居中，对齐图标中心 */
  transform: translateY(-50%) translateX(0);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: block;
  /* 关键：在折叠状态下默认不使用 transition，确保从展开切换到折叠时文案瞬间消失 */
  transition: none !important;
}

/* 展开状态：覆盖所有 tooltip 属性 */
.main-layout:not(.sidebar-collapsed) .sidebar-nav .nav-brand span:not(.logo),
.main-layout:not(.sidebar-collapsed) .sidebar-nav .category-option .option-content span:last-child,
.main-layout:not(.sidebar-collapsed) .sidebar-nav .sidebar-footer .lang-label,
.main-layout:not(.sidebar-collapsed) .sidebar-nav .sidebar-footer .theme-btn span:last-child,
.main-layout:not(.sidebar-collapsed) .sidebar-nav .sidebar-toggle span:last-child {
  position: static !important;
  opacity: 1 !important; 
  visibility: visible !important;
  background: transparent !important;
  padding: 0 !important;
  box-shadow: none !important;
  border: none !important;
  transform: none !important;
  display: inline-block !important;
  pointer-events: auto !important;
  transition: none !important;
}

/* 仅在悬浮时启用 transition，实现气泡提示效果 */
.sidebar-collapsed .sidebar-nav .category-option:hover .option-content span:last-child,
.sidebar-collapsed .sidebar-nav .sidebar-footer .lang-selector:not(:has(.lang-menu.open)):hover .lang-label,
.sidebar-collapsed .sidebar-nav .sidebar-footer .theme-btn:hover span:last-child,
.sidebar-collapsed .sidebar-nav .sidebar-footer .sidebar-toggle:hover span:last-child {
  opacity: 1 !important;
  visibility: visible !important;
  /* 保持 translateY(-50%) 以维持垂直居中 */
  transform: translateY(-50%) translateX(6px) !important;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease !important;
}

/* 提示框小三角 */
.sidebar-collapsed .sidebar-nav .category-option:hover .option-content span:last-child::before,
.sidebar-collapsed .sidebar-nav .sidebar-footer .lang-selector:not(:has(.lang-menu.open)):hover .lang-label::before,
.sidebar-collapsed .sidebar-nav .sidebar-footer .theme-btn:hover span:last-child::before,
.sidebar-collapsed .sidebar-nav .sidebar-footer .sidebar-toggle:hover span:last-child::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 5px 5px 5px 0;
  border-style: solid;
  border-color: transparent #1e293b transparent transparent;
}

/* 亮色模式下的悬浮提示 */
.light-theme.sidebar-collapsed .sidebar-nav .category-option .option-content span:last-child,
.light-theme.sidebar-collapsed .sidebar-nav .sidebar-footer .lang-label,
.light-theme.sidebar-collapsed .sidebar-nav .sidebar-footer .theme-btn span:last-child,
.light-theme.sidebar-collapsed .sidebar-nav .sidebar-footer .sidebar-toggle span:last-child {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.light-theme.sidebar-collapsed .sidebar-nav .category-option:hover .option-content span:last-child::before,
.light-theme.sidebar-collapsed .sidebar-nav .sidebar-footer .lang-selector:not(:has(.lang-menu.open)):hover .lang-label::before,
.light-theme.sidebar-collapsed .sidebar-nav .sidebar-footer .theme-btn:hover span:last-child::before,
.light-theme.sidebar-collapsed .sidebar-nav .sidebar-footer .sidebar-toggle:hover span:last-child::before {
  border-color: transparent #e2e8f0 transparent transparent;
}

.sidebar-collapsed .nav-brand {
  gap: 0;
  justify-content: center;
}

.sidebar-collapsed .nav-brand .logo-icon-container {
  margin-right: 0;
}

.sidebar-collapsed .nav-brand-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
}

.sidebar-collapsed .side-toggle {
  display: flex;
  margin: 0;
  justify-content: center;
}

.sidebar-collapsed .nav-header {
  height: 64px;
  padding: 0;
}

.sidebar-collapsed .category-option {
  justify-content: center;
}

/* 侧边栏折叠按钮 */
.sidebar-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  height: auto;
  min-height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 10px 12px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

.sidebar-footer .sidebar-toggle,
.sidebar-footer .theme-btn,
.sidebar-footer .lang-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  cursor: pointer;
  transition: all 0.2s;
  box-sizing: border-box;
  height: auto;
  min-height: 40px;
}

.sidebar-footer .theme-btn span:first-child,
.sidebar-footer .lang-btn span:first-child {
  width: 24px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.sidebar-footer .theme-btn:hover,
.sidebar-footer .lang-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
  transform: none;
  box-shadow: none;
}

.light-theme .sidebar-footer .theme-btn,
.light-theme .sidebar-footer .lang-btn {
  color: #64748b;
}

.light-theme .sidebar-footer .theme-btn:hover,
.light-theme .sidebar-footer .lang-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.sidebar-collapsed .sidebar-toggle {
  padding: 0;
  width: 40px;
  height: 40px;
  justify-content: center;
}

.sidebar-toggle .toggle-icon {
  font-size: 18px;
  display: inline-flex;
  width: 24px;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

.sidebar-toggle:active {
  transform: translateY(0);
}

.light-theme .sidebar-toggle {
  background: transparent;
  border: 1px solid transparent;
  color: #64748b;
}

.light-theme .sidebar-toggle:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.side-toggle {
  /* 移除之前的负边距 */
}

/* 主内容区域适配 */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* 翻页效果样式 */
.paging-container {
  height: 100vh;
  overflow: hidden; /* 改为 hidden，完全由 JS 控制翻页动画 */
  position: relative;
}

.paging-content {
  height: 100%;
  width: 100%;
  /* 使用强力且丝滑的贝塞尔曲线，移除回弹（抖动），保留速度感 */
  transition: transform 0.7s cubic-bezier(0.19, 1, 0.22, 1);
  will-change: transform;
}

/* 隐藏翻页容器的滚动条，保持页面整洁 */
.paging-container::-webkit-scrollbar {
  display: none;
}

.page-section {
  width: 100%;
  height: 100vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* 第二页及以后的默认样式 */
.page-section.secondary-page {
}

.is-home-page .main-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.light-theme .main-layout {
  background: #f8fafc;
}

.light-theme .paging-container {
  background: #f8fafc;
}

.light-theme .intro-related-section {
  background: #ffffff;
}

.light-theme .intro-bottom-section {
  background: #ffffff;
}
