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

:root {
  --blue:      #1a5fa8;
  --blue-dark: #14437a;
  --blue-lt:   #e8f0fb;
  --green:     #27ae60;
  --green-lt:  #eafaf1;
  --red:       #e74c3c;
  --red-lt:    #fdedec;
  --orange:    #e67e22;
  --bg:        #f0f4f8;
  --card:      #ffffff;
  --text:      #2c3e50;
  --muted:     #6c7a8d;
  --border:    #dce3ec;
  --radius:    8px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
}

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

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--blue);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  position: sticky; top: 0; z-index: 100;
}
.navbar-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 58px;
}
.navbar-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; }
.navbar-brand:hover { text-decoration: none; color: #fff; }
.brand-aes { background: #fff; color: var(--blue); padding: 3px 9px; border-radius: 5px; font-size: 16px; }
.brand-text { opacity: .9; }
.navbar-right { display: flex; align-items: center; gap: 12px; }
.nav-user { color: rgba(255,255,255,.85); font-size: 14px; }
.nav-badge { background: rgba(255,255,255,.2); color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }

/* ── Container ────────────────────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.container-narrow { max-width: 860px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); font-size: 14px; font-weight: 600;
  cursor: pointer; border: 2px solid transparent; transition: all .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(.93); }
.btn-primary  { background: var(--blue);  color: #fff; border-color: var(--blue); }
.btn-success  { background: var(--green); color: #fff; border-color: var(--green); }
.btn-danger   { background: var(--red);   color: #fff; border-color: var(--red); }
.btn-outline  { background: transparent;  color: var(--blue); border-color: var(--blue); }
.btn-outline:hover { background: var(--blue-lt); }
.btn-sm  { padding: 6px 13px; font-size: 13px; }
.btn-xs  { padding: 4px 10px; font-size: 12px; border-radius: 5px; }
.btn-xl  { padding: 14px 28px; font-size: 16px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-danger  { background: var(--red-lt);  color: #922b21; border: 1px solid #f5b7b1; }
.alert-success { background: var(--green-lt);color: #1e6b3e; border: 1px solid #a9dfbf; }
.alert-warning { background: #fef9e7; color: #7d6608; border: 1px solid #f9e79f; }

/* ── Auth page ────────────────────────────────────────────────────────────── */
.auth-body { background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-box { background: #fff; border-radius: 14px; box-shadow: 0 8px 40px rgba(0,0,0,.2); padding: 44px 40px; width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.logo-firm { display: block; font-size: 36px; font-weight: 900; color: var(--blue); letter-spacing: -1px; }
.logo-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.auth-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 24px; color: var(--text); }
.auth-hint { margin-top: 20px; text-align: center; font-size: 13px; color: var(--muted); }

/* ── Form fields ──────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--text); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,95,168,.12);
}
.field input[readonly] { background: #f8f9fa; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }
.checkbox-group { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 6px; }
.checkbox-group label { display: flex; align-items: center; gap: 6px; font-weight: 400; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-success { background: var(--green-lt); color: var(--green); }
.badge-danger  { background: var(--red-lt);   color: var(--red); }
.badge-lg { font-size: 15px; padding: 5px 14px; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 26px; font-weight: 800; color: var(--text); }
.subtitle { color: var(--muted); font-size: 14px; margin-top: 2px; }
.breadcrumb { margin-bottom: 16px; font-size: 14px; }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-card { background: var(--card); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); margin-bottom: 24px; }
.progress-info { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 10px; }
.progress-bar-wrap { background: var(--border); border-radius: 20px; height: 10px; overflow: hidden; }
.progress-bar-fill { background: linear-gradient(90deg, var(--blue), #4a9edd); height: 100%; border-radius: 20px; transition: width .4s; }

/* ── Topics grid ──────────────────────────────────────────────────────────── */
.topics-grid { display: flex; flex-direction: column; gap: 8px; }
.cast-header { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-top: 20px; margin-bottom: 4px; padding: 0 4px; }
.topic-card {
  display: flex; align-items: center; gap: 16px; background: var(--card);
  border: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
  text-decoration: none; color: var(--text); transition: all .15s;
}
.topic-card:hover { border-color: var(--blue); box-shadow: var(--shadow); transform: translateX(2px); }
.topic-card.done { border-color: var(--green); background: var(--green-lt); }
.topic-num { width: 32px; height: 32px; border-radius: 50%; background: var(--blue-lt); color: var(--blue); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.topic-card.done .topic-num { background: var(--green); color: #fff; }
.topic-body { flex: 1; }
.topic-title { font-weight: 600; font-size: 15px; }
.topic-meta { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 8px; }
.topic-arrow { color: var(--muted); font-size: 20px; }

/* ── Exam/Info banners ────────────────────────────────────────────────────── */
.exam-banner, .info-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-radius: var(--radius); margin-top: 28px; gap: 16px; flex-wrap: wrap;
}
.exam-banner { background: var(--green-lt); border: 1.5px solid var(--green); }
.info-banner { background: var(--blue-lt);  border: 1.5px solid #a8c8ef; font-size: 14px; color: var(--blue); }

/* ── Topic article ────────────────────────────────────────────────────────── */
.tema-article { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 24px; overflow: hidden; }
.tema-header { background: var(--blue); color: #fff; padding: 28px 32px; }
.tema-cast-badge { font-size: 12px; background: rgba(255,255,255,.2); padding: 3px 10px; border-radius: 20px; }
.tema-header h1 { font-size: 24px; margin-top: 10px; }
.tema-meta { opacity: .85; margin-top: 8px; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.tema-content { padding: 32px; }
.tema-content h2, .tema-content h3 { color: var(--blue); margin: 24px 0 10px; }
.tema-content p { margin-bottom: 14px; line-height: 1.75; }
.tema-content ul, .tema-content ol { padding-left: 22px; margin-bottom: 14px; }
.tema-content li { margin-bottom: 6px; line-height: 1.65; }
.tema-content .law-ref { background: var(--blue-lt); border-left: 4px solid var(--blue); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 16px 0; font-size: 14px; }
.tema-content .key-point { background: #fff8e1; border-left: 4px solid var(--orange); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 16px 0; }
.placeholder-content { text-align: center; padding: 48px 32px; color: var(--muted); }
.placeholder-icon { font-size: 48px; margin-bottom: 16px; }
.placeholder-content h3 { color: var(--text); font-size: 20px; margin-bottom: 10px; }
.placeholder-content ul { text-align: left; display: inline-block; margin-top: 14px; }
.tema-nav { display: flex; justify-content: space-between; align-items: center; padding: 20px 0; gap: 12px; }
.tema-nav-center { flex: 1; text-align: center; }

/* ── Exam ─────────────────────────────────────────────────────────────────── */
.exam-body { background: #1a2744; }
.exam-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; padding: 20px 0; border-bottom: 1px solid rgba(255,255,255,.1); flex-wrap: wrap; gap: 12px; }
.exam-header h1 { color: #fff; font-size: 24px; }
.exam-header p { color: rgba(255,255,255,.7); margin-top: 4px; }
.exam-timer-wrap { text-align: center; }
.exam-timer { font-size: 36px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.exam-timer.warning { color: #f39c12; }
.exam-timer.danger  { color: var(--red); animation: pulse 1s infinite; }
.exam-timer-wrap small { color: rgba(255,255,255,.6); font-size: 12px; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.exam-info-bar { display: flex; gap: 20px; background: rgba(255,255,255,.07); border-radius: var(--radius); padding: 12px 20px; margin-bottom: 24px; font-size: 14px; color: rgba(255,255,255,.8); flex-wrap: wrap; }
.question-card { background: #fff; border-radius: var(--radius); padding: 24px 28px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.question-num { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; margin-bottom: 10px; }
.question-text { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 18px; line-height: 1.5; }
.question-options { display: flex; flex-direction: column; gap: 10px; }
.option-label { display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all .15s; }
.option-label:hover { border-color: var(--blue); background: var(--blue-lt); }
.option-label:has(input:checked) { border-color: var(--blue); background: var(--blue-lt); }
.option-label input { flex-shrink: 0; margin-top: 2px; accent-color: var(--blue); width: 16px; height: 16px; }
.option-key { font-weight: 700; color: var(--blue); min-width: 20px; }
.option-text { flex: 1; }
.exam-submit-bar { background: rgba(255,255,255,.07); border-radius: var(--radius); padding: 20px 24px; margin-top: 10px; text-align: center; }

/* ── Results ──────────────────────────────────────────────────────────────── */
.result-card { background: var(--card); border-radius: 14px; padding: 40px 32px; text-align: center; box-shadow: var(--shadow); margin-bottom: 32px; border: 3px solid var(--border); }
.result-pass { border-color: var(--green); }
.result-fail { border-color: var(--red); }
.result-icon { font-size: 52px; margin-bottom: 10px; }
.result-verdict { font-size: 32px; font-weight: 900; margin-bottom: 8px; }
.result-pass .result-verdict { color: var(--green); }
.result-fail .result-verdict { color: var(--red); }
.result-score { font-size: 22px; margin-bottom: 20px; color: var(--text); }
.result-meta { font-size: 15px; color: var(--muted); line-height: 1.9; margin-bottom: 24px; }
.result-actions { margin-top: 8px; }
.result-retry { color: var(--muted); font-size: 14px; margin-top: 16px; }

/* ── Answer review ────────────────────────────────────────────────────────── */
.answers-review h2 { font-size: 20px; margin-bottom: 16px; }
.review-item { display: flex; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 10px; border-left: 4px solid var(--border); }
.review-ok   { border-left-color: var(--green); }
.review-wrong{ border-left-color: var(--red); }
.review-num  { font-weight: 800; color: var(--muted); min-width: 28px; }
.review-body { flex: 1; }
.review-q    { font-weight: 600; margin-bottom: 10px; }
.review-answers { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.review-option { padding: 5px 10px; border-radius: 5px; }
.review-option.correct { background: var(--green-lt); color: var(--green); font-weight: 600; }
.review-option.wrong-chosen { background: var(--red-lt); color: var(--red); font-weight: 600; }

/* ── Admin layout ─────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: calc(100vh - 58px); }
.admin-sidebar { width: 220px; flex-shrink: 0; background: var(--blue-dark); padding: 20px 0; }
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-nav a { padding: 12px 20px; color: rgba(255,255,255,.75); font-size: 14px; font-weight: 500; transition: all .15s; text-decoration: none; border-left: 3px solid transparent; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: #fff; font-weight: 700; }
.sidebar-nav hr { border: none; border-top: 1px solid rgba(255,255,255,.1); margin: 10px 0; }
.sidebar-logout { color: rgba(255,100,100,.8) !important; }
.admin-main { flex: 1; padding: 32px; overflow-x: auto; }
.admin-page-title { font-size: 26px; font-weight: 800; margin-bottom: 24px; }
.admin-section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h2 { font-size: 18px; }

/* ── Stats ────────────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 18px; text-align: center; border-top: 4px solid var(--border); }
.stat-active  { border-top-color: var(--blue); }
.stat-success { border-top-color: var(--green); }
.stat-info    { border-top-color: #9b59b6; }
.stat-num { font-size: 38px; font-weight: 900; color: var(--text); line-height: 1; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 10px 14px; background: #f8f9fa; border-bottom: 2px solid var(--border); font-weight: 700; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fbff; }
.data-table .actions { display: flex; gap: 6px; }
code { background: #f1f3f5; padding: 2px 6px; border-radius: 4px; font-size: 13px; color: var(--blue-dark); }

/* ── Mini progress ────────────────────────────────────────────────────────── */
.mini-progress { background: var(--border); border-radius: 20px; height: 6px; width: 80px; overflow: hidden; margin-bottom: 3px; }
.mini-progress-bar { background: var(--blue); height: 100%; border-radius: 20px; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 36px; color: var(--muted); font-size: 15px; }

/* ── Detail grid ──────────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr auto; gap: 20px; background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 24px; }
.detail-card .detail-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.detail-card .detail-row:last-child { border-bottom: none; }
.detail-card .detail-row span { color: var(--muted); }

/* ── Questions admin ──────────────────────────────────────────────────────── */
.filter-bar { margin-bottom: 20px; }
.filter-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.filter-form select { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.filter-count { color: var(--muted); font-size: 14px; }
.q-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 12px; }
.q-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.q-id { font-weight: 700; color: var(--muted); font-size: 13px; min-width: 36px; }
.q-tags { flex: 1; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { background: var(--blue-lt); color: var(--blue); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.tag-kat { background: #f0e6ff; color: #7b2fa8; }
.q-actions { display: flex; gap: 6px; }
.q-text { font-weight: 600; font-size: 15px; margin-bottom: 12px; line-height: 1.5; }
.q-options { display: flex; gap: 8px; flex-wrap: wrap; }
.q-opt { background: #f8f9fa; padding: 5px 12px; border-radius: 5px; font-size: 13px; }
.q-opt-correct { background: var(--green-lt); color: var(--green); font-weight: 600; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-box form { padding: 24px; }

/* ── Admin form ───────────────────────────────────────────────────────────── */
.admin-form { max-width: 700px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .exam-header { flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
}
