/* HMind 管理后台 —— 深色仪表盘。零依赖,纯手写。品牌色对齐 App 紫渐变。 */

:root {
  --bg: #0a0b0e;
  --surface: #131418;
  --surface-2: #1a1b20;
  --surface-3: #22242a;
  --border: #26282e;
  --border-strong: #34363d;
  --text: #e9eaec;
  --text-2: #9a9da6;
  --text-3: #6b6e78;

  /* HMind 品牌紫渐变（取自 App 图标端点） */
  --brand-1: #9b84ee;
  --brand-2: #6a50ce;
  --accent: #9b84ee;
  --accent-2: #6a50ce;
  --accent-weak: rgba(155, 132, 238, 0.15);
  --accent-line: rgba(155, 132, 238, 0.38);
  --brand-grad: linear-gradient(135deg, var(--brand-1), var(--brand-2));

  /* 语义色 */
  --danger: #ff6b6b;
  --danger-weak: rgba(255, 107, 107, 0.14);
  --danger-line: rgba(255, 107, 107, 0.35);
  --green: #34c77b;
  --green-weak: rgba(52, 199, 123, 0.14);
  --amber: #f5a623;
  --amber-weak: rgba(245, 166, 35, 0.14);
  --blue: #5a9cf8;
  --blue-weak: rgba(90, 156, 248, 0.14);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.5);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #45484f; background-clip: padding-box; border: 3px solid transparent; }

/* ---------- 品牌 logo ---------- */

.brand-mark { display: inline-flex; }
.brand-mark .mark { display: block; width: 100%; height: 100%; }

/* ---------- 登录 ---------- */

.login {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(680px 360px at 50% -8%, rgba(155, 132, 238, 0.16), transparent 70%),
    var(--bg);
}

.login-card {
  width: 344px;
  padding: 38px 32px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 2px;
  border-radius: 15px;
  box-shadow: 0 8px 22px rgba(106, 80, 206, 0.4);
}

.login-card h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }

.login-hint { color: var(--text-2); font-size: 12.5px; }

.login-card input {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.login-card input:focus { border-color: var(--accent); }

.login-error { color: var(--danger); font-size: 12.5px; }

.clerk-sign-in { width: 100%; text-align: left; }

/* ---------- 布局 ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 18px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand span em { color: var(--text-2); font-style: normal; font-weight: 500; }

.brand-logo { width: 30px; height: 30px; border-radius: 8px; flex: none; box-shadow: 0 3px 10px rgba(106, 80, 206, 0.35); }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav a:hover { background: var(--surface-2); color: var(--text); }

.nav a.active {
  background: var(--accent-weak);
  border-color: var(--accent-line);
  color: #c9b8ff;
  font-weight: 500;
}

.nav-icon { width: 17px; height: 17px; flex: none; }

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }

/* 账户卡 */
.account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 8px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.account:hover { background: var(--surface-2); }
.account-info { min-width: 0; flex: 1; }
.account-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-email { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* 头像 */
.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  object-fit: cover;
  overflow: hidden;
  user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.avatar-sm { width: 28px; height: 28px; font-size: 11.5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10, 11, 14, 0.82);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.topbar h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }

.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- 通用组件 ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13.5px;
}

.panel-body { padding: 18px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, transform 0.05s ease;
}

.btn:hover { border-color: var(--border-strong); background: var(--surface-3); }
.btn:active { transform: translateY(0.5px); }

.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary {
  background: var(--brand-grad);
  border-color: transparent;
  color: #fff;
  font-weight: 500;
}

.btn-primary:hover { filter: brightness(1.08); border-color: transparent; }

.btn-danger { color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-weak); border-color: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }

.btn-block { width: 100%; }

.user-actions { display: flex; gap: 6px; justify-content: flex-end; }

.input, select.input {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input:focus { border-color: var(--accent); }

textarea.input { height: auto; padding: 8px 10px; resize: vertical; font-family: inherit; }

/* ---------- 统计卡片 ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }

.stat-label {
  color: var(--text-2);
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-ic {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-weak);
  color: var(--accent);
}
.stat-ic svg { width: 16px; height: 16px; }
.stat-ic.g { background: var(--green-weak); color: var(--green); }
.stat-ic.a { background: var(--amber-weak); color: var(--amber); }
.stat-ic.b { background: var(--blue-weak); color: var(--blue); }

.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.stat-sub { color: var(--text-3); font-size: 12px; }

.stat-sub b { color: var(--green); font-weight: 600; }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td { text-align: left; padding: 11px 18px; white-space: nowrap; }

th {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

td { border-bottom: 1px solid var(--border); color: var(--text); }

tr:last-child td { border-bottom: none; }

tbody tr { transition: background 0.12s ease; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }

.cell-sub { color: var(--text-3); font-size: 12px; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .avatar { width: 32px; height: 32px; font-size: 12.5px; }

.mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); }

/* ---------- 徽标 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-accent { background: var(--accent-weak); color: #c1adff; border-color: var(--accent-line); }
.badge-green { background: var(--green-weak); color: var(--green); border-color: rgba(52, 199, 123, 0.3); }
.badge-amber { background: var(--amber-weak); color: var(--amber); border-color: rgba(245, 166, 35, 0.3); }
.badge-blue { background: var(--blue-weak); color: var(--blue); border-color: rgba(90, 156, 248, 0.3); }
.badge-gray { background: rgba(255, 255, 255, 0.06); color: var(--text-2); border-color: var(--border-strong); }

/* ---------- 工具条 / 分页 ---------- */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.toolbar .spacer { flex: 1; }

.chip {
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chip:hover { color: var(--text); border-color: var(--border-strong); }

.chip.active { background: var(--accent-weak); border-color: var(--accent-line); color: #c1adff; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 12px 18px; color: var(--text-3); font-size: 12.5px; }

/* ---------- 反馈卡片 ---------- */

.feedback-list { display: flex; flex-direction: column; gap: 12px; }

.feedback-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease;
}
.feedback-card:hover { border-color: var(--border-strong); }

.feedback-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.feedback-time { margin-left: auto; color: var(--text-3); font-size: 12px; }

.feedback-message { white-space: pre-wrap; word-break: break-word; color: var(--text); font-size: 13.5px; }

.feedback-meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; color: var(--text-3); font-size: 12px; }

.feedback-meta span b { color: var(--text-2); font-weight: 500; }

.feedback-author { display: flex; align-items: center; gap: 8px; }

.feedback-resources { display: flex; gap: 8px; flex-wrap: wrap; }

.feedback-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.feedback-note {
  color: var(--amber);
  font-size: 12.5px;
  background: var(--amber-weak);
  border: 1px solid rgba(245, 166, 35, 0.24);
  padding: 8px 12px;
  border-radius: 8px;
}

/* ---------- 空状态 ---------- */

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  opacity: 0.9;
}

/* ---------- 骨架屏 ---------- */

.skeleton { display: flex; flex-direction: column; gap: 14px; }
.skel {
  height: 76px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 200% 100%;
  animation: skel 1.2s ease-in-out infinite;
  border: 1px solid var(--border);
}
.skel-row { height: 44px; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ---------- 弹窗 ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 400px;
  max-width: calc(100vw - 40px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-pop);
  animation: pop 0.16s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

.modal h2 { font-size: 15px; font-weight: 600; }

.modal-wide { width: 680px; }

.diagnostics-text {
  max-height: min(60vh, 520px);
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text-2);
  font: 11.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.modal .field { display: flex; flex-direction: column; gap: 6px; }

.modal .field label { color: var(--text-2); font-size: 12.5px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 100;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.toast.error { border-color: var(--danger-line); color: var(--danger); }

@media (max-width: 760px) {
  .sidebar { width: 64px; }
  .brand span, .nav a { font-size: 0; }
  .brand { justify-content: center; padding: 20px 0 18px; }
  .nav a { justify-content: center; }
  .nav-badge { display: none; }
  .account-info { display: none; }
  .account { justify-content: center; }
  .content { padding: 16px; }
}
