/* =========================================================
 *  sidebar.css — 左侧分类侧边栏 + 右侧题目清单抽屉
 *  1:1 从 style.css 拆分，视觉零改动
 * ========================================================= */

/* =========================================================
 *  侧边栏
 * ========================================================= */

.sidebar {
  flex-shrink: 0;
  width: 248px;
  height: 100vh;
  background: var(--panel-side);
  border-right: 1px solid #1c293d;
  overflow: hidden;
  transition: width 220ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 15;
}

.sidebar.is-collapsed {
  width: 0;
  border-right-color: transparent;
}

.sidebar-inner {
  width: 248px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid #16202f;
}

.brand {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: linear-gradient(90deg, #5aa0ff, #7dd3fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 18px 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #6a7b93;
  text-transform: uppercase;
  gap: 8px;
}

.sidebar-label-hint {
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  color: #7a8ba3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.category-list {
  list-style: none;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #24334a transparent;
}

.category-list::-webkit-scrollbar {
  width: 6px;
}

.category-list::-webkit-scrollbar-thumb {
  background: #24334a;
  border-radius: 3px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13.5px;
  transition: background 130ms ease, color 130ms ease, box-shadow 130ms ease,
    opacity 130ms ease;
  position: relative;
  user-select: none;
  outline: none;
}

.category-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #c8d6e8;
}

.category-item.is-active {
  background: linear-gradient(90deg, rgba(61, 139, 253, 0.18), rgba(61, 139, 253, 0.04));
  color: #ffffff;
  box-shadow: inset 2px 0 0 var(--accent);
}

.category-item.is-dragging {
  opacity: 0.42;
  cursor: grabbing;
}

.category-item.drop-above::before,
.category-item.drop-below::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(61, 139, 253, 0.85);
  pointer-events: none;
}

.category-item.drop-above::before {
  top: -2px;
}

.category-item.drop-below::after {
  bottom: -2px;
}

.cat-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.cat-count {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: #63768f;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 7px;
  min-width: 22px;
  text-align: center;
  border-radius: 999px;
  flex-shrink: 0;
  transition: color 130ms ease, background 130ms ease, opacity 140ms ease,
    transform 140ms ease;
}

.category-item.is-active .cat-count {
  color: #b8cce8;
  background: rgba(61, 139, 253, 0.2);
}

/* 悬停时数量徽章淡出，给右侧浮动操作栏让位（不产生布局跳动） */
.category-item:hover .cat-count,
.category-item:focus-within .cat-count {
  opacity: 0;
  transform: scale(0.85);
}

/* 悬停右侧浮动操作栏：设置 / 下载 */
.cat-actions {
  position: absolute;
  top: 50%;
  right: 6px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: linear-gradient(180deg, #26374f, #1e293b);
  border: 1px solid rgba(90, 160, 255, 0.28);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5),
    0 0 12px rgba(61, 139, 253, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(6px);
  transition: opacity 150ms ease,
    transform 160ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 160ms ease;
}

.category-item:hover .cat-actions,
.category-item:focus-within .cat-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55),
    0 0 14px rgba(61, 139, 253, 0.3);
}

.cat-action-btn {
  appearance: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #a9bcd6;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease,
    box-shadow 130ms ease, transform 80ms ease;
}

.cat-action-btn:hover {
  color: #ffffff;
  background: rgba(61, 139, 253, 0.28);
  border-color: rgba(90, 160, 255, 0.45);
  box-shadow: 0 0 10px rgba(61, 139, 253, 0.4);
}

.cat-action-btn:active {
  transform: translateY(1px);
}

.cat-action-btn[data-action="settings"] {
  font-size: 14px;
}

.cat-action-btn[data-action="download"] {
  color: #9ecbff;
}

/* 登录解锁后，侧边栏必须恢复可交互（避免残留 pointer-events: none） */
body:not(.auth-locked) .sidebar {
  pointer-events: auto;
}

.sidebar-footer {
  padding: 12px 14px 16px;
  border-top: 1px solid #16202f;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-block {
  width: 100%;
  display: block;
}

/* =========================================================
 *  题目列表抽屉
 * ========================================================= */

/* 📋 题目列表按钮：尺寸 / 圆角 / 悬停统一继承 .btn.btn-ghost */
.drawer-toggle.is-open {
  background: rgba(61, 139, 253, 0.18);
  border-color: var(--accent);
  color: #c8d6e8;
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.18);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 8, 14, 0.42);
  opacity: 0;
  /* 🛡️ 关闭态：visibility:hidden + pointer-events:none 双保险，
   * 绝不让透明遮罩继续拦截全站点击。 */
  visibility: hidden;
  pointer-events: none;
  transition: opacity 260ms ease, visibility 0s linear 260ms;
}

.drawer-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 260ms ease, visibility 0s;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 92vw);
  z-index: 95;
  background: var(--panel);
  border-left: 1px solid #2a3a4f;
  display: flex;
  flex-direction: column;
  box-shadow: -14px 0 46px rgba(0, 0, 0, 0.55);
  transform: translateX(105%);
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.drawer-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.drawer-title h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #dbe6f5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

.drawer-count {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.drawer-close {
  appearance: none;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 140ms ease, color 140ms ease;
  flex-shrink: 0;
}

.drawer-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.drawer-toolbar {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20, 29, 42, 0.6);
}

.drawer-sort-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.drawer-sort-select {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: #101827;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.drawer-sort-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.2);
}

.drawer-list {
  list-style: none;
  padding: 8px 10px 18px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: #24334a transparent;
}

.drawer-list::-webkit-scrollbar {
  width: 6px;
}

.drawer-list::-webkit-scrollbar-thumb {
  background: #24334a;
  border-radius: 3px;
}

.drawer-empty {
  padding: 34px 16px;
  text-align: center;
  color: #5c6c82;
  font-size: 13px;
  line-height: 1.7;
}

.drawer-item {
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease,
    transform 100ms ease, box-shadow 140ms ease;
}

.drawer-item:hover {
  background: rgba(61, 139, 253, 0.09);
  border-color: rgba(61, 139, 253, 0.35);
  box-shadow: 0 2px 12px rgba(61, 139, 253, 0.14);
}

.drawer-item:active {
  transform: translateY(1px);
}

.drawer-item-title {
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.4;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  transition: filter 140ms ease;
}

.drawer-item:hover .drawer-item-title {
  filter: brightness(1.28);
}

.drawer-item-meta {
  margin-top: 4px;
  font-size: 10.5px;
  color: #5f7086;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================
 *  移动端适配
 * ========================================================= */

@media (max-width: 720px) {
  .sidebar {
    width: 220px;
  }

  .sidebar-inner {
    width: 220px;
  }

  .drawer {
    width: min(320px, 94vw);
  }
}