/* =========================================================
   ClassTrend — Global Light Theme
   ========================================================= */

/* ---------- Color System ---------- */
:root {
  /* Brand palette */
  --brand-1: #048ABF;  /* primary (teal-blue) */
  --brand-2: #04B2D9;  /* bright accent (cyan) */
  --brand-3: #04BF55;  /* success (green) */
  --brand-4: #F2B705;  /* warning (gold) */
  --brand-5: #F24405;  /* danger (orange-red) */

  /* Light neutrals */
  --bg:         #fafbff;   /* page background */
  --surface:    #ffffff;   /* card/modal surface */
  --border:     #e6e9f0;   /* card/input borders */
  --text:       #101826;   /* primary text */
  --muted:      #5b6472;   /* secondary text */
  --shadow:     0 8px 24px rgba(16, 24, 38, 0.08);

  /* Focus ring */
  --focus:      rgba(4, 178, 217, 0.35);
  --danger: #E64545;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container, .wrap {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

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

/* Headings */
h1, h2, h3 { margin: 0 0 12px; line-height: 1.15; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ---------- Layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row   { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid  { display: grid; gap: 12px; }

/* Responsive grids (override per page if needed) */
.grid.auto-220 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.auto-240 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.auto-160 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* Utilities */
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono  { font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Forms ---------- */
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: box-shadow .15s ease, border-color .15s ease;
}

input[type="number"] { width: 120px; }

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px var(--focus);
}

/* Search bar container option */
.search { min-width: 240px; flex: 1; }

/* ---------- Buttons (works for <button> and <a class="button">) ---------- */
.button, .btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--brand-1);
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  transition: filter .15s ease, transform .02s ease, box-shadow .15s ease;
}

.button:hover, .btn:hover, button:hover { filter: brightness(1.06); }
.button:active, .btn:active, button:active { transform: translateY(1px); }

.button:focus-visible, .btn:focus-visible, button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus);
}

/* Variants */
.button.primary, .btn.primary { background: var(--brand-1); color: #fff; }
.button.accent,  .btn.accent  { background: var(--brand-2); color: #03252c; }
.button.success, .btn.success { background: var(--brand-3); color: #062914; }
.button.warn,    .btn.warn    { background: var(--brand-4); color: #2a2100; }
.button.danger,  .btn.danger  { background: var(--brand-5); color: #2a0b04; }

/* Outline variant */
.button.outline, .btn.outline {
  background: transparent;
  color: var(--brand-1);
  border-color: var(--brand-1);
}
.button.outline:hover, .btn.outline:hover {
  background: rgba(4, 138, 191, 0.07);
}

/* Disabled */
.button[disabled], .btn[disabled], button[disabled] {
  opacity: .6; cursor: not-allowed; filter: none; transform: none;
}

/* Full-width convenience */
.btn.block, .button.block { width: 100%; }

/* ---------- Pills / Badges / Chips ---------- */
.pill, .badge, .chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #f7f9ff;
  color: var(--text);
}
.pill.ok   { background: #e9fbf1; border-color: #c8f1d9; color: #0f6b3a; }     /* success */
.pill.warn { background: #fff7e2; border-color: #ffe7ad; color: #5f4700; }     /* warning */

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f2f6ff;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.tab[aria-selected="true"], .tab.active {
  background: #e8f7fc;
  border-color: #bfe9f7;
  color: #073f4f;
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { font-weight: 600; user-select: none; }

/* ---------- Roster tiles (kick-able names) ---------- */
.name {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7faff;
  cursor: pointer;
  user-select: none;
}
.name.confirm {
  border-color: #ffc2b4;
  background: #fff0ec;
}

/* ---------- Avatars ---------- */
.avatar {
  width: 72px; height: 72px;
  border-radius: 12px;
  background: #f2f6ff;
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 32px;
  background-size: cover; background-position: center;
}

/* ---------- Big code + timer ---------- */
.big-code {
  font-size: clamp(28px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: 6px;
  text-align: center;
  padding: 24px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: #fff;
}

.timer { font-variant-numeric: tabular-nums; }

/* ---------- Banners / Info rows ---------- */
.banner {
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #f7faff;
  font-size: 14px;
}

/* ---------- Modal ---------- */
.modalOverlay {
  position: fixed; inset: 0;
  background: rgba(16, 24, 38, 0.35);  /* subtle dark backdrop */
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
}
.modalOverlay.open { display: flex; }

.modal {
  width: min(900px, 92vw);
  max-height: 85vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: grid; grid-template-rows: auto 1fr;
}
.modalHeader {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.modalTitle { font-weight: 600; font-size: 18px; }
.modalClose {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 10px;
  background: #f7faff;
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
}
.modalBody { padding: 14px; overflow: auto; line-height: 1.5; }

/* Transcript “markdown-ish” */
.modalBody .turn { margin: 10px 0; }
.modalBody .who { display: inline-block; min-width: 90px; font-weight: 600; color: var(--brand-1); }
.modalBody .who.me { color: var(--brand-3); }
.modalBody .text { white-space: pre-wrap; }

/* ---------- Toast (admin page) ---------- */
.toast {
  position: fixed; right: 14px; bottom: 14px; z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

/* ---------- CTA link wrapper (for <a><button> cases) ---------- */
.cta { text-decoration: none; }

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .button, .btn, button { transition: none; }
}
/* --- Small aliases / bridges so existing pages “just work” --- */

/* meta → same tone as .muted */
.meta { color: var(--fg-muted); }

/* pill badges used for status chips */
.pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--fg-muted);
}
.pill.ok {
  background: var(--success-soft);
  color: var(--success-ink);
  border-color: var(--success-ink);
}
.pill.warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-color: var(--warn-ink);
}

/* roster name chips */
.name {
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
}
.name.confirm { outline: 2px solid var(--danger); }

/* bridge: make .button-link look like our primary .button */
.button-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s ease, transform .02s ease;
}
.button-link:hover { filter: brightness(1.08); }
.button-link:active { transform: translateY(1px); }
.button-primary { font-weight: 700; } /* harmless keep */

/* Teacher Insights: small chips/tags used in tables & snippets */
.chip {
  display: inline-block;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px dashed var(--card-border);
  color: var(--fg-muted);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--card-border);
  color: var(--fg-muted);
}

/* Modal overlay backdrop (page uses .modalOverlay) */
.modalOverlay {
  background: rgba(16, 24, 38, 0.35); /* soft, light-friendly scrim */
}

/* Modal container layout (surface comes from .card) */
.modal {
  /* just layout; visuals are from .card */
  width: min(900px, 92vw);
  max-height: 85vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ---------- Optional: quick helpers for spacing ---------- */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }