/* Catppuccin Latte (light) */
:root,
[data-theme="latte"] {
  --ctp-rosewater: #dc8a78;
  --ctp-flamingo: #dd7878;
  --ctp-pink: #ea76cb;
  --ctp-mauve: #8839ef;
  --ctp-red: #d20f39;
  --ctp-maroon: #e64553;
  --ctp-peach: #fe640b;
  --ctp-yellow: #df8e1d;
  --ctp-green: #40a02b;
  --ctp-teal: #179299;
  --ctp-sky: #04a5e5;
  --ctp-sapphire: #209fb5;
  --ctp-blue: #1e66f5;
  --ctp-lavender: #7287fd;
  --ctp-text: #4c4f69;
  --ctp-subtext1: #5c5f77;
  --ctp-subtext0: #6c6f85;
  --ctp-overlay2: #7c7f93;
  --ctp-overlay1: #8c8fa1;
  --ctp-overlay0: #9ca0b0;
  --ctp-surface2: #acb0be;
  --ctp-surface1: #bcc0cc;
  --ctp-surface0: #ccd0da;
  --ctp-base: #eff1f5;
  --ctp-mantle: #e6e9ef;
  --ctp-crust: #dce0e8;

  --bg: var(--ctp-base);
  --bg-alt: var(--ctp-mantle);
  --bg-card: #ffffff;
  --border: var(--ctp-surface0);
  --text: var(--ctp-text);
  --text-muted: var(--ctp-subtext0);
  --accent: var(--ctp-blue);
  --accent-hover: var(--ctp-sapphire);
  --success: var(--ctp-green);
  --warning: var(--ctp-yellow);
  --danger: var(--ctp-red);
  --half: var(--ctp-peach);
  --shadow: rgba(76, 79, 105, 0.12);
}

/* Catppuccin Frappe (dark) */
[data-theme="frappe"] {
  --ctp-rosewater: #f2d5cf;
  --ctp-flamingo: #eebebe;
  --ctp-pink: #f4b8e4;
  --ctp-mauve: #ca9ee6;
  --ctp-red: #e78284;
  --ctp-maroon: #ea999c;
  --ctp-peach: #ef9f76;
  --ctp-yellow: #e5c890;
  --ctp-green: #a6d189;
  --ctp-teal: #81c8be;
  --ctp-sky: #99d1db;
  --ctp-sapphire: #85c1dc;
  --ctp-blue: #8caaee;
  --ctp-lavender: #babbf1;
  --ctp-text: #c6d0f5;
  --ctp-subtext1: #b5bfe2;
  --ctp-subtext0: #a5adce;
  --ctp-overlay2: #949cbb;
  --ctp-overlay1: #838ba7;
  --ctp-overlay0: #737994;
  --ctp-surface2: #626880;
  --ctp-surface1: #51576d;
  --ctp-surface0: #414559;
  --ctp-base: #303446;
  --ctp-mantle: #292c3c;
  --ctp-crust: #232634;

  --bg: var(--ctp-base);
  --bg-alt: var(--ctp-mantle);
  --bg-card: var(--ctp-crust);
  --border: var(--ctp-surface0);
  --text: var(--ctp-text);
  --text-muted: var(--ctp-subtext0);
  --accent: var(--ctp-blue);
  --accent-hover: var(--ctp-lavender);
  --success: var(--ctp-green);
  --warning: var(--ctp-yellow);
  --danger: var(--ctp-red);
  --half: var(--ctp-peach);
  --shadow: rgba(0, 0, 0, 0.3);
}

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

img, video { max-width: 100%; border-radius: 8px; }

/* Layout */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

.container--narrow { max-width: 640px; }
.container--wide { max-width: 1400px; }

/* Navbar */
.navbar {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar__brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s, border-color 0.15s;
}

.theme-toggle:hover { background: var(--border); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px var(--shadow);
}

.card--flat { box-shadow: none; }
.card + .card { margin-top: 1rem; }

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.card__title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--success { background: var(--success); color: #fff; }
.btn--danger  { background: var(--danger); color: #fff; }
.btn--warning { background: var(--warning); color: #fff; }
.btn--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn--ghost:hover { background: var(--bg-alt); }

.btn--sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn--lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn--full { width: 100%; justify-content: center; }
.btn--icon { padding: 0.5rem; }

/* Grade buttons */
.btn--correct { background: var(--success); color: #fff; }
.btn--half    { background: var(--half); color: #fff; }
.btn--wrong   { background: var(--danger); color: #fff; }

/* Forms */
.form-group { margin-bottom: 1rem; }

label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 80px; }

input[type="checkbox"], input[type="radio"] {
  width: auto;
  accent-color: var(--accent);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Alerts / flash messages */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.alert--error   { background: color-mix(in srgb, var(--danger) 15%, var(--bg)); border: 1px solid var(--danger); color: var(--danger); }
.alert--success { background: color-mix(in srgb, var(--success) 15%, var(--bg)); border: 1px solid var(--success); color: var(--success); }
.alert--info    { background: color-mix(in srgb, var(--accent) 15%, var(--bg)); border: 1px solid var(--accent); color: var(--accent); }
.alert--warning { background: color-mix(in srgb, var(--warning) 15%, var(--bg)); border: 1px solid var(--warning); color: var(--warning); }

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-alt);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:hover td { background: var(--bg-alt); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--draft    { background: color-mix(in srgb, var(--text-muted) 20%, var(--bg)); color: var(--text-muted); }
.badge--active   { background: color-mix(in srgb, var(--success) 20%, var(--bg)); color: var(--success); }
.badge--finished { background: color-mix(in srgb, var(--accent) 20%, var(--bg)); color: var(--accent); }

/* Quiz phases */
.phase-banner {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
}

.phase-banner__title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.phase-banner__sub {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Timer */
.timer {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin: 1rem 0;
}

.timer--warning { color: var(--warning); }
.timer--danger  { color: var(--danger); }

/* Question display */
.question-card {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 1.5rem;
}

.question-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.question-card__text {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* Answer options (MC) */
.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--bg);
}

.option-item:hover { border-color: var(--accent); }
.option-item input { width: auto; flex-shrink: 0; }
.option-item--selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }

/* Scoreboard */
.scoreboard { display: flex; flex-direction: column; gap: 0.5rem; }

.score-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.score-row__rank {
  font-size: 1.1rem;
  font-weight: 800;
  width: 2rem;
  text-align: center;
  color: var(--accent);
}

.score-row__name { flex: 1; font-weight: 600; }

.score-row__points {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.score-row--first  { border-color: #f1c40f; background: color-mix(in srgb, #f1c40f 8%, var(--bg-card)); }
.score-row--second { border-color: #bdc3c7; background: color-mix(in srgb, #bdc3c7 8%, var(--bg-card)); }
.score-row--third  { border-color: #cd6133; background: color-mix(in srgb, #cd6133 8%, var(--bg-card)); }

/* Help button */
.help-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--warning);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  z-index: 50;
}

.help-btn:hover { transform: scale(1.1); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px var(--shadow);
}

.modal__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* Waiting room */
.waiting-room {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 1.5rem;
}

.waiting-room__pulse {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 20%, var(--bg));
  border: 3px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.7; }
}

/* Splash screen */
.splash {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.5rem;
}

.splash__image {
  max-height: 300px;
  width: auto;
  border-radius: 12px;
  object-fit: cover;
}

.splash__round-number {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.splash__title {
  font-size: 2.5rem;
  font-weight: 800;
}

/* Admin grading */
.grading-table td { vertical-align: middle; }

.grade-controls {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* Answer review (end of round) */
.review-question {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg-card);
}

.review-question__answer-box {
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

/* Grid helpers */
.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Flex helpers */
.flex { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.flex--between { justify-content: space-between; }
.flex--center  { justify-content: center; }
.flex--col     { flex-direction: column; align-items: stretch; }

/* Spacing */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.text-sm     { font-size: 0.85rem; }
.text-lg     { font-size: 1.2rem; }
.fw-bold     { font-weight: 700; }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
}

.login-box {
  width: 100%;
  max-width: 400px;
}

.login-box__logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-box__logo-icon {
  font-size: 3rem;
  color: var(--accent);
  display: block;
  margin-bottom: 0.5rem;
}

.login-box__logo-title {
  font-size: 1.5rem;
  font-weight: 800;
}

/* Admin sidebar layout */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 57px);
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
}

.sidebar__nav { list-style: none; }

.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  color: var(--text);
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar__nav a:hover, .sidebar__nav a.active {
  background: var(--bg-card);
  border-left-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.admin-content {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

/* Help requests indicator */
.help-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  width: 1.2rem;
  height: 1.2rem;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: auto;
}

/* Video container */
.video-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

video { display: block; width: 100%; }

/* Definitive answer indicator */
.answer-definitive {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
}

/* Pagination / step indicators */
.question-progress {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
  margin: 1rem 0;
}

.question-progress__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.question-progress__dot--done     { background: var(--success); }
.question-progress__dot--active   { background: var(--accent); }
.question-progress__dot--skipped  { background: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
  }

  .sidebar__nav { display: flex; overflow-x: auto; padding: 0 0.5rem; }

  .sidebar__nav a {
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 0.5rem 0.75rem;
  }

  .sidebar__nav a:hover, .sidebar__nav a.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .phase-banner__title { font-size: 1.4rem; }
  .splash__title { font-size: 1.8rem; }
  .timer { font-size: 2rem; }
  .card { padding: 1rem; }
}
