/* ==========================================================================
   base.css —— 全局变量、重置、通用组件（按钮 / 表单 / 卡片 / 表格 / 弹窗 / 星级）
   无构建、无第三方依赖；两个前端入口（考生端 / 管理端）共用本文件。
   ========================================================================== */

:root {
  --c-primary: #2f6fed;
  --c-primary-dark: #1f57c9;
  --c-primary-soft: #eaf1ff;
  --c-text: #1f2329;
  --c-text-2: #4e5969;
  --c-muted: #86909c;
  --c-border: #e5e6eb;
  --c-bg: #f5f6f8;
  --c-card: #ffffff;
  --c-danger: #d92d20;
  --c-danger-soft: #fff1f0;
  --c-ok: #12a150;
  --c-ok-soft: #e8f8ee;
  --c-warn: #d97706;
  --c-warn-soft: #fff7e6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(31, 35, 41, 0.06);
  --shadow-lg: 0 8px 32px rgba(31, 35, 41, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  /* min-width:0 是 flex/grid 子项能被压缩的关键，缺了它长英文/长数字会撑破布局 */
  min-width: 0;
}

html,
body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, p, ul, ol, dl {
  margin: 0;
}

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

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ------------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--c-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--c-primary);
  color: var(--c-primary);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--c-primary-dark);
  border-color: var(--c-primary-dark);
  color: #fff;
}

.btn-danger {
  background: var(--c-danger);
  border-color: var(--c-danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  color: #fff;
  opacity: 0.9;
}

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

.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ------------------------------------------------------------------ 表单 */
.field {
  display: block;
  margin-bottom: 14px;
}

.field > .label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--c-text-2);
}

.input,
.select,
.textarea {
  width: 100%;
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}

.textarea {
  resize: vertical;
  line-height: 1.7;
}

.hint {
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 4px;
}

.checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}

.checkbox input {
  margin-top: 4px;
  width: 16px;
  height: 16px;
  flex: none;
}

/* ------------------------------------------------------------------ 卡片 */
.card {
  background: var(--c-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card + .card {
  margin-top: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ------------------------------------------------------------------ 表格 */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

.table th {
  font-weight: 600;
  color: var(--c-text-2);
  background: #fafbfc;
  white-space: nowrap;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

/* ------------------------------------------------------------------ 标签 */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 20px;
  background: #f2f3f5;
  color: var(--c-text-2);
  white-space: nowrap;
}

.tag-primary { background: var(--c-primary-soft); color: var(--c-primary); }
.tag-ok { background: var(--c-ok-soft); color: var(--c-ok); }
.tag-warn { background: var(--c-warn-soft); color: var(--c-warn); }
.tag-danger { background: var(--c-danger-soft); color: var(--c-danger); }

.star {
  color: #f5a623;
  letter-spacing: 1px;
  white-space: nowrap;
}

.muted { color: var(--c-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.danger { color: var(--c-danger); }
.ok { color: var(--c-ok); }
.bold { font-weight: 600; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }

/* ------------------------------------------------------------------ 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

.modal h3 {
  font-size: 17px;
  margin-bottom: 12px;
}

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

/* ------------------------------------------------------------------ 提示 */
.toast-box {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1200;
  pointer-events: none;
  max-width: 90vw;
}

.toast {
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(31, 35, 41, 0.9);
  color: #fff;
  font-size: 14px;
  max-width: 90vw;
  text-align: center;
  animation: toast-in 0.18s ease-out;
}

.toast-error { background: rgba(217, 45, 32, 0.94); }
.toast-ok { background: rgba(18, 161, 80, 0.94); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------ 空态 */
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--c-muted);
  font-size: 14px;
}

.loading {
  padding: 30px;
  text-align: center;
  color: var(--c-muted);
  font-size: 14px;
}

/* 原文展示：保留换行但不解析 HTML（防 XSS 的关键做法） */
.plain {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
