/* ============================================================
   TKA SMA — Stylesheet Utama
   Import di semua halaman HTML
   ============================================================ */

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

:root {
  --primary:    #1d4ed8;
  --primary-dk: #1e3a8a;
  --primary-lt: #dbeafe;
  --accent:     #0ea5e9;
  --success:    #16a34a;
  --success-lt: #dcfce7;
  --danger:     #dc2626;
  --danger-lt:  #fee2e2;
  --warn:       #d97706;
  --warn-lt:    #fef3c7;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-600:   #475569;
  --gray-800:   #1e293b;
  --white:      #ffffff;
  --radius:     10px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.10);
  --font:       'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── TYPOGRAPHY ───────────────────────────────────────────── */
h1 { font-size: 2rem;    font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem;  font-weight: 700; line-height: 1.3; }
h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 1rem;    font-weight: 600; }
p  { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

/* ── LAYOUT ───────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.container-sm { max-width: 560px; margin: 0 auto; padding: 0 1.25rem; }

/* ── CARD ─────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
.card-sm { padding: 1.25rem; }

/* ── NAVBAR ───────────────────────────────────────────────── */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 100;
}
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.navbar-brand {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; font-size: 1.1rem; color: var(--primary-dk);
  text-decoration: none;
}
.navbar-brand span.badge-sma {
  background: var(--primary); color: white;
  font-size: .65rem; font-weight: 700; padding: .15rem .45rem;
  border-radius: 4px; letter-spacing: .05em;
}
.navbar-user {
  display: flex; align-items: center; gap: 1rem;
  font-size: .875rem; color: var(--gray-600);
}
.navbar-user strong { color: var(--gray-800); }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .45rem; padding: .6rem 1.25rem;
  border-radius: var(--radius); border: none; cursor: pointer;
  font-family: var(--font); font-size: .9rem; font-weight: 600;
  transition: background .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--primary);    color: white; }
.btn-primary:hover:not(:disabled)   { background: var(--primary-dk); }

.btn-success   { background: var(--success);    color: white; }
.btn-success:hover:not(:disabled)   { background: #15803d; }

.btn-danger    { background: var(--danger);     color: white; }
.btn-danger:hover:not(:disabled)    { background: #b91c1c; }

.btn-outline   {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover:not(:disabled)   { background: var(--primary-lt); }

.btn-ghost     { background: transparent; color: var(--gray-600); }
.btn-ghost:hover:not(:disabled)     { background: var(--gray-100); color: var(--gray-800); }

.btn-sm  { padding: .4rem .9rem; font-size: .8rem; }
.btn-lg  { padding: .8rem 1.75rem; font-size: 1rem; }
.btn-full { width: 100%; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label {
  display: block; margin-bottom: .4rem;
  font-size: .875rem; font-weight: 600; color: var(--gray-800);
}
.form-label .optional {
  font-weight: 400; color: var(--gray-400); font-size: .8rem;
}
.form-control {
  width: 100%; padding: .625rem .875rem;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  font-family: var(--font); font-size: .9rem; color: var(--gray-800);
  background: var(--white); transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,78,216,.1);
}
.form-control.is-valid   { border-color: var(--success); }
.form-control.is-invalid { border-color: var(--danger);  }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.5rem; }
.form-hint { margin-top: .35rem; font-size: .8rem; color: var(--gray-400); }
.form-error { margin-top: .35rem; font-size: .8rem; color: var(--danger); }
.form-valid { margin-top: .35rem; font-size: .8rem; color: var(--success); }

/* ── ALERTS ───────────────────────────────────────────────── */
.alert {
  padding: .875rem 1.1rem; border-radius: var(--radius);
  font-size: .875rem; margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: .6rem;
}
.alert-info    { background: var(--primary-lt); color: var(--primary-dk); border: 1px solid #bfdbfe; }
.alert-success { background: var(--success-lt); color: #14532d;            border: 1px solid #bbf7d0; }
.alert-danger  { background: var(--danger-lt);  color: #7f1d1d;            border: 1px solid #fecaca; }
.alert-warn    { background: var(--warn-lt);    color: #78350f;            border: 1px solid #fde68a; }

/* ── BADGE ────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 20px;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em;
}
.badge-blue    { background: var(--primary-lt); color: var(--primary-dk); }
.badge-green   { background: var(--success-lt); color: #14532d; }
.badge-red     { background: var(--danger-lt);  color: #7f1d1d; }
.badge-yellow  { background: var(--warn-lt);    color: #78350f; }
.badge-gray    { background: var(--gray-100);   color: var(--gray-600); }

/* ── DIVIDER ──────────────────────────────────────────────── */
.divider {
  border: none; border-top: 1px solid var(--gray-200); margin: 1.5rem 0;
}
.divider-text {
  display: flex; align-items: center; gap: .75rem;
  color: var(--gray-400); font-size: .8rem; margin: 1.25rem 0;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; border-top: 1px solid var(--gray-200);
}

/* ── STAT CARDS ───────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: white; border-radius: var(--radius);
  padding: 1.1rem 1.25rem; box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card.green  { border-left-color: var(--success); }
.stat-card.red    { border-left-color: var(--danger);  }
.stat-card.yellow { border-left-color: var(--warn);    }
.stat-label { font-size: .8rem; color: var(--gray-600); font-weight: 500; margin-bottom: .25rem; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--gray-800); line-height: 1; }
.stat-sub   { font-size: .75rem; color: var(--gray-400); margin-top: .2rem; }

/* ── SPINNER / LOADING ────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--gray-200); border-top-color: var(--primary);
  animation: spin .7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; z-index: 999;
}
.loading-overlay p { color: var(--gray-600); font-size: .95rem; }

/* ── KATEX / SOAL CONTENT ─────────────────────────────────── */
.soal-content {
  font-size: 1rem; line-height: 1.8; color: var(--gray-800);
}
.soal-content img {
  max-width: 100%; border-radius: 6px;
  margin: .75rem auto; display: block;
}
.katex { font-size: 1.05em; }
.katex-display { overflow-x: auto; padding: .5rem 0; }

/* ── PILIHAN SOAL (opsi A-E) ──────────────────────────────── */
.opsi-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }
.opsi-item {
  display: flex; align-items: flex-start; gap: .875rem;
  padding: .75rem 1rem; border-radius: var(--radius);
  border: 1.5px solid var(--gray-200); cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.opsi-item:hover { border-color: var(--primary); background: var(--primary-lt); }
.opsi-item.selected { border-color: var(--primary); background: var(--primary-lt); }
.opsi-item.benar    { border-color: var(--success); background: var(--success-lt); }
.opsi-item.salah    { border-color: var(--danger);  background: var(--danger-lt); }
.opsi-huruf {
  min-width: 28px; height: 28px; border-radius: 50%;
  background: var(--gray-100); border: 1.5px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; flex-shrink: 0; margin-top: .1rem;
}
.opsi-item.selected .opsi-huruf { background: var(--primary); color: white; border-color: var(--primary); }
.opsi-item.benar .opsi-huruf    { background: var(--success); color: white; border-color: var(--success); }
.opsi-item.salah .opsi-huruf    { background: var(--danger);  color: white; border-color: var(--danger);  }
.opsi-teks { font-size: .95rem; line-height: 1.7; flex: 1; }

/* ── NAVIGASI SOAL GRID ───────────────────────────────────── */
.soal-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: .4rem;
}
.soal-grid-btn {
  aspect-ratio: 1; border-radius: 6px; border: 1.5px solid var(--gray-200);
  background: var(--white); font-size: .8rem; font-weight: 600;
  cursor: pointer; transition: all .15s; color: var(--gray-600);
}
.soal-grid-btn:hover     { border-color: var(--primary); color: var(--primary); }
.soal-grid-btn.aktif     { border-color: var(--primary); background: var(--primary); color: white; }
.soal-grid-btn.dijawab   { border-color: var(--success); background: var(--success-lt); color: var(--success); }
.soal-grid-btn.ragu      { border-color: var(--warn); background: var(--warn-lt); color: var(--warn); }

/* ── TIMER ────────────────────────────────────────────────── */
.timer-box {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem; border-radius: var(--radius);
  background: var(--gray-100); font-weight: 700; font-size: 1.1rem;
}
.timer-box.warning { background: var(--warn-lt); color: var(--warn); }
.timer-box.danger  { background: var(--danger-lt); color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }

/* ── PEMBAHASAN ───────────────────────────────────────────── */
.pembahasan-box {
  margin-top: 1rem; padding: 1rem; border-radius: var(--radius);
  background: #f0fdf4; border: 1px solid #bbf7d0;
  font-size: .9rem; line-height: 1.7;
}
.pembahasan-box.hidden { display: none; }
.pembahasan-label {
  font-weight: 700; color: var(--success); margin-bottom: .5rem;
  display: flex; align-items: center; gap: .4rem;
}

/* ── MODAL ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal-box {
  background: white; border-radius: calc(var(--radius) * 1.5);
  max-width: 480px; width: 100%; padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: .75rem; }
.modal-body  { font-size: .9rem; color: var(--gray-600); margin-bottom: 1.5rem; line-height: 1.7; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* ── AUTH PAGES ───────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 2rem 1rem;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 50%, #e0f2fe 100%);
}
.auth-card {
  background: white; border-radius: calc(var(--radius) * 1.5);
  box-shadow: var(--shadow-lg); padding: 2.25rem;
  width: 100%; max-width: 440px;
}
.auth-logo {
  text-align: center; margin-bottom: 1.5rem;
}
.auth-logo .app-name {
  font-size: 1.4rem; font-weight: 800; color: var(--primary-dk);
}
.auth-logo .app-tagline {
  font-size: .8rem; color: var(--gray-400); margin-top: .2rem;
}
.auth-title { font-size: 1.3rem; font-weight: 700; margin-bottom: .25rem; }
.auth-subtitle { font-size: .875rem; color: var(--gray-600); margin-bottom: 1.5rem; }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  .container { padding: 0 1rem; }
  .card { padding: 1.25rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .soal-grid { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
}

/* ── UTILITY ──────────────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }  .mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; }  .mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.flex   { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.text-center { text-align: center; }
.text-sm  { font-size: .875rem; } .text-xs { font-size: .75rem; }
.text-muted { color: var(--gray-400); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.block  { display: block; }
.rounded { border-radius: var(--radius); }
