/* css/teachers.css -- the teachers' app (/teachers). Light design; loaded after /css/home.css (tokens, nav,
   buttons, footer) and /css/page.css (page-hero band, .page-body). Independent of /style.css, which is the
   dark game theme and is NOT loaded here.
   The page is a set of views (<section class="t-view">), one visible at a time (js/teacher.js showView).
   Many class names below are written into the page by js/teacher.js and js/teacher-controls.js
   (manage-room-*, rs-*, copy-code-mini, chip, op, switch, warn, ...): keep both sides in step. */

/* the JS shows and hides things by toggling .hidden */
.hidden { display: none !important; }

.t-body { min-height: 62vh; padding-top: 32px; }
.t-view { width: 100%; }

/* ---------- the white app card, with a brand-blue top edge ---------- */
.t-card {
  max-width: 520px; margin: 0 auto; padding: 28px;
  background: var(--paper); border: 1px solid var(--line); border-top: 5px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow);
}
.t-card-wide { max-width: none; }
.t-card h2 { font-size: clamp(24px, 3.2vw, 30px); line-height: 1.2; font-weight: 700; letter-spacing: -.2px; overflow-wrap: anywhere; }
.t-sub { margin-top: 8px; margin-bottom: 20px; color: var(--muted); font-size: 17px; line-height: 1.55; }
.t-hint { margin-top: -8px; margin-bottom: 16px; color: var(--muted); font-size: 15px; }
.t-center { text-align: center; }
.t-actions { display: grid; gap: 12px; }
.t-switch { margin-top: 16px; text-align: center; color: var(--muted); font-size: 16px; }
.t-linkbtn { font: inherit; font-weight: 600; color: var(--blue-strong); background: none; border: 0; padding: 4px 2px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }
.t-linkbtn:hover { color: var(--blue-dark); }
.t-gap { margin-top: 18px; }
.t-notice { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--green-soft); color: #1d6b34; font-weight: 600; font-size: 16px; }

/* back / sign out: a plain text button at the top-left of the card */
.t-back {
  display: inline-flex; align-items: center; min-height: 44px; margin: -8px 0 6px -12px; padding: 0 12px;
  background: none; border: 0; border-radius: 999px;
  color: var(--blue-strong); font: inherit; font-weight: 600; cursor: pointer;
}
.t-back:hover { background: var(--pale); text-decoration: underline; text-underline-offset: 3px; }
.t-center .t-back { display: flex; margin-right: auto; }

/* ---------- buttons (the app's own; same look as .btn) ---------- */
.big-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 26px;
  background: var(--blue-strong); color: #fff; border: 2px solid var(--blue-strong); border-radius: 999px;
  font: inherit; font-size: 15px; font-weight: 600; letter-spacing: .04em; line-height: 1.2; text-align: center;
  cursor: pointer; transition: background-color .15s, color .15s, box-shadow .15s;
}
.big-btn:hover { background: var(--blue-dark); border-color: var(--blue-dark); box-shadow: 0 4px 12px rgba(5, 104, 214, .3); }
.big-btn:focus-visible { box-shadow: 0 0 0 3px #fff; }
.big-btn.small { min-height: 44px; padding: 0 18px; font-size: 14px; }
.big-btn.block { display: flex; width: 100%; }
.big-btn.ghost { background: #fff; color: var(--blue-strong); border-color: var(--blue-strong); }
.big-btn.ghost:hover { background: var(--pale-deep); box-shadow: none; }
.big-btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.big-btn.danger:hover { background: var(--red-soft); border-color: var(--red); box-shadow: none; }
.big-btn.danger-solid { background: var(--red); color: #fff; border-color: var(--red); }
.big-btn.danger-solid:hover { background: #A61F1F; border-color: #A61F1F; box-shadow: none; }
.big-btn:disabled, .rs-pin-save:disabled, .rs-pin-change:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* ---------- form fields ---------- */
.t-field { margin-bottom: 16px; }
.t-field label { display: block; margin-bottom: 6px; font-size: 15px; font-weight: 600; }
/* a hint inside a field sits below its input, not pulled up into it */
.t-field .t-hint { margin: 8px 0 0; }
.t-input, .rs-pin-input {
  display: block; width: 100%; min-height: 48px; padding: 0 14px;
  background: #fff; color: var(--navy); border: 2px solid var(--field); border-radius: 12px;
  font: inherit; font-size: 17px; font-weight: 600;
}
.t-input::placeholder { color: #6B7085; font-weight: 600; }
.t-input:focus, .rs-pin-input:focus { border-color: var(--blue-strong); }
select.t-input, select.rs-pin-input { appearance: auto; }

.modal-error {
  margin: 0 0 16px; padding: 12px 14px;
  background: var(--red-soft); color: #8E1B1B; border-left: 4px solid var(--red); border-radius: 0 12px 12px 0;
  font-size: 16px; font-weight: 600; line-height: 1.5;
}
.modal-note { margin-top: 14px; color: var(--muted); font-size: 15px; line-height: 1.55; }

/* ---------- Your Rooms ---------- */
.manage-room-list { display: grid; gap: 12px; margin-bottom: 20px; }
.manage-room-list:empty { display: none; }
.manage-room-item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.manage-room-item > div:first-child { flex: 1; min-width: 0; }
.manage-room-item > .big-btn { flex: none; }
.manage-room-name { font-size: 19px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.manage-room-code-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
.manage-room-code-label { color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.manage-room-code {
  padding: 2px 10px; background: var(--pale-deep); border-radius: 8px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 19px; font-weight: 700; letter-spacing: .14em; overflow-wrap: anywhere;
}
.manage-room-meta { margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 1.45; }

/* small outlined copy button beside a room code */
.copy-code-mini {
  min-height: 44px; min-width: 68px; padding: 0 14px;
  background: #fff; color: var(--blue-strong); border: 2px solid var(--blue-strong); border-radius: 999px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.copy-code-mini:hover { background: var(--pale-deep); }
.copy-code-mini.copied { background: var(--green-soft); color: #0C5F2D; border-color: var(--green); }

/* ---------- Room Created ---------- */
.room-code-display {
  margin: 4px 0 18px; padding: 18px 12px;
  background: var(--pale-deep); border: 2px dashed var(--blue-strong); border-radius: var(--radius);
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: clamp(34px, 11vw, 56px); font-weight: 700; letter-spacing: .16em; text-indent: .16em;
  line-height: 1.1; overflow-wrap: anywhere;
}

/* ---------- Manage Room: name / grade / code rows ---------- */
.manage-info { margin-top: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.manage-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; min-height: 60px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.manage-row:last-child { border-bottom: 0; }
.manage-label { flex: 0 0 130px; color: var(--muted); font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.manage-label small { display: block; margin-top: 1px; font-size: 12.5px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.manage-name-view, .manage-code-wrap, .manage-name-edit { display: flex; align-items: center; flex-wrap: wrap; flex: 1; gap: 6px 10px; min-width: 0; }
.manage-value { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.manage-value.manage-room-code { padding: 2px 10px; }
.manage-grade-none { color: var(--berry); }
.manage-name-edit { flex-wrap: wrap; }
.rs-pin-input.manage-name-input { flex: 1 1 180px; width: auto; min-width: 0; }
.rs-pin-input.grade-select { flex: 1 1 160px; width: auto; min-width: 0; }

/* the four stat tiles */
.manage-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.manage-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--brand); border-radius: 14px; box-shadow: var(--shadow); }
/* each tile's figure takes a palette colour in turn (the label under it says what it counts) */
.manage-stats > div:nth-child(2) { border-top-color: var(--teal); }
.manage-stats > div:nth-child(3) { border-top-color: var(--violet); }
.manage-stats > div:nth-child(4) { border-top-color: var(--berry); }
.manage-stats b { color: var(--brand); font-size: 26px; font-weight: 700; line-height: 1.1; }
.manage-stats > div:nth-child(2) b { color: var(--teal); }
.manage-stats > div:nth-child(3) b { color: var(--violet); }
.manage-stats > div:nth-child(4) b { color: var(--berry); }
.manage-stats span { color: var(--muted); font-size: 13.5px; font-weight: 600; line-height: 1.25; }

/* small buttons used in the name/grade rows and the students table */
.rs-pin-change, .rs-pin-save {
  min-height: 44px; min-width: 44px; padding: 0 14px;
  border: 2px solid var(--blue-strong); border-radius: 999px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.rs-pin-change { background: #fff; color: var(--blue-strong); }
.rs-pin-change:hover { background: var(--pale-deep); }
.rs-pin-save { background: var(--blue-strong); color: #fff; }
.rs-pin-save:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

/* ---------- Manage Room: header (title, code and grade for reference, then the totals) ---------- */
.manage-title-name { color: var(--blue-strong); }
.manage-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin-top: 12px; }
.manage-badge { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.manage-badge-label { color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.manage-badge-value { font-size: 18px; font-weight: 700; }
.manage-badge .manage-room-code { padding: 2px 10px; }

/* ---------- Manage Room: tabs ---------- */
.source-tabs { display: flex; gap: 8px; margin: 22px 0 18px; }
.source-tab {
  flex: 1; min-height: 48px; padding: 6px 10px;
  background: #fff; color: var(--blue-strong); border: 2px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.source-tab:hover { border-color: var(--blue-strong); }
.source-tab.selected { background: var(--blue-strong); color: #fff; border-color: var(--blue-strong); }

/* ---------- Manage Room: classroom controls ---------- */
.class-controls { padding: 18px; background: var(--pale); border: 1px solid var(--line); border-radius: 14px; }
.class-controls-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.class-controls h3 { font-size: 18px; font-weight: 700; line-height: 1.25; }
.class-controls .modal-note { margin-top: 8px; }
.class-controls-body { margin-top: 6px; }
.class-controls-body h3 { margin: 22px 0 10px; font-size: 16px; }
.class-controls-body > h3:first-child { margin-top: 14px; }
.insane-tag { margin-left: 6px; padding: 2px 9px; background: var(--purple); color: #fff; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; vertical-align: 2px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  flex: 1 1 80px; min-height: 56px; padding: 6px 12px;
  background: #fff; color: var(--navy); border: 2px solid var(--field); border-radius: 12px;
  font: inherit; font-size: 16px; font-weight: 700; line-height: 1.2; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.chip small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; font-weight: 600; }
.chip:hover { border-color: var(--blue-strong); }
.chip.selected { background: var(--blue-strong); color: #fff; border-color: var(--blue-strong); }
.chip.selected small { color: #fff; }

.op-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.op {
  position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 52px; padding: 6px 12px;
  background: #fff; border: 2px solid var(--field); border-radius: 12px; cursor: pointer; user-select: none;
  transition: background-color .15s, border-color .15s;
}
.op input { position: absolute; opacity: 0; width: 100%; height: 100%; left: 0; top: 0; margin: 0; cursor: pointer; }
.op:focus-within { outline: 3px solid var(--navy); outline-offset: 2px; }
.op-sym { display: grid; place-items: center; flex: none; width: 32px; height: 32px; background: var(--pale-deep); color: var(--blue-strong); border-radius: 50%; font-size: 20px; font-weight: 700; line-height: 1; }
.op-name { font-size: 16px; font-weight: 600; }
.op.checked { background: var(--pale-deep); border-color: var(--blue-strong); }
.op.checked .op-sym { background: var(--blue-strong); color: #fff; }
.op.checked::after { content: "\2713"; position: absolute; top: -8px; right: -8px; display: grid; place-items: center; width: 22px; height: 22px; background: var(--blue-strong); color: #fff; border: 2px solid #fff; border-radius: 50%; font-size: 12px; font-weight: 700; line-height: 1; }

/* the shake-able "pick at least one" warning keeps its space, so nothing jumps */
.warn { visibility: hidden; margin-top: 8px; color: var(--red); font-size: 15px; font-weight: 600; }
.warn.show { visibility: visible; }
@media (prefers-reduced-motion: no-preference) {
  .warn.show { animation: t-shake .35s; }
}
@keyframes t-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* on/off switch: the checkbox is visually hidden but still focusable */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; left: 0; top: 0; margin: 0; cursor: pointer; }
.switch-track { position: relative; flex: none; width: 56px; height: 32px; background: #6B7085; border-radius: 999px; transition: background-color .15s; }
.switch-knob { position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(16, 47, 103, .35); }
.switch.on .switch-track { background: var(--blue-strong); }
.switch.on .switch-knob { transform: translateX(24px); }
@media (prefers-reduced-motion: no-preference) { .switch-knob { transition: transform .15s; } }
.switch:focus-within .switch-track { outline: 3px solid var(--navy); outline-offset: 3px; }
.switch-label { min-width: 2.2em; font-size: 17px; font-weight: 600; color: var(--muted); }
.switch.on .switch-label { color: var(--blue-strong); }

.class-controls #cc-save { width: 100%; margin-top: 20px; }
.class-controls #cc-error { margin: 14px 0 0; }
.class-controls-saved {
  margin-top: 14px; padding: 12px 14px;
  background: var(--green-soft); color: #0C5F2D; border-left: 4px solid var(--green); border-radius: 0 12px 12px 0;
  font-size: 16px; font-weight: 600;
}

/* ---------- Manage Room: students ---------- */
.room-students-list .modal-note { margin: 4px 0; }
.rs-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.rs-table th, .rs-table td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.rs-table th { color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.rs-table tbody tr:last-child td { border-bottom: 0; }
.rs-table .rs-num { text-align: right; white-space: nowrap; }
.rs-name { width: 100%; font-weight: 700; overflow-wrap: anywhere; }   /* the name column takes the slack */
.rs-date { white-space: nowrap; }
.rs-pin { white-space: nowrap; }
/* a student's name in the list is a link to their Student Summary (a button, so keyboard and screen readers get it) */
.rs-name-link {
  display: inline; min-height: 32px; padding: 0; margin: 0; background: none; border: 0; text-align: left;
  color: var(--blue-strong); font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.rs-name-link:hover, .rs-name-link:focus-visible { color: var(--blue-dark); }
.rs-pin b { font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace; font-size: 17px; font-weight: 700; letter-spacing: .12em; }
.rs-first { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-top: 2px; font-weight: 600; }
.rs-first::before { content: "First name:"; color: var(--muted); font-size: 13px; font-weight: 600; }
.rs-first b { font-weight: 600; }
.rs-first-none { color: var(--muted); }

/* narrower screens: each student becomes a small card instead of a sideways-scrolling table */
@media (max-width: 859px) {
  .rs-table, .rs-table tbody { display: block; }
  .rs-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rs-table tr.rs-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
    margin-bottom: 10px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  }
  .rs-table td { display: block; padding: 0; border: 0; text-align: left; }
  .rs-table .rs-num { text-align: left; }
  .rs-table td.rs-name { grid-column: 1 / -1; width: auto; font-size: 17px; }
  .rs-table td.rs-pin { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 0; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .rs-pin::before { content: "PIN"; width: 100%; color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .08em; }
  .rs-table td:nth-child(n+3)::before { display: block; color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
  .rs-table td:nth-child(3)::before { content: "Games"; }
  .rs-table td:nth-child(4)::before { content: "Equations"; }
  .rs-table td:nth-child(5)::before { content: "Time Spent"; }
  .rs-table td:nth-child(6)::before { content: "Last Sign-In"; }
}

/* ---------- Manage Room: delete ---------- */
.manage-actions { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.manage-confirm { margin-top: 24px; padding: 16px 18px; background: var(--red-soft); border: 1px solid #F0B8B8; border-left: 4px solid var(--red); border-radius: 0 14px 14px 0; }
.manage-confirm p { margin: 0 0 14px; font-size: 16px; font-weight: 600; line-height: 1.55; overflow-wrap: anywhere; }
.manage-confirm-actions { display: flex; flex-wrap: wrap; gap: 10px; }
#manage-error { margin: 16px 0 0; }

/* ---------- Student Summary ---------- */
@media (max-width: 599px) {
  .student-stats > div:last-child:nth-child(odd) { grid-column: 1 / -1; }   /* two-up on phones: the fifth takes the whole row */
}
.student-section-title { margin: 26px 0 10px; font-size: 19px; font-weight: 700; }
.student-info { margin-top: 0; }
/* Student Details: label on the left, the value after it, and the edit controls pushed to the right edge */
@media (min-width: 600px) {
  .student-info .manage-row { padding: 12px 20px; gap: 8px 24px; }
  .student-info .manage-label { flex: 0 0 230px; }
  .student-info .manage-name-view { justify-content: space-between; }
  .student-info .manage-name-edit { justify-content: flex-end; }
  .student-info .manage-name-edit .manage-name-input { flex: 1 1 220px; max-width: 360px; }
}
.student-pin { font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace; font-size: 20px; letter-spacing: .18em; }
.rs-pin-input.student-pin-input { width: 6em; flex: none; text-align: center; letter-spacing: .25em; font-family: ui-monospace, "SFMono-Regular", Consolas, "Courier New", monospace; }
#student-error { margin: 16px 0 0; }
#student-saved { margin: 16px 0 0; }

/* ---------- type and detail pass: figures line up, table rows read across, buttons settle when pressed ---------- */
/* numbers, the room code and PINs use tabular figures so columns and codes line up */
.manage-stats b, .manage-value, .manage-room-code, .manage-badge-value, .rs-num, .rs-pin, .rs-pin b, .student-pin,
.room-code-display, .op-sym, .switch-label, .chip small { font-variant-numeric: tabular-nums; }
.manage-stats b { font-size: var(--fs-kpi); line-height: 1.1; }
.rs-table th { font-size: 13px; }
.rs-table td { line-height: var(--lh-body); }
/* desktop table: a faint zebra, and a clear hover row (declared after the zebra so it wins) */
@media (min-width: 860px) { .rs-table tbody tr:nth-child(even) td { background: #F7F9FE; } }
.rs-table tbody tr:hover td { background: var(--pale); }
.t-field label { line-height: 1.3; }
@media (prefers-reduced-motion: no-preference) {
  .big-btn:active, .copy-code-mini:active, .source-tab:active, .chip:active { transform: translateY(1px); }
}

/* ---------- larger screens ---------- */
@media (min-width: 600px) {
  .manage-stats { grid-template-columns: repeat(4, 1fr); }
  /* five totals: three across the top, two wider ones below, so the last row isn't lopsided */
  .manage-stats.student-stats { grid-template-columns: repeat(6, 1fr); }
  .student-stats > div { grid-column: span 2; }
  .student-stats > div:nth-child(n+4) { grid-column: span 3; }
  .op-grid { grid-template-columns: repeat(4, 1fr); }
  .class-controls #cc-save { width: auto; min-width: 240px; }
}

/* ---------- phones ---------- */
@media (max-width: 520px) {
  .t-body { padding-top: 22px; }
  .t-card { padding: 20px 16px; }
  .manage-room-item { flex-direction: column; align-items: stretch; }
  .manage-room-item > .big-btn { width: 100%; }
  .manage-row { padding: 10px 14px; }
  .manage-label { flex: 1 0 100%; }
  .class-controls { padding: 14px; }
  .op { gap: 8px; padding: 6px 8px; }
  .op-sym { width: 28px; height: 28px; font-size: 18px; }
  .op-name { font-size: 15px; }
  .source-tab { font-size: 14px; }
  .manage-confirm-actions .big-btn { flex: 1 1 100%; }
}
@media (max-width: 380px) {
  .manage-stats b { font-size: 22px; }
  .manage-room-code { font-size: 17px; }
}
