/* ===== BASE ===== */
html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

html {
  position: relative;
  min-height: 100%;
  color-scheme: light dark;
}

/* ===== CSS VARIABLES ===== */
[data-bs-theme="light"] {
  --ep-bg: #f0f4f8;
  --ep-surface: #ffffff;
  --ep-surface-2: #f8fafc;
  --ep-border: #e2e8f0;
  --ep-text: #1e293b;
  --ep-text-muted: #64748b;
  --ep-primary: #4f46e5;
  --ep-primary-hover: #4338ca;
  --ep-primary-subtle: #eef2ff;
  --ep-navbar-bg: rgba(255, 255, 255, 0.88);
  --ep-card-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --ep-card-shadow-hover: 0 10px 28px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.07);
  --ep-card-header-gradient: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
}

[data-bs-theme="dark"] {
  --ep-bg: #0d1117;
  --ep-surface: #161b22;
  --ep-surface-2: #21262d;
  --ep-border: #30363d;
  --ep-text: #f1f5f9;
  --ep-text-muted: #8b949e;
  --ep-primary: #818cf8;
  --ep-primary-hover: #6366f1;
  --ep-primary-subtle: #1e1b4b;
  --ep-navbar-bg: rgba(22, 27, 34, 0.92);
  --ep-card-shadow: 0 1px 3px rgba(0,0,0,0.35);
  --ep-card-shadow-hover: 0 10px 30px rgba(0,0,0,0.45);
  --ep-card-header-gradient: linear-gradient(135deg, #312e81 0%, #1e1b4b 100%);
}

/* ===== LAYOUT ===== */
body {
  background-color: var(--ep-bg);
  color: var(--ep-text);
  margin-bottom: 60px;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ===== NAVBAR ===== */
.app-navbar {
  position: relative;
  z-index: 1030;
  background-color: var(--ep-navbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ep-border) !important;
  box-shadow: 0 1px 0 var(--ep-border);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--ep-primary) !important;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: opacity 0.15s ease;
}

.navbar-brand:hover {
  opacity: 0.82;
}

.navbar-brand .brand-icon {
  font-size: 1.3rem;
}

.nav-link {
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 6px;
  padding: 0.4rem 0.75rem !important;
  transition: background-color 0.15s ease, color 0.15s ease;
  color: var(--ep-text) !important;
}

.nav-link:hover {
  background-color: var(--ep-surface-2);
  color: var(--ep-text) !important;
}

.nav-link.active {
  background-color: var(--ep-primary-subtle);
  color: var(--ep-primary) !important;
}

.dropdown-toggle::after {
  margin-left: 0.35em;
  vertical-align: 0.18em;
}

.dropdown-menu {
  background-color: var(--ep-surface);
  border: 1px solid var(--ep-border);
  border-radius: 0.6rem;
  box-shadow: var(--ep-card-shadow-hover);
  padding: 0.4rem;
  font-size: 0.875rem;
}

.dropdown-item {
  border-radius: 4px;
  padding: 0.45rem 0.75rem;
  color: var(--ep-text);
  transition: background-color 0.12s ease;
}

.dropdown-item:hover {
  background-color: var(--ep-surface-2);
  color: var(--ep-text);
}

.dropdown-divider {
  border-color: var(--ep-border);
  margin: 0.35rem 0;
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--ep-border);
  background: transparent;
  color: var(--ep-text-muted);
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--ep-primary);
  color: var(--ep-primary);
  background: var(--ep-primary-subtle);
}

/* ===== CARDS ===== */
.card {
  background-color: var(--ep-surface);
  border: 1px solid var(--ep-border);
  border-radius: 0.75rem;
  box-shadow: var(--ep-card-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-body {
  padding: 1.25rem;
}

/* ===== EXAM CARDS ===== */
.exam-card {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.exam-card:hover {
  box-shadow: var(--ep-card-shadow-hover);
  transform: translateY(-2px);
}

.exam-card .card-header {
  background: var(--ep-card-header-gradient);
  color: #fff;
  border-radius: 0.75rem 0.75rem 0 0 !important;
  border: none;
  padding: 1.15rem 1.25rem 1rem;
}

.exam-card .card-header-inner {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.exam-card .card-header-icon {
  font-size: 1.35rem;
  opacity: 0.85;
  flex-shrink: 0;
  margin-top: 1px;
}

.exam-card .card-title {
  font-weight: 700;
  font-size: 0.975rem;
  margin-bottom: 0;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: #fff;
}

.exam-card .card-body {
  padding: 1rem 1.25rem;
  flex-grow: 1;
}

.exam-card .card-text {
  font-size: 0.875rem;
  color: var(--ep-text-muted);
  line-height: 1.55;
  margin: 0;
}

.exam-card .list-group-item {
  padding: 0.6rem 1.25rem;
  background-color: transparent;
  border-color: var(--ep-border);
  font-size: 0.85rem;
  color: var(--ep-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.exam-card .list-group-item:last-child {
  border-radius: 0 0 0.75rem 0.75rem;
}

.exam-card .list-group-item .action-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.exam-card .btn {
  font-size: 0.78rem;
  padding: 0.28rem 0.7rem;
  border-radius: 6px;
  flex-shrink: 0;
}

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}

.section-header-icon {
  font-size: 1.4rem;
  color: var(--ep-primary);
  line-height: 1;
}

.section-header h2 {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--ep-text);
}

.section-badge {
  background-color: var(--ep-primary-subtle);
  color: var(--ep-primary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 2rem;
  min-height: 55vh;
}

.empty-state-icon {
  font-size: 4.5rem;
  color: var(--ep-text-muted);
  margin-bottom: 1.5rem;
  opacity: 0.35;
  line-height: 1;
}

.empty-state h3 {
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.025em;
  color: var(--ep-text);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--ep-text-muted);
  font-size: 0.95rem;
  max-width: 360px;
  margin-bottom: 1.75rem;
  line-height: 1.6;
}

/* ===== SCORE COLORS ===== */
.score-high { color: #16a34a; font-weight: 600; }
.score-mid  { color: #d97706; font-weight: 600; }
.score-low  { color: #dc2626; font-weight: 600; }

[data-bs-theme="dark"] .score-high { color: #4ade80; }
[data-bs-theme="dark"] .score-mid  { color: #fbbf24; }
[data-bs-theme="dark"] .score-low  { color: #f87171; }

/* ===== TABLES ===== */
.table {
  font-size: 0.875rem;
  --bs-table-bg: transparent;
}

.table thead th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ep-text-muted);
  border-bottom: 2px solid var(--ep-border);
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
  white-space: nowrap;
}

.table tbody td {
  vertical-align: middle;
  border-color: var(--ep-border);
  color: var(--ep-text);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-accent-bg: var(--ep-surface-2);
  color: var(--ep-text);
}

/* ===== BADGES ===== */
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.35em 0.65em;
  border-radius: 6px;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
  font-size: 0.83rem;
  margin-bottom: 1rem;
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--ep-text-muted);
}

.breadcrumb-item a {
  color: var(--ep-primary);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
}

/* ===== FOOTER ===== */
.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 60px;
  line-height: 60px;
  background-color: var(--ep-navbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--ep-border) !important;
  font-size: 0.83rem;
  color: var(--ep-text-muted);
}

.footer a {
  color: var(--ep-primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* ===== KNOWLEDGE AREA CHECKLIST ===== */
.ka-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.5rem;
  border: 1px solid var(--ep-border);
  border-radius: 0.5rem;
  background-color: var(--ep-surface-2);
}

.ka-check-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.12s ease;
  user-select: none;
}

.ka-check-item:hover {
  background-color: var(--ep-primary-subtle);
}

.ka-check-input {
  flex-shrink: 0;
  accent-color: var(--ep-primary);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.ka-check-input:checked + .ka-check-label {
  color: var(--ep-primary);
  font-weight: 600;
}

.ka-check-label {
  font-size: 0.875rem;
  color: var(--ep-text);
  transition: color 0.12s ease;
}

/* ===== QUIZ OPTIONS ===== */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--ep-border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  user-select: none;
}

.quiz-option:hover {
  border-color: var(--ep-primary);
  background-color: var(--ep-primary-subtle);
}

.quiz-option.selected {
  border-color: var(--ep-primary);
  background-color: var(--ep-primary-subtle);
}

.quiz-option-input {
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--ep-primary);
}

.quiz-option-key {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--ep-primary);
  min-width: 1.25rem;
}

.quiz-option-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ep-text);
}

/* ===== QUIZ NAVIGATOR WIDGET ===== */
.quiz-nav-widget {
  position: sticky;
  top: 80px;
}

.quiz-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.quiz-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 6px;
  border: 1px solid var(--ep-border);
  background-color: var(--ep-surface-2);
  color: var(--ep-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.quiz-nav-btn:hover {
  border-color: var(--ep-primary);
  color: var(--ep-primary);
  background-color: var(--ep-primary-subtle);
}

.quiz-nav-btn.current {
  background-color: var(--ep-primary);
  border-color: var(--ep-primary);
  color: #fff;
}

.quiz-nav-btn.answered {
  background-color: #dcfce7;
  border-color: #16a34a;
  color: #15803d;
}

[data-bs-theme="dark"] .quiz-nav-btn.answered {
  background-color: #14532d;
  border-color: #4ade80;
  color: #4ade80;
}

.quiz-nav-btn.flagged {
  background-color: #fef9c3;
  border-color: #d97706;
  color: #92400e;
}

[data-bs-theme="dark"] .quiz-nav-btn.flagged {
  background-color: #451a03;
  border-color: #fbbf24;
  color: #fbbf24;
}

.quiz-nav-flag {
  font-size: 0.6rem;
}

/* ===== QUIZ NAV LEGEND ===== */
.quiz-nav-legend {
  font-size: 0.72rem;
}

.legend-item {
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--ep-border);
}

.legend-current {
  background-color: var(--ep-primary);
  border-color: var(--ep-primary);
  color: #fff;
}

.legend-answered {
  background-color: #dcfce7;
  border-color: #16a34a;
  color: #15803d;
}

[data-bs-theme="dark"] .legend-answered {
  background-color: #14532d;
  border-color: #4ade80;
  color: #4ade80;
}

.legend-flagged {
  background-color: #fef9c3;
  border-color: #d97706;
  color: #92400e;
}

[data-bs-theme="dark"] .legend-flagged {
  background-color: #451a03;
  border-color: #fbbf24;
  color: #fbbf24;
}

.legend-unanswered {
  background-color: var(--ep-surface-2);
  color: var(--ep-text-muted);
}

/* ===== QUIZ TIMER ===== */
.quiz-timer-badge {
  background-color: var(--ep-primary);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
}

.quiz-timer-urgent {
  background-color: #dc2626 !important;
  animation: timer-pulse 1s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* ===== FINISH SCREEN ===== */
.finish-question-list .finish-question-row {
  padding: 0.75rem 1rem;
  border-color: var(--ep-border);
  background-color: transparent;
  color: var(--ep-text);
  transition: background-color 0.12s ease;
}

.finish-question-row:hover {
  background-color: var(--ep-surface-2);
}

.finish-row-flagged {
  border-left: 3px solid #d97706;
}

.finish-q-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.finish-q-number.answered {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #16a34a;
}

[data-bs-theme="dark"] .finish-q-number.answered {
  background-color: #14532d;
  color: #4ade80;
  border-color: #4ade80;
}

.finish-q-number.unanswered {
  background-color: var(--ep-surface-2);
  color: var(--ep-text-muted);
  border: 1px solid var(--ep-border);
}

.finish-q-text {
  font-size: 0.875rem;
  color: var(--ep-text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 0; /* forces truncation in flex */
  min-width: 50px;
}

/* ===== FORMS ===== */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem var(--ep-surface), 0 0 0 0.25rem var(--ep-primary);
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
  color: var(--ep-text-muted);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ===== PAGE TITLES ===== */
.page-title {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--ep-text);
}
