:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --secondary: #312e81;
  --accent: #06b6d4;
  --bg: #f0fdfa;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --sidebar-w: 240px;
  --radius: 10px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 14px;
  font-weight: 500; border: none; cursor: pointer;
  transition: all .15s ease; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #1e1b4b; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-success { background: var(--success); color: #fff; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; background: #fff;
  transition: border-color .15s; outline: none; color: var(--text);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,.12); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 16px; font-weight: 700; color: var(--text); }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: #f8fafc; padding: 11px 14px; text-align: left;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-gray    { background: #f1f5f9; color: #475569; }

/* ══════════════════════════════════════════════════════════
   ADMIN LAYOUT
══════════════════════════════════════════════════════════ */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: var(--secondary);
  color: #fff; flex-shrink: 0; display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo img { width: 38px; height: 38px; object-fit: contain; }
.sidebar-logo-text { font-size: 15px; font-weight: 700; line-height: 1.2; }
.sidebar-logo-sub { font-size: 10px; opacity: .6; font-weight: 400; }

.sidebar-nav { padding: 16px 0; flex: 1; }
.nav-section { padding: 8px 16px 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; opacity: .4; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(255,255,255,.75); font-size: 14px;
  transition: all .15s; border-left: 3px solid transparent;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.08); color: #fff;
  border-left-color: var(--accent);
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1);
  font-size: 13px; opacity: .6;
}

.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

.page-content { padding: 28px; }

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 20px; border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; color: var(--secondary); }
.stat-icon { float: right; font-size: 28px; opacity: .15; margin-top: -36px; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tab-btn {
  padding: 10px 18px; font-size: 14px; font-weight: 500;
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: all .15s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Skill Chip ──────────────────────────────────────────── */
.skill-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #ede9fe; color: var(--secondary);
  padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 500;
  margin: 2px;
}

/* ══════════════════════════════════════════════════════════
   CANDIDATE / EXAM
══════════════════════════════════════════════════════════ */
.exam-layout { min-height: 100vh; background: #f8fafc; }

.exam-header {
  background: var(--secondary); color: #fff;
  padding: 14px 28px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.exam-brand { display: flex; align-items: center; gap: 10px; }
.exam-brand img { width: 34px; height: 34px; object-fit: contain; }
.exam-brand-name { font-size: 15px; font-weight: 700; }

.timer-box {
  background: rgba(255,255,255,.12); border-radius: 8px;
  padding: 8px 16px; text-align: center;
}
.timer-label { font-size: 10px; opacity: .7; text-transform: uppercase; letter-spacing: .5px; }
.timer-value { font-size: 22px; font-weight: 800; letter-spacing: 2px; }
.timer-box.warning { background: rgba(217,119,6,.3); }
.timer-box.danger  { background: rgba(220,38,38,.4); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.7} }

.question-progress {
  background: #fff; padding: 12px 28px;
  border-bottom: 1px solid var(--border); display: flex;
  align-items: center; gap: 16px; font-size: 13px; flex-wrap: wrap;
}
.progress-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; min-width: 100px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; }

.exam-body { max-width: 860px; margin: 0 auto; padding: 24px 20px 80px; }

.question-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 20px;
  overflow: hidden;
}
.question-card-header {
  background: #f8fafc; padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.question-number { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.question-marks { font-size: 12px; background: #ede9fe; color: var(--secondary); padding: 2px 8px; border-radius: 12px; font-weight: 600; }
.question-body { padding: 18px; }
.question-text { font-size: 15px; line-height: 1.7; margin-bottom: 18px; font-weight: 500; }

.options-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.option-item label {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border: 1.5px solid var(--border);
  border-radius: 8px; cursor: pointer; transition: all .15s; line-height: 1.5;
}
.option-item input[type=radio] { flex-shrink: 0; margin-top: 2px; accent-color: var(--primary); }
.option-item label:hover { border-color: var(--primary); background: #f0fdfa; }
.option-item input:checked + span { font-weight: 500; }
.option-item:has(input:checked) label { border-color: var(--primary); background: #f0fdfa; }

.short-answer input { width: 100%; }

.submit-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; padding: 14px 28px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 -4px 12px rgba(0,0,0,.06); z-index: 90;
}
.answered-count { font-size: 14px; color: var(--text-muted); }

/* ── Auth / Landing ──────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: linear-gradient(135deg, var(--secondary) 0%, #1e3a5f 50%, var(--primary-dark) 100%);
  padding: 20px;
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo img { width: 70px; height: 70px; object-fit: contain; }
.auth-logo h1 { font-size: 22px; font-weight: 800; color: var(--secondary); margin-top: 10px; }
.auth-logo p { font-size: 13px; color: var(--text-muted); }
.auth-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.auth-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

/* ── Result Page ─────────────────────────────────────────── */
.result-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.result-card { background: #fff; border-radius: 16px; padding: 48px 40px; max-width: 500px; width: 100%; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,.08); }
.score-circle {
  width: 140px; height: 140px; border-radius: 50%; margin: 0 auto 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 38px; font-weight: 900; color: #fff;
}
.score-circle.high   { background: linear-gradient(135deg, var(--success), #4ade80); }
.score-circle.medium { background: linear-gradient(135deg, var(--warning), #fbbf24); }
.score-circle.low    { background: linear-gradient(135deg, var(--danger), #f87171); }
.score-label { font-size: 12px; font-weight: 600; opacity: .8; margin-top: -4px; }

/* ── Misc ────────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 800; }
.page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.full-width { width: 100%; }

/* ── Skill selector for question set ─────────────────────── */
.skill-row { display: flex; align-items: center; gap: 12px; padding: 10px; background: #f8fafc; border-radius: 8px; margin-bottom: 8px; }
.skill-row .form-control { width: auto; }

/* ── Code/pre ────────────────────────────────────────────── */
.copy-box {
  background: #1e293b; color: #e2e8f0; padding: 16px 20px;
  border-radius: 8px; font-family: monospace; font-size: 13px;
  word-break: break-all; position: relative;
}
.copy-box button {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,.15); color: #fff; border: none;
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.copy-box button:hover { background: rgba(255,255,255,.25); }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
