@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   EOC EXAM PORTAL — Design System
   ============================================================ */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a1f35;
  --bg-card-hover: #212845;
  --bg-glass: rgba(30, 41, 72, 0.6);
  --bg-input: #0f1629;
  --border: rgba(99, 130, 191, 0.15);
  --border-focus: rgba(99, 130, 191, 0.4);

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --yellow: #f59e0b;
  --yellow-dim: rgba(245, 158, 11, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);

  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 28px;
}

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

/* ===== HEADER / NAV ===== */
.top-bar {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.95) 0%, rgba(10, 14, 26, 0.95) 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
}

.top-bar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-bar .brand-icon {
  font-size: 1.5rem;
}

.top-bar .brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.top-bar .brand .subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: -2px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.user-badge .role-tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}

.user-badge .role-tag.chair {
  background: var(--accent-glow);
  color: var(--accent-light);
}

.user-badge .role-tag.teacher {
  background: var(--blue-dim);
  color: var(--blue);
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: var(--transition);
}

.card:hover { border-color: var(--border-focus); }
.card.glow { box-shadow: 0 0 30px var(--accent-glow); }

.card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ===== STAT CARDS ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card.accent::before { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.stat-card.green::before  { background: var(--green); }
.stat-card.red::before    { background: var(--red); }
.stat-card.yellow::before { background: var(--yellow); }
.stat-card.blue::before   { background: var(--blue); }

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 4px;
  line-height: 1.1;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  border: none;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }

.btn-success {
  background: var(--green);
  color: #fff;
  border: none;
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
}
.btn-danger:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-focus); background: var(--bg-card); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

/* ===== FORMS ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }

/* ===== LOGIN PAGE ===== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
    var(--bg-primary);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-card .logo-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.login-card .logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card .logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.login-card .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  margin-top: 8px;
}

.login-error {
  background: var(--red-dim);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

/* ===== SCANTRON / ANSWER SHEET ===== */
.exam-header {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
}

.exam-header .exam-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.exam-header .exam-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.timer-display {
  font-size: 1.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--green);
}

.timer-display.warning { color: var(--yellow); }
.timer-display.danger { color: var(--red); animation: pulse-timer 1s ease-in-out infinite; }

@keyframes pulse-timer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.focus-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--green);
}

.focus-indicator.lost {
  color: var(--red);
  animation: focus-flash 0.5s ease-in-out 3;
}

@keyframes focus-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.answer-sheet {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.answer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.answer-row:hover { border-color: var(--border-focus); }
.answer-row.answered { border-left: 3px solid var(--accent); }
.answer-row.flagged { border-left: 3px solid var(--yellow); }

.q-number {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 36px;
  text-align: center;
}

.mc-bubbles {
  display: flex;
  gap: 8px;
}

.mc-bubble {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.mc-bubble:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-glow);
}

.mc-bubble.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

.numeric-input {
  width: 140px;
  padding: 8px 12px;
  font-size: 0.9rem;
  text-align: center;
  font-weight: 600;
}

.text-input {
  flex: 1;
  max-width: 300px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.flag-btn {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.3;
  transition: var(--transition);
  padding: 4px;
}

.flag-btn:hover { opacity: 0.7; }
.flag-btn.flagged { opacity: 1; }

/* ===== DATA TABLES ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.data-table thead th:hover { color: var(--accent-light); }

.data-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: var(--transition);
}

.data-table tbody tr:hover { background: var(--bg-card-hover); }

.data-table td {
  padding: 10px 14px;
  vertical-align: middle;
}

/* ===== PILLS / BADGES ===== */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}

.pill.green  { background: var(--green-dim); color: var(--green); }
.pill.red    { background: var(--red-dim); color: var(--red); }
.pill.yellow { background: var(--yellow-dim); color: var(--yellow); }
.pill.blue   { background: var(--blue-dim); color: var(--blue); }
.pill.accent { background: var(--accent-glow); color: var(--accent-light); }

.course-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.course-tag.pre_algebra { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.course-tag.algebra_1   { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.course-tag.geometry    { background: rgba(34, 197, 94, 0.12); color: #4ade80; }
.course-tag.algebra_2   { background: rgba(168, 85, 247, 0.12); color: #c084fc; }

/* ===== PROGRESS BAR ===== */
.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ===== SECTION HEADERS ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

/* ===== FOCUS LOST OVERLAY ===== */
.focus-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.focus-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.focus-overlay-content {
  text-align: center;
  padding: 40px;
}

.focus-overlay-content .warn-icon { font-size: 4rem; margin-bottom: 16px; }
.focus-overlay-content h2 { font-size: 1.5rem; color: var(--red); margin-bottom: 8px; }
.focus-overlay-content p { color: var(--text-secondary); max-width: 400px; }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
  margin-bottom: -1px;
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 0.85rem; max-width: 320px; margin: 0 auto; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .page-container { padding: 16px; }
  .top-bar { padding: 12px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .login-card { padding: 28px 20px; }
  .mc-bubble { width: 34px; height: 34px; font-size: 0.78rem; }
  .answer-row { padding: 8px 12px; gap: 8px; }
  .nav-links { display: none; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .exam-header { flex-direction: column; gap: 8px; text-align: center; }
}
