/* =============================================================
   main.css - Sistem desain & tata letak
   Palet: abu-abu gelap, putih, aksen biru.
   Mendukung mode terang & gelap melalui [data-theme].
   ============================================================= */

/* ---------- Token Warna ---------- */
:root {
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-soft: rgba(37, 99, 235, 0.12);

  /* Mode terang (default) */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e2e5ea;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);

  --risk-rendah: #16a34a;
  --risk-sedang: #d97706;
  --risk-tinggi: #dc2626;

  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: #16181d;
  --surface: #1e2128;
  --surface-2: #262a32;
  --border: #2e333c;
  --text: #e7e9ee;
  --text-muted: #9aa1ad;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

.hidden { display: none !important; }

/* ---------- Banner keamanan ---------- */
.security-banner {
  background: var(--blue-soft);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  padding: 0.55rem 1rem;
  text-align: center;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}
.security-banner svg { color: var(--blue); flex-shrink: 0; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-danger { color: var(--risk-tinggi); border-color: var(--risk-tinggi); }
.btn-danger:hover { background: rgba(220, 38, 38, 0.1); }
.btn-icon { padding: 0.5rem; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  animation: pop 0.35s ease;
}
.login-logo {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
}
.login-card h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.login-card .subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 500; margin-bottom: 0.35rem; color: var(--text-muted); }
.input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
textarea { resize: vertical; min-height: 70px; }
.login-warning {
  background: rgba(217, 119, 6, 0.12);
  border: 1px solid rgba(217, 119, 6, 0.3);
  color: var(--text);
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  margin-bottom: 1.25rem;
  display: flex; gap: 0.5rem;
}
.login-warning svg { color: var(--risk-sedang); flex-shrink: 0; }
.login-error { color: var(--risk-tinggi); font-size: 0.82rem; margin-top: 0.75rem; min-height: 1rem; }

/* ---------- Layout dashboard ---------- */
.app { display: flex; flex-direction: column; height: 100dvh; }
.app-body { flex: 1; display: flex; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; }
.topbar .brand .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.topbar .spacer { flex: 1; }
.topbar .user-chip { color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-tools { padding: 0.9rem; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.6rem; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; }
.search-wrap .input { padding-left: 2.1rem; }
.filters { display: flex; gap: 0.5rem; }
.filters select { flex: 1; font-size: 0.8rem; padding: 0.45rem 0.5rem; }

.stats-bar {
  display: flex; gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.stat {
  flex: 1; text-align: center;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.25rem;
}
.stat .num { font-size: 1.1rem; font-weight: 700; color: var(--blue); }
.stat .lbl { font-size: 0.68rem; color: var(--text-muted); }

.people-list { flex: 1; overflow-y: auto; padding: 0.6rem; }
.person-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
  margin-bottom: 0.3rem;
}
.person-card:hover { background: var(--surface-2); }
.person-card.active { background: var(--blue-soft); border-color: var(--blue); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-weight: 600; font-size: 0.95rem;
  overflow: hidden;
}
.person-card .meta { min-width: 0; flex: 1; }
.person-card .meta .name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-card .meta .sub { font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-card .rating-pill {
  font-size: 0.72rem; font-weight: 600;
  background: var(--surface-2); color: var(--text);
  padding: 0.15rem 0.45rem; border-radius: 999px;
}

.empty-list { text-align: center; color: var(--text-muted); font-size: 0.85rem; padding: 2rem 1rem; }

/* ---------- Panel utama / detail ---------- */
.main-panel { flex: 1; overflow-y: auto; padding: 1.5rem; }
.detail-empty {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted); gap: 0.75rem; text-align: center;
}
.detail-empty svg { width: 48px; height: 48px; opacity: 0.4; }

.profile-header {
  display: flex; align-items: center; gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  animation: fade 0.3s ease;
}
.profile-header .avatar-lg {
  width: 88px; height: 88px; border-radius: 18px;
  object-fit: cover; flex-shrink: 0;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700; color: var(--text-muted);
  overflow: hidden;
}
.profile-header .h-info { flex: 1; min-width: 200px; }
.profile-header .h-info h2 { font-size: 1.5rem; }
.profile-header .h-info .tagline { color: var(--text-muted); font-size: 0.9rem; }
.profile-header .h-actions { display: flex; gap: 0.5rem; }

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.72rem; font-weight: 600;
  padding: 0.22rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--border);
  margin-top: 0.5rem;
}
.badge.risk-rendah { color: var(--risk-rendah); border-color: var(--risk-rendah); }
.badge.risk-sedang { color: var(--risk-sedang); border-color: var(--risk-sedang); }
.badge.risk-tinggi { color: var(--risk-tinggi); border-color: var(--risk-tinggi); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow);
}
.metric .m-label { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.metric .m-value { font-size: 1.25rem; font-weight: 700; }
.metric .bar { height: 6px; border-radius: 999px; background: var(--surface-2); margin-top: 0.5rem; overflow: hidden; }
.metric .bar > span { display: block; height: 100%; background: var(--blue); border-radius: 999px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
  animation: fade 0.3s ease;
}
.card h3 { font-size: 0.95rem; margin-bottom: 0.9rem; display: flex; align-items: center; gap: 0.4rem; }
.card h3 svg { color: var(--blue); width: 18px; height: 18px; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px dashed var(--border); font-size: 0.86rem; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-muted); flex-shrink: 0; }
.kv .v { text-align: right; word-break: break-word; }

/* Timeline peristiwa */
.timeline { list-style: none; }
.timeline li { position: relative; padding-left: 1.4rem; padding-bottom: 1rem; border-left: 2px solid var(--border); margin-left: 0.3rem; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--blue); border: 2px solid var(--surface);
}
.timeline .t-date { font-size: 0.72rem; color: var(--text-muted); }
.timeline .t-title { font-weight: 600; font-size: 0.88rem; }
.timeline .t-desc { font-size: 0.82rem; color: var(--text-muted); }
.cat-tag { display: inline-block; font-size: 0.68rem; background: var(--blue-soft); color: var(--blue); padding: 0.1rem 0.45rem; border-radius: 999px; margin-top: 0.2rem; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 50; animation: fade 0.2s ease;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 640px; max-height: 90dvh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: pop 0.25s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { font-size: 1.05rem; }
.modal-body { padding: 1.25rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.form-group-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--blue); font-weight: 700; margin: 1.25rem 0 0.6rem; }
.form-group-title:first-child { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.range-value { font-size: 0.8rem; color: var(--text-muted); float: right; }
.sub-item { background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.75rem; margin-bottom: 0.6rem; }
.sub-item .form-row { grid-template-columns: 1fr; }
.confirm-text { font-size: 0.9rem; color: var(--text); }

/* ---------- Toast notifikasi ---------- */
.toast-wrap { position: fixed; bottom: 1.25rem; right: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 100; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius-sm); padding: 0.75rem 1rem;
  box-shadow: var(--shadow-lg); font-size: 0.86rem;
  display: flex; align-items: center; gap: 0.5rem;
  animation: slideIn 0.3s ease; max-width: 320px;
}
.toast.success { border-left-color: var(--risk-rendah); }
.toast.error { border-left-color: var(--risk-tinggi); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Animasi ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---------- Responsif ---------- */
.menu-toggle { display: none; }
@media (max-width: 860px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform 0.25s ease;
    width: 85%; max-width: 340px; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .main-panel { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 39; }
}
