/* ConfusionEngine — Styles */
/* Copyright (c) 2026 Mustafa Uzumeri. All rights reserved. */

:root {
  --bg: #0b0b12;
  --bg-card: #141420;
  --bg-elevated: #1a1a2a;
  --bg-input: #0e0e1a;
  --bg-hover: #20203a;
  --text: #e4e4f0;
  --text-dim: #8888a0;
  --text-muted: #555568;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99,102,241,0.2);
  --g0: #6b7280; --g0-bg: rgba(107,114,128,0.15);
  --g1: #f59e0b; --g1-bg: rgba(245,158,11,0.15);
  --g2: #3b82f6; --g2-bg: rgba(59,130,246,0.15);
  --g3: #10b981; --g3-bg: rgba(16,185,129,0.15);
  --border: #1e1e30;
  --danger: #ef4444;
  --success: #10b981;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.35);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ---- HEADER ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header .header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.header-user {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ---- LOGIN ---- */
.login-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, rgba(99,102,241,0.06) 0%, transparent 60%);
}
.login-box {
  width: 100%;
  max-width: 460px;
  text-align: center;
}
.login-box .logo {
  font-size: 3rem;
  margin-bottom: 8px;
}
.login-box h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.login-box .tagline {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 32px;
}
.role-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
}
.role-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 200ms;
}
.role-tab.active {
  background: var(--accent);
  color: #fff;
}
.login-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: left;
}
.login-form h2 {
  font-size: 1.1rem;
  margin-bottom: 20px;
  font-weight: 600;
}
.demo-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.demo-divider::before, .demo-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---- FORMS ---- */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color 200ms;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 200ms;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  padding: 8px 12px;
}
.btn-ghost:hover { color: var(--text); }
.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ---- DASHBOARD ---- */
.dashboard {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
}
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.dashboard-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}
.course-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-glow);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--accent-hover);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ---- CHAPTER CARDS ---- */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chapter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: border-color 200ms, transform 200ms;
}
.chapter-card:hover {
  border-color: rgba(99,102,241,0.3);
  transform: translateY(-1px);
}
.chapter-info { flex: 1; }
.chapter-info h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.chapter-info .chapter-question {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 8px;
}
.chapter-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.chapter-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-open { background: rgba(16,185,129,0.15); color: var(--success); }
.status-closed { background: rgba(107,114,128,0.15); color: var(--g0); }
.status-upcoming { background: rgba(59,130,246,0.15); color: var(--g2); }
.status-graded { background: rgba(245,158,11,0.15); color: var(--g1); }

/* ---- GRADING SCREEN ---- */
.grading-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
}
.grading-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.grading-topbar h2 { font-size: 1rem; font-weight: 600; }
.grading-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.progress-bar {
  width: 160px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 400ms ease;
}
.mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.mode-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 200ms;
}
.mode-btn.active {
  background: var(--bg-elevated);
  color: var(--text);
}

.grading-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  position: relative;
  overflow: hidden;
}
.grading-card-wrapper {
  width: 100%;
  max-width: 640px;
}
.grading-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  transition: transform 350ms ease, opacity 300ms ease;
}
.grading-card.exit-left {
  transform: translateX(-120%);
  opacity: 0;
}
.grading-card.enter-right {
  transform: translateX(120%);
  opacity: 0;
}
.grading-student {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.grading-response {
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--text);
  min-height: 80px;
}
.grading-response.empty {
  color: var(--text-muted);
  font-style: italic;
}

.ai-suggestion {
  margin-top: 20px;
  padding: 16px;
  background: var(--accent-glow);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: var(--radius-sm);
}
.ai-suggestion .ai-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.ai-suggestion .ai-rationale {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.ai-suggestion .ai-grade {
  display: inline-block;
  font-weight: 700;
  font-size: 1rem;
  margin-right: 8px;
}

.grade-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
  flex-wrap: wrap;
}
.grade-btn {
  width: 72px;
  height: 72px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 200ms;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.grade-btn .grade-label {
  font-size: 0.6rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  opacity: 0.8;
}
.grade-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.grade-btn:active {
  transform: translateY(0);
}
.grade-btn[data-grade="0"] { background: var(--g0-bg); color: var(--g0); border-color: rgba(107,114,128,0.3); }
.grade-btn[data-grade="0"]:hover { border-color: var(--g0); }
.grade-btn[data-grade="0"].suggested { border-color: var(--g0); box-shadow: 0 0 16px rgba(107,114,128,0.3); }
.grade-btn[data-grade="1"] { background: var(--g1-bg); color: var(--g1); border-color: rgba(245,158,11,0.3); }
.grade-btn[data-grade="1"]:hover { border-color: var(--g1); }
.grade-btn[data-grade="1"].suggested { border-color: var(--g1); box-shadow: 0 0 16px rgba(245,158,11,0.3); }
.grade-btn[data-grade="2"] { background: var(--g2-bg); color: var(--g2); border-color: rgba(59,130,246,0.3); }
.grade-btn[data-grade="2"]:hover { border-color: var(--g2); }
.grade-btn[data-grade="2"].suggested { border-color: var(--g2); box-shadow: 0 0 16px rgba(59,130,246,0.3); }
.grade-btn[data-grade="3"] { background: var(--g3-bg); color: var(--g3); border-color: rgba(16,185,129,0.3); }
.grade-btn[data-grade="3"]:hover { border-color: var(--g3); }
.grade-btn[data-grade="3"].suggested { border-color: var(--g3); box-shadow: 0 0 16px rgba(16,185,129,0.3); }

.grading-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  width: 100%;
  max-width: 640px;
}
.grading-done {
  text-align: center;
  padding: 48px;
}
.grading-done h2 { font-size: 1.6rem; margin-bottom: 12px; }
.grading-done p { color: var(--text-dim); margin-bottom: 24px; }
.keyboard-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
}
.keyboard-hint kbd {
  display: inline-block;
  padding: 2px 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font);
  font-size: 0.72rem;
}

/* ---- SUMMARY ---- */
.summary {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px;
  width: 100%;
}
.summary h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 24px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
}
.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
}
.grade-chart {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 120px;
  margin-bottom: 32px;
  padding: 0 40px;
}
.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.chart-bar {
  width: 100%;
  max-width: 80px;
  border-radius: 4px 4px 0 0;
  transition: height 600ms ease;
  min-height: 2px;
}
.chart-bar-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 600;
}
.chart-bar-count {
  font-size: 0.8rem;
  font-weight: 600;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.response-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 32px;
}
.response-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.response-table td {
  padding: 12px 14px;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(30,30,48,0.5);
  vertical-align: top;
}
.response-table tr:hover td {
  background: rgba(99,102,241,0.04);
}
.response-text-cell {
  max-width: 400px;
  line-height: 1.5;
}
.grade-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
}
.grade-pill.g0 { background: var(--g0-bg); color: var(--g0); }
.grade-pill.g1 { background: var(--g1-bg); color: var(--g1); }
.grade-pill.g2 { background: var(--g2-bg); color: var(--g2); }
.grade-pill.g3 { background: var(--g3-bg); color: var(--g3); }

/* ---- STUDENT VIEWS ---- */
.student-response-box {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 24px;
}
.question-display {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.due-date {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 24px;
}
.response-textarea {
  min-height: 140px;
}
.rubric-hint {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.rubric-hint strong {
  color: var(--accent);
}
.submission-status {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--success);
}

.assignment-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 200ms, transform 200ms;
}
.assignment-card:hover {
  border-color: rgba(99,102,241,0.3);
  transform: translateY(-1px);
}
.assignment-card h3 { font-size: 1rem; margin-bottom: 4px; }
.assignment-card .assignment-meta {
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ---- ROSTER ---- */
.roster-list {
  display: grid;
  gap: 8px;
}
.roster-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.roster-item .student-name { font-weight: 500; }
.roster-item .student-email { font-size: 0.82rem; color: var(--text-dim); }

/* ---- SETTINGS ---- */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.settings-card h3 { font-size: 1rem; margin-bottom: 16px; }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 1000;
  animation: toast-in 300ms ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---- EMPTY STATES ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow);
}
.modal h2 { font-size: 1.2rem; margin-bottom: 20px; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .chapter-card { flex-direction: column; align-items: stretch; }
  .chapter-actions { justify-content: flex-end; }
  .form-row { grid-template-columns: 1fr; }
  .grading-topbar { padding: 12px 16px; }
  .grading-body { padding: 16px; }
  .grading-card { padding: 24px; }
  .grading-response { font-size: 1rem; }
  .grade-btn { width: 60px; height: 60px; font-size: 1.3rem; }
  .dashboard { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .response-table { font-size: 0.82rem; }
}

/* ---- PRINT ---- */
@media print {
  body { background: #fff; color: #000; }
  .app-header, .btn, .mode-toggle, .toast { display: none !important; }
  .summary { max-width: 100%; padding: 0; }
  .stat-card { border: 1px solid #ccc; }
  .response-table th { border-bottom: 2px solid #000; }
  .response-table td { border-bottom: 1px solid #ccc; }
  .grade-pill { border: 1px solid #ccc; }
}
