/* AI 评估师 —— 全局样式（Material 风格） */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --accent: #8b5cf6;
  --bg: #f4f5fb;
  --surface: #ffffff;
  --text: #1f2330;
  --muted: #6b7280;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(30, 41, 59, 0.08);
  --shadow-lg: 0 12px 32px rgba(30, 41, 59, 0.14);
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- 顶栏 ---------- */
.topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(30, 41, 59, 0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
}

/* ---------- 通用卡片 ---------- */
.card {
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.page-main { max-width: 960px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- 首页 Hero ---------- */
.hero {
  border-radius: 24px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%);
  color: #fff;
  padding: 56px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.hero h1 { font-size: 2.2rem; font-weight: 800; margin-bottom: 12px; }
.hero p { opacity: 0.92; font-size: 1.05rem; margin-bottom: 28px; }
.hero .btn { border-radius: 999px; padding: 10px 28px; font-weight: 600; }
.hero .btn-light { color: var(--primary-dark); }
.hero .btn-outline-light:hover { background: rgba(255,255,255,.15); }

.step-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  height: 100%;
}
.step-no {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}

/* ---------- 按钮 ---------- */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: 0;
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, var(--primary-dark), #7c3aed);
  border: 0;
}
.btn { border-radius: 10px; }

/* ---------- 芯片 ---------- */
.chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #eef0ff;
  color: var(--primary);
}
.chip-outline { background: transparent; border: 1px solid #d9dcf5; color: var(--muted); }

/* ---------- 题库选择卡片 ---------- */
.bank-card {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  height: 100%;
}
.bank-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.bank-card h5 { font-weight: 700; }

.draw-config-card {
  max-width: 720px;
  margin: 14px auto 4px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid #e2e6f7;
  background: linear-gradient(180deg, #ffffff, #f9faff);
  box-shadow: 0 8px 24px rgba(30, 41, 59, 0.08);
}

.draw-config-title {
  font-weight: 700;
  color: #334155;
  margin-bottom: 10px;
}

.draw-config-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.draw-stepper-btn {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  border: 1px solid #d2d9f3;
  background: #fff;
  color: #374151;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s ease;
}

.draw-stepper-btn:hover {
  border-color: #b6c2eb;
  background: #f4f7ff;
}

.draw-stepper-btn:active {
  transform: translateY(1px);
}

.draw-count-input {
  width: 110px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid #cfd8f3;
  background: #fff;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1f2937;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.draw-count-input:focus {
  border-color: #7c88f7;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.13);
}

.draw-count-input::-webkit-outer-spin-button,
.draw-count-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.draw-count-input[type="number"] {
  -moz-appearance: textfield;
}

.draw-config-hint {
  margin-top: 10px;
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
}

.draw-config-hint.ready {
  color: #0f766e;
  font-weight: 600;
}

.draw-confirm-pulse {
  animation: drawConfirmPulse 0.55s ease;
}

@keyframes drawConfirmPulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.28); }
  100% { box-shadow: 0 0 0 14px rgba(79, 70, 229, 0); }
}

.bank-card-pending {
  opacity: 0.82;
}

.bank-card .start-exam-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.bank-card .draw-preview {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #64748b;
}

/* ---------- 答题页 ---------- */
.stepper { display: flex; gap: 8px; justify-content: center; margin: 6px 0 22px; }
.step-dot {
  width: 34px; height: 34px; border-radius: 50%;
  background: #e5e7f3; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
}
.step-dot.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.35); }
.step-dot.done { background: #dcd6fe; color: var(--primary-dark); }

.exam-card { padding: 32px; }
.question-text { font-size: 1.45rem; font-weight: 700; line-height: 1.5; margin: 12px 0 26px; }

.record-zone { text-align: center; padding: 12px 0 4px; }
.mic-btn {
  width: 84px; height: 84px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.4);
  transition: transform 0.15s ease;
}
.mic-btn:hover { transform: scale(1.05); }
.mic-btn.recording { background: linear-gradient(135deg, #ef4444, #f97316); animation: pulse 1.5s infinite; }
.mic-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  70% { box-shadow: 0 0 0 22px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.mic-icon { width: 34px; height: 34px; }
.record-status { margin-top: 14px; color: var(--muted); font-size: 0.95rem; }
.record-timer { font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 700; margin-top: 6px; }

.level-track {
  max-width: 320px; height: 8px; border-radius: 999px;
  background: #eceef7; margin: 14px auto 0; overflow: hidden;
}
.level-bar {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.08s linear;
}

audio.preview { width: 100%; max-width: 420px; margin: 0 auto; display: block; }

.transcript-label { font-weight: 700; margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
.transcript-box {
  background: #f7f8fd;
  border: 1px solid #e6e8f5;
  border-radius: 12px;
  padding: 14px 16px;
  min-height: 64px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.objective-options {
  border: 1px solid #e6e8f5;
  background: #f8f9ff;
  border-radius: 12px;
  padding: 12px 14px;
}

.objective-option-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
}

.objective-option-item:hover {
  background: #eef1ff;
}

.objective-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #cfd8f3;
  padding: 10px 12px;
  outline: none;
}

.objective-input:focus {
  border-color: #7c88f7;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.13);
}

/* ---------- 加载遮罩 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(20, 22, 34, 0.55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- 自定义确认弹窗 ---------- */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(16,18,30,0.5); display:flex; align-items:center; justify-content:center;
}
.confirm-card {
  background: #fff; border-radius: 12px; padding: 18px 20px; width: 520px; max-width: 92vw; box-shadow: var(--shadow-lg);
}
.confirm-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 8px; }
.confirm-message { color: var(--muted); margin-bottom: 10px; }
.confirm-list { background:#f8fafc; border:1px solid #eef2ff; padding:10px; border-radius:8px; max-height:160px; overflow:auto; color:#334155; }
.confirm-list .item { padding:6px 8px; border-radius:6px; background:#fff; margin-bottom:6px; border:1px solid #eef2ff; display:inline-block; margin-right:6px; }
.overlay-card {
  background: #fff; border-radius: var(--radius);
  padding: 34px 46px; text-align: center;
  box-shadow: var(--shadow-lg);
}
.spinner-ring {
  width: 46px; height: 46px; margin: 0 auto 16px;
  border: 4px solid #e6e8f5; border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.app-toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #23263a; color: #fff;
  padding: 12px 22px; border-radius: 12px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
  z-index: 1000; max-width: 86vw; text-align: center;
}
.app-toast.show { opacity: 1; }
.app-toast.error { background: #b91c1c; }

/* ---------- 报告页 ---------- */
.ring-wrap { position: relative; width: 190px; height: 190px; margin: 0 auto; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { stroke: #e9eaf5; }
.ring-fg {
  stroke: url(#scoreGradient);
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-score { font-size: 2.6rem; font-weight: 800; line-height: 1; color: var(--primary-dark); }
.ring-full { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

.score-item-card { padding: 22px 24px; }
.score-badge {
  font-weight: 800; font-size: 1.05rem;
  padding: 6px 14px; border-radius: 999px;
  background: #eef0ff; color: var(--primary-dark);
}
.score-bar { height: 8px; border-radius: 999px; background: #eceef7; overflow: hidden; }
.score-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 1s ease;
}
.reason-text { line-height: 1.8; margin-top: 10px; }
.detail-block { margin-top: 12px; }
.detail-block summary { cursor: pointer; color: var(--primary); font-weight: 600; }

/* ---------- 管理页 ---------- */
.list-group-item.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent;
}
.table > :not(caption) > * > * { padding: 0.8rem 0.9rem; }
.q-text-cell { max-width: 380px; }
.q-text-cell .clamp {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.chip-light {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.paper-item {
  border: 1px solid #e6e8f5;
  background: #fafbff;
  border-radius: 12px;
  padding: 12px;
}

/* 表格与列表项：默认不换行并用省略号截断，避免列被强行撑高 */
.table td:not(.q-text-cell), .table th:not(.q-text-cell) {
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* 允许第一列稍宽一些（例如标题列） */
.table td:first-child:not(.q-text-cell), .table th:first-child:not(.q-text-cell) {
  max-width: 320px;
}

/* 首页、试卷卡片：标题截断以保持行高一致 */
.paper-item .fw-bold {
  display: block;
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.paper-item .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.auth-body {
  min-height: 100vh;
  background: radial-gradient(circle at 16% 20%, #dbeafe 0%, #eef2ff 35%, #f8fafc 100%);
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 28px 24px;
}

.auth-brand {
  justify-content: center;
  margin-bottom: 10px;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
}

@media (max-width: 576px) {
  .hero { padding: 40px 22px; }
  .hero h1 { font-size: 1.7rem; }
  .exam-card { padding: 22px 18px; }
  .question-text { font-size: 1.2rem; }
  .draw-config-card { padding: 14px 12px; }
  .draw-count-input { width: 88px; }
}

/* 小屏幕允许表格内容换行以防溢出 */
@media (max-width: 768px) {
  .table td:not(.q-text-cell), .table th:not(.q-text-cell) {
    white-space: normal;
    max-width: none;
  }
  .paper-item .fw-bold { max-width: 100%; white-space: normal; }
}

/* 题型说明面板样式 */
.qtype-help {
  border: 1px solid rgba(0,0,0,0.06);
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
}
.qtype-help .bg-light {
  background: #f8f9fa;
}

/* ---------- 后台增强布局 ---------- */
body.admin-page {
  background:
    radial-gradient(1200px 480px at -10% -10%, rgba(79, 70, 229, 0.12), rgba(79, 70, 229, 0) 55%),
    radial-gradient(800px 360px at 110% -20%, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0) 55%),
    var(--bg);
}

body.admin-page .topbar-inner {
  max-width: 1320px;
}

body.admin-page .page-main {
  max-width: 1320px;
  padding-top: 20px;
}

.admin-section-card {
  border: 1px solid rgba(79, 70, 229, 0.08);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.stat-card {
  border-radius: 12px;
  border: 1px solid #e6e8f5;
  background: linear-gradient(180deg, #ffffff, #f7f8ff);
  padding: 10px 12px;
  min-height: 82px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chart-box {
  border: 1px solid #e6e8f5;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #fbfbff);
}

.chart-canvas-wrap {
  position: relative;
  height: 260px;
}

.chart-canvas-wrap > canvas {
  width: 100% !important;
  height: 100% !important;
}

.bank-list-panel #bank-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border: 0;
  background: transparent;
}

.bank-list-panel #bank-menu .list-group-item {
  border: 1px solid #e6e8f5;
  border-radius: 10px;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.bank-list-tools {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.pagination-wrap {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pagination-wrap .btn {
  min-width: 34px;
}

.paper-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table.table-sm > :not(caption) > * > * {
  padding: 0.56rem 0.55rem;
}

.record-status-badge {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 3px 9px;
  display: inline-block;
  font-weight: 600;
}

.status-in-progress { background: #fff7ed; color: #c2410c; }
.status-scored { background: #ecfdf5; color: #047857; }
.status-not-started { background: #f3f4f6; color: #6b7280; }

.retake-input {
  width: 74px;
  display: inline-block;
}

.preview-cell {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}

.preview-cell > span {
  display: inline-block;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-detail-table td:nth-child(3),
.report-detail-table td:nth-child(5) {
  max-width: 360px;
}

.full-text-body {
  white-space: pre-wrap;
  line-height: 1.75;
  word-break: break-word;
}

@media (max-width: 991px) {
  body.admin-page .page-main {
    max-width: 100%;
  }

  .bank-list-panel #bank-menu {
    grid-template-columns: 1fr;
  }

  .bank-list-tools {
    grid-template-columns: 1fr;
  }

  .pagination-wrap {
    justify-content: flex-start;
  }
}
