/* StudyOnTV QMS - light theme */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-weak: #eef0fe;
  --danger: #dc2626;
  --danger-weak: #fee2e2;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; }
code { background: var(--accent-weak); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
a { color: var(--accent); }

/* ---------- 登录 ---------- */
.login-view {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef0fe 0%, #f5f6f8 60%);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, 0.10);
  padding: 36px 40px; width: 340px; text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { font-size: 18px; margin: 10px 0 4px; }
.login-card form { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
#login-password {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
#login-password:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* ---------- 顶栏 ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 26px; }
.brand-title { font-weight: 600; font-size: 16px; }
.brand-sub { font-size: 11px; }

/* ---------- 布局 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- 题库条 ---------- */
.bank-bar { padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.bank-select-wrap { display: flex; align-items: center; gap: 8px; }
#bank-select { min-width: 180px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 14px; }
.bank-actions { display: flex; gap: 8px; }
.import-url-box {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
  font-size: 12px; max-width: 100%;
}
.import-url-box code {
  max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block;
}

/* ---------- 工具条 ---------- */
.toolbar { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type="search"] { flex: 1 1 180px; min-width: 150px; }
.toolbar-right { display: flex; gap: 8px; margin-left: auto; }

input, select, textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: var(--font); background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
textarea { resize: vertical; width: 100%; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--accent-weak); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-weak); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--accent-weak); }
.btn.tiny { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 批量条 ---------- */
.bulk-bar {
  padding: 8px 16px; border-radius: var(--radius); font-size: 13px;
  background: var(--accent-weak); border: 1px solid var(--accent);
  display: flex; align-items: center; gap: 12px;
}

/* ---------- 表格 ---------- */
.table-card { overflow: hidden; }
.q-table { width: 100%; border-collapse: collapse; }
.q-table th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 500;
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: #fafbfc;
}
.q-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.q-table tbody tr:hover { background: #fafbff; }
.q-table tbody tr:last-child td { border-bottom: none; }
.q-stem { max-width: 460px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-all; }
.col-check { width: 36px; }
.col-type { width: 64px; }
.col-meta { width: 72px; }
.col-diff { width: 92px; }
.col-actions { width: 120px; white-space: nowrap; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: var(--accent-weak); color: var(--accent); white-space: nowrap;
}
.badge.gray { background: #f1f2f4; color: var(--muted); }
.stars { color: #f59e0b; letter-spacing: 1px; font-size: 12px; }
.row-actions { display: flex; gap: 6px; }

.empty { text-align: center; padding: 48px 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 12px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-card {
  background: var(--surface); border-radius: 14px; width: 480px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}
.modal-lg { width: 680px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16px; margin: 0; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 20px; border-top: 1px solid var(--border);
}
.modal-foot > div { display: flex; gap: 8px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-3 input[type="number"] { width: 100%; }

/* ---------- AI 出题 ---------- */
.gen-actions { display: flex; align-items: center; gap: 12px; }
.gen-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.gen-item {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: #fafbfc;
}
.gen-item input[type="checkbox"] { width: 16px; height: 16px; margin-top: 3px; accent-color: var(--accent); cursor: pointer; }
.gen-item-main { flex: 1; min-width: 0; }
.gen-item-q { word-break: break-all; }
.gen-item-meta { display: flex; gap: 8px; margin-top: 4px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.gen-item-ans { margin-top: 4px; font-size: 12px; color: var(--muted); word-break: break-all; }
.gen-item.invalid { opacity: 0.6; border-color: var(--danger); }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select { width: 100%; }
#e-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.option-row { display: flex; align-items: center; gap: 8px; }
.option-row .opt-key { font-weight: 600; color: var(--accent); width: 18px; }
.option-row input[type="text"] { flex: 1; }
.option-row input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.radio-row { display: flex; gap: 18px; }
.radio { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.extra-fields summary { font-size: 13px; color: var(--muted); cursor: pointer; margin-bottom: 10px; }
#e-preview-box {
  border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px;
  background: #fafbfc; min-height: 44px;
}
.preview-label { font-size: 12px; display: block; margin-bottom: 6px; }
#import-text { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
#import-file { margin-bottom: 10px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 99; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); max-width: 80vw;
}
.toast.ok { background: var(--ok); }
.toast.fail { background: var(--danger); }

.footer { text-align: center; padding: 10px 0 24px; font-size: 12px; }

@media (max-width: 720px) {
  .import-url-box { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .col-meta, .col-diff { display: none; }
}
