/*
  🧑‍🏫 The look of the teacher pages (B1 sign-in and B2 dashboard).
*/

.small-p { font-size: 13px; margin: 0; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, Menlo, monospace !important; letter-spacing: 0.14em; }

.input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font: inherit;
  font-size: 15px;
  color: var(--color-text);
  caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius);
}
.input:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 25%, transparent); }
.field > label { display: block; font-size: 12px; margin-bottom: 5px; color: color-mix(in srgb, var(--color-text) 70%, transparent); }
.form-error { font-size: 14px; color: var(--oops); }
.form-error:empty { display: none; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn-big { height: 44px; font-size: 15px; }

.seg { display: inline-flex; overflow: hidden; border: 1px solid var(--color-divider); border-radius: var(--radius); }
.seg-opt { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; font: inherit; font-size: 13px; color: var(--color-text); background: transparent; border: none; cursor: pointer; }
.seg-opt + .seg-opt { border-left: 1px solid var(--color-divider); }
.seg-opt.on { color: var(--color-accent); box-shadow: inset 0 0 0 1px var(--color-accent); }
.seg-opt:not(.on):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }

.note {
  padding: 12px 16px; border-radius: var(--radius); font-size: 14px;
  background: var(--color-accent-900); box-shadow: inset 0 0 0 1px var(--color-accent-700);
}
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent); }

/* ====================== B1: SIGN IN ====================== */

body.b1 { background: radial-gradient(ellipse 900px 600px at 85% 0%, var(--glow), var(--color-bg) 65%) fixed; }
.b1-page {
  max-width: 1200px; min-height: 100vh; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) 520px; gap: 64px;
  padding: 64px 72px; align-items: center; align-content: center;
}
.b1-page .note { grid-column: 1 / -1; }
.b1-left { display: flex; flex-direction: column; gap: 20px; align-self: stretch; }
.b1-brand { display: flex; align-items: center; gap: 12px; }
.b1-brand .brand { text-decoration: none; color: inherit; }
.b1-left h1 { font-size: 48px; max-width: 480px; margin: auto 0 0; }
.b1-left p { font-size: 16px; max-width: 440px; margin: 0; }
.student-link { text-decoration: none; }
.student-link:hover { color: var(--color-accent); }

.b1-card { padding: 36px; gap: 18px; box-shadow: var(--shadow-lg); }
.tabs { align-self: flex-start; }
.t-form { display: flex; flex-direction: column; gap: 16px; }
.card-title.big { font-size: 24px; }
.roles { display: flex; }
.roles .seg-opt { flex: 1; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ====================== B2: DASHBOARD ====================== */

body.b2 { background: var(--color-bg); }
.dash {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 330px;
}

/* ---------- sidebar ---------- */
.side {
  display: flex; flex-direction: column; gap: 4px;
  padding: 22px 14px;
  background: var(--color-neutral-900);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .brand { padding: 0 10px 18px; font-size: 17px; text-decoration: none; color: inherit; }
.side-top { display: flex; align-items: flex-start; justify-content: space-between; }
.side-top .theme-btn { margin-top: -8px; }
.side-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: color-mix(in srgb, var(--color-text) var(--muted), transparent); padding: 6px 10px; }
.class-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: none; border-radius: var(--radius);
  font: inherit; font-size: 14px; text-align: left;
  color: var(--color-text); background: transparent; cursor: pointer;
}
.class-btn .count { margin-left: auto; font-size: 12px; color: color-mix(in srgb, var(--color-text) var(--muted), transparent); }
.class-btn:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); }
.class-btn.on { color: var(--color-accent-300); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.new-class { color: var(--color-accent-300); }
.new-class-form { display: flex; flex-direction: column; gap: 8px; padding: 6px 4px; }
.new-class-form .row { display: flex; gap: 6px; }
.new-class-form .btn { height: 32px; font-size: 13px; }

.code-card { margin-top: auto; padding: 14px; gap: 6px; }
.code-big { font: 500 18px ui-monospace, Menlo, monospace; letter-spacing: 0.12em; }
.code-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.code-actions .btn { font-size: 12px; }
.confirm { font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.confirm .row { display: flex; gap: 6px; }

.me-row { display: flex; align-items: center; gap: 8px; padding: 12px 6px 0; font-size: 13px; }
.me-row .who { flex: 1; min-width: 0; line-height: 1.25; }
.me-row .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-row .role { font-size: 11px; color: color-mix(in srgb, var(--color-text) var(--muted), transparent); }
.me-row .btn { font-size: 12px; padding: 4px 6px; white-space: nowrap; }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; gap: 18px; padding: 22px 28px; min-width: 0; }
#class-view { display: flex; flex-direction: column; gap: 18px; }
.main-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.main-head .title { margin-right: auto; }
.main-head h2 { margin: 0; font-size: 22px; }
.search { width: 220px; }
#lb-link { text-decoration: none; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; gap: 2px; box-shadow: var(--shadow-sm); }
.stat .label { font-size: 11px; color: color-mix(in srgb, var(--color-text) var(--muted), transparent); }
.stat .num { font-size: 26px; font-weight: 500; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) var(--muted), transparent); padding: 8px; white-space: nowrap;
  border-bottom: 1px solid var(--color-divider);
}
.table td { padding: 7px 8px; border-bottom: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent); white-space: nowrap; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
.table tbody tr.on { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.table .num-col { text-align: right; }
.learner-cell { display: flex; align-items: center; gap: 8px; }
.mini-avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--color-neutral-700); flex: none; }
.pts-cell { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; }
.pts-input { width: 84px; height: 28px; padding: 2px 8px; text-align: right; font-size: 13px; }
.icon-btn { width: 28px; height: 28px; padding: 0; border: none; border-radius: 6px; background: transparent; color: var(--color-accent); cursor: pointer; font-size: 14px; }
.icon-btn:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.muted { color: color-mix(in srgb, var(--color-text) var(--muted), transparent); }

.empty { padding: 28px; text-align: center; gap: 10px; box-shadow: var(--shadow-sm); align-items: center; }
.empty .code-big { font-size: 26px; }
.first-class { max-width: 460px; padding: 28px; gap: 14px; box-shadow: var(--shadow-md); }
.first-class .row { display: flex; gap: 10px; }

/* ---------- learner panel ---------- */
.panel { display: flex; flex-direction: column; gap: 14px; padding: 22px; background: var(--color-surface); min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 12px; }
.big-avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; background: var(--color-accent-800); color: var(--color-accent-100); flex: none; }
.panel-name { font-size: 18px; font-weight: 500; }
.panel-sub { font-size: 12px; color: color-mix(in srgb, var(--color-text) var(--muted), transparent); overflow-wrap: anywhere; }
.section-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: color-mix(in srgb, var(--color-text) var(--muted), transparent); margin-top: 4px; }
.level-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.level-row .sub { flex: 1; }
.level-row .bar { width: 60px; height: 4px; border-radius: 2px; background: var(--color-neutral-800); overflow: hidden; }
.level-row .bar span { display: block; height: 100%; background: var(--color-accent); }
.level-row .v { width: 22px; text-align: center; font-weight: 500; font-size: 14px; }
.step-btn { width: 26px; height: 26px; padding: 0; border-radius: 6px; border: 1px solid var(--color-divider); background: transparent; color: var(--color-text); cursor: pointer; font-size: 15px; line-height: 1; }
.step-btn:hover:not(:disabled) { border-color: var(--color-accent); color: var(--color-accent); }
.step-btn:disabled { opacity: 0.3; cursor: default; }
.recent-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.recent-row .g { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row .p { width: 44px; text-align: right; font-weight: 500; }
.temp-box { padding: 12px; gap: 6px; background: var(--color-accent-900); box-shadow: inset 0 0 0 1px var(--color-accent-700); }
.temp-pw { font: 500 20px ui-monospace, Menlo, monospace; letter-spacing: 0.06em; }
.panel-empty { color: color-mix(in srgb, var(--color-text) var(--muted), transparent); font-size: 14px; text-align: center; margin-top: 40px; }

/* ---------- pop-up box ---------- */
.dialog-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: var(--backdrop); }
.dialog { width: min(460px, 100%); padding: 24px; gap: 12px; box-shadow: var(--shadow-lg); }
.dialog ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.dialog .code-big { font-size: 28px; text-align: center; padding: 10px; border-radius: var(--radius); background: var(--color-bg); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  padding: 10px 16px; border-radius: var(--radius); font-size: 14px;
  background: var(--color-accent-800); color: var(--color-accent-100); box-shadow: var(--shadow-md);
}

/* ---------- smaller screens ---------- */
@media (max-width: 1150px) {
  .dash { grid-template-columns: 220px minmax(0, 1fr); }
  .panel { grid-column: 2; }
}
@media (max-width: 860px) {
  .b1-page { grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 24px 18px; }
  .b1-left h1 { font-size: 32px; margin-top: 8px; }
  .b1-card { padding: 22px; }
  .two-col { grid-template-columns: 1fr; }
  .tabs { display: flex; align-self: stretch; }
  .tabs .seg-opt { flex: 1; padding: 8px 6px; }

  .dash { display: flex; flex-direction: column; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px; }
  .side .brand { padding: 0 6px 0 2px; }
  .side-label, .me-row .who { display: none; }
  .side .brand { margin-right: auto; }
  .side-top { margin-right: auto; align-items: center; }
  .side-top .theme-btn { margin-top: 0; }
  #class-list { order: 5; flex-basis: 100%; display: flex; gap: 6px; overflow-x: auto; }
  #class-list .class-btn { flex: none; }
  .new-class { order: 6; }
  .code-card { order: 7; }
  .new-class-form { order: 6; }
  .table th:last-child, .table td:last-child { display: none; }
  .new-class-form { flex-basis: 100%; }
  .code-card { margin-top: 0; flex-basis: 100%; flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap; }
  .me-row { padding: 0; }
  .main { padding: 16px 12px; }
  .search { width: 100%; }
  .stats { gap: 8px; }
  .stat { padding: 10px; }
  .stat .num { font-size: 20px; }
  .panel { padding: 16px 12px; }
}

/* Loading placeholders */
.dash-skeleton { display: flex; flex-direction: column; gap: 12px; }
.dash-skeleton .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
