/* ─────────────────────────────────────────────────────────────
   portal.css — sign-in screen and project dashboard.

   Deliberately separate from styles.css (the IDE's VS Code look): these
   two pages are the "front door" of the classroom, so they get their own,
   warmer visual language. Same accent teal as the IDE.

   Theme: html[data-theme="light"] flips the tokens, exactly like the IDE.
   ───────────────────────────────────────────────────────────── */

:root {
  --p-bg: #0d1117;
  --p-bg-2: #11161d;
  --p-surface: #161c24;
  --p-surface-2: #1c232d;
  --p-border: #253040;
  --p-text: #e6edf3;
  --p-dim: #93a1b1;
  --p-accent: #0e9ea6;
  --p-accent-2: #22d3ee;
  --p-green: #3fb950;
  --p-red: #f0596b;
  --p-amber: #d9a23b;
  --p-shadow: 0 24px 60px #00000066;
  --p-font: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  --p-mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;
}

html[data-theme="light"] {
  --p-bg: #f4f7fa;
  --p-bg-2: #eaf0f6;
  --p-surface: #ffffff;
  --p-surface-2: #f7f9fc;
  --p-border: #dbe3ec;
  --p-text: #17212b;
  --p-dim: #61707f;
  --p-accent: #0b8790;
  --p-accent-2: #0891b2;
  --p-shadow: 0 18px 44px #0b203318;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--p-bg);
  color: var(--p-text);
  font-family: var(--p-font);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(900px 520px at 12% -10%, #0e9ea61f, transparent 60%),
    radial-gradient(760px 460px at 92% 0%, #22d3ee14, transparent 60%);
  background-repeat: no-repeat;
}

a { color: var(--p-accent-2); }

code { font-family: var(--p-mono); font-size: 0.93em; }

/* ══════════════════ shared bits ══════════════════ */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: 0.2px;
}
.brand .mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--p-accent), #0b6b72);
  color: #eafcfd;
  box-shadow: 0 4px 16px #0e9ea655;
  flex: none;
}
.brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--p-dim);
  letter-spacing: 0.3px;
}

.pbtn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  color: #041d20;
  background: linear-gradient(180deg, var(--p-accent-2), var(--p-accent));
  transition: transform 0.08s, filter 0.15s, box-shadow 0.15s;
  box-shadow: 0 6px 18px #0e9ea63d;
}
.pbtn:hover { filter: brightness(1.06); }
.pbtn:active { transform: translateY(1px); }
.pbtn:disabled { opacity: 0.55; cursor: default; box-shadow: none; }

.pbtn-ghost {
  background: transparent;
  border-color: var(--p-border);
  color: var(--p-text);
  box-shadow: none;
}
.pbtn-ghost:hover { background: var(--p-surface-2); filter: none; }

.pbtn-danger {
  background: transparent;
  border-color: #f0596b55;
  color: var(--p-red);
  box-shadow: none;
}
.pbtn-danger:hover { background: #f0596b14; }

.pbtn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }

.ptag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid var(--p-border);
  color: var(--p-dim);
  background: var(--p-surface-2);
  white-space: nowrap;
}
.ptag.ok { color: var(--p-green); border-color: #3fb95044; background: #3fb95014; }
.ptag.bad { color: var(--p-red); border-color: #f0596b44; background: #f0596b14; }
.ptag.warn { color: var(--p-amber); border-color: #d9a23b44; background: #d9a23b14; }
.ptag.on { color: var(--p-accent-2); border-color: #22d3ee44; background: #22d3ee14; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #04181a;
  flex: none;
  background: linear-gradient(145deg, var(--p-accent-2), var(--p-accent));
  text-transform: uppercase;
}
.avatar.student { background: linear-gradient(145deg, #a78bfa, #6366f1); color: #0f1020; }

.dot-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--p-green);
  box-shadow: 0 0 0 3px #3fb95022;
  display: inline-block;
}
.dot-online.off { background: #4a5563; box-shadow: none; }

/* ══════════════════ sign-in ══════════════════ */

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 460px;
  gap: 0;
  align-items: stretch;
}

.auth-hero {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 46px 54px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 26px;
  border-right: 1px solid var(--p-border);
  background:
    radial-gradient(700px 420px at 20% 15%, #0e9ea62e, transparent 65%),
    linear-gradient(160deg, #0b1a20, var(--p-bg));
}
html[data-theme="light"] .auth-hero {
  background: radial-gradient(700px 420px at 20% 15%, #0e9ea61f, transparent 65%), linear-gradient(160deg, #e8f4f6, var(--p-bg));
}

/* the same hexagon motif as the IDE logo, big and faint */
.auth-hero::after {
  content: "";
  position: absolute;
  inset: -10% -20% auto auto;
  width: 620px;
  height: 620px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='104' viewBox='0 0 120 104'%3E%3Cg fill='none' stroke='%230e9ea6' stroke-opacity='0.30' stroke-width='1'%3E%3Cpath d='M30 2 60 19v34L30 70 0 53V19z'/%3E%3Cpath d='M90 2 120 19v34L90 70 60 53V19z'/%3E%3Cpath d='M60 70 90 87v34L60 138 30 121V87z'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
  pointer-events: none;
}

.auth-hero h1 {
  position: relative;
  margin: 0 0 14px;
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.8px;
}

.auth-hero .eyebrow {
  position: relative;
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--p-accent-2);
}

.auth-hero .signature {
  position: relative;
  margin: 16px 0 0;
  font-size: 12.5px;
  color: var(--p-dim);
}
.auth-hero .signature b { color: var(--p-text); font-weight: 600; }
.auth-hero h1 em {
  font-style: normal;
  background: linear-gradient(90deg, var(--p-accent-2), #7dd3fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-hero p.lead {
  position: relative;
  max-width: 46ch;
  color: var(--p-dim);
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}
.auth-points {
  position: relative;
  display: grid;
  gap: 12px;
  margin-top: 28px;
  max-width: 470px;
}
.auth-point {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
  padding: 13px 15px;
  border: 1px solid var(--p-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--p-surface) 78%, transparent);
  backdrop-filter: blur(6px);
}
.auth-point .ico {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #0e9ea61f;
  color: var(--p-accent-2);
  font-size: 15px;
}
.auth-point b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.auth-point span { font-size: 12.5px; color: var(--p-dim); line-height: 1.5; }

.auth-hero footer {
  position: relative;
  font-size: 12px;
  color: var(--p-dim);
}

.auth-side {
  display: grid;
  place-items: center;
  padding: 40px 34px;
  background: var(--p-bg-2);
}

.auth-card {
  width: 100%;
  max-width: 372px;
}

.auth-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.3px;
}
.auth-card .sub {
  margin: 0 0 24px;
  color: var(--p-dim);
  font-size: 13px;
  line-height: 1.5;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--p-dim);
  margin-bottom: 6px;
}
.field .wrap { position: relative; }
.field input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--p-border);
  background: var(--p-surface);
  color: var(--p-text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input::placeholder { color: color-mix(in srgb, var(--p-dim) 75%, transparent); }
.field input:focus {
  border-color: var(--p-accent);
  box-shadow: 0 0 0 3px #0e9ea62b;
}
.field .eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--p-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 6px;
}
.field .eye:hover { background: var(--p-surface-2); color: var(--p-text); }

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 18px;
  font-size: 12.5px;
  color: var(--p-dim);
}
.auth-row label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.auth-row input[type="checkbox"] { accent-color: var(--p-accent); }

.auth-card .pbtn { width: 100%; padding: 12px; font-size: 14px; }

.p-error {
  display: none;
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid #f0596b55;
  background: #f0596b14;
  color: #ffb3bd;
  font-size: 12.5px;
  line-height: 1.45;
}
.p-error.show { display: block; }
html[data-theme="light"] .p-error { color: #9d2130; }

.auth-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--p-border);
  font-size: 12px;
  color: var(--p-dim);
  line-height: 1.6;
}
.auth-foot code {
  background: var(--p-surface-2);
  border: 1px solid var(--p-border);
  padding: 1px 5px;
  border-radius: 5px;
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-side { min-height: 100vh; padding: 28px 20px; }
  .auth-card { max-width: 392px; }
}

/* ══════════════════ dashboard ══════════════════ */

.dash-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 26px;
  background: color-mix(in srgb, var(--p-bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--p-border);
}

.dash-nav { display: flex; gap: 4px; margin-left: 8px; }
.dash-nav button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--p-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
}
.dash-nav button:hover { color: var(--p-text); background: var(--p-surface-2); }
.dash-nav button.active {
  color: var(--p-text);
  background: var(--p-surface);
  border-color: var(--p-border);
}

.dash-top .spacer { flex: 1; }

.usermenu { position: relative; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--p-border);
  background: var(--p-surface);
  color: var(--p-text);
  padding: 5px 11px 5px 6px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.user-chip:hover { border-color: var(--p-accent); }
.user-chip .who { display: grid; text-align: left; line-height: 1.15; }
.user-chip .who small { color: var(--p-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; }

.usermenu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 208px;
  padding: 6px;
  border-radius: 11px;
  border: 1px solid var(--p-border);
  background: var(--p-surface);
  box-shadow: var(--p-shadow);
  z-index: 30;
}
.usermenu-pop button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--p-text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.usermenu-pop button:hover { background: var(--p-surface-2); }
.usermenu-pop .sep { height: 1px; background: var(--p-border); margin: 5px 2px; }

.dash-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 34px 26px 70px;
}

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.dash-head h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.5px; }
.dash-head p { margin: 0; color: var(--p-dim); font-size: 13.5px; }
.dash-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

.toolbar-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar-row input[type="search"] {
  flex: 1;
  min-width: 200px;
  max-width: 340px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--p-border);
  background: var(--p-surface);
  color: var(--p-text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.toolbar-row input[type="search"]:focus { border-color: var(--p-accent); box-shadow: 0 0 0 3px #0e9ea62b; }

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
}

.pcard {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 13px;
  border: 1px solid var(--p-border);
  background: linear-gradient(180deg, var(--p-surface), color-mix(in srgb, var(--p-surface) 80%, var(--p-bg)));
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  min-height: 158px;
}
.pcard:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--p-accent) 60%, var(--p-border));
  box-shadow: 0 14px 34px #00000030;
}
.pcard .top { display: flex; align-items: flex-start; gap: 10px; }
.pcard .thumb {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: #0e9ea61f;
  color: var(--p-accent-2);
  border: 1px solid #0e9ea633;
}
.pcard h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.2px;
  word-break: break-word;
}
.pcard .meta { font-size: 11.5px; color: var(--p-dim); margin-top: 3px; }
.pcard .stats {
  display: flex;
  gap: 12px;
  font-size: 11.5px;
  color: var(--p-dim);
  flex-wrap: wrap;
}
.pcard .stats b { color: var(--p-text); font-weight: 600; }
.pcard .bar {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--p-border-soft, var(--p-border));
}
.pcard .when { font-size: 11.5px; color: var(--p-dim); }
.pcard .row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.12s; }
.pcard:hover .row-actions, .pcard:focus-within .row-actions { opacity: 1; }
.iconbtn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--p-dim);
  border-radius: 7px;
  padding: 4px 6px;
  font-size: 12.5px;
  cursor: pointer;
  line-height: 1;
}
.iconbtn:hover { background: var(--p-surface-2); color: var(--p-text); border-color: var(--p-border); }
.iconbtn.danger:hover { color: var(--p-red); border-color: #f0596b55; }

.newcard {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 6px;
  border: 1.5px dashed var(--p-border);
  background: transparent;
  min-height: 158px;
  color: var(--p-dim);
}
.newcard:hover {
  border-color: var(--p-accent);
  color: var(--p-text);
  background: #0e9ea60d;
  transform: translateY(-2px);
}
.newcard .plus {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  border: 1px solid var(--p-border);
  background: var(--p-surface);
  color: var(--p-accent-2);
}
.newcard b { font-size: 13.5px; color: var(--p-text); }
.newcard span { font-size: 11.5px; }

.empty {
  padding: 46px 20px;
  text-align: center;
  border: 1px dashed var(--p-border);
  border-radius: 14px;
  color: var(--p-dim);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ── teacher: students table ── */

.monitor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px 0 16px;
}
.monitor-head .stat {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1px solid var(--p-border);
  background: var(--p-surface);
}
.monitor-head .stat b { font-size: 18px; }
.monitor-head .stat span { font-size: 11.5px; color: var(--p-dim); text-transform: uppercase; letter-spacing: 0.4px; }

.students { display: grid; gap: 10px; }

.student {
  border: 1px solid var(--p-border);
  border-radius: 12px;
  background: var(--p-surface);
  overflow: hidden;
}
.student-head {
  display: grid;
  grid-template-columns: 30px minmax(130px, 1.2fr) repeat(4, minmax(64px, 0.7fr)) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 15px;
  cursor: pointer;
}
.student-head:hover { background: var(--p-surface-2); }
.student-head .name { display: grid; line-height: 1.25; }
.student-head .name b { font-size: 13.5px; }
.student-head .name small { color: var(--p-dim); font-size: 11.5px; }
.student-head .num { font-size: 13px; }
.student-head .num small { display: block; font-size: 10.5px; color: var(--p-dim); text-transform: uppercase; letter-spacing: 0.4px; }
.student-body {
  display: none;
  padding: 4px 15px 15px;
  border-top: 1px solid var(--p-border);
  background: color-mix(in srgb, var(--p-bg-2) 55%, transparent);
}
.student.open .student-body { display: block; }
.student-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--p-border) 60%, transparent);
  font-size: 12.5px;
}
.student-row:last-child { border-bottom: 0; }
.student-row .grow { flex: 1; min-width: 0; }
.student-row .pname { font-weight: 600; font-size: 13px; }
.student-row .pmeta { color: var(--p-dim); font-size: 11.5px; }
.student-row .actions { display: flex; gap: 6px; }

/* ══════════════════ modal + toast ══════════════════ */

.pmodal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #000000a8;
  backdrop-filter: blur(3px);
}
.pmodal[hidden] { display: none; }
.pmodal-card {
  width: min(430px, 100%);
  border-radius: 15px;
  border: 1px solid var(--p-border);
  background: var(--p-surface);
  box-shadow: var(--p-shadow);
  padding: 22px;
}
.pmodal-card h3 { margin: 0 0 4px; font-size: 17px; }
.pmodal-card .hint { margin: 0 0 18px; color: var(--p-dim); font-size: 12.5px; line-height: 1.5; }
.pmodal-card select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--p-border);
  background: var(--p-surface-2);
  color: var(--p-text);
  font: inherit;
  font-size: 13.5px;
}
.pmodal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

.ptoast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: grid;
  gap: 8px;
}
.ptoast {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--p-border);
  background: var(--p-surface);
  box-shadow: var(--p-shadow);
  font-size: 13px;
  animation: ptoast-in 0.18s ease-out;
  max-width: 340px;
}
.ptoast.ok { border-color: #3fb95055; color: var(--p-green); }
.ptoast.warn { border-color: #d9a23b55; color: var(--p-amber); }
@keyframes ptoast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.themebtn {
  border: 1px solid var(--p-border);
  background: var(--p-surface);
  color: var(--p-dim);
  border-radius: 9px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 14px;
}
.themebtn:hover { color: var(--p-text); border-color: var(--p-accent); }

@media (max-width: 760px) {
  .student-head { grid-template-columns: 30px 1fr auto; }
  .student-head .num { display: none; }
  .dash-top { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .dash-wrap { padding: 22px 14px 60px; }
  .user-chip .who { display: none; }
  .pcard .row-actions { opacity: 1; }
}
