/* NextGen CBT Pro — Zero-CDN Modern Design System */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Utilities */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 10px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.w-full { width: 100%; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--mono); }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 16px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  font-family: inherit;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: #cbd5e1; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-soft-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn-soft-danger:hover { background: #fee2e2; }
.btn-soft-primary { background: var(--primary-soft); color: var(--primary); border-color: #bfdbfe; }
.btn-soft-primary:hover { background: #dbeafe; }
.btn-soft-warning { background: var(--warning-soft); color: #b45309; border-color: #fde68a; }
.btn-soft-success { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }

/* Inputs */
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, .12);
}
.textarea { min-height: 90px; resize: vertical; }
.form-group { margin-bottom: 12px; }
.form-label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 5px; color: #334155; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-title { margin: 0; font-size: 16px; font-weight: 700; }

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: #f1f5f9; color: #475569; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .2); }
.dot-red { background: #ef4444; }
.dot-amber { background: #f59e0b; }
.dot-gray { background: #94a3b8; }

/* Grid Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -0.5px; }
.stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
th {
  text-align: left;
  background: var(--surface-2);
  color: #475569;
  font-weight: 700;
  font-size: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
tr.row-blocked td { background: #fff1f2; }

/* Admin Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand img { width: 34px; height: 34px; border-radius: 8px; }
.sidebar-brand h1 { margin: 0; font-size: 15px; font-weight: 800; color: #fff; line-height: 1.2; }
.sidebar-brand small { color: #94a3b8; font-size: 11px; }
.nav-section { padding: 12px 12px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: #64748b; font-weight: 700; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin: 2px 8px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: calc(100% - 16px);
  font-family: inherit;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar-footer { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #94a3b8; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.content { padding: 20px 22px 40px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* Auth Screen */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 50%, #ecfdf5 100%);
}
.auth-card {
  width: 100%;
  max-width: 430px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
}

/* Toast */
#toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 11px 15px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.warning { background: #92400e; }

/* Alert boxes */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-info { background: var(--primary-soft); border-color: #bfdbfe; color: #1e3a8a; }
.alert-warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.alert-danger { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.alert-success { background: var(--success-soft); border-color: #a7f3d0; color: #065f46; }

/* Token Display Box */
.token-pill {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
  background: #0f172a;
  color: #34d399;
  padding: 6px 14px;
  border-radius: 8px;
  display: inline-block;
}

/* Student Exam Specific */
.exam-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 18px;
  max-width: 1260px;
  margin: 18px auto;
  padding: 0 16px 40px;
}
.q-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}
.q-num-btn {
  padding: 9px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
.q-num-btn.answered { background: #059669; color: #fff; border-color: #059669; }
.q-num-btn.doubt { background: #f59e0b; color: #fff; border-color: #d97706; }
.q-num-btn.current { outline: 3px solid #1d4ed8; outline-offset: 1px; }

.option-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  margin-bottom: 10px;
  transition: border-color .15s, background .15s;
}
.option-card:hover { border-color: #93c5fd; background: #f8fafc; }
.option-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.option-badge {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #f1f5f9;
  color: #334155;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.option-card.selected .option-badge { background: var(--primary); color: #fff; }

.timer-box {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
}
.timer-box.urgent { background: var(--danger); }

/* Mobile */
.mobile-menu-btn { display: none; }
@media (max-width: 960px) {
  .dash-grid { grid-template-columns: 1fr !important; }
  .sidebar { position: fixed; top: 0; left: 0; transform: translateX(-105%); z-index: 50; transition: transform .2s; max-width: 85vw; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex; }
  .exam-layout { grid-template-columns: 1fr; }
}
#ua-form { flex-wrap: wrap; }
#ua-form .input { flex: 1 1 160px; }

/* Print */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}
