/* ============================================================
   Online E-Assessment System — Design System
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #0ea5e9;
  --info-light: #e0f2fe;

  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --sidebar-width: 264px;
  --topbar-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);

  --transition: all .2s ease;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--gray-900); letter-spacing: -.015em; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- App Layout ---------- */
.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #cbd5e1;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.app-sidebar .brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-weight: 700;
  color: #fff;
  font-size: 1rem;
  letter-spacing: -.01em;
}
.app-sidebar .brand .brand-logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  display: grid; place-items: center;
  color: #fff; font-size: 1.05rem;
}
.app-sidebar .brand small { display: block; font-size: .7rem; font-weight: 400; color: #94a3b8; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .75rem; }
.sidebar-nav .nav-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: #64748b; padding: .75rem .75rem .35rem; font-weight: 600;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .75rem; border-radius: var(--radius-sm);
  color: #cbd5e1; font-weight: 500; font-size: .875rem;
  transition: var(--transition); margin-bottom: 2px;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active {
  background: linear-gradient(90deg, rgba(79,70,229,.9), rgba(99,102,241,.7));
  color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.35);
}

.sidebar-footer {
  padding: 1rem .75rem;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: .75rem; color: #64748b;
}

.app-topbar {
  position: fixed;
  top: 0; right: 0; left: var(--sidebar-width);
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 1.5rem; gap: 1rem;
  z-index: 1020;
  transition: var(--transition);
}
.app-topbar .page-title { font-weight: 700; font-size: 1.05rem; margin: 0; }
.app-topbar .page-title small { display:block; font-weight:400; font-size:.75rem; color: var(--gray-500); }

.topbar-search {
  position: relative; max-width: 360px; width: 100%;
}
.topbar-search input {
  width: 100%; border: 1px solid var(--gray-200);
  background: var(--gray-50); border-radius: 10px;
  padding: .5rem .9rem .5rem 2.35rem; font-size: .85rem;
  transition: var(--transition);
}
.topbar-search input:focus {
  outline: none; background: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.topbar-search i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--gray-400); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--gray-200); background: #fff;
  display: grid; place-items: center; color: var(--gray-600);
  transition: var(--transition); position: relative;
}
.icon-btn:hover { background: var(--gray-50); color: var(--primary); border-color: var(--primary); }
.icon-btn .dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid #fff;
}

.user-chip {
  display: flex; align-items: center; gap: .6rem;
  padding: .35rem .6rem .35rem .35rem;
  border-radius: 999px; border: 1px solid var(--gray-200);
  background: #fff; cursor: pointer; transition: var(--transition);
}
.user-chip:hover { border-color: var(--primary); }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff; display: grid; place-items: center;
  font-weight: 600; font-size: .8rem;
}
.user-chip .meta { line-height: 1.1; }
.user-chip .meta strong { display: block; font-size: .8rem; color: var(--gray-800); }
.user-chip .meta span { font-size: .7rem; color: var(--gray-500); }

.app-main {
  margin-left: var(--sidebar-width);
  padding: calc(var(--topbar-height) + 1.5rem) 1.5rem 2rem;
  min-height: 100vh;
  transition: var(--transition);
}

/* ---------- Cards ---------- */
.card-clean {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card-clean:hover { box-shadow: var(--shadow-md); }
.card-clean .card-head {
  padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.card-clean .card-head h6 { margin: 0; font-size: .95rem; font-weight: 700; }
.card-clean .card-body { padding: 1.25rem; }

/* Stat cards */
.stat-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.25rem;
  margin-bottom: .85rem;
}
.stat-card .stat-value { font-size: 1.85rem; font-weight: 800; line-height: 1; color: var(--gray-900); letter-spacing: -.03em; }
.stat-card .stat-label { font-size: .8rem; color: var(--gray-500); margin-top: .35rem; font-weight: 500; }
.stat-card .stat-trend { font-size: .72rem; font-weight: 600; margin-top: .6rem; display: inline-flex; align-items: center; gap: .25rem; }
.stat-card .stat-trend.up { color: var(--success); }
.stat-card .stat-trend.down { color: var(--danger); }

.stat-card.primary .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.info    .stat-icon { background: var(--info-light); color: var(--info); }
.stat-card.danger  .stat-icon { background: var(--danger-light); color: var(--danger); }

/* ---------- Buttons ---------- */
.btn { font-weight: 600; font-size: .85rem; border-radius: 9px; padding: .55rem 1rem; transition: var(--transition); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-soft-primary { background: var(--primary-light); color: var(--primary); border: none; }
.btn-soft-primary:hover { background: #e0e7ff; color: var(--primary-dark); }
.btn-soft-danger { background: var(--danger-light); color: var(--danger); border: none; }
.btn-soft-danger:hover { background: #fecaca; color: #b91c1c; }
.btn-soft-success { background: var(--success-light); color: #047857; border: none; }
.btn-soft-success:hover { background: #a7f3d0; color: #065f46; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px; }

/* ---------- Tables ---------- */
.table-clean { margin: 0; }
.table-clean thead th {
  background: var(--gray-50); color: var(--gray-500);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 700; border-bottom: 1px solid var(--gray-200);
  padding: .75rem 1rem; white-space: nowrap;
}
.table-clean tbody td {
  padding: .85rem 1rem; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle; font-size: .85rem; color: var(--gray-700);
}
.table-clean tbody tr:hover { background: var(--gray-50); }
.table-clean tbody tr:last-child td { border-bottom: none; }

.student-cell { display: flex; align-items: center; gap: .75rem; }
.student-cell .avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #818cf8, #4f46e5);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.student-cell .meta strong { display: block; color: var(--gray-900); font-size: .85rem; }
.student-cell .meta span { font-size: .72rem; color: var(--gray-500); }

/* ---------- Badges ---------- */
.badge-soft { padding: .3rem .6rem; border-radius: 6px; font-size: .7rem; font-weight: 600; }
.badge-soft.success { background: var(--success-light); color: #047857; }
.badge-soft.warning { background: var(--warning-light); color: #b45309; }
.badge-soft.danger  { background: var(--danger-light); color: #b91c1c; }
.badge-soft.info    { background: var(--info-light); color: #0369a1; }
.badge-soft.primary { background: var(--primary-light); color: var(--primary); }
.badge-soft.secondary { background: var(--gray-100); color: var(--gray-600); }

/* ---------- Forms ---------- */
.form-label { font-size: .8rem; font-weight: 600; color: var(--gray-700); margin-bottom: .35rem; }
.form-control, .form-select {
  border: 1px solid var(--gray-300); border-radius: 9px;
  padding: .55rem .85rem; font-size: .85rem; transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

/* ---------- Login Page ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
  background: #fff;
}
.auth-hero {
  background: linear-gradient(135deg, #0f172a 0%, #312e81 50%, #4f46e5 100%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-hero::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(129,140,248,.35), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(99,102,241,.4), transparent 45%);
  pointer-events: none;
}
.auth-hero .brand-row { display: flex; align-items: center; gap: .75rem; position: relative; }
.auth-hero .brand-logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(255,255,255,.15); backdrop-filter: blur(10px);
  display: grid; place-items: center; font-size: 1.3rem;
}
.auth-hero h1 { font-size: 2.4rem; line-height: 1.15; margin: 2rem 0 1rem; position: relative; letter-spacing: -.03em; }
.auth-hero p.lead { color: #c7d2fe; font-size: 1rem; position: relative; max-width: 440px; }
.auth-hero .feature-list { list-style: none; padding: 0; margin: 2rem 0; position: relative; }
.auth-hero .feature-list li { display: flex; align-items: center; gap: .75rem; margin-bottom: .85rem; color: #e0e7ff; font-size: .9rem; }
.auth-hero .feature-list i { color: #34d399; font-size: 1.1rem; }
.auth-hero .footer-note { font-size: .78rem; color: #94a3b8; position: relative; }

.auth-form-wrap {
  display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.auth-form { width: 100%; max-width: 400px; }
.auth-form .auth-logo-mobile { display: none; }
.auth-form h2 { font-size: 1.6rem; margin-bottom: .35rem; }
.auth-form .auth-sub { color: var(--gray-500); font-size: .875rem; margin-bottom: 2rem; }
.auth-form .form-control { padding: .7rem .9rem; font-size: .9rem; }
.auth-form .input-group-text { background: var(--gray-50); border: 1px solid var(--gray-300); border-right: none; border-radius: 9px 0 0 9px; color: var(--gray-400); }
.auth-form .input-group .form-control { border-left: none; border-radius: 0 9px 9px 0; }
.auth-form .input-group:focus-within .input-group-text { border-color: var(--primary); color: var(--primary); }
.auth-form .input-group:focus-within .form-control { box-shadow: none; }
.auth-form .form-check-label { font-size: .8rem; color: var(--gray-600); }
.auth-form .btn-primary { padding: .7rem 1rem; font-size: .9rem; }

/* ---------- Exam Layout ---------- */
body[data-page="student-exam"] { background: var(--gray-100); overflow: hidden; height: 100vh; }
.exam-shell { height: 100vh; display: flex; flex-direction: column; }
.exam-header {
  height: 64px; background: #fff; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; padding: 0 1.25rem; gap: 1rem; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.exam-header .exam-title { font-weight: 700; font-size: .95rem; }
.exam-header .exam-title small { display:block; font-size:.72rem; color: var(--gray-500); font-weight: 400; }
.exam-timer {
  margin-left: auto; display: flex; align-items: center; gap: .6rem;
  padding: .5rem .9rem; background: var(--primary-light); border-radius: 10px;
  font-weight: 700; color: var(--primary); font-size: 1rem; font-variant-numeric: tabular-nums;
}
.exam-timer.warning { background: var(--warning-light); color: #b45309; }
.exam-timer.danger { background: var(--danger-light); color: #b91c1c; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .65; } }

.exam-body { flex: 1; display: flex; overflow: hidden; }
.exam-question-area { flex: 1; overflow-y: auto; padding: 1.5rem; }
.exam-navigator {
  width: 300px; background: #fff; border-left: 1px solid var(--gray-200);
  padding: 1.25rem; overflow-y: auto; flex-shrink: 0;
  display: flex; flex-direction: column;
}
.exam-navigator h6 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); margin-bottom: .75rem; }
.qnav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; margin-bottom: 1.25rem; }
.qnav-btn {
  aspect-ratio: 1; border-radius: 9px; border: 1.5px solid var(--gray-200);
  background: #fff; color: var(--gray-700); font-weight: 600; font-size: .85rem;
  display: grid; place-items: center; cursor: pointer; transition: var(--transition);
}
.qnav-btn:hover { border-color: var(--primary); color: var(--primary); }
.qnav-btn.answered { background: var(--success); border-color: var(--success); color: #fff; }
.qnav-btn.marked { background: var(--warning); border-color: var(--warning); color: #fff; }
.qnav-btn.current { border-color: var(--primary); border-width: 2.5px; color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.qnav-btn.answered.current, .qnav-btn.marked.current { color: #fff; }

.qnav-legend { font-size: .75rem; color: var(--gray-600); margin-bottom: 1rem; }
.qnav-legend .row { display:flex; align-items:center; gap:.5rem; margin-bottom:.4rem; }
.qnav-legend .swatch { width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--gray-200); }
.qnav-legend .swatch.answered { background: var(--success); border-color: var(--success); }
.qnav-legend .swatch.marked { background: var(--warning); border-color: var(--warning); }
.qnav-legend .swatch.current { border-color: var(--primary); border-width: 2px; }

.exam-progress { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--gray-200); }
.exam-progress .progress { height: 8px; border-radius: 4px; background: var(--gray-100); }
.exam-progress .progress-bar { background: linear-gradient(90deg, var(--primary), #818cf8); }
.exam-progress .progress-meta { display:flex; justify-content:space-between; font-size:.75rem; color: var(--gray-500); margin-bottom:.4rem; }

.question-card { max-width: 880px; margin: 0 auto; }
.question-card .q-number { font-size: .75rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; }
.question-card .q-text { font-size: 1.05rem; font-weight: 600; color: var(--gray-900); line-height: 1.6; margin-bottom: 1.25rem; }
.question-card .q-image { max-width: 100%; border-radius: var(--radius); margin-bottom: 1.25rem; border: 1px solid var(--gray-200); }

.option-item {
  display: flex; align-items: flex-start; gap: .85rem;
  padding: 1rem 1.1rem; border: 1.5px solid var(--gray-200);
  border-radius: 11px; cursor: pointer; transition: var(--transition);
  margin-bottom: .65rem; background: #fff;
}
.option-item:hover { border-color: var(--primary); background: var(--primary-light); }
.option-item.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.option-item .option-key {
  width: 26px; height: 26px; border-radius: 7px; border: 1.5px solid var(--gray-300);
  display: grid; place-items: center; font-weight: 700; font-size: .78rem; color: var(--gray-600); flex-shrink: 0;
}
.option-item.selected .option-key { background: var(--primary); border-color: var(--primary); color: #fff; }
.option-item .option-text { flex: 1; font-size: .9rem; color: var(--gray-700); padding-top: 2px; }
.option-item.selected .option-text { color: var(--gray-900); font-weight: 500; }

.exam-footer {
  background: #fff; border-top: 1px solid var(--gray-200);
  padding: .85rem 1.5rem; display: flex; align-items: center; gap: .6rem;
  flex-shrink: 0;
}

/* ---------- Status / Empty States ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state .icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--gray-100); color: var(--gray-400);
  display: grid; place-items: center; font-size: 1.6rem; margin: 0 auto 1rem;
}
.empty-state h6 { font-size: .95rem; margin-bottom: .35rem; }
.empty-state p { font-size: .82rem; color: var(--gray-500); margin: 0; }

/* ---------- Subject Cards (Student) ---------- */
.subject-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  transition: var(--transition); position: relative; overflow: hidden;
}
.subject-card:hover { box-shadow: var(--shadow-md); border-color: var(--gray-300); }
.subject-card .sub-icon {
  width: 52px; height: 52px; border-radius: 13px;
  display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0;
}
.subject-card .sub-body { flex: 1; min-width: 0; }
.subject-card .sub-body h6 { margin: 0 0 .2rem; font-size: .95rem; }
.subject-card .sub-body .sub-meta { font-size: .75rem; color: var(--gray-500); display: flex; gap: .9rem; flex-wrap: wrap; }
.subject-card .sub-body .sub-meta span { display: inline-flex; align-items: center; gap: .25rem; }

.subject-card.locked { opacity: .68; background: var(--gray-50); }
.subject-card.locked:hover { box-shadow: var(--shadow-sm); border-color: var(--gray-200); }
.subject-card.locked .sub-icon { background: var(--gray-200) !important; color: var(--gray-400) !important; }
.subject-card.completed .sub-icon { background: var(--success-light) !important; color: var(--success) !important; }
.subject-card.available .sub-icon { background: var(--primary-light) !important; color: var(--primary) !important; }

/* Lock overlay badge */
.subject-card .lock-badge {
  position: absolute; top: .75rem; right: .75rem;
  font-size: .68rem; font-weight: 600; color: var(--gray-500);
  background: var(--gray-100); padding: .2rem .55rem; border-radius: 6px;
  display: inline-flex; align-items: center; gap: .25rem;
}

/* ---------- Progress Ring (Dashboard) ---------- */
.progress-ring { position: relative; width: 120px; height: 120px; }
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring .ring-bg { fill: none; stroke: var(--gray-100); stroke-width: 10; }
.progress-ring .ring-fg { fill: none; stroke: url(#ringGradient); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.progress-ring .ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 800; font-size: 1.4rem; color: var(--gray-900);
}
.progress-ring .ring-label small { display:block; font-size:.65rem; font-weight:500; color: var(--gray-500); text-align:center; }

/* ---------- Misc ---------- */
.avatar-sm { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.divider { height: 1px; background: var(--gray-200); margin: 1rem 0; }
.text-muted-sm { font-size: .78rem; color: var(--gray-500); }

.toast-container { z-index: 1090; }

/* Responsive */
@media (max-width: 992px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .app-topbar { left: 0; }
  .app-main { margin-left: 0; padding: calc(var(--topbar-height) + 1rem) 1rem 2rem; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-form .auth-logo-mobile { display: flex; align-items: center; gap: .75rem; margin-bottom: 2rem; }
  .auth-form .auth-logo-mobile .brand-logo { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--primary), #818cf8); color:#fff; display:grid; place-items:center; }
  .exam-navigator { display: none; }
  .exam-navigator.mobile-open { display: flex; position: fixed; inset: 0; width: 100%; z-index: 1050; }
}
@media (max-width: 576px) {
  .topbar-search { display: none; }
  .stat-card .stat-value { font-size: 1.5rem; }
}