/* ==========================================================================
   DESIGN TOKENS
   Tema: terinspirasi manuskrip mushaf klasik (kertas hangat, tinta hijau tua,
   aksen emas iluminasi, merah tua untuk tanda koreksi — seperti tradisi
   rubrikasi pada manuskrip lama). Bukan tema "AI generik".
   ========================================================================== */
:root {
  /* Warna */
  --color-bg: #FAF6EC;          /* kertas hangat */
  --color-bg-card: #FFFDF7;     /* kartu, sedikit lebih terang dari bg */
  --color-bg-alt: #F1EAD9;      /* panel sekunder */
  --color-ink: #1F3B36;         /* teks utama, hijau tua tinta */
  --color-ink-soft: #4B5B56;    /* teks sekunder */
  --color-gold: #B8933D;        /* aksen emas iluminasi */
  --color-gold-soft: #E4D3A0;   /* border emas lembut */
  --color-emerald: #3F7A5D;     /* status benar / sukses */
  --color-emerald-bg: #E4EFE8;
  --color-maroon: #8C2F39;      /* status salah / koreksi (rubrikasi) */
  --color-maroon-bg: #F5E6E7;
  --color-border: #D8CBA9;      /* garis tipis hangat */
  --color-shadow: rgba(31, 59, 54, 0.08);

  /* Tipografi */
  --font-arabic: 'Amiri', 'Scheherazade New', serif;
  --font-display: 'Cormorant', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  /* Skala & jarak */
  --radius-sm: 6px;
  --radius-md: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 40px;

  --max-width: 720px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-ink);
  margin: 0 0 var(--space-2) 0;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

p { line-height: 1.6; color: var(--color-ink-soft); margin: 0 0 var(--space-2) 0; }

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

/* Fokus keyboard selalu terlihat (aksesibilitas) */
:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

/* Hormati preferensi "reduce motion" */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */
.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-3);
  padding-bottom: 88px; /* ruang untuk bottom-nav di HP */
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0 var(--space-4) 0;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-ink);
}
.topbar .brand .mark {
  width: 28px; height: 28px;
  border: 1.5px solid var(--color-gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-gold);
  font-family: var(--font-arabic);
  font-size: 1rem;
}

/* Navigasi bawah - khusus mobile, mudah dijangkau ibu jari */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  padding: var(--space-2) var(--space-2) max(var(--space-2), env(safe-area-inset-bottom));
  z-index: 20;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.7rem;
  color: var(--color-ink-soft);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}
.bottom-nav a.active { color: var(--color-emerald); font-weight: 600; }
.bottom-nav .icon { font-size: 1.25rem; }

/* Desktop: nav jadi sidebar horizontal atas, bukan bottom-nav */
@media (min-width: 768px) {
  .app-shell { padding: var(--space-5) var(--space-4); }
  .bottom-nav {
    position: static;
    border-top: none;
    border-bottom: 1px solid var(--color-border);
    justify-content: flex-start;
    gap: var(--space-4);
    padding: 0 0 var(--space-3) 0;
    margin-bottom: var(--space-4);
  }
  .bottom-nav a { flex-direction: row; font-size: 0.85rem; }
  .app-shell { padding-bottom: var(--space-5); }
}

/* ==========================================================================
   KOMPONEN UMUM
   ========================================================================== */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  box-shadow: 0 2px 8px var(--color-shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
  width: 100%;
}
@media (min-width: 480px) { .btn { width: auto; } }

.btn-primary { background: var(--color-ink); color: var(--color-bg-card); }
.btn-primary:hover { box-shadow: 0 4px 12px var(--color-shadow); }
.btn-gold { background: var(--color-gold); color: #fff; }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-ink); }
.btn-danger { background: var(--color-maroon); color: #fff; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  background: var(--color-bg-card);
  color: var(--color-ink);
}
.input:focus { border-color: var(--color-gold); }

.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-ink-soft);
  margin-bottom: var(--space-1);
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.badge-emerald { background: var(--color-emerald-bg); color: var(--color-emerald); }
.badge-maroon { background: var(--color-maroon-bg); color: var(--color-maroon); }
.badge-gold { background: var(--color-gold-soft); color: #6b5220; }

.toast {
  position: fixed;
  bottom: 96px; left: 50%;
  transform: translateX(-50%);
  background: var(--color-ink);
  color: var(--color-bg-card);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }

/* ==========================================================================
   SIGNATURE ELEMENT — bingkai "mushaf" bergaya iluminasi manuskrip
   Dipakai membungkus area baca (baca.html). Ini elemen paling khas di app ini.
   ========================================================================== */
.mushaf-frame {
  position: relative;
  background: var(--color-bg-card);
  border: 2px solid var(--color-gold);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-3);
  margin: var(--space-3) 0;
}
.mushaf-frame::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--color-gold-soft);
  border-radius: 8px;
  pointer-events: none;
}
.mushaf-frame .halaman-label {
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg);
  padding: 0 var(--space-2);
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--color-gold);
  letter-spacing: 0.05em;
}

.mushaf-baris {
  direction: rtl;
  font-family: var(--font-arabic);
  font-size: 1.9rem;
  line-height: 2.6;
  text-align: center;
  color: var(--color-ink);
  padding: var(--space-1) 0;
}
@media (min-width: 768px) { .mushaf-baris { font-size: 2.2rem; } }

.kata {
  display: inline-block;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.kata.status-benar { color: var(--color-emerald); }
.kata.status-salah { background: var(--color-maroon-bg); color: var(--color-maroon); text-decoration: underline wavy var(--color-maroon); }
.kata.status-sekarang { background: var(--color-gold-soft); box-shadow: 0 0 0 2px var(--color-gold); }
.kata.status-netral { color: var(--color-ink); }

/* Tombol rekam - elemen sentral halaman baca */
.rekam-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) 0 var(--space-2);
}
.tombol-rekam {
  width: 76px; height: 76px;
  border-radius: 50%;
  background: var(--color-maroon);
  border: none;
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(140, 47, 57, 0.35);
  transition: transform 0.15s ease;
}
.tombol-rekam.merekam {
  background: var(--color-emerald);
  animation: pulse-rekam 1.6s ease-in-out infinite;
}
@keyframes pulse-rekam {
  0%, 100% { box-shadow: 0 0 0 0 rgba(63, 122, 93, 0.4); }
  50% { box-shadow: 0 0 0 14px rgba(63, 122, 93, 0); }
}
.status-teks { font-size: 0.85rem; color: var(--color-ink-soft); }

/* Grid statistik ringkas */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}
@media (min-width: 600px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-item {
  background: var(--color-bg-alt);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  text-align: center;
}
.stat-item .angka {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--color-ink);
  display: block;
}
.stat-item .keterangan { font-size: 0.75rem; color: var(--color-ink-soft); }

/* List riwayat / santri */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-2);
}
.list-item:last-child { border-bottom: none; }
.list-item .info .judul { font-weight: 600; color: var(--color-ink); }
.list-item .info .sub { font-size: 0.8rem; color: var(--color-ink-soft); }

.empty-state {
  text-align: center;
  padding: var(--space-5) var(--space-3);
  color: var(--color-ink-soft);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
}
.switch {
  position: relative;
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: var(--color-border);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}
.switch input:checked + .slider { background: var(--color-emerald); }
.switch input:checked + .slider::before { transform: translateX(20px); }
