/* ═══════════════════════════════════════════════
   Actuarial Exam Prep — Styles
   ═══════════════════════════════════════════════ */

:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-nav: #1a1a2e;
  --text: #212529;
  --text-secondary: #6c757d;
  --text-light: #adb5bd;
  --accent: #4361ee;
  --accent-hover: #3a56d4;
  --border: #dee2e6;
  --success: #2d6a4f;
  --success-bg: #d8f3dc;
  --danger: #d62828;
  --warning: #e9c46a;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-sm: 4px;

  --exam-p: #4361ee;
  --exam-fm: #e63946;
  --exam-fam: #2a9d8f;
  --exam-srm: #e9c46a;
  --exam-altam: #6a4c93;
  --exam-astam: #f4a261;
  --exam-pa: #264653;
  --exam-cas: #1a1a2e;
}

[data-theme="dark"] {
  --bg: #0f0f23;
  --bg-card: #1a1a2e;
  --bg-nav: #0a0a1a;
  --text: #e8e8e8;
  --text-secondary: #a0a0b0;
  --text-light: #6c6c80;
  --border: #2a2a40;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --success-bg: #1a3a2a;
  --accent: #5e7ce2;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ─── Navigation ─── */
.app-nav {
  background: var(--bg-nav);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 0.5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
}

.nav-logo {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  margin-left: 1.5rem;
  flex: 1;
  overflow-x: auto;
}

.nav-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  color: white;
  background: rgba(255,255,255,0.1);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* ─── Views ─── */
.view { display: none; padding: 2rem; max-width: 1200px; margin: 0 auto; }
.view.active { display: block; }

h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }

.view-subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.95rem; }

/* ─── Cards ─── */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.welcome-card {
  background: linear-gradient(135deg, var(--accent), #7209b7);
  color: white;
  padding: 2rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.welcome-card h1 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.welcome-card p { opacity: 0.9; font-size: 1rem; }

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.dash-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }

.dash-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.dash-card-header h3 { margin: 0; font-size: 1rem; }

.exam-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  color: white;
  flex-shrink: 0;
}

.exam-p { background: var(--exam-p); }
.exam-fm { background: var(--exam-fm); }
.exam-fam { background: var(--exam-fam); }
.exam-srm { background: var(--exam-srm); color: #333; }
.exam-altam { background: var(--exam-altam); }
.exam-astam { background: var(--exam-astam); }
.exam-pa { background: var(--exam-pa); }
.exam-cas { background: var(--exam-cas); }

.stat-row { display: flex; justify-content: space-between; padding: 0.35rem 0; font-size: 0.875rem; border-bottom: 1px solid var(--border); }
.stat-row:last-of-type { border-bottom: none; }

.dash-card-link {
  display: block;
  text-align: center;
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  transition: background 0.2s;
}

.dash-card-link:hover { background: var(--accent-hover); }

/* ─── Quick Actions ─── */
.quick-actions h2 { margin-bottom: 0.75rem; }

.action-buttons { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.action-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.action-btn:hover { background: var(--accent-hover); }
.action-btn:active { transform: scale(0.97); }

.danger-btn { background: var(--danger); }
.danger-btn:hover { background: #b91c1c; }

/* ─── Exam Selector ─── */
.exam-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.exam-tab {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  transition: all 0.2s;
  color: var(--text);
}

.exam-tab:hover { border-color: var(--accent); }
.exam-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.exam-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 200px;
}

.exam-loading, .empty-state {
  color: var(--text-secondary);
  text-align: center;
  padding: 3rem 1rem;
}

/* Exam Content Styles */
.exam-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.meta-item { padding: 0.75rem; background: var(--bg); border-radius: var(--radius-sm); }
.meta-label { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.meta-value { font-weight: 700; font-size: 1.1rem; margin-top: 0.25rem; }

.topic-group { margin-bottom: 1.5rem; }
.topic-group h3 { color: var(--accent); margin-bottom: 0.75rem; font-size: 1.05rem; }

.obj-list { list-style: none; padding: 0; }
.obj-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.25rem;
  cursor: pointer;
  transition: background 0.2s;
}

.obj-item:hover { background: var(--bg); }

.obj-check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-light);
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.obj-check.done {
  background: var(--success);
  border-color: var(--success);
}

.obj-check.done::after {
  content: "✓";
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
}

.obj-text { font-size: 0.9rem; flex: 1; }
.obj-text.done { text-decoration: line-through; color: var(--text-secondary); }

/* ─── Study View ─── */
.study-controls { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.study-controls label { font-weight: 600; font-size: 0.875rem; margin-right: 0.5rem; }
.study-controls select {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.875rem;
}

.study-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 300px;
}

/* ─── Problems ─── */
.problem-controls { margin-bottom: 1.5rem; padding: 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }

.problem-filter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.problem-filter label { font-weight: 600; font-size: 0.8rem; }
.problem-filter select {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
}

.problem-actions { display: flex; align-items: center; gap: 1rem; }
#problemCounter { font-size: 0.8rem; color: var(--text-secondary); }

.problem-display {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 200px;
}

/* Problem card */
.problem-card { }
.problem-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.problem-topic { font-weight: 600; color: var(--accent); }
.problem-difficulty {
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.diff-easy { background: var(--success-bg); color: var(--success); }
.diff-medium { background: #fff3cd; color: #856404; }
.diff-hard { background: #f8d7da; color: #721c24; }

.problem-text {
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.problem-options { display: grid; gap: 0.5rem; margin-bottom: 1rem; }

.option-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.9rem;
  text-align: left;
  transition: all 0.2s;
}

.option-btn:hover { border-color: var(--accent); background: rgba(67, 97, 238, 0.05); }
.option-btn.selected { border-color: var(--accent); background: rgba(67, 97, 238, 0.1); }
.option-btn.correct { border-color: var(--success); background: var(--success-bg); }
.option-btn.incorrect { border-color: var(--danger); background: #f8d7da; }

.option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.option-btn.correct .option-letter { background: var(--success); color: white; }
.option-btn.incorrect .option-letter { background: var(--danger); color: white; }
.option-btn.selected .option-letter { background: var(--accent); color: white; }

.problem-feedback {
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-weight: 600;
}

.feedback-correct { background: var(--success-bg); color: var(--success); }
.feedback-incorrect { background: #f8d7da; color: #721c24; }

.view-solution-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

.view-solution-btn:hover { background: rgba(67, 97, 238, 0.1); }

/* ─── Resources ─── */
.resources-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }

.resource-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.resource-card h3 { margin-bottom: 0.5rem; }
.resource-card p { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 1rem; }

.resource-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: none;
}

.resource-detail.visible { display: block; }

/* ─── Progress ─── */
.progress-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.summary-card h3 { font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.summary-number { font-size: 2rem; font-weight: 800; color: var(--accent); }

.mastery-matrix { }
.mastery-row { display: flex; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); gap: 1rem; }
.mastery-row:last-child { border-bottom: none; }

.mastery-exam-label { font-weight: 700; font-size: 0.75rem; width: 50px; flex-shrink: 0; }
.mastery-topic-label { font-size: 0.85rem; width: 180px; flex-shrink: 0; }
.mastery-bar-bg { flex: 1; height: 20px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.mastery-bar-fill { height: 100%; border-radius: 99px; transition: width 0.5s; }
.mastery-pct { font-size: 0.8rem; font-weight: 700; width: 45px; text-align: right; flex-shrink: 0; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4rem;
  overflow-y: auto;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { margin: 0; font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
}

.modal-body { padding: 1.5rem; line-height: 1.7; }

/* ─── Formula Sheet Styles ─── */
.formula-section { margin-bottom: 1.5rem; }
.formula-section h3 { color: var(--accent); margin-bottom: 0.5rem; font-size: 1rem; }
.formula-box {
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  margin-bottom: 0.5rem;
  font-family: "Times New Roman", Times, serif;
  font-size: 1.05rem;
  overflow-x: auto;
}

/* ─── SOA Links ─── */
.link-group { margin-bottom: 1.5rem; }
.link-group h3 { margin-bottom: 0.5rem; font-size: 1rem; }
.link-item {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--accent);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  margin-bottom: 0.25rem;
}

.link-item:hover { background: var(--bg); border-left-color: var(--accent); }

/* ─── Study Tips ─── */
.tip-card {
  background: var(--bg);
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border-left: 3px solid var(--accent);
}

.tip-card h4 { margin-bottom: 0.25rem; }
.tip-card p { font-size: 0.9rem; color: var(--text-secondary); }

/* ─── Footer ─── */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .nav-toggle { display: block; }

  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-nav);
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
  }

  .nav-links.open { display: flex; }

  .nav-link { padding: 0.65rem 1rem; }

  .view { padding: 1rem; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .resources-grid { grid-template-columns: 1fr; }
  .progress-summary { grid-template-columns: 1fr 1fr; }

  .exam-meta { grid-template-columns: 1fr 1fr; }
  .mastery-row { flex-wrap: wrap; }
  .mastery-topic-label { width: 120px; }

  .problem-filter { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .progress-summary { grid-template-columns: 1fr; }
}

/* ─── Categories View ─── */
.topic-group {
  margin-bottom: 1.5rem;
}
.topic-group h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}
