/* ============================================================
   乐浔AI助教 · 设计系统（学员端深色 / 管理端浅色共用）
   ============================================================ */

:root {
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --bg: #070b14;
  --bg-soft: #0a1120;
  --panel: #101a2d;
  --panel-2: #16223a;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9eefb;
  --text-2: #c3cce4;
  --muted: #8794b2;
  --brand: #6d5efc;
  --brand-2: #22d3ee;
  --brand-soft: rgba(109, 94, 252, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 3px rgba(109, 94, 252, 0.35);

  /* 主题化表面色（管理端浅色主题会覆盖） */
  --surface-1: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-3: rgba(255, 255, 255, 0.1);
  --hover: rgba(255, 255, 255, 0.06);
  --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  --modal-bg: #101a2d;
  --toast-bg: rgba(20, 28, 46, 0.96);
  --row-line: rgba(255, 255, 255, 0.05);
  --switch-off: rgba(255, 255, 255, 0.14);
  --table-head-bg: rgba(10, 16, 30, 0.9);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }

::selection { background: rgba(109, 94, 252, 0.4); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(140, 155, 190, 0.28); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(140, 155, 190, 0.5); background-clip: content-box; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(0.995); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary {
  background: linear-gradient(135deg, #7c5cff 0%, #5b7cfa 48%, #22d3ee 100%);
  color: #fff;
  box-shadow: 0 8px 22px rgba(97, 90, 250, 0.32);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 28px rgba(97, 90, 250, 0.45); filter: brightness(1.05); }

.btn-soft {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
.btn-soft:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); }

.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--hover); }

.btn-danger { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.3); color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.2); }

.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 14.5px; border-radius: 13px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: all 0.18s ease;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.field .hint { font-size: 12px; color: var(--muted); }

.input, .textarea, .select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-1);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.textarea { height: auto; min-height: 88px; padding: 11px 13px; resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: rgba(135, 148, 178, 0.7); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: rgba(109, 94, 252, 0.7);
  box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.18);
  background: var(--surface-2);
}
.input:disabled, .textarea:disabled { opacity: 0.55; cursor: not-allowed; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238794b2' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}
.select option { background: var(--modal-bg); color: var(--text); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px;
  border-radius: 7px;
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.tag-brand { background: rgba(109, 94, 252, 0.16); color: #b9b0ff; }
.tag-ok { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; }
.tag-warn { background: rgba(251, 191, 36, 0.14); color: #fcd34d; }
.tag-err { background: rgba(248, 113, 113, 0.14); color: #fca5a5; }
.tag-muted { background: rgba(255, 255, 255, 0.05); color: var(--muted); }

.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 56px 24px; text-align: center; color: var(--muted);
}
.empty .empty-icon {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  margin-bottom: 2px;
}
.empty strong { color: var(--text-2); font-size: 14.5px; }

.skel {
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.09) 37%, rgba(255, 255, 255, 0.05) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }

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

.toast-wrap {
  position: fixed; left: 50%; bottom: 108px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 9999; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  max-width: min(92vw, 460px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--toast-bg);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  animation: pop-in 0.22s ease;
  backdrop-filter: blur(12px);
}
.toast.ok { border-color: rgba(52, 211, 153, 0.4); }
.toast.err { border-color: rgba(248, 113, 113, 0.45); }
.toast .toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-2); flex: none; }
.toast.ok .toast-dot { background: var(--ok); }
.toast.err .toast-dot { background: var(--err); }

/* -------------------------------- Modal -------------------------------- */

.modal-wrap {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(4, 8, 16, 0.66);
  backdrop-filter: blur(6px);
  animation: fade-in 0.2s ease;
}
.modal {
  width: min(560px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  background: var(--modal-bg);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: pop-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.modal.wide { width: min(820px, 100%); }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 22px 0;
}
.modal-head h3 { font-size: 16.5px; font-weight: 700; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.modal-body { padding: 18px 22px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 0 22px 20px;
}

/* -------------------------------- Table -------------------------------- */

.table-wrap { overflow: auto; border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  padding: 10px 12px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--table-head-bg);
}
.table td { padding: 12px; border-bottom: 1px solid var(--row-line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--hover); }

.switch {
  position: relative; width: 40px; height: 23px; border-radius: 99px;
  background: var(--switch-off); border: none; cursor: pointer;
  transition: background 0.2s ease; flex: none;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px; border-radius: 50%; background: #fff;
  transition: transform 0.2s cubic-bezier(0.3, 0.9, 0.4, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.switch.on { background: linear-gradient(135deg, #7c5cff, #22d3ee); }
.switch.on::after { transform: translateX(17px); }
.switch:focus-visible { outline: none; box-shadow: var(--ring); }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
