/* Lịch trợ giảng VDC — tối giản kiểu MathVision: nền trắng, viền tóc, một màu nhấn. */

:root {
  --ink: #1f1f1f;
  --muted: #5f6368;
  --faint: #80868b;
  --line: #e3e3e3;
  --line-soft: #efefef;
  --bg: #ffffff;
  --bg-soft: #f8f9fa;
  --accent: #0b57d0;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fe;
  --danger: #b3261e;
  --danger-soft: #fce8e6;
  --ok: #1e7a37;
  --ok-soft: #e6f4ea;
  --warn: #8a5300;
  --warn-soft: #fef7e0;

  --cream: #fdf3d4;   --cream-line: #ead9a6;  --cream-ink: #6b5620;
  --k10: #deebd6;     --k10-line: #b6d0a6;    --k10-ink: #33591f;
  --k11: #d7e4ee;     --k11-line: #a8c4d8;    --k11-ink: #1f4a66;
  --k12: #f6dad9;     --k12-line: #e0afad;    --k12-ink: #7a2f2c;

  --r: 10px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(60,64,67,.1), 0 2px 8px rgba(60,64,67,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Google Sans', 'Google Sans Text', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
b, strong { font-weight: 600; }

/* ------------------------------------------------------------------ nút --- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink);
  font: inherit; font-weight: 500; line-height: 1;
  cursor: pointer; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--bg-soft); border-color: #d6d6d6; }
.btn:active { background: #f1f3f4; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #0a4bb5; border-color: #0a4bb5; }
.btn.primary:active { background: #093f99; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-soft); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.block { width: 100%; }

.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 50%; background: transparent;
  font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer;
  transition: background .12s ease;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.input, select.input {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink); font: inherit;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { height: 32px; padding: 0 8px; font-size: 13px; }

/* -------------------------------------------------------------- thanh trên --- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  box-shadow: inset 0 6px 0 var(--cream);
}
.brand-name { color: var(--muted); }
.brand-name b { color: var(--ink); }
.monthnav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.month-label { min-width: 148px; text-align: center; font-size: 15px; font-weight: 600; }
.legend { display: flex; gap: 6px; }
.chip {
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
}
.chip-k10 { background: var(--k10); border-color: var(--k10-line); color: var(--k10-ink); }
.chip-k11 { background: var(--k11); border-color: var(--k11-line); color: var(--k11-ink); }
.chip-k12 { background: var(--k12); border-color: var(--k12-line); color: var(--k12-ink); }

main { padding: 16px 20px 40px; }

/* ---------------------------------------------------------------- cảnh báo --- */

.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid;
  font-size: 13px;
}
.alert.warn { background: var(--warn-soft); border-color: #f0dda6; color: var(--warn); }
.alert.error { background: var(--danger-soft); border-color: #f3c3bd; color: var(--danger); }
.alert.ok { background: var(--ok-soft); border-color: #b7dfc2; color: var(--ok); }
.alert .grow { flex: 1; }

/* ------------------------------------------------------------------ lịch --- */

.calendar { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.weekhead, .weekrow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) 210px;
}
.weekhead { background: var(--bg-soft); border-bottom: 1px solid var(--line); }
.wh {
  padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--muted);
  border-right: 1px solid var(--line-soft);
}
.wh:last-child { border-right: 0; }
.wh-off { color: var(--faint); }
.wh-week { background: #fff; }

.grid { display: flex; flex-direction: column; }
.weekrow { border-bottom: 1px solid var(--line); }
.weekrow:last-child { border-bottom: 0; }
/* tuần hiện tại luôn nằm hàng đầu — vệt nhấn phải vẽ TRONG ô ngày, vì nền của ô
   phủ lên box-shadow của cả hàng */
.weekrow.current .day:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.day {
  border-right: 1px solid var(--line-soft);
  padding: 6px; display: flex; flex-direction: column; gap: 4px;
  min-height: 116px; background: #fff;
}
.day.outside { background: #fcfcfc; }
.day.sunday { background: #fafafa; }

.daybar {
  display: flex; align-items: center; gap: 6px;
  background: var(--cream); border: 1px solid var(--cream-line);
  color: var(--cream-ink); border-radius: 6px; padding: 3px 8px;
  font-size: 12px; font-weight: 600;
}
.day.outside .daybar { opacity: .5; }
.daybar .dnum { font-size: 13px; }
.daybar .dow { font-weight: 500; opacity: .8; }
.daybar .today-dot {
  margin-left: auto; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 600;
}

.cell {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid; border-radius: 6px; padding: 4px 7px;
  font-size: 12px; cursor: pointer; text-align: left; width: 100%;
  background: #fff; font-family: inherit;
  transition: filter .12s ease, box-shadow .12s ease;
}
.cell:hover { filter: brightness(.975); box-shadow: var(--shadow); }
.cell:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.cell .g { font-weight: 700; letter-spacing: .2px; }
.cell .ta { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .95; }
.cell .ta.empty { opacity: .45; font-style: italic; }
.cell .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cell .dot.has { background: var(--ok); }
.cell .dot.none { background: transparent; border: 1.5px solid currentColor; opacity: .35; }
.cell .dot.bad { background: var(--danger); }

.cell.k10 { background: var(--k10); border-color: var(--k10-line); color: var(--k10-ink); }
.cell.k11 { background: var(--k11); border-color: var(--k11-line); color: var(--k11-ink); }
.cell.k12 { background: var(--k12); border-color: var(--k12-line); color: var(--k12-ink); }
.cell.off {
  background: #fff; border-color: var(--line-soft); color: var(--faint);
  cursor: default; border-style: dashed;
}
.cell.off:hover { filter: none; box-shadow: none; }
.cell.off.locked { background: #fafafa; border-style: solid; color: #b0b3b8; }
.day.locked { background: #fbfbfb; }
.day.locked .daybar { background: #f2f2f2; border-color: #e6e6e6; color: #a9adb2; }

/* -------------------------------------------------------------- cột tuần --- */

.weekcol { padding: 6px; display: flex; flex-direction: column; gap: 4px; background: #fff; }
.wk {
  display: flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px 3px 6px;
  font-size: 12px; background: #fff; width: 100%; color: var(--ink);
}
.wk .main {
  display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0;
  border: 0; background: transparent; padding: 2px 0; cursor: pointer;
  font: inherit; text-align: left; color: inherit; border-radius: 4px;
}
.wk:hover { background: var(--bg-soft); }
.wk .main:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.wk .dl {
  flex: none; text-decoration: none; font-weight: 600; font-size: 11px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok); border: 1px solid #b7dfc2;
}
.wk .dl:hover { background: #d6ecdd; }
.wk .dl:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.wk .tag { font-weight: 700; font-size: 11px; padding: 1px 6px; border-radius: 4px; flex: none; }
.wk.k10 .tag { background: var(--k10); color: var(--k10-ink); }
.wk.k11 .tag { background: var(--k11); color: var(--k11-ink); }
.wk.k12 .tag { background: var(--k12); color: var(--k12-ink); }
.wk .txt { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk .st { flex: none; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.st.done { background: var(--ok-soft); color: var(--ok); }
.st.pending { background: var(--bg-soft); color: var(--faint); }
.st.miss { background: var(--warn-soft); color: var(--warn); border: 1px solid #f0dda6; }
.st.error { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------- drawer --- */

.scrim { position: fixed; inset: 0; background: rgba(32,33,36,.32); z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw);
  background: #fff; border-left: 1px solid var(--line); z-index: 31;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(60,64,67,.12);
}
/* display của tác giả luôn thắng [hidden] của trình duyệt — phải tắt tay. */
.drawer[hidden], .scrim[hidden], .toast[hidden] { display: none; }
.drawer-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.drawer-title { font-size: 16px; font-weight: 600; }
.drawer-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.drawer-body { padding: 16px; overflow-y: auto; overflow-x: hidden; flex: 1; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }

.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--r);
  padding: 18px; text-align: center; color: var(--muted);
  background: var(--bg-soft); cursor: pointer; font-size: 13px;
  transition: border-color .12s ease, background .12s ease;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 2px; word-break: break-all; }
.dropzone.over b { color: var(--accent); }
.dropzone.picked {
  border-style: solid; border-color: #b7dfc2; background: var(--ok-soft); color: var(--ok);
}
.dropzone.picked b { color: var(--ok); }
.dropzone.picked .btn { margin-top: 8px; }

.filecard {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px;
}
.filecard .fi { flex: 1; min-width: 0; }
.filecard .fn { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filecard .fm { font-size: 12px; color: var(--muted); }

.rowlist { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.rowlist .r {
  display: flex; align-items: center; gap: 10px; padding: 8px 11px;
  border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.rowlist .r:last-child { border-bottom: 0; }
.rowlist .r .d { width: 62px; font-weight: 600; color: var(--muted); font-size: 12px; }
.rowlist .r .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowlist .r .q { font-size: 12px; color: var(--muted); }
.rowlist .r.miss { background: var(--warn-soft); }

.qlist { display: flex; flex-direction: column; gap: 6px; }
.qrow {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) 124px; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 9px; font-size: 12.5px;
}
/* ô lưới mặc định min-width:auto nên chuỗi dài vẫn đẩy tràn dù đã ellipsis */
.qrow > * { min-width: 0; }
.qrow .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow .idx { font-weight: 700; color: var(--muted); }
.qrow .pv { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.qrow .meta { font-size: 11px; color: var(--faint); }
.qrow.low { border-color: #f0dda6; background: var(--warn-soft); }

.note { font-size: 12.5px; color: var(--muted); margin: 10px 0; }
.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.foot { margin-top: 14px; font-size: 12.5px; color: var(--faint); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #202124; color: #fff; padding: 10px 16px; border-radius: var(--r-sm);
  font-size: 13px; z-index: 40; box-shadow: var(--shadow); max-width: 80vw;
}

.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
.btn:not(.primary) .spin { border-color: rgba(0,0,0,.15); border-top-color: var(--accent); }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .weekhead, .weekrow { grid-template-columns: repeat(7, minmax(96px, 1fr)) 200px; }
  .calendar { overflow-x: auto; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .monthnav { margin-left: 0; }
  .legend { display: none; }
}
