/* ═══════════════════════════════════════════════════════════════════
   CORRECTION MASTER — Design System
   Dark sci-fi theme: deep navy + indigo/purple accents
   (Full Replicated Version for Server)
═══════════════════════════════════════════════════════════════════ */

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

:root {
  --bg-base:     #080812;
  --bg-surface:  #0f0f1e;
  --bg-card:     #161628;
  --bg-card-2:   #1e1e38;
  --bg-hover:    #252545;

  --accent:      #6366f1;
  --accent-glow: rgba(99,102,241,0.25);
  --accent-2:    #8b5cf6;
  --green:       #22c55e;
  --red:         #ef4444;
  --orange:      #f59e0b;
  --blue:        #3b82f6;

  --text-primary:  #e2e8f0;
  --text-muted:    #64748b;
  --text-dim:      #334155;

  --border:      rgba(99,102,241,0.15);
  --border-dim:  rgba(255,255,255,0.06);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;

  --sidebar-w: 240px;
  --transition: 0.2s ease;
}

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 3px; }

/* ── Layout ──────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 24px;
}
.logo-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: 0 0 20px var(--accent-glow);
}
.logo-title { font-size: 13px; font-weight: 700; color: var(--text-primary); letter-spacing: 0.02em; }
.logo-sub { font-size: 11px; color: var(--text-muted); }

.nav-steps { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
}
.nav-step:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-step.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.08));
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.nav-step.active .step-icon {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 0 12px var(--accent-glow);
}
.step-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg-card-2); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
  transition: all var(--transition);
}
.step-label { font-size: 13px; font-weight: 600; }
.step-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.sidebar-bottom { padding-top: 16px; }
.version-badge {
  font-size: 11px; color: var(--text-dim);
  text-align: center; padding: 8px;
}

/* ── Main Content ────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.page {
  position: absolute; inset: 0;
  overflow-y: auto;
  padding: 32px 40px;
  display: none;
  animation: fadeIn 0.25s ease;
}
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page Header ─────────────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-title {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; transition: all var(--transition);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 28px rgba(99,102,241,0.4); }
.btn-primary:disabled { opacity: 0.4; transform: none; cursor: not-allowed; }
.btn-secondary { background: var(--bg-card-2); color: var(--text-muted); border: 1px solid var(--border-dim); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-ghost { color: var(--text-muted); border: 1px solid var(--border-dim); }
.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); }
.btn-success { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.btn-success:hover { background: rgba(34,197,94,0.25); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 32px; font-size: 15px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 8px; }

/* ── File Upload Zones ───────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-dim);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(99,102,241,0.05);
}
.upload-zone.has-file {
  border-color: rgba(34,197,94,0.4);
  background: rgba(34,197,94,0.04);
}
.upload-icon { font-size: 28px; margin-bottom: 10px; color: var(--text-muted); }
.upload-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.upload-hint { font-size: 12px; color: var(--text-muted); }
.upload-file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card-2); border-radius: 8px; padding: 8px 12px;
  font-size: 12px; text-align: left;
}
.file-item-icon { font-size: 16px; flex-shrink: 0; }
.file-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.file-item-remove {
  color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  width: 20px; height: 20px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.file-item-remove:hover { background: rgba(239,68,68,0.2); color: var(--red); }

/* ── Form Controls ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; display: block; text-transform: uppercase; letter-spacing: 0.06em; }
.form-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-base); border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 13px; transition: border-color var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-dim); }
.form-select {
  width: 100%; padding: 10px 14px;
  background: var(--bg-base); border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 13px; outline: none; cursor: pointer;
  appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}
.form-select:focus { border-color: var(--accent); }

/* ── Stage Progress ──────────────────────────────────────────────── */
.stages {
  display: flex; gap: 0; margin-bottom: 28px;
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border-dim); overflow: hidden;
}
.stage-item {
  flex: 1; padding: 14px 16px;
  border-right: 1px solid var(--border-dim);
  display: flex; align-items: center; gap: 10px;
  transition: all var(--transition);
}
.stage-item:last-child { border-right: none; }
.stage-item.active { background: rgba(99,102,241,0.1); }
.stage-item.done { background: rgba(34,197,94,0.06); }
.stage-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg-card-2); flex-shrink: 0;
  border: 2px solid var(--border-dim);
  transition: all var(--transition);
}
.stage-item.active .stage-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 1.5s infinite;
}
.stage-item.done .stage-dot { background: var(--green); border-color: var(--green); }
.stage-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.stage-item.active .stage-label, .stage-item.done .stage-label { color: var(--text-primary); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 6px var(--accent-glow); }
  50% { box-shadow: 0 0 16px rgba(99,102,241,0.5); }
}

/* ── Log Panel ───────────────────────────────────────────────────── */
.log-panel {
  background: var(--bg-base);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 16px;
  height: 300px; overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.7;
}
.log-entry { display: flex; gap: 8px; }
.log-time { color: var(--text-dim); flex-shrink: 0; }
.log-msg.info  { color: var(--text-primary); }
.log-msg.error { color: var(--red); }
.log-msg.warn  { color: var(--orange); }
.log-msg.success { color: var(--green); }

/* ── Progress bar ────────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--bg-base); border-radius: 100px;
  height: 6px; overflow: hidden; margin-bottom: 8px;
}
.progress-bar-fill {
  height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
  min-width: 2%;
}
.progress-label { font-size: 12px; color: var(--text-muted); text-align: right; }

/* ── Student Grid ────────────────────────────────────────────────── */
.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.student-mini-card {
  background: var(--bg-card-2); border-radius: var(--radius);
  padding: 12px 14px; border: 1px solid var(--border-dim);
  transition: all var(--transition);
}
.student-mini-card.grading { border-color: var(--accent); }
.student-mini-card.done { border-color: rgba(34,197,94,0.3); }
.student-mini-card.error { border-color: rgba(239,68,68,0.3); }
.student-mini-name { font-size: 12px; font-weight: 600; margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-mini-status { font-size: 11px; color: var(--text-muted); }
.student-mini-score { font-size: 13px; font-weight: 700; color: var(--green); }

/* ── Results ─────────────────────────────────────────────────────── */
.summary-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg); padding: 20px;
  text-align: center;
}
.stat-value { font-size: 32px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.student-result-card {
  background: var(--bg-card); border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg); margin-bottom: 16px; overflow: hidden;
  transition: all var(--transition);
}
.student-result-card:hover { border-color: var(--border); }
.student-result-header {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 22px; cursor: pointer;
}
.student-rank {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg-card-2); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text-muted); flex-shrink: 0;
}
.student-rank.top { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #1a1a00; }
.student-result-name { flex: 1; }
.student-result-name-main { font-size: 15px; font-weight: 600; }
.student-result-name-sub { font-size: 11px; color: var(--text-muted); }
.student-score-badge {
  padding: 6px 16px; border-radius: 100px; font-weight: 700; font-size: 14px;
}
.score-high { background: rgba(34,197,94,0.15); color: var(--green); }
.score-mid  { background: rgba(245,158,11,0.15); color: var(--orange); }
.score-low  { background: rgba(239,68,68,0.15); color: var(--red); }
.student-result-expand { color: var(--text-muted); transition: transform var(--transition); }
.student-result-expand.open { transform: rotate(180deg); }

.student-result-body {
  padding: 0 22px 22px; display: none;
  border-top: 1px solid var(--border-dim);
  padding-top: 18px;
}
.student-result-body.open { display: block; }

.question-result-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.qr-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 14px; border-radius: 8px; background: var(--bg-card-2);
  border: 1px solid var(--border-dim);
}
.qr-item.wrong { border-left: 3px solid var(--red); }
.qr-item.correct { border-left: 3px solid var(--green); }
.qr-status { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.qr-id { font-weight: 700; font-size: 12px; color: var(--text-muted); flex-shrink: 0; min-width: 36px; }
.qr-content { flex: 1; font-size: 12px; }
.qr-question { color: var(--text-primary); margin-bottom: 4px; }
.qr-ans-row { display: flex; gap: 16px; font-size: 11px; }
.qr-student-ans { color: var(--red); }
.qr-correct-ans { color: var(--green); }
.qr-feedback { color: var(--text-muted); font-style: italic; }
.qr-review-badge {
  background: rgba(245,158,11,0.15); color: var(--orange);
  font-size: 10px; padding: 2px 8px; border-radius: 100px;
  font-weight: 600; flex-shrink: 0;
}

.error-analysis {
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.05));
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  font-size: 13px; line-height: 1.7; white-space: pre-wrap;
  color: var(--text-primary);
}
.error-analysis-label { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }

.export-bar {
  display: flex; gap: 12px; align-items: center;
  padding: 16px 20px;
  background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border-dim); margin-bottom: 24px;
}
.export-bar-title { font-size: 13px; font-weight: 600; flex: 1; }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none !important; }
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 640px; max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-header { padding: 24px; border-bottom: 1px solid var(--border-dim); }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-actions { padding: 16px 24px; border-top: 1px solid var(--border-dim); display: flex; gap: 10px; }

.review-section {}
.review-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.review-content { padding: 12px; border-radius: 8px; background: var(--bg-card); font-size: 13px; line-height: 1.6; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.accent-purple { border-left: 3px solid var(--accent-2); }
.accent-green  { border-left: 3px solid var(--green); }
.accent-orange { border-left: 3px solid var(--orange); }
.muted { color: var(--text-muted); }

/* ── Setup Layout ────────────────────────────────────────────────── */
.setup-grid { display: grid; grid-template-columns: 1fr 380px; gap: 24px; }
.upload-stack { display: flex; flex-direction: column; gap: 16px; }
.config-panel { display: flex; flex-direction: column; gap: 16px; }

/* ── Badge ───────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 100px; font-size: 11px; font-weight: 600; }
.badge-blue   { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-green  { background: rgba(34,197,94,0.15);  color: var(--green); }
.badge-red    { background: rgba(239,68,68,0.15);  color: var(--red); }
.badge-orange { background: rgba(245,158,11,0.15); color: var(--orange); }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 13px; min-width: 240px;
  animation: slideUp 0.3s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error   { border-color: rgba(239,68,68,0.3); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Utility ─────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
