/* ===== SOP Disdikbud Karimun — tema navy & emas (sesuai mockup resmi) ===== */
:root {
  --navy: #1B2A5E;
  --navy-2: #26376F;
  --navy-3: #0F1B45;
  --gold: #C99A3C;
  --gold-2: #E2B95C;
  --bg: #F4F5FA;
  --card: #FFFFFF;
  --teks: #22263A;
  --teks-2: #6B7186;
  --garis: #E3E6EF;
  --merah: #C0392B;
  --hijau: #1E8E5A;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(27, 42, 94, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--teks);
  min-height: 100vh;
  font-size: 15px;
}

#app { max-width: 860px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.view { flex: 1; padding: 16px 16px 84px; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(15, 27, 69, .35);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.topbar .brand img { width: 34px; height: 34px; border-radius: 8px; }
.topbar .brand b { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .chip-user {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
  color: #fff; font-size: 12px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
}

/* ===== Bottom nav ===== */
.bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 860px; z-index: 20;
  background: #fff; border-top: 1px solid var(--garis);
  display: flex; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a {
  flex: 1; text-align: center; text-decoration: none; color: var(--teks-2);
  font-size: 11px; padding: 4px 0; border-radius: 10px;
}
.bottomnav a .ico { display: block; font-size: 20px; line-height: 1.2; }
.bottomnav a.active { color: var(--navy); background: #EEF1FA; font-weight: 600; }

/* ===== Komponen umum ===== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; border: 1px solid var(--garis); }
h1 { font-size: 20px; color: var(--navy); margin-bottom: 6px; }
h2 { font-size: 16px; color: var(--navy); margin: 4px 0 10px; }
h3 { font-size: 14px; color: var(--navy); margin-bottom: 6px; }
.muted { color: var(--teks-2); font-size: 13px; }
.pill {
  display: inline-block; font-size: 11.5px; padding: 3px 10px; border-radius: 999px;
  background: #EEF1FA; color: var(--navy); margin: 2px 4px 2px 0; font-weight: 500;
}
.pill.gold { background: #F8EFDD; color: #8A6A1F; }
.pill.lock { background: #FBEAEA; color: var(--merah); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-family: inherit; font-weight: 600;
  border-radius: 10px; padding: 11px 18px; font-size: 14px; transition: .15s;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-2); }
.btn-ghost { background: transparent; border: 1.5px solid var(--garis); color: var(--teks); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

input, textarea, select {
  font-family: inherit; font-size: 14.5px; color: var(--teks);
  border: 1.5px solid var(--garis); border-radius: 10px; padding: 11px 14px;
  width: 100%; background: #fff; outline: none;
}
input:focus, textarea:focus { border-color: var(--navy); }
label { font-size: 13px; font-weight: 500; color: var(--teks); display: block; margin: 10px 0 5px; }

/* ===== Beranda ===== */
.hero {
  background: linear-gradient(145deg, var(--navy-3), var(--navy) 55%, var(--navy-2));
  border-radius: 18px; color: #fff; text-align: center;
  padding: 30px 18px 26px; margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(15, 27, 69, .35);
}
.hero .logo {
  width: 84px; height: 84px; border-radius: 22px; background: #fff;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
}
.hero .logo img { width: 64px; height: 64px; }
.hero h1 { color: #fff; font-size: 19px; line-height: 1.45; margin-bottom: 6px; }
.hero .sub { color: var(--gold-2); font-size: 12.5px; letter-spacing: .4px; font-weight: 500; }
.hero .versi { color: rgba(255,255,255,.55); font-size: 11.5px; margin-top: 10px; }

.searchbar { display: flex; gap: 8px; margin-bottom: 16px; }
.searchbar input { flex: 1; }

.grid-kategori { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kat-kartu {
  background: var(--card); border: 1px solid var(--garis); border-radius: var(--radius);
  padding: 16px 12px; text-align: center; cursor: pointer; transition: .15s; text-decoration: none; color: var(--teks); display: block;
}
.kat-kartu:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow); }
.kat-kartu .emblem {
  width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 8px;
  background: #EEF1FA; display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.kat-kartu b { font-size: 13px; color: var(--navy); display: block; line-height: 1.35; }
.kat-kartu .n { font-size: 11.5px; color: var(--teks-2); margin-top: 3px; }

/* ===== Daftar layanan ===== */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  background: var(--card); border: 1px solid var(--garis); border-radius: 12px;
  margin-bottom: 9px; text-decoration: none; color: var(--teks); cursor: pointer;
}
.list-item:hover { border-color: var(--gold); }
.list-item .no {
  min-width: 44px; text-align: center; font-size: 11px; font-weight: 600;
  background: #EEF1FA; color: var(--navy); border-radius: 8px; padding: 5px 4px; line-height: 1.3;
}
.list-item b { font-size: 13.5px; font-weight: 500; line-height: 1.4; }

/* ===== Detail layanan ===== */
.detail-head { border-left: 4px solid var(--gold); padding-left: 14px; margin-bottom: 14px; }
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 8px; bottom: 8px; width: 2px; background: var(--garis); }
.langkah { position: relative; padding: 10px 0 14px; border-bottom: 1px dashed var(--garis); }
.langkah:last-child { border-bottom: none; }
.langkah .dot {
  position: absolute; left: -26px; top: 12px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.langkah .meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.langkah .meta .pill { background: #F6F0E4; color: #7A5D1E; }
.kv { margin: 4px 0; font-size: 13.5px; line-height: 1.55; }
.kv b { color: var(--navy); }

/* ===== Chat ===== */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 380px; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 2px 10px; }
.bubble {
  max-width: 86%; padding: 10px 14px; border-radius: 14px; margin-bottom: 10px;
  font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word;
}
.bubble.user { background: var(--navy); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.bot { background: var(--card); border: 1px solid var(--garis); border-bottom-left-radius: 4px; }
.bubble.bot .ref-link { display: block; margin-top: 8px; font-size: 12.5px; color: var(--navy); font-weight: 500; text-decoration: underline dotted; }
.bubble.typing span {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--teks-2);
  margin-right: 4px; animation: blink 1.2s infinite;
}
.bubble.typing span:nth-child(2) { animation-delay: .2s; }
.bubble.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-input { display: flex; gap: 8px; padding-top: 10px; }
.chat-input textarea { flex: 1; resize: none; height: 46px; max-height: 120px; }
.saran { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.saran button {
  font-size: 12.5px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--garis);
  background: #fff; color: var(--navy); cursor: pointer; font-family: inherit;
}
.saran button:hover { border-color: var(--gold); }

/* ===== Admin ===== */
table.admin { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin th, table.admin td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--garis); vertical-align: top; }
table.admin th { color: var(--teks-2); font-weight: 600; font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--garis); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--navy); }
.stat span { font-size: 11.5px; color: var(--teks-2); }

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--navy-3); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 50; box-shadow: 0 4px 16px rgba(0,0,0,.3);
  animation: fadein .2s;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; } }

.back-link { display: inline-block; margin-bottom: 12px; color: var(--navy); text-decoration: none; font-size: 13.5px; font-weight: 500; }
.empty { text-align: center; color: var(--teks-2); padding: 30px 10px; font-size: 13.5px; }

@media (min-width: 700px) {
  .view { padding: 22px 20px 90px; }
  .hero { padding: 44px 24px 36px; }
  .hero h1 { font-size: 24px; }
}
