
/* =========================================================
   在线考试系统 - 全局样式
   设计方向：简洁、专业、清晰、响应式
========================================================= */

/* ===== 设计令牌 ===== */
:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;

  --ink: #253247;
  --muted: #718096;
  --line: #e3e9f0;

  --brand: #356fae;
  --brand-dark: #285987;
  --brand-soft: #edf4fc;

  --ok: #23845b;
  --ok-soft: #eaf6ef;

  --warn: #b8792d;
  --warn-soft: #fff5e8;

  --danger: #c45454;
  --danger-soft: #fff0f0;

  --info: #36859a;
  --info-soft: #eaf6f8;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-sm: 0 2px 8px rgba(34, 54, 80, .035);
  --shadow: 0 5px 18px rgba(34, 54, 80, .055);

  --font: -apple-system, BlinkMacSystemFont,
          "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans CJK SC",
          "Noto Sans SC", "Helvetica Neue",
          Arial, sans-serif;

  --transition: .2s ease;
}

/* ===== 基础 ===== */
* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  line-height: 1.35;
  margin: 0 0 .65em;
  color: var(--ink);
}

h1 {
  font-size: 1.7rem;
  font-weight: 700;
}

h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

h3 {
  font-size: 1.05rem;
  font-weight: 650;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--brand-dark);
}

:focus-visible {
  outline: 3px solid rgba(53, 111, 174, .3);
  outline-offset: 2px;
}

.muted {
  color: var(--muted);
}

.nowrap {
  white-space: nowrap;
}

.mono {
  font-family: ui-monospace, SFMono-Regular,
               Menlo, Consolas, monospace;
  font-size: .92em;
}

/* ===== 表单 ===== */
label {
  display: block;
  font-weight: 600;
  margin: 0 0 .4em;
  color: #43536a;
}

input[type=text],
input[type=password],
input[type=search],
input[type=file],
input[type=number],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: .6em .85em;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d8e0e9;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition),
              box-shadow var(--transition),
              background var(--transition);
}

input[type=text]:hover,
input[type=password]:hover,
input[type=search]:hover,
input[type=number]:hover,
select:hover,
textarea:hover {
  border-color: #b9c9da;
}

input[type=text]:focus,
input[type=password]:focus,
input[type=search]:focus,
input[type=file]:focus,
input[type=number]:focus,
select:focus,
textarea:focus {
  border-color: #77a4d0;
  box-shadow: 0 0 0 3px rgba(53, 111, 174, .09);
}

input[type=file] {
  padding: .55em;
  background: var(--surface-soft);
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.7;
}

.field {
  margin-bottom: 1.2rem;
}

.field-hint {
  color: var(--muted);
  font-size: .86rem;
  margin: .35em 0 0;
}

.check {
  display: flex;
  align-items: center;
  gap: .6em;
  font-weight: 400;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brand);
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;

  min-height: 40px;
  padding: .5em 1.1em;

  font: inherit;
  font-size: 14px;
  font-weight: 600;

  text-decoration: none;
  cursor: pointer;

  color: #526174;
  background: #fff;
  border: 1px solid #d8e0e9;
  border-radius: var(--radius-sm);

  transition: background var(--transition),
              border-color var(--transition),
              color var(--transition),
              transform var(--transition),
              box-shadow var(--transition);
}

.btn:hover {
  color: var(--ink);
  background: #f5f8fb;
  border-color: #c5d1df;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

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

.btn-primary:hover {
  color: #fff;
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  box-shadow: 0 3px 9px rgba(53, 111, 174, .18);
}

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

.btn-danger:hover {
  color: #b33e3e;
  background: var(--danger-soft);
  border-color: #e5b7b7;
}

.btn-sm {
  min-height: 33px;
  padding: .25em .75em;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn-link {
  background: none;
  border: 0;
  padding: 0;
  min-height: 0;
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* ===== 提示信息 ===== */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;

  padding: .8em 1em;
  border-radius: var(--radius-sm);
  margin: 0 0 1rem;

  border: 1px solid transparent;
  border-left-width: 4px;

  font-size: 14px;
}

.flash.error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f2dada;
  border-left-color: var(--danger);
}

.flash.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #d6ebde;
  border-left-color: var(--ok);
}

.flash.warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: #f1e2c8;
  border-left-color: var(--warn);
}

/* ===== 状态标签 ===== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: .2em .7em;
  border-radius: 5px;
  font-size: .82rem;
  font-weight: 600;
  background: #eef1f5;
  color: #697789;
}

.tag.on {
  background: var(--ok-soft);
  color: var(--ok);
}

.tag.off {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ===== 表格 ===== */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  font-size: 13px;
}

th,
td {
  padding: .8em .95em;
  text-align: left;
  border-bottom: 1px solid #edf0f4;
  vertical-align: middle;
}

th {
  font-size: .86rem;
  color: #718096;
  font-weight: 650;
  background: #f7f9fc;
  white-space: nowrap;
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: #f8fbff;
}

tr:last-child td {
  border-bottom: 0;
}

td.actions {
  white-space: nowrap;
  text-align: right;
}

td.actions .btn {
  margin-left: .25rem;
}

.empty {
  padding: 2.8rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ===== 分页 ===== */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  align-items: center;
  margin-top: 1.2rem;
  color: var(--muted);
  font-size: 13px;
}

/* ===== 提示页 ===== */
.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.message-box {
  max-width: 460px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}

/* =========================================================
   考生入口：左侧试卷信息 + 右侧登录
========================================================= */
.entry {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  background: #fff;
}

.entry-paper {
  position: relative;
  overflow: hidden;

  background: linear-gradient(145deg, #356fae, #285987);
  color: #fff;

  padding: clamp(1.5rem, 6vw, 4.5rem);

  display: flex;
  flex-direction: column;
  justify-content: center;
}

.entry-paper::after {
  content: "";
  position: absolute;
  width: 360px;
  height: 360px;
  right: -140px;
  bottom: -170px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  box-shadow:
    0 0 0 35px rgba(255,255,255,.035),
    0 0 0 70px rgba(255,255,255,.025);
  pointer-events: none;
}

.entry-paper h1 {
  color: #fff;
  font-size: clamp(1.8rem, 4.2vw, 3rem);
  letter-spacing: .01em;
  margin-bottom: .5em;
}

.entry-paper .lead {
  max-width: 34em;
  font-size: 1.05rem;
  opacity: .92;
  line-height: 1.9;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .45em 1.4em;
  margin: 1.4rem 0 0;
}

.facts dt {
  opacity: .78;
}

.facts dd {
  margin: 0;
  font-weight: 600;
}

.entry-form {
  padding: clamp(1.5rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.entry-form .hint {
  margin-top: 1.2rem;
  color: var(--muted);
  font-size: .9rem;
}

/* =========================================================
   考生须知页
========================================================= */
.exam-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.2rem 3.5rem;
}

.exam-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.panel .facts dt {
  color: var(--muted);
  opacity: 1;
}

/* =========================================================
   后台布局
========================================================= */
.admin {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 1.2rem .8rem;

  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.side .brand {
  font-weight: 750;
  font-size: 1.1rem;
  padding: 0 .7rem 1.1rem;
  color: var(--brand-dark);
}

.side a.nav {
  display: block;
  padding: .65em .85em;
  border-radius: var(--radius-sm);
  color: #536176;
  text-decoration: none;
  font-size: 14px;
  transition: background var(--transition),
              color var(--transition);
}

.side a.nav:hover {
  background: #f2f6fb;
  color: var(--brand-dark);
}

.side a.nav[aria-current=page] {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 650;
}

.side .who {
  margin-top: auto;
  padding: 1rem .7rem 0;
  border-top: 1px solid var(--line);
  font-size: .9rem;
  color: var(--muted);
}

.main {
  padding: 1.7rem clamp(1rem, 3vw, 2.5rem) 3rem;
  min-width: 0;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: 1.3rem;
}

.page-head h1 {
  margin: 0;
  font-size: 1.5rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
  margin-bottom: 1rem;
}

.toolbar input[type=search] {
  width: 220px;
}

.toolbar select {
  width: auto;
  min-width: 130px;
}

.form-card {
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
}

/* ===== 后台统计 ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0;

  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stats div {
  padding: 1.2rem;
  border-right: 1px solid var(--line);
}

.stats div:last-child {
  border-right: 0;
}

.stats b {
  display: block;
  font-size: 1.9rem;
  line-height: 1.25;
  color: var(--ink);
}

.stats span {
  color: var(--muted);
  font-size: .88rem;
}

/* ===== 后台标签 ===== */
.tabs {
  display: flex;
  gap: 1.3rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs a {
  padding: .6em 0;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tabs a[aria-current=page] {
  color: var(--brand-dark);
  border-color: var(--brand);
  font-weight: 650;
}

/* =========================================================
   会话失效弹层
========================================================= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 42, 60, .58);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
  backdrop-filter: blur(3px);
}

.overlay .box {
  background: #fff;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 15px 50px rgba(20, 35, 55, .18);
  animation: dialogIn .22s ease both;
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* =========================================================
   题库 / 题目
========================================================= */
textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.7;
}

.form-wide {
  max-width: 760px;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.opts {
  display: grid;
  gap: .7rem;
}

.opt {
  display: grid;
  grid-template-columns: 1.6rem 1.6rem minmax(0, 1fr);
  gap: .6rem;
  align-items: center;
}

.opt b {
  text-align: center;
}

.opt input[type=radio],
.opt input[type=checkbox] {
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--brand);
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.6rem;
}

/* =========================================================
   响应式布局
========================================================= */
@media (max-width: 860px) {
  .entry {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .entry-paper {
    padding: 2rem 1.3rem;
  }

  .entry-form {
    padding: 2rem 1.3rem 2.8rem;
  }

  .admin {
    grid-template-columns: 1fr;
  }

  .side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .4rem;
    padding: .65rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side .brand {
    padding: 0 .6rem 0 .2rem;
  }

  .side .who {
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
  }

  .main {
    padding: 1.3rem 1rem 2.5rem;
  }

  .toolbar input[type=search] {
    width: 100%;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  h1 {
    font-size: 1.45rem;
  }

  h2 {
    font-size: 1.18rem;
  }

  .row2 {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 1.1rem;
  }

  .exam-wrap {
    padding: 1.2rem .8rem 2.5rem;
  }

  .exam-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-head {
    align-items: flex-start;
  }

  .page-head h1 {
    font-size: 1.35rem;
  }

  .form-card {
    padding: 1.1rem;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats div {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .stats div:nth-child(2n) {
    border-right: 0;
  }

  .stats div:last-child {
    border-bottom: 0;
  }

  .pager {
    gap: .6rem;
  }

  .message-box {
    padding: 1.4rem;
  }

  .side .who {
    width: 100%;
    margin: .5rem 0 0;
  }
}

/* ===== 减少动态效果偏好 ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
