/* PrepProof Design System — matches landing page */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500;600&display=swap');

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

:root {
  --bg: #0c0c0f;
  --surface: #16161a;
  --surface-2: #1e1e24;
  --accent: #4ade80;
  --accent-dim: #22c55e;
  --accent-glow: rgba(74, 222, 128, 0.12);
  --text: #f0f0f2;
  --text-muted: #8b8b9e;
  --text-dim: #5c5c6f;
  --border: #2a2a35;
  --red: #f87171;
  --red-glow: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-glow: rgba(251, 191, 36, 0.12);
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.02em;
}
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }

/* Layout */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Nav */
.app-nav {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  text-decoration: none;
}
.logo span { color: var(--accent); }
.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-link {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-dim);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--text-dim);
}
.btn-danger {
  background: var(--red-glow);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
}
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.btn-lg { padding: 16px 32px; font-size: 1rem; }
.btn-full { width: 100%; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  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-error {
  color: var(--red);
  font-size: 0.82rem;
  margin-top: 6px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 100px;
}
.badge-green {
  color: var(--accent);
  background: var(--accent-glow);
}
.badge-red {
  color: var(--red);
  background: var(--red-glow);
}
.badge-amber {
  color: var(--amber);
  background: var(--amber-glow);
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Auth pages */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 70px);
  padding: 40px 24px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
}
.auth-card h1 {
  margin-bottom: 8px;
}
.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 32px;
}
.auth-card .form-input {
  background: var(--surface);
}
.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.88rem;
  color: var(--text-dim);
}
.auth-footer a {
  color: var(--accent);
  text-decoration: none;
}
.auth-footer a:hover {
  text-decoration: underline;
}
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.alert-error {
  background: var(--red-glow);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.2);
}
.alert-success {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

/* Dashboard */
.dashboard-header {
  padding: 40px 0 24px;
}
.dashboard-header h1 {
  margin-bottom: 4px;
}
.dashboard-header .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding-bottom: 60px;
}
.student-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}
.student-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.student-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
}
.student-code {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: monospace;
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Week chart */
.week-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.day-col { text-align: center; }
.day-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.day-bar {
  height: 64px;
  border-radius: 6px;
  position: relative;
  transition: all 0.3s;
}
.day-bar.done { background: linear-gradient(180deg, var(--accent) 0%, rgba(74, 222, 128, 0.4) 100%); }
.day-bar.partial { background: linear-gradient(180deg, var(--amber) 0%, rgba(251, 191, 36, 0.3) 100%); height: 38px; margin-top: 26px; }
.day-bar.missed { background: var(--surface-2); border: 1px dashed var(--border); }
.day-bar.rushed { background: linear-gradient(180deg, var(--red) 0%, rgba(248, 113, 113, 0.3) 100%); height: 50px; margin-top: 14px; }
.day-bar.today { background: var(--surface-2); border: 1px solid var(--accent); border-style: dashed; }
.day-bar.future { background: var(--surface-2); border: 1px dashed var(--border); opacity: 0.4; }

/* Metrics row */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.metric-box {
  text-align: center;
  padding: 16px 8px;
  background: var(--bg);
  border-radius: 10px;
}
.metric-val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}
.metric-val.green { color: var(--accent); }
.metric-val.amber { color: var(--amber); }
.metric-val.red { color: var(--red); }
.metric-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Behavior flags */
.flags-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.flags-title {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 500;
}
.flag-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.flag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.flag-dot.red { background: var(--red); }
.flag-dot.amber { background: var(--amber); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h3 {
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state p {
  margin-bottom: 24px;
  font-size: 0.95rem;
}

/* Study page */
.study-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 24px;
}
.study-progress {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}
.progress-bar-track {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.progress-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  margin-bottom: 24px;
}
.question-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.question-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
}
.question-difficulty {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.question-timer {
  margin-left: auto;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
}
.question-timer.warning { color: var(--amber); }
.question-timer.danger { color: var(--red); }
.question-text {
  font-size: 1.1rem;
  line-height: 1.7;
  margin-bottom: 28px;
}
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  font-family: 'DM Sans', sans-serif;
}
.option-btn:hover:not(.selected):not(.correct):not(.incorrect) {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.option-letter {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.option-btn.selected .option-letter {
  background: var(--accent);
  color: var(--bg);
}
.option-btn.correct {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.option-btn.correct .option-letter {
  background: var(--accent);
  color: var(--bg);
}
.option-btn.incorrect {
  border-color: var(--red);
  background: var(--red-glow);
}
.option-btn.incorrect .option-letter {
  background: var(--red);
  color: white;
}
.option-btn.disabled {
  pointer-events: none;
  opacity: 0.7;
}
.explanation-box {
  margin-top: 20px;
  padding: 16px 20px;
  background: var(--bg);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.study-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Session summary */
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
}
.summary-card h2 {
  margin-bottom: 8px;
}
.summary-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}
.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.summary-stat {
  padding: 20px;
  background: var(--bg);
  border-radius: 12px;
}
.summary-stat .val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
}
.summary-stat .label {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* Add student modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
}
.modal-card h2 {
  margin-bottom: 8px;
}
.modal-card .subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 24px;
}

/* Student code display */
.code-display {
  text-align: center;
  padding: 32px;
  background: var(--bg);
  border-radius: 12px;
  margin: 20px 0;
}
.code-display .code {
  font-family: 'Space Grotesk', monospace;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
}
.code-display p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .summary-stats { grid-template-columns: 1fr; }
  .week-chart { gap: 4px; }
  .question-card { padding: 24px; }
  .study-container { padding: 24px 16px; }
}

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 70px);
  flex-direction: column;
  gap: 16px;
  color: var(--text-muted);
}

/* Session history */
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 0.88rem;
}
.session-date { color: var(--text-muted); }
.session-score { font-weight: 600; }
