/* ============ 教师听课记录系统 · 公共样式 ============ */
:root {
  --brand: #2f5597;
  --brand-dark: #1f3864;
  --brand-light: #d9e2f3;
  --brand-mid: #8eaadb;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e3e8f2;
  --ok: #12a150;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 56, 100, .08);
  --shadow-sm: 0 2px 8px rgba(31, 56, 100, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.6;
}

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

.container { max-width: 1180px; margin: 0 auto; padding: 0 18px; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(120deg, var(--brand-dark) 0%, var(--brand) 60%, #3a6bc4 100%);
  color: #fff;
  padding: 20px 0 22px;
  box-shadow: 0 4px 18px rgba(31, 56, 100, .18);
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: .5px; display: flex; align-items: center; gap: 10px; }
.topbar .sub { margin: 6px 0 0; font-size: 13px; opacity: .86; }
.topbar .row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.badge-admin {
  display: inline-block; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 20px;
  margin: 20px 0;
  border: 1px solid rgba(227, 232, 242, .9);
}
.card > h2 {
  margin: 0 0 16px; font-size: 17px; color: var(--brand-dark);
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.card > h2 .idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 8px; background: var(--brand);
  color: #fff; font-size: 13px; font-weight: 700;
}

/* ---------- 表单 ---------- */
.grid { display: grid; gap: 16px 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid .span2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13.5px; font-weight: 600; color: #374151; }
.field label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--muted); }

input[type=text], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14.5px; font-family: inherit; color: var(--text);
  background: #fcfdff; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgba(47, 85, 151, .12); background: #fff;
}
input.bad, select.bad {
  border-color: #f0a3a3;
  background: #fffafa;
}
input.bad:focus, select.bad:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .1);
}
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8.5 1.5 4h9z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; background-size: 11px; padding-right: 30px; }
input[type=date]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .65; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  background: var(--brand); color: #fff; transition: transform .08s, box-shadow .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn.ghost { background: #fff; color: var(--brand); border-color: var(--brand-mid); }
.btn.ghost:hover { background: var(--brand-light); }
.btn.grey { background: #fff; color: #4b5563; border-color: var(--line); }
.btn.grey:hover { background: #f3f4f6; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 13px 26px; font-size: 16px; width: 100%; }

/* ---------- 上传区 ---------- */
.drop {
  border: 2px dashed var(--brand-mid); border-radius: 12px; background: #f8faff;
  padding: 22px 16px; text-align: center; cursor: pointer; transition: background .15s, border-color .15s;
}
.drop:hover, .drop.over { background: var(--brand-light); border-color: var(--brand); }
.drop .big { font-size: 26px; }
.drop p { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); }
.drop strong { color: var(--brand); }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.thumb {
  position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-sm);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; font-size: 13px; line-height: 20px; text-align: center;
  cursor: pointer; border: none; padding: 0;
}
.thumb .x:hover { background: var(--danger); }

/* ---------- 提示 ---------- */
.alert { padding: 11px 14px; border-radius: 10px; font-size: 14px; margin: 0 0 14px; display: none; }
.alert.show { display: block; }
.alert.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

.note { font-size: 13px; color: var(--muted); background: #f8fafc; border-left: 3px solid var(--brand-mid); padding: 10px 14px; border-radius: 0 8px 8px 0; }

/* ---------- 成功页 ---------- */
.success-wrap { text-align: center; padding: 26px 10px 10px; }
.success-wrap .tick {
  width: 68px; height: 68px; margin: 0 auto 14px; border-radius: 50%;
  background: #e8f8ee; color: var(--ok); font-size: 36px; line-height: 68px; font-weight: 700;
}
.success-wrap h3 { margin: 0 0 8px; color: var(--brand-dark); }
.success-wrap p { margin: 4px 0; color: var(--muted); font-size: 14px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table.tb { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; min-width: 880px; }
table.tb th {
  background: var(--brand); color: #fff; font-weight: 600; font-size: 13.5px;
  padding: 11px 10px; text-align: center; white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.tb td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tb tbody tr:nth-child(even) { background: #fafcff; }
table.tb tbody tr:hover { background: var(--brand-light); }
table.tb td.c { text-align: center; }
table.tb td.topic { max-width: 240px; }
table.tb .mini-thumb { width: 42px; height: 42px; border-radius: 7px; object-fit: cover; border: 1px solid var(--line); cursor: zoom-in; display: block; }

/* ---------- 统计块 ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: linear-gradient(150deg, #fff, #f6f9ff); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.kpi .n { font-size: 26px; font-weight: 800; color: var(--brand-dark); line-height: 1.2; }
.kpi .l { font-size: 13px; color: var(--muted); margin-top: 2px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13.5px; }
.bar-row .nm { width: 92px; flex: 0 0 auto; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { flex: 1; height: 16px; background: #eef2fa; border-radius: 8px; overflow: hidden; }
.bar-row .fill { height: 100%; background: linear-gradient(90deg, var(--brand-mid), var(--brand)); border-radius: 8px; transition: width .4s ease; }
.bar-row .vl { width: 46px; text-align: right; font-weight: 700; color: var(--brand); flex: 0 0 auto; }

.chart-box { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 760px) { .chart-box { grid-template-columns: 1fr; } }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 18px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 720px;
  max-height: 92vh; overflow: auto; box-shadow: 0 24px 60px rgba(15,23,42,.28);
}
.modal header {
  padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; z-index: 2;
}
.modal header h3 { margin: 0; font-size: 16.5px; color: var(--brand-dark); }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: #fff; }
.icon-btn { border: none; background: #f3f4f6; width: 32px; height: 32px; border-radius: 9px; font-size: 17px; cursor: pointer; color: #4b5563; line-height: 1; }
.icon-btn:hover { background: #e5e7eb; }

.view-img { width: 100%; border-radius: 10px; border: 1px solid var(--line); margin-top: 8px; }

/* ---------- 登录 ---------- */
.login-box { max-width: 400px; margin: 60px auto; }
.login-box .card { padding: 30px 26px; }
.login-box h2 { justify-content: center; border: none; padding: 0; margin-bottom: 6px; }
.login-box .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  padding: 10px 18px; cursor: pointer; font-size: 14.5px; font-weight: 600; color: var(--muted);
  border: none; background: none; border-bottom: 3px solid transparent; margin-bottom: -2px; font-family: inherit;
}
.tab:hover { color: var(--brand); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; font-size: 14px; color: var(--muted); }

.footer { text-align: center; color: #9aa4b6; font-size: 12.5px; padding: 26px 0 34px; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt0 { margin-top: 0; }
.mt12 { margin-top: 12px; }
.mb0 { margin-bottom: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--brand-light); color: var(--brand-dark); font-size: 12px; font-weight: 600; }
.tag-img { display: inline-block; font-size: 11.5px; color: var(--brand); background: #eef3fd; border-radius: 6px; padding: 1px 6px; margin-left: 4px; }

.loading { text-align: center; padding: 30px; color: var(--muted); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--brand-light); border-top-color: var(--brand); border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -3px; margin-right: 7px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- 班级/节次配置列表 ---------- */
.catalog-list {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  max-height: 420px; overflow-y: auto; background: #fff;
}
.cat-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid var(--line); font-size: 14px; transition: background .12s;
}
.cat-item:last-child { border-bottom: none; }
.cat-item:hover { background: #f8faff; }
.cat-item.off { background: #fafafa; color: #9aa4b6; }
.cat-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item .nm input { padding: 6px 9px; font-size: 14px; }
.cat-item .use {
  font-size: 11.5px; color: var(--brand); background: #eef3fd; border-radius: 999px;
  padding: 2px 9px; flex: 0 0 auto; white-space: nowrap;
}
.cat-item .use.zero { color: #9aa4b6; background: #f3f4f6; }
.cat-item .acts { display: flex; gap: 5px; flex: 0 0 auto; }
.cat-item .mini {
  border: 1px solid var(--line); background: #fff; border-radius: 7px; cursor: pointer;
  font-size: 12.5px; padding: 4px 9px; color: #4b5563; font-family: inherit; line-height: 1.3;
  white-space: nowrap;
}
.cat-item .mini:hover { background: var(--brand-light); border-color: var(--brand-mid); color: var(--brand-dark); }
.cat-item .mini.warn:hover { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.cat-item .mini:disabled { opacity: .45; cursor: not-allowed; }
.cat-tag { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: #f3f4f6; color: #6b7280; flex: 0 0 auto; }

/* ==================== 弹窗式操作提醒（Toast） ==================== */
/* 关键：始终 position: fixed，脱离文档流，无论页面上滑到哪都固定可见 */
.toast-wrap {
  position: fixed;
  top: 20px;
  right: 20px;
  left: auto;
  bottom: auto;
  z-index: 2147483000;   /* 高于页面所有元素（含弹窗遮罩） */
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: max-content;
  max-width: min(380px, calc(100vw - 40px));
  pointer-events: none;
  /* 移动端软键盘弹起时也会随视口收缩，不会被顶出可视区 */
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 32px rgba(31, 56, 100, .22), 0 2px 8px rgba(31, 56, 100, .12);
  border-left: 5px solid var(--brand);
  transform: translateX(120%);
  opacity: 0;
  transition: transform .26s cubic-bezier(.22, 1, .36, 1), opacity .26s ease;
  min-width: 260px;
  max-width: 100%;
}
.toast.in { transform: translateX(0); opacity: 1; }
.toast.out { transform: translateX(120%); opacity: 0; }

.toast-icon {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  background: var(--brand);
  margin-top: 1px;
}
.toast-body { flex: 1 1 auto; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 700; color: var(--brand-dark); margin-bottom: 3px; }
.toast-msg { font-size: 13.5px; line-height: 1.5; color: #374151; word-break: break-word; }

.toast-close {
  flex: 0 0 auto;
  border: none; background: transparent; cursor: pointer;
  font-size: 20px; line-height: 1; color: #9aa4b6;
  padding: 0 2px; margin-top: -2px;
  transition: color .15s;
}
.toast-close:hover { color: #4b5563; }

.toast.ok { border-left-color: var(--ok); }
.toast.ok .toast-icon { background: var(--ok); }
.toast.ok .toast-title { color: #166534; }

.toast.err { border-left-color: var(--danger); }
.toast.err .toast-icon { background: var(--danger); }
.toast.err .toast-title { color: #991b1b; }

.toast.warn { border-left-color: var(--warn); }
.toast.warn .toast-icon { background: var(--warn); }
.toast.warn .toast-title { color: #92400e; }

.toast.info { border-left-color: var(--brand); }
.toast.info .toast-icon { background: var(--brand); }
.toast.info .toast-title { color: var(--brand-dark); }

/* 小屏（手机）：改为底部居中堆叠，避开顶部地址栏/软键盘，滑到页面任何位置都能看见 */
@media (max-width: 640px) {
  .toast-wrap {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    max-width: none;
    width: auto;
    flex-direction: column-reverse; /* 新提示贴着屏幕下缘出现 */
    align-items: stretch;
  }
  .toast {
    min-width: 0;
    max-width: none;
    /* 小屏从下方滑入，视觉更贴合底部位置 */
    transform: translateY(140%);
    box-shadow: 0 12px 30px rgba(31, 56, 100, .28), 0 3px 10px rgba(31, 56, 100, .16);
  }
  .toast.in { transform: translateY(0); }
  .toast.out { transform: translateY(140%); }
  .toast-close { font-size: 24px; padding: 2px 6px; } /* 加大点击热区，方便手指点 */
}
