/* ==========================================================================
   QuizLive style.css —— 答题端 / 管理后台 / 数据大屏 统一样式
   无任何外部字体或图片依赖：图标均为内联资源，离线环境也能正常显示。
   ========================================================================== */

:root {
  --ql-primary: #2563eb;
  --ql-primary-dark: #1d4ed8;
  --ql-ink: #1f2937;
  --ql-muted: #6b7280;
  --ql-line: #e5e7eb;
  --ql-bg: #f5f7fb;
  --ql-radius: 14px;
  --screen-bg: #070d1c;
  --screen-panel: #0f172b;
  --screen-line: rgba(148, 163, 184, 0.18);
  --screen-ink: #e8eefc;
  --screen-muted: #93a3c1;
  --screen-accent: #38bdf8;
  --screen-green: #34d399;
  --screen-amber: #fbbf24;
  --screen-red: #f87171;
}

* { -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ql-ink);
}

/* ==========================================================================
   1. 答题端
   ========================================================================== */

.quiz-body {
  background: linear-gradient(180deg, #eef2ff 0%, var(--ql-bg) 240px, var(--ql-bg) 100%);
  min-height: 100vh;
  padding-bottom: 32px;
}

.quiz-header {
  background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #3b82f6);
  color: #fff;
  padding: 18px 16px 22px;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.18);
}

.quiz-title {
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 10px;
  word-break: break-word;
}

.quiz-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.quiz-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #a7f3d0;
}

.quiz-status.status-ongoing .dot { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.35); animation: pulse 1.8s infinite; }
.quiz-status.status-not_started .dot { background: #fcd34d; }
.quiz-status.status-ended .dot { background: #cbd5e1; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.quiz-main {
  max-width: 640px;
  margin: -12px auto 0;
  padding: 0 14px;
}

.quiz-card {
  border: none;
  border-radius: var(--ql-radius);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.07);
  margin-top: 14px;
}

.quiz-card .card-body { padding: 20px 18px; }

.center-card { text-align: center; padding: 12px 4px; }

.state-emoji { font-size: 2.4rem; margin-bottom: 8px; }
.state-title { font-size: 1.12rem; font-weight: 700; margin-bottom: 8px; }

.step-badge {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--ql-primary);
  background: #e8efff;
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 10px;
}

/* --- 选项胶囊（层级 / 职责） --- */
.option-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip { margin: 0; cursor: pointer; }

.chip input {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}

.chip span {
  display: inline-block;
  padding: 10px 18px;
  border: 1.5px solid var(--ql-line);
  border-radius: 999px;
  background: #fff;
  font-size: 1rem;
  transition: all 0.15s ease;
  min-width: 64px;
  text-align: center;
}

.chip input:checked + span {
  border-color: var(--ql-primary);
  background: var(--ql-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.chip input:focus-visible + span { outline: 2px solid var(--ql-primary); outline-offset: 2px; }

/* --- 题目块 --- */
.question-block {
  background: #fff;
  border-radius: var(--ql-radius);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.07);
  padding: 18px 16px;
  margin-bottom: 14px;
}

.question-index {
  font-size: 0.76rem;
  color: #fff;
  background: var(--ql-primary);
  border-radius: 6px;
  padding: 2px 8px;
  margin-right: 8px;
  vertical-align: 2px;
}

.question-content {
  font-size: 1.06rem;
  font-weight: 600;
  line-height: 1.55;
  margin-bottom: 14px;
  word-break: break-word;
}

.question-tags { margin-bottom: 10px; }

.question-options { display: flex; flex-direction: column; gap: 10px; }

.option-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1.5px solid var(--ql-line);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
}

.option-row:hover { border-color: #bfdbfe; background: #f8fbff; }

.option-row input { display: none; }

.option-key {
  flex: 0 0 26px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #eef2f7;
  color: var(--ql-muted);
  font-weight: 700;
  font-size: 0.86rem;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}

.option-text { flex: 1; font-size: 1rem; line-height: 1.5; word-break: break-word; }

.option-row.selected {
  border-color: var(--ql-primary);
  background: #eef4ff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

.option-row.selected .option-key { background: var(--ql-primary); color: #fff; }

/* --- 结果区 --- */
.result-detail { margin-top: 14px; text-align: left; }

.result-item {
  border-left: 4px solid var(--ql-line);
  background: #fafbfe;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.result-item.ok { border-left-color: #10b981; }
.result-item.bad { border-left-color: #ef4444; }

.result-question { font-weight: 600; line-height: 1.5; }
.result-answers { margin-top: 6px; font-size: 0.92rem; color: var(--ql-muted); }

.result-actions { text-align: center; margin-top: 8px; }

.quiz-alert {
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.quiz-alert.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.quiz-alert.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.quiz-alert.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }

.quiz-footer {
  text-align: center;
  color: #9aa4b2;
  font-size: 0.78rem;
  margin-top: 22px;
}

/* ==========================================================================
   2. 登录页 / 错误页
   ========================================================================== */

.login-body, .error-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a, #1e3a8a 60%, #2563eb);
  padding: 20px;
}

.login-card, .error-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  padding: 26px 24px;
  box-shadow: 0 20px 50px rgba(2, 6, 23, 0.35);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

.login-logo {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  color: #fff;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

.login-title { font-weight: 700; font-size: 1.06rem; }
.login-sub { color: var(--ql-muted); font-size: 0.82rem; }

.login-hint {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--ql-muted);
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.6;
}

.login-links { margin-top: 14px; text-align: center; font-size: 0.85rem; color: var(--ql-muted); }

.error-card { text-align: center; }
.error-emoji { font-size: 2.6rem; }
.error-title { font-size: 1.2rem; font-weight: 700; margin: 6px 0 8px; }
.error-message { color: var(--ql-muted); }
.error-actions { margin-top: 18px; display: flex; gap: 10px; justify-content: center; }

/* ==========================================================================
   3. 管理后台
   ========================================================================== */

.admin-body { background: var(--ql-bg); min-height: 100vh; display: flex; flex-direction: column; }

.admin-navbar { background: #111c33; }
.admin-navbar .nav-link { color: rgba(255, 255, 255, 0.72); }
.admin-navbar .nav-link:hover { color: #fff; }
.admin-navbar .nav-link.active { color: #fff; font-weight: 600; box-shadow: inset 0 -2px 0 var(--screen-accent); }

.admin-main { flex: 1; padding: 18px 18px 4px; }

.admin-footer { border-top: 1px solid var(--ql-line); background: #fff; margin-top: 18px; }

.status-badge { font-weight: 600; }
.status-badge.status-not_started { background: #fef3c7; color: #92400e; }
.status-badge.status-ongoing { background: #dcfce7; color: #166534; }
.status-badge.status-ended { background: #e2e8f0; color: #334155; }

.stat-card { border: none; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06); padding: 16px; height: 100%; }
.stat-label { color: var(--ql-muted); font-size: 0.82rem; }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1.25; color: var(--ql-ink); }
.stat-unit { font-size: 1rem; font-weight: 600; margin-left: 2px; }
.stat-foot { color: #94a3b8; font-size: 0.76rem; }

.q-content { font-weight: 600; line-height: 1.5; }

.q-options {
  margin-top: 4px;
  max-height: 22px;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.js-q-summary.expanded .q-options { max-height: 400px; }

.q-opt {
  display: block;
  font-size: 0.84rem;
  color: var(--ql-muted);
  line-height: 1.6;
  word-break: break-word;
}

.q-opt-correct { color: #15803d; font-weight: 600; }

.import-metric { font-size: 1.7rem; font-weight: 800; line-height: 1.2; }

.csv-head {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

.settings-qrcode {
  width: 150px; height: 150px;
  border: 1px solid var(--ql-line);
  border-radius: 10px;
  background: #fff;
  padding: 4px;
}

/* ==========================================================================
   4. 数据大屏
   ========================================================================== */

.screen-body {
  background: radial-gradient(1200px 600px at 15% -10%, #142246 0%, var(--screen-bg) 55%);
  color: var(--screen-ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 8px;
}

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 1px solid var(--screen-line);
  padding-bottom: 12px;
}

.screen-title {
  font-size: clamp(1.4rem, 2.4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0;
  background: linear-gradient(90deg, #ffffff, #7dd3fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.screen-sub {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: clamp(0.8rem, 1vw, 1rem);
  color: var(--screen-muted);
}

.screen-updated b { color: var(--screen-ink); }

.screen-header-right { display: flex; align-items: center; gap: 14px; }

.qr-box {
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.22);
}

.qr-box img { width: clamp(84px, 7vw, 124px); height: clamp(84px, 7vw, 124px); display: block; }
.qr-caption { color: #0f172a; font-size: 0.72rem; font-weight: 700; margin-top: 2px; }

.screen-main { flex: 1; margin-top: 14px; }

.screen-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.kpi-card {
  background: linear-gradient(160deg, rgba(56, 189, 248, 0.16), rgba(15, 23, 43, 0.9));
  border: 1px solid var(--screen-line);
  border-radius: 16px;
  padding: 14px 18px;
}

.kpi-label { color: var(--screen-muted); font-size: clamp(0.8rem, 1vw, 1.05rem); }
.kpi-value { font-size: clamp(1.9rem, 3.4vw, 3.4rem); font-weight: 800; line-height: 1.1; color: #fff; }
.kpi-unit { font-size: clamp(0.9rem, 1.4vw, 1.4rem); margin-left: 4px; color: var(--screen-accent); }
.kpi-foot { color: var(--screen-muted); font-size: clamp(0.72rem, 0.9vw, 0.9rem); }

.screen-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.42fr);
  gap: 14px;
  align-items: start;
}

.screen-col-left { display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: var(--screen-panel);
  border: 1px solid var(--screen-line);
  border-radius: 16px;
  padding: 12px 14px;
}

.panel-title {
  font-size: clamp(0.9rem, 1.1vw, 1.15rem);
  font-weight: 700;
  color: #cfe3ff;
  margin-bottom: 10px;
}

.panel-note { font-size: 0.74rem; color: var(--screen-muted); font-weight: 400; }

.chart-wrap { position: relative; height: clamp(150px, 17vh, 230px); }
.chart-wrap-tall { height: clamp(170px, 20vh, 260px); }

/* --- 逐题分析 --- */
.question-stats { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; }

.qs-item {
  border: 1px solid var(--screen-line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(15, 23, 43, 0.6);
}

.qs-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.qs-content { font-size: clamp(0.84rem, 1vw, 1rem); font-weight: 600; color: #e2ecff; line-height: 1.45; }
.qs-meta { color: var(--screen-muted); font-size: 0.76rem; white-space: nowrap; }
.qs-rate { font-size: clamp(1rem, 1.3vw, 1.35rem); font-weight: 800; }
.qs-rate.good { color: var(--screen-green); }
.qs-rate.mid { color: var(--screen-amber); }
.qs-rate.bad { color: var(--screen-red); }

.qs-bars { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }

.qs-bar-row { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; }

.qs-key {
  flex: 0 0 20px;
  text-align: center;
  font-weight: 700;
  color: var(--screen-muted);
}

.qs-bar {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.qs-bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 0.4s ease;
}

.qs-bar-row.correct .qs-bar > i { background: linear-gradient(90deg, #34d399, #10b981); }
.qs-bar-row.correct .qs-key { color: var(--screen-green); }

.qs-bar-text { flex: 0 0 auto; color: var(--screen-muted); min-width: 96px; text-align: right; }

/* --- 最新提交 --- */
.recent-list { display: flex; flex-direction: column; gap: 8px; max-height: 74vh; overflow-y: auto; }

.recent-item {
  border: 1px solid var(--screen-line);
  border-left: 4px solid var(--screen-muted);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(15, 23, 43, 0.62);
  animation: slide-in 0.35s ease;
}

.recent-item.ok { border-left-color: var(--screen-green); }
.recent-item.bad { border-left-color: var(--screen-red); }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.recent-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.recent-name { font-weight: 700; font-size: clamp(0.86rem, 1vw, 1.05rem); }
.recent-time { color: var(--screen-muted); font-size: 0.74rem; }
.recent-meta { color: var(--screen-muted); font-size: 0.76rem; margin-top: 2px; }
.recent-q { color: #cbd9f2; font-size: 0.78rem; margin-top: 4px; line-height: 1.45; }

.empty-hint { color: var(--screen-muted); text-align: center; padding: 22px 0; font-size: 0.9rem; }

.screen-footer {
  display: flex;
  gap: 18px;
  justify-content: flex-end;
  color: var(--screen-muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--screen-line);
  margin-top: 12px;
  padding-top: 8px;
}

.conn-ok { color: var(--screen-green); }
.conn-bad { color: var(--screen-red); }

/* 大屏深色滚动条 */
.question-stats::-webkit-scrollbar, .recent-list::-webkit-scrollbar { width: 6px; }
.question-stats::-webkit-scrollbar-thumb, .recent-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 3px;
}

/* ==========================================================================
   5. 响应式
   ========================================================================== */

@media (max-width: 992px) {
  .screen-grid { grid-template-columns: 1fr; }
  .recent-list { max-height: 40vh; }
  .question-stats { max-height: none; }
}

@media (max-width: 576px) {
  .screen-body { padding: 10px 10px 6px; }
  .screen-kpis { grid-template-columns: 1fr; gap: 10px; }
  .screen-header { flex-direction: column; }
  .screen-header-right { width: 100%; justify-content: space-between; }
  .kpi-value { font-size: 1.9rem; }
  .admin-main { padding: 14px 12px 4px; }
}
