/* ===================================================
   AEQUITAS — Global Stylesheet
   Design: Warm Minimal Academic
   Fonts: Lora (display) + DM Sans (body)
   =================================================== */

/* --- CSS Variables --- */
:root {
  --bg:          #e8ddd0;
  --surface:     #ffffff;
  --surface-2:   #f5ede4;
  --border:      #d8cfc7;
  --text-primary:#1a1614;
  --text-secondary:#6b6460;
  --text-muted:  #9c948f;
  --accent:      #6d8fad;
  --accent-hover:#5a7d9c;
  --accent-light:#e8f0f7;
  --danger:      #c0392b;
  --danger-light:#fdf0ef;
  --success:     #27ae60;
  --success-light:#edfbf3;
  --warning:     #f39c12;
  --warning-light:#fef9ec;
  --shadow:      0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.12);
  --radius:      14px;
  --radius-sm:   8px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  font-family: 'DM Sans', -apple-system, sans-serif;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
}

.app-wrapper { min-height: 100vh; background: var(--bg); }

/* ===================================================
   AUTH PAGES (Login / Register)
   =================================================== */
.auth-bg {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  font-size: 1.8rem;
  background: var(--accent-light);
  border-radius: 10px;
  padding: 6px 10px;
}

.logo-text {
  font-family: 'Lora', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.auth-title {
  font-family: 'Lora', serif;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: -0.5rem;
}

.auth-link {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-link a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-link a:hover { text-decoration: underline; }

/* ===================================================
   FORMS
   =================================================== */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

.form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.form-input::placeholder { color: var(--text-muted); }
.form-input:focus { border-color: var(--accent); }

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
}

.form-row .form-input:last-child { width: 90px; }

/* ===================================================
   BUTTONS
   =================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.4rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 0.85rem;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover { background: var(--accent-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover { background: #219a52; }

.full-width { width: 100%; justify-content: center; }

.btn-signout {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.18s;
}
.btn-signout:hover { background: var(--surface-2); }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
  font-size: 1rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--surface-2); }
.btn-icon.delete:hover { background: var(--danger-light); }

/* ===================================================
   ALERTS
   =================================================== */
.alert {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #f5c6c2;
}

/* ===================================================
   STUDENT LAYOUT
   =================================================== */
.student-layout {
  min-height: 100vh;
  background: var(--bg);
}

.student-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Lora', serif;
  font-size: 1.2rem;
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.welcome-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.student-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.page-hero { margin-bottom: 2.5rem; }

.page-title {
  font-family: 'Lora', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.page-subtitle { color: var(--text-secondary); font-size: 1rem; }

/* Subjects Grid */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.5rem;
}

.subject-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  border: 1.5px solid transparent;
}

.subject-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.subject-card.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  height: 160px;
}

@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

.subject-icon-wrap {
  width: 54px;
  height: 54px;
  background: var(--accent-light);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.subject-name {
  font-family: 'Lora', serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.subject-count {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.view-link {
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
}

/* Exam List */
.exam-list-page .back-link {
  display: inline-block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  transition: color 0.15s;
}

.exam-list-page .back-link:hover { color: var(--text-primary); }

.exam-list { display: flex; flex-direction: column; gap: 1rem; }

.exam-list-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  gap: 1.5rem;
}

.exam-title {
  font-family: 'Lora', serif;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.exam-meta {
  display: flex;
  gap: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.exam-list-item .btn-primary { width: auto; white-space: nowrap; }

/* Exam Preview Card */
.preview-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.preview-icon { font-size: 2rem; background: var(--accent-light); border-radius: 50%; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.preview-title { font-family: 'Lora', serif; font-size: 1.6rem; font-weight: 700; }
.preview-subject { color: var(--text-secondary); }

.preview-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stat-box {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.stat-icon { font-size: 1.1rem; color: var(--accent); }
.stat-value { font-weight: 700; font-size: 1.3rem; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); }

.warning-box {
  background: var(--warning-light);
  border: 1px solid #f7d67c;
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  text-align: left;
}

.warning-title { color: var(--warning); font-weight: 600; margin-bottom: 0.5rem; }
.warning-box ul { padding-left: 1.2rem; color: #b7770d; font-size: 0.875rem; }
.warning-box li { margin-bottom: 0.2rem; }

.back-text-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
}
.back-text-link:hover { color: var(--text-primary); }

/* ===================================================
   EXAM TAKING PAGE
   =================================================== */
.exam-page { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }

.exam-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.exam-header-title { font-family: 'Lora', serif; font-weight: 600; font-size: 1rem; }
.exam-timer { font-weight: 700; font-size: 1rem; color: var(--text-primary); }
.exam-timer.timer-urgent { color: var(--danger); }
.exam-progress { font-size: 0.85rem; color: var(--text-secondary); }

.exam-body {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 2rem;
  align-items: start;
}

.question-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.question-num { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 0.75rem; }
.question-text { font-family: 'Lora', serif; font-size: 1.25rem; font-weight: 600; margin-bottom: 1.75rem; }

.options-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2rem; }

.option {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.18s;
}

.option:hover { border-color: var(--accent); background: var(--accent-light); }
.option-selected { border-color: var(--accent) !important; background: var(--accent-light) !important; }

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

.option-selected .option-label { background: var(--accent); color: #fff; }
.option-text { font-size: 0.95rem; }

.question-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.question-nav .btn { width: auto; }

/* Navigator */
.navigator-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 80px;
}

.navigator-title { font-weight: 700; font-size: 0.875rem; margin-bottom: 1rem; }

.navigator-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}

.nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn.nav-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.nav-btn.nav-answered { background: var(--accent-light); border-color: var(--accent); }

/* ===================================================
   RESULT CARD
   =================================================== */
.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.result-icon { font-size: 1.8rem; background: var(--accent-light); border-radius: 50%; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.result-title { font-family: 'Lora', serif; font-size: 1.5rem; font-weight: 700; }
.result-exam { color: var(--text-secondary); }

.score-box {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
}

.score-pct { font-family: 'Lora', serif; font-size: 2.5rem; font-weight: 700; color: var(--accent); display: block; margin-bottom: 0.5rem; }
.score-meta { display: flex; justify-content: center; gap: 1.5rem; color: var(--text-secondary); font-size: 0.875rem; }

.result-actions { display: flex; gap: 1rem; }
.result-actions .btn { flex: 1; }

/* ===================================================
   ANSWERS PAGE
   =================================================== */
.answers-page .back-link {
  display: inline-block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.answers-page .back-link:hover { color: var(--text-primary); }

.answer-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.answer-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.answer-status {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.status-correct { background: var(--success-light); color: var(--success); }
.status-wrong { background: var(--danger-light); color: var(--danger); }

.answer-num { font-size: 0.8rem; color: var(--text-secondary); }
.answer-question { font-weight: 600; font-size: 1rem; }

.answer-options { display: flex; flex-direction: column; gap: 0.5rem; }

.answer-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  border: 1.5px solid transparent;
}

.answer-option.opt-correct { background: var(--success-light); border-color: var(--success); color: var(--success); font-weight: 600; }
.answer-option.opt-wrong { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }

.opt-label { font-weight: 700; min-width: 20px; }
.correct-badge { margin-left: auto; font-size: 0.8rem; }

/* ===================================================
   ADMIN LAYOUT
   =================================================== */
.admin-wrapper {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.admin-sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.5rem 1.25rem;
  font-family: 'Lora', serif;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item:hover, .nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item.active { font-weight: 600; }

.sidebar-signout {
  margin: 1rem;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s;
}
.sidebar-signout:hover { background: var(--surface-2); }

.admin-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.menu-toggle { background: none; border: none; font-size: 1.2rem; cursor: pointer; }
.topbar-user { color: var(--text-secondary); font-size: 0.9rem; }

.admin-main { padding: 2.5rem; flex: 1; }

/* Admin Page Header */
.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.admin-page-title {
  font-family: 'Lora', serif;
  font-size: 1.75rem;
  font-weight: 700;
}

.admin-page-header .btn-primary { width: auto; }

/* Stat Cards (Dashboard) */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.stat-label { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 0.5rem; }
.stat-number { font-family: 'Lora', serif; font-size: 2.2rem; font-weight: 700; }

/* Data Table */
.data-table-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 1rem 1.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1.5px solid var(--border);
}

.data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--surface-2);
  font-size: 0.9rem;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }

.td-bold { font-weight: 600; }
.td-muted { color: var(--text-secondary); }
.td-actions { display: flex; gap: 0.5rem; }

/* Filter Bar */
.filter-bar { margin-bottom: 1.25rem; }
.filter-input { max-width: 400px; }

/* ===================================================
   MODAL
   =================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-wide { max-width: 680px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-family: 'Lora', serif; font-size: 1.2rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-secondary); }

/* Question Builder */
.questions-section { display: flex; flex-direction: column; gap: 0.75rem; }
.questions-label { font-weight: 600; font-size: 0.9rem; color: var(--text-secondary); }

.question-builder {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  border: 1px solid var(--border);
}

.qb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.correct-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.correct-row select {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.875rem;
}

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-content { margin-left: 0; }
  .stat-cards { grid-template-columns: 1fr; }
  .exam-body { grid-template-columns: 1fr; }
  .navigator-panel { order: -1; }
  .subjects-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .subjects-grid { grid-template-columns: 1fr; }
  .student-header { padding: 1rem; }
}
