/* ============================================================
 * MyClass11 班级日志 · 大屏样式
 * 风格：Claude 奶白色配色 + Anthropic 式轻度动画
 * 字体、按钮、点按区域都偏大，方便讲台距离操作（鼠标/键盘/触屏通用）
 * ============================================================ */

:root {
  --bg: #FAF9F5;          /* 奶白页面底色 */
  --bg-soft: #F0EEE6;     /* 次级底色（表头/悬停） */
  --panel: #FFFFFF;       /* 卡片 */
  --text: #29261B;        /* 主文字（深炭） */
  --text-soft: #6B675C;   /* 次级文字 */
  --text-faint: #A8A496;  /* 已撤销等弱化文字 */
  --line: #E5E1D5;        /* 分隔线 */
  --accent: #D97757;      /* Claude 赤陶色 */
  --accent-hover: #C4633F;
  --accent-soft: #F7E8E1; /* 赤陶浅底 */
  --danger: #B3492F;      /* 危险操作 */
  --ok: #4F6C44;          /* 有效状态（橄榄绿） */
  --radius: 14px;
  --shadow: 0 2px 10px rgba(41, 38, 27, .06), 0 1px 3px rgba(41, 38, 27, .05);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html { font-size: 18px; } /* 大屏基础字号 */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

.app { max-width: 1400px; margin: 0 auto; padding: 34px 40px 48px; }

/* ---------------- 顶栏 ---------------- */

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; margin-bottom: 26px;
}
.brand h1 {
  margin: 0; font-size: 2rem; font-weight: 700; letter-spacing: .01em;
  display: flex; align-items: center; gap: 14px;
}
.brand-tag {
  font-size: .85rem; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 5px 14px;
}
.brand-sub { margin: 6px 0 0; color: var(--text-soft); font-size: .95rem; }

.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---------------- 按钮（大点按区域） ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 26px;
  border: none; border-radius: 999px;
  font-family: inherit; font-size: 1rem; font-weight: 600;
  cursor: pointer; user-select: none; touch-action: manipulation; /* 触屏防双击缩放 */
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 3px solid rgba(217, 119, 87, .45); outline-offset: 2px; }

.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(217, 119, 87, .35); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-ghost { background: var(--panel); color: var(--text); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: #CFC9B8; background: var(--bg-soft); transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #993F29; transform: translateY(-1px); }

.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none !important; }

.row-btn { min-height: 46px; padding: 0 18px; font-size: .95rem; }

/* ---------------- 开关（显示已撤销） ---------------- */

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 58px; height: 32px; border-radius: 999px; background: #D8D3C4;
  position: relative; transition: background .18s ease; flex: none;
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .18s cubic-bezier(.2, .7, .3, 1.2);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(26px); }
.switch input:focus-visible + .track { outline: 3px solid rgba(217, 119, 87, .45); outline-offset: 2px; }
.switch-label { font-size: .95rem; font-weight: 600; color: var(--text-soft); }

/* ---------------- 记录表格 ---------------- */

.content { flex: 1; }
.table-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.table-scroll { overflow-x: auto; }

table.records { width: 100%; border-collapse: collapse; min-width: 1120px; }

.records th {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg-soft); color: var(--text-soft);
  font-size: .88rem; font-weight: 700; letter-spacing: .06em;
  text-align: left; padding: 16px 18px;
  border-bottom: 2px solid var(--line); white-space: nowrap;
}

.records td {
  padding: 15px 18px; border-bottom: 1px solid #EFECE3;
  font-size: 1rem; vertical-align: top;
}
.records tbody tr { animation: fadeUp .4s ease backwards; animation-delay: calc(var(--i, 0) * 26ms); }
.records tbody tr:hover { background: #FBFAF6; }
.records tbody tr:last-child td { border-bottom: none; }
/* 修复：动画不能用 both/forwards 填充——结束后会在 tr 上留下持久 stacking context，
   导致「更多」菜单被后续行的内容盖住、点不到 */
.records tbody tr:has(details.more[open]) { position: relative; z-index: 100; }
/* 底部两行的菜单改为向上弹出，避免被表格卡片的 overflow 裁剪 */
.records tbody tr:nth-last-child(-n+2) details.more .menu { top: auto; bottom: calc(100% + 6px); }

.c-date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-soft); }
.c-target { font-weight: 700; }
.c-points { font-weight: 700; color: var(--danger); white-space: nowrap; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.c-detail { max-width: 460px; white-space: pre-wrap; word-break: break-word; }
.c-actions { white-space: nowrap; }
.c-recorder { white-space: nowrap; color: var(--text-soft); }
.none { color: var(--text-faint); }

/* 已撤销的行整体弱化 */
tr.revoked td { color: var(--text-faint); }
tr.revoked .c-target, tr.revoked .c-detail { text-decoration: line-through; text-decoration-color: #C9C4B4; }

/* 徽章 */
.badge {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.badge-person { background: var(--accent-soft); color: #B05D3F; }
.badge-dorm { background: #EBEFE3; color: #5F6C46; }
.status-active { background: #E8F0E4; color: var(--ok); }
.status-revoked { background: #EFEDE6; color: #8D897B; }

/* 更多操作下拉（删除藏在这里，避免误触） */
details.more { position: relative; display: inline-block; }
details.more summary { list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(41, 38, 27, .14); padding: 8px; min-width: 190px;
}
.menu button {
  display: block; width: 100%; min-height: 46px; padding: 8px 16px;
  background: none; border: none; border-radius: 8px; text-align: left;
  font-family: inherit; font-size: .95rem; color: var(--text-soft); cursor: pointer;
  transition: background .13s ease, color .13s ease;
}
.menu button:hover, .menu button:focus-visible { background: var(--bg-soft); color: var(--danger); }

/* 状态区（加载中 / 空 / 出错） */
.state { padding: 64px 24px; text-align: center; color: var(--text-soft); font-size: 1.05rem; }
.state .err { color: var(--danger); font-weight: 600; margin: 0 0 14px; }
.state .btn { margin-top: 6px; }

.footnote { color: var(--text-faint); font-size: .85rem; margin: 14px 4px 0; }

/* ---------------- 弹窗（dialog） ---------------- */

dialog.modal {
  border: none; border-radius: 20px; padding: 0;
  width: min(720px, calc(100vw - 48px));
  box-shadow: 0 24px 80px rgba(41, 38, 27, .28);
  background: var(--panel); color: var(--text);
}
dialog.modal::backdrop { background: rgba(41, 38, 27, .42); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: popIn .22s cubic-bezier(.2, .7, .3, 1.1); }

.modal-inner { padding: 30px 34px 32px; }
.modal-inner h2 { margin: 0 0 6px; font-size: 1.5rem; }
.modal-hint { margin: 0 0 22px; color: var(--text-soft); font-size: .95rem; }
.modal-warn {
  margin: 14px 0 0; padding: 14px 18px; border-radius: 12px;
  background: #F9ECE7; color: #92472F; font-size: .95rem;
}
.delete-info {
  margin: 0; padding: 12px 18px; border-radius: 12px;
  background: var(--bg-soft); color: var(--text);
  font-size: 1.05rem; font-weight: 600; word-break: break-all;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 14px; margin-top: 26px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label { font-size: .9rem; color: var(--text-soft); font-weight: 700; }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 1.05rem; color: var(--text);
  padding: 12px 16px; min-height: 52px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #FDFCF9;
  transition: border-color .15s ease, box-shadow .15s ease;
  width: 100%;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(217, 119, 87, .16);
}
.summary-preview {
  margin: 20px 0 0; font-size: .9rem; color: var(--text-soft);
  background: var(--bg-soft); border-radius: 10px; padding: 10px 16px;
  word-break: break-all;
}

/* ---------------- 轻提示（toast） ---------------- */

#toasts {
  position: fixed; right: 24px; bottom: 24px; z-index: 1000;
  display: flex; flex-direction: column; gap: 12px; max-width: min(480px, calc(100vw - 48px));
}
.toast {
  background: #29261B; color: #FAF9F5;
  padding: 16px 22px; border-radius: 14px; font-size: 1rem; line-height: 1.5;
  box-shadow: 0 10px 30px rgba(41, 38, 27, .32);
  animation: toastIn .25s cubic-bezier(.2, .7, .3, 1.1);
}
.toast-success { background: #3F5233; }
.toast-error { background: #7A3A2E; }
.toast-out { opacity: 0; transform: translateY(8px); transition: opacity .28s ease, transform .28s ease; }

/* ---------------- 调试栏 ---------------- */

.debugbar { margin-top: 18px; }
.debugbar details { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.debugbar summary {
  padding: 13px 20px; cursor: pointer; color: var(--text-soft);
  font-size: .92rem; font-weight: 600; user-select: none; list-style: none;
}
.debugbar summary::-webkit-details-marker { display: none; }
.debugbar summary::before { content: "▸ "; }
.debugbar details[open] summary::before { content: "▾ "; }
.debugbar summary:focus-visible { outline: 3px solid rgba(217, 119, 87, .45); outline-offset: -3px; border-radius: 12px; }
.debug-body { padding: 0 20px 18px; }
.debug-meta { margin: 0 0 10px; font-size: .88rem; color: var(--text-soft); word-break: break-all; }
.debug-table { width: 100%; border-collapse: collapse; }
.debug-table th { text-align: left; font-size: .78rem; color: var(--text-faint); padding: 4px 10px; letter-spacing: .05em; }
.debug-table td {
  font-family: var(--mono); font-size: .8rem; color: var(--text-soft);
  padding: 6px 10px; border-top: 1px dashed var(--line); word-break: break-all;
}

/* ---------------- 加载动画 ---------------- */

.spinner {
  width: 44px; height: 44px; margin: 0 auto 16px;
  border-radius: 50%;
  border: 4px solid var(--bg-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

/* ---------------- 动画定义 ---------------- */

@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------- 窄屏适配（优先大屏，此处兜底） ---------------- */

@media (max-width: 860px) {
  html { font-size: 16px; }
  .app { padding: 22px 18px 32px; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
