/* ====================================
   Sidebar v3 · 主导航 + 子菜单折叠
   参照主站右侧导航 + Arco Design 风格
   ==================================== */

.sidebar {
  width: 240px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-base);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-base);
  border-radius: 2px;
}

/* ============ Brand 区 ============ */
.sidebar-brand {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border-base);
}
.sidebar-brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #722ed1 0%, #165DFF 50%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(22, 93, 255, 0.25);
}
.sidebar-brand-text { flex: 1; min-width: 0; }
.sidebar-brand-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.2px;
}
.sidebar-brand-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.2;
}
.sidebar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--success-light);
  border-radius: 6px;
  font-size: 11px;
}
.sidebar-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(0,180,42,0.5); }
  70% { box-shadow: 0 0 0 6px rgba(0,180,42,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,180,42,0); }
}
.sidebar-status-text {
  color: var(--success);
  font-weight: 500;
}

/* ============ 搜索 ============ */
.sidebar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px 12px 8px;
  padding: 7px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border-base);
  border-radius: 8px;
  transition: all 0.15s;
}
.sidebar-search:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.08);
  background: var(--bg-elevated);
}
.sidebar-search-icon { font-size: 12px; opacity: 0.6; }
.sidebar-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 12.5px;
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}
.sidebar-search input::placeholder { color: var(--text-tertiary); }
.sidebar-search kbd {
  font-size: 10px;
  font-family: monospace;
  padding: 1px 5px;
  background: var(--bg-hover);
  border: 1px solid var(--border-base);
  border-radius: 3px;
  color: var(--text-tertiary);
}

/* ============ Mini 卡片 ============ */
.sidebar-mini {
  margin: 0 12px 12px;
  padding: 10px;
  background: var(--bg-base);
  border-radius: 8px;
  border: 1px solid var(--border-base);
}
.sidebar-mini-score {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.sidebar-mini-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: conic-gradient(var(--brand-primary) calc(var(--p, 85) * 1%), var(--bg-hover) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.sidebar-mini-circle::before {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--bg-base);
  border-radius: 50%;
}
.sidebar-mini-circle span {
  position: relative;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-text);
}
.sidebar-mini-meta { flex: 1; min-width: 0; }
.sidebar-mini-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 1px;
}
.sidebar-mini-sub {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
}
.sidebar-mini-quota { }
.sidebar-mini-quota-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.sidebar-mini-quota-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.sidebar-mini-quota-bar {
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}
.sidebar-mini-quota-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--info));
  border-radius: 2px;
  transition: width 0.4s;
}

/* ============ Section Label ============ */
.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-tertiary);
  padding: 8px 18px 6px;
  font-weight: 600;
  opacity: 0.7;
}

/* ============ 主导航 + 子菜单（参照参考图） ============ */
.sidebar-nav {
  padding: 0 12px;
  flex: 1;
}

.sidebar-nav-group {
  margin-bottom: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  transition: all 0.18s ease;
  cursor: pointer;
  user-select: none;
}

/* 主导航项：flat 状态 */
.sidebar-item.main-item {
  font-size: 14px;
  font-weight: 500;
  padding: 11px 14px;
}
.sidebar-item.main-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* 主导航 active 蓝色 button 风格（参照主站） */
.sidebar-item.main-item.active {
  background: var(--brand-primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(22, 93, 255, 0.32);
}
.sidebar-item.main-item.active .sidebar-item-icon { color: white; }
.sidebar-item.main-item.active .sidebar-item-badge {
  background: rgba(255,255,255,0.22);
  color: white;
}
.sidebar-item.main-item.active .sidebar-item-chevron { color: white; }

/* chevron */
.sidebar-item-chevron {
  margin-left: auto;
  font-size: 18px;
  color: var(--text-tertiary);
  transition: transform 0.25s ease;
  font-weight: 400;
  display: flex;
  align-items: center;
  height: 16px;
}
.sidebar-item.expanded .sidebar-item-chevron {
  transform: rotate(90deg);
}

.sidebar-item-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.sidebar-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* badge */
.sidebar-item-badge {
  background: var(--bg-hover);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sidebar-item-badge.small { font-size: 9px; padding: 1px 5px; }
.sidebar-item.main-item.active .sidebar-item-badge { background: rgba(255,255,255,0.2); color: white; }

/* NEW 星标 */
.sidebar-item.is-new .sidebar-item-badge {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  font-weight: 800;
}

/* ============ 子菜单（折叠） ============ */
.sidebar-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
  background: var(--bg-base);
  border-radius: 10px;
  margin: 2px 0 4px 0;
  opacity: 0;
}
.sidebar-submenu.open {
  max-height: 600px;
  padding: 4px 0;
  opacity: 1;
  box-shadow: inset 0 0 0 1px var(--border-base);
}
.sidebar-submenu .sidebar-item.sub-item {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.15s;
}
.sidebar-submenu.open .sidebar-item.sub-item {
  opacity: 1;
  transform: translateY(0);
}
.sidebar-submenu.open .sidebar-item.sub-item:nth-child(1) { transition-delay: 0.05s; }
.sidebar-submenu.open .sidebar-item.sub-item:nth-child(2) { transition-delay: 0.10s; }
.sidebar-submenu.open .sidebar-item.sub-item:nth-child(3) { transition-delay: 0.15s; }
.sidebar-submenu.open .sidebar-item.sub-item:nth-child(4) { transition-delay: 0.20s; }
.sidebar-submenu.open .sidebar-item.sub-item:nth-child(5) { transition-delay: 0.25s; }

.sidebar-item.sub-item {
  padding: 9px 14px 9px 38px;
  margin: 0;
  border-radius: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  position: relative;
  transition: all 0.15s;
}
.sidebar-item.sub-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  padding-left: 42px;
}
.sidebar-item.sub-item.active {
  background: var(--bg-active);
  color: var(--brand-text);
  font-weight: 600;
  padding-left: 42px;
}
.sidebar-item.sub-item.active::before {
  content: '';
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 16px;
  background: var(--brand-primary);
  border-radius: 2px;
}
.sidebar-item.sub-item .sidebar-item-icon { font-size: 14px; opacity: 0.8; }
.sidebar-item.sub-item.active .sidebar-item-icon { opacity: 1; }

/* ============ Footer ============ */
.sidebar-footer {
  padding: 8px 12px 16px;
}
.sidebar-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-base);
  border-radius: 8px;
  border-left: 3px solid var(--info);
}
.sidebar-tip-icon { font-size: 14px; flex-shrink: 0; }
.sidebar-tip-text {
  line-height: 1.5;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.sidebar-tip-text strong {
  display: block;
  color: var(--text-primary);
  margin-bottom: 2px;
  font-size: 12px;
}

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 80;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.show { left: 0; }
}

/* ============ 用户卡片（sidebar 底部） ============ */
.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 8px;
  padding: 10px;
  background: var(--bg-base);
  border: 1px solid var(--border-base);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.sidebar-user-card:hover {
  border-color: var(--brand-primary);
  background: var(--bg-hover);
}
.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar-user-meta {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.sidebar-user-plan {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.plan-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.4);
}
.sidebar-user-chevron {
  color: var(--text-tertiary);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  margin-left: auto;
}

/* ============ 下拉菜单 ============ */
.sidebar-user-dropdown {
  position: absolute;
  bottom: 80px;
  left: 12px;
  right: 12px;
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-base);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: all 0.2s ease;
  z-index: 100;
}
.sidebar-user-dropdown.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.sud-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border-base);
  margin-bottom: 8px;
}
.sud-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #165DFF 0%, #722ed1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}
.sud-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}
.sud-email {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.sud-plan-card {
  background: linear-gradient(135deg, var(--brand-light) 0%, transparent 100%);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--brand-primary);
  margin-bottom: 8px;
}
.sud-plan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.sud-plan-label {
  font-size: 11px;
  color: var(--text-tertiary);
}
.sud-plan-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: white;
}
.sud-plan-progress {
  margin-top: 8px;
}
.sud-plan-bar {
  height: 5px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.sud-plan-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--info));
  border-radius: 3px;
  transition: width 0.4s;
}
.sud-plan-text {
  font-size: 11px;
  color: var(--text-secondary);
}
.sud-plan-text strong {
  color: var(--brand-text);
  font-weight: 700;
}
.sud-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}
.sud-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.sud-item span:first-child {
  font-size: 14px;
  width: 18px;
  text-align: center;
}
