/* Tokens */
:root {
  --bg: #eef1f4;
  --bg-2: #dde3ea;
  --card: #ffffff;
  --card-solid: #ffffff;
  --text: #1f2d3d;
  --muted: #607088;
  --line: #d7dee6;
  --primary: #2f80ed;
  --primary-dark: #1f6ed6;
  --accent: #2f80ed;
  --danger: #d64545;
  --shadow: 0 8px 18px rgba(31, 45, 61, 0.08);
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius-panel: 16px;
}

/* Base */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(37, 99, 235, 0.06), transparent 32%),
    radial-gradient(circle at 100% 100%, rgba(14, 165, 233, 0.06), transparent 34%),
    var(--bg);
}

h1,
h2,
h3,
h4 {
  font-family: "Sora", sans-serif;
  margin: 0;
}

p {
  margin: 0;
}

.hidden {
  display: none !important;
}

/* Auth */
.auth-shell {
  position: relative;
  min-height: 100vh;
  padding: 36px 22px;
  display: grid;
  place-items: center;
}

.auth-container {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: stretch;
}

.auth-copy,
.auth-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.auth-copy {
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-card {
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e40af;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.auth-copy h1 {
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.16;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

.lead {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
  margin-bottom: 18px;
}

.auth-points {
  margin: 0;
  padding-left: 20px;
  color: #334155;
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.auth-card h2 {
  font-size: 28px;
  margin-bottom: 8px;
}

.auth-card-subtitle {
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.55;
}

#auth-status {
  min-height: 24px;
  margin-top: 12px;
  color: #9f1239;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.22), transparent 30%),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.2), transparent 34%),
    linear-gradient(135deg, #0b1220 0%, #111827 46%, #172554 100%);
  display: grid;
  place-items: center;
}

.welcome-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, transparent, black 14%, black 86%, transparent);
  animation: drift-grid 14s linear infinite;
}

.welcome-glow {
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 999px;
  filter: blur(16px);
  opacity: 0.7;
}

.welcome-glow-a {
  top: -90px;
  right: -40px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.5), transparent 68%);
  animation: float-glow 7s ease-in-out infinite alternate;
}

.welcome-glow-b {
  bottom: -120px;
  left: -40px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.4), transparent 68%);
  animation: float-glow 9s ease-in-out infinite alternate-reverse;
}

.welcome-panel {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100vw - 48px));
  text-align: center;
  color: #f8fafc;
  padding: 40px 28px;
}

.welcome-kicker {
  margin-bottom: 18px;
  color: rgba(191, 219, 254, 0.88);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.welcome-panel h1 {
  font-size: clamp(46px, 8vw, 92px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-shadow: 0 18px 50px rgba(15, 23, 42, 0.44);
}

.welcome-subtitle {
  margin-top: 18px;
  color: rgba(226, 232, 240, 0.92);
  font-size: clamp(16px, 2vw, 22px);
}

/* App Shell */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand-block p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.topbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

#user-pill {
  background: #0f172a0d;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: calc(100vh - 78px);
}

.sidebar {
  background: linear-gradient(180deg, #1f2d3a, #1a2733);
  color: #d7e3f1;
  border-right: 1px solid #1b2733;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 78px);
}

.sidebar-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8fa1b3;
  margin-bottom: 8px;
}

.tab-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d7e3f1;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font-weight: 600;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.tab-btn:hover {
  background: #2d3d4d;
}

.tab-btn.active {
  background: #2f80ed;
  border-color: #2f80ed;
  color: #ffffff;
}

.content {
  padding: 24px;
  width: min(1320px, 100%);
  margin: 0 auto;
}

.class-picker-page {
  min-height: calc(100vh - 78px);
  padding: 28px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 26%),
    radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.08), transparent 30%),
    var(--bg);
}

.class-picker-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 28px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(14px);
}

/* Shared Layout */
.tab {
  display: none;
  animation: fade-up 0.2s ease;
}

.tab.active {
  display: block;
}

.card {
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}

.card h3 {
  margin-bottom: 12px;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.picker-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(16, 35, 63, 0.12);
}

.btn.primary {
  border-color: transparent;
  background: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.danger {
  border-color: transparent;
  background: linear-gradient(90deg, #dc2626, #b91c1c);
  color: white;
}

.btn.wide {
  width: 100%;
}

/* Status + Header Bars */
.banner {
  min-height: 40px;
  margin-bottom: 16px;
  color: #1f2d3d;
  font-weight: 600;
  background: linear-gradient(180deg, #f8fbff, #f1f5f9);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 12px;
}

.class-code-wrap {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.class-code-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.class-code-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: #2f80ed;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.08em;
  min-width: 110px;
  justify-content: center;
}

/* Screens + Students */
.screens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.screen-card {
  border: 1px solid #dbe5f0;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  transition: transform 0.16s ease, box-shadow 0.2s ease;
}

.screen-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(16, 35, 63, 0.16);
}

.screen-card img {
  width: 100%;
  height: 166px;
  object-fit: cover;
  background: var(--bg-2);
}

.screen-unavailable {
  width: 100%;
  height: 166px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: linear-gradient(180deg, #e2e8f0, #cbd5e1);
  color: #1e293b;
}

.screen-unavailable strong {
  font-size: 14px;
}

.screen-unavailable span {
  font-size: 12px;
  color: #475569;
  word-break: break-word;
}

.screen-meta {
  padding: 12px;
  font-size: 14px;
}

.screen-tabs-preview {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f8fafc;
}

.student-row:last-child {
  margin-bottom: 0;
}

.admin-shell {
  display: grid;
  gap: 14px;
}

.admin-overview p {
  color: var(--muted);
  margin-top: 6px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.admin-stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.admin-stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-stat strong {
  font-size: 24px;
  line-height: 1;
  color: #0f172a;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-panel-card {
  margin-bottom: 0;
  padding: 16px;
}

.admin-panel-wide {
  grid-column: 1 / -1;
}

.admin-panel-head {
  margin-bottom: 10px;
}

.admin-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
}

.admin-row-main {
  min-width: 0;
}

.admin-row-title {
  font-weight: 700;
  color: #0f172a;
}

.admin-row-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.admin-empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  background: #f8fafc;
}

.admin-controls {
  display: flex;
  gap: 8px;
  margin: 8px 0 14px;
}

.admin-controls input {
  margin-bottom: 0;
}

.approval-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.approve-select {
  width: 180px;
  margin: 0;
}

/* Forms */
.managed-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 6px 0 14px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #fdba74;
  background: #fff7ed;
}

textarea,
input,
select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin: 6px 0 12px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
}

textarea:focus,
input:focus,
select:focus {
  outline: 2px solid #fdba74;
  border-color: #fb923c;
}

.category-dropdown {
  min-height: 210px;
  background: #fffdf8;
}

.category-dropdown option {
  padding: 8px;
}

.form-help {
  color: var(--muted);
  font-size: 13px;
  margin-top: -6px;
  margin-bottom: 12px;
}

.settings-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  margin-bottom: 14px;
  overflow: hidden;
}

.settings-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 0;
  background: #eef4fb;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.settings-chevron {
  font-size: 18px;
  transition: transform 0.18s ease;
}

.settings-group.collapsed .settings-chevron {
  transform: rotate(-90deg);
}

.settings-panel {
  padding: 16px 16px 6px;
}

.settings-group.collapsed .settings-panel {
  display: none;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.58);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}

.modal-content {
  width: min(560px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid #ffffff88;
  padding: 20px;
  box-shadow: 0 25px 60px rgba(2, 6, 23, 0.36);
  animation: pop-in 0.24s ease-out;
}

.modal-content.large {
  width: min(980px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
}

.class-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.class-picker-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

/* Classroom Selection */
.class-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.class-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(16, 35, 63, 0.16);
}

.class-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.class-card-checkbox {
  width: auto;
  margin: 0;
}

.class-card-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.class-plus-btn {
  margin-top: 18px;
  width: 110px;
  height: 110px;
  border-radius: 18px;
  border: 2px dashed #fb923c;
  background: #fff7ed;
  color: #f97316;
  font-size: 48px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.class-plus-btn.small {
  width: 52px;
  height: 52px;
  font-size: 32px;
  margin-top: 0;
  border-radius: 12px;
}

.class-students-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  max-height: 220px;
  overflow: auto;
  background: #f8fafc;
  margin-bottom: 12px;
}

.test-mode-links {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.class-student-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-bottom: 1px dashed var(--line);
}

.class-student-row:last-child {
  border-bottom: none;
}

/* Screen Modal */
.screen-modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 14px;
  margin-top: 12px;
}

.screen-modal-left {
  background: #0b1220;
  border-radius: 12px;
  padding: 10px;
}

.screen-modal-right {
  display: flex;
  flex-direction: column;
}

.tabs-browser {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  overflow: hidden;
}

.tabs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#screen-modal-image {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
  background: #0b1220;
  border-radius: 10px;
}

#screen-modal-image.preview-unavailable {
  min-height: 320px;
  background: linear-gradient(180deg, #e2e8f0, #cbd5e1);
  border: 1px solid var(--line);
}

.tabs-panel {
  max-height: 420px;
  overflow: auto;
}

.tab-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  cursor: pointer;
  background: #f8fafc;
}

.tab-row:last-child {
  border-bottom: none;
}

.tab-row.active-tab {
  background: #e0f2fe;
}

.tab-title {
  font-weight: 700;
  color: #0f172a;
}

.tab-url {
  grid-column: 1 / 2;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.tab-close {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  font-weight: 700;
  cursor: pointer;
}

.command-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  position: sticky;
  bottom: 0;
  background: #fff;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.command-bar input {
  margin-bottom: 0;
}

/* Motion */
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(18px);
  }
}

@keyframes drift-grid {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(54px, 54px, 0);
  }
}

@keyframes float-glow {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(20px, -18px, 0) scale(1.08);
  }
}

/* Responsive */
@media (max-width: 980px) {
  .auth-container {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    flex-direction: row;
    overflow-x: auto;
    gap: 10px;
  }

  .sidebar-title {
    display: none;
  }

  .tab-btn {
    min-width: 118px;
  }
}

@media (max-width: 700px) {
  .auth-shell {
    padding: 18px 12px;
  }

  .auth-copy,
  .auth-card {
    padding: 20px;
  }

  .content {
    padding: 14px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .command-bar {
    flex-direction: column;
  }

  .screen-modal-body {
    grid-template-columns: 1fr;
  }

  .class-plus-btn {
    width: 90px;
    height: 90px;
  }

  .admin-controls,
  .approval-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-row {
    flex-direction: column;
    align-items: stretch;
  }

  .managed-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .approve-select {
    width: 100%;
  }
}
