/* ==========================================================================
   Database Generus — tema visual yang SAMA dengan aplikasi live (React/Tailwind).
   Token warna & tipografi diambil dari frontend/src/index.css + design_guidelines.json
   ========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

:root {
  --background: #f8fafc;
  --foreground: #0f172a;
  --card: #ffffff;
  --muted: #f1f5f9;
  --muted-fg: #64748b;
  --border: #e2e8f0;
  --input: #cbd5e1;
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-fg: #ffffff;
  --sidebar: #0f172a;
  --sidebar-fg: #f8fafc;
  --sidebar-accent: #1e293b;
  --sidebar-active: #38bdf8;
  --destructive: #dc2626;
  --radius: 0.625rem;
  --font-heading: "Outfit", system-ui, sans-serif;
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-pop: 0 18px 40px rgba(15, 23, 42, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 15px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-name { font-family: var(--font-heading); letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 4px; }
h3 { font-size: 0.95rem; font-weight: 700; margin: 22px 0 8px; }
a { color: var(--primary); }
.muted { color: var(--muted-fg); font-size: 0.875rem; }
code { background: var(--muted); padding: 1px 6px; border-radius: 6px; font-size: 0.8rem; }

/* ---------- Layout: sidebar gelap + header sticky (sama dgn AppShell.tsx) ---------- */
.layout { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 256px;
  background: var(--sidebar);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 24px 20px; }
.brand-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 18px;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.35);
}
.brand-name { font-size: 1.05rem; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 0.72rem; color: #94a3b8; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-left: 2px solid transparent; border-radius: 8px;
  color: #cbd5e1; font-size: 0.875rem; font-weight: 500; text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.sidebar-nav a .ico { width: 18px; text-align: center; opacity: 0.9; }
.sidebar-nav a:hover { background: rgba(30, 41, 59, 0.7); color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-accent); border-left-color: var(--sidebar-active); color: var(--sidebar-active); }

.sidebar-user { position: relative; z-index: 1; border-top: 1px solid var(--sidebar-accent); padding: 16px; display: flex; align-items: center; gap: 12px; }
.sidebar-user .who { min-width: 0; flex: 1; }
.sidebar-user .who strong { display: block; font-size: 0.85rem; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who .badge { margin-top: 4px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; color: #cbd5e1;
  text-decoration: none; transition: background-color 0.18s ease, color 0.18s ease;
}
.icon-btn:hover { background: var(--sidebar-accent); color: #fff; }
.logout-btn { width: auto; padding: 0 8px; gap: 6px; white-space: nowrap; }

.content { margin-left: 256px; transition: margin-left 0.25s ease; }
body.nav-collapsed .sidebar { transform: translateX(-100%); }
body.nav-collapsed .content { margin-left: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 64px; padding: 0 32px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .titles { min-width: 0; flex: 1; }
.topbar .titles h1 { font-size: 1.05rem; margin: 0; }
.topbar .titles p { margin: 0; font-size: 0.72rem; color: var(--muted-fg); }
.hamburger { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid transparent; border-radius: 9px; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: #475569; transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease; }
.hamburger:hover { background: #f1f5f9; border-color: var(--border); color: #0f172a; }
.sidebar-overlay { display: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 28px 32px 64px; }

/* ---------- Kartu statistik dashboard (warna per jenjang, sama dgn live) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08); }
.card .label { display: block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-fg); }
.card strong { display: block; font-family: var(--font-heading); font-size: 2.1rem; line-height: 1.1; margin: 10px 0 4px; }
.card small { color: var(--muted-fg); font-size: 0.75rem; }

.card-total { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 10px 26px rgba(2, 132, 199, 0.25); }
.card-total .label, .card-total small { color: #e0f2fe; }
.card-caberawit { background: #eff6ff; border-color: #dbeafe; color: #1e3a8a; }
.card-caberawit .label, .card-caberawit small { color: #2563eb; }
.card-pra-remaja { background: #ecfdf5; border-color: #d1fae5; color: #064e3b; }
.card-pra-remaja .label, .card-pra-remaja small { color: #059669; }
.card-remaja { background: #fffbeb; border-color: #fef3c7; color: #78350f; }
.card-remaja .label, .card-remaja small { color: #d97706; }
.card-dewasa { background: #faf5ff; border-color: #f3e8ff; color: #581c87; }
.card-dewasa .label, .card-dewasa small { color: #9333ea; }

/* ---------- Panel / tabel ---------- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow-card); }
.panel > h2 + .muted { margin-top: 0; }
.panel-head { margin-bottom: 14px; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

.panel > h3 { margin-top: 26px; }
.table-wrap { overflow-x: auto; margin: 0 -22px; }
.panel > .table-wrap:last-child { margin-bottom: -20px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th {
  text-align: left; background: var(--muted); color: #475569;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 12px 14px; white-space: nowrap;
}
td { padding: 12px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background-color 0.15s ease; }
tbody tr:hover td { background: #f8fbff; }
td strong { font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  background: #eff6ff; color: #1e3a8a; border: 1px solid #dbeafe;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.01em;
}
.badge-caberawit { background: #eff6ff; color: #1e3a8a; border-color: #dbeafe; }
.badge-pra-remaja { background: #ecfdf5; color: #065f46; border-color: #d1fae5; }
.badge-remaja { background: #fffbeb; color: #92400e; border-color: #fef3c7; }
.badge-dewasa { background: #faf5ff; color: #6b21a8; border-color: #f3e8ff; }
.badge-superadmin { background: #faf5ff; color: #6b21a8; border-color: #f3e8ff; }
.badge-admin { background: #eff6ff; color: #1e40af; border-color: #dbeafe; }
.badge-user { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }

.thumb, .avatar {
  width: 36px; height: 36px; border-radius: 999px; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 0.78rem;
}
.actions { display: flex; gap: 6px; align-items: center; }
.inline { display: inline; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; color: #0f172a; font: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.btn:hover { background: var(--muted); border-color: var(--input); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); box-shadow: 0 6px 16px rgba(2, 132, 199, 0.25); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--destructive); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Form & filter ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: center; }
.filters input[name="q"] { grid-column: span 2; }
.filters .btn { justify-content: center; }
input, select, textarea {
  padding: 9px 12px; border: 1px solid var(--input); border-radius: 10px;
  font: inherit; font-size: 0.875rem; background: #fff; color: var(--foreground);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.18);
}
input[readonly] { background: var(--muted); color: var(--muted-fg); }
label { display: block; font-size: 0.8rem; font-weight: 600; color: #334155; margin: 12px 0; }
label input, label select { display: block; width: 100%; margin-top: 6px; }
fieldset {
  border: 1px solid var(--border); border-radius: 14px; margin: 0 0 16px; padding: 6px 18px 16px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px;
}
fieldset > legend, fieldset > p { grid-column: 1 / -1; }
legend { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--primary); padding: 0 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2px 18px; align-items: end; }
.form-grid .btn { margin: 12px 0; }

.alert { padding: 11px 14px; border-radius: 12px; font-size: 0.85rem; font-weight: 500; margin: 10px 0; }
.alert.error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }

.checklist { margin: 0; padding-left: 20px; }
.checklist li { margin: 7px 0; font-size: 0.85rem; color: #334155; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

/* ---------- Detail member modal ---------- */
.detail-modal[hidden] { display: none; }
.detail-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.detail-backdrop { position: absolute; inset: 0; border: 0; background: rgba(15, 23, 42, 0.62); backdrop-filter: blur(8px); cursor: pointer; }
.detail-dialog { position: relative; width: min(100%, 600px); max-height: min(720px, calc(100vh - 40px)); overflow: auto; border: 1px solid var(--border); border-radius: 18px; background: #fff; box-shadow: var(--shadow-pop); animation: fade-up 0.2s ease both; }
.detail-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px; border-bottom: 1px solid var(--border); background: #f7f9ff; }
.detail-dialog-head h2 { margin: 3px 0 0; font-size: 1.25rem; }
.detail-kicker { color: var(--primary); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.detail-close { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: #64748b; font-size: 24px; cursor: pointer; transition: background-color 0.18s ease, color 0.18s ease; }
.detail-close:hover { background: #eaf0ff; color: var(--primary-dark); }
.detail-dialog-body { padding: 24px; }
.detail-identity { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.detail-photo, .detail-identity .avatar { width: 88px; height: 88px; flex: 0 0 88px; border: 1px solid var(--border); border-radius: 12px; object-fit: cover; }
.detail-identity .avatar { font-size: 1.2rem; }
.detail-identity [hidden] { display: none !important; }
.detail-identity strong { display: block; margin-bottom: 5px; font-family: var(--font-heading); font-size: 1rem; }
.detail-age { display: block; margin: 0 0 7px; color: var(--muted-fg); font-size: 0.8rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.detail-grid div { min-width: 0; }
.detail-grid span, .detail-family > span { display: block; color: #94a3b8; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.detail-grid strong { display: block; margin-top: 5px; color: #1e293b; font-size: 0.9rem; font-weight: 600; }
.detail-family { margin-top: 22px; padding: 15px 16px; border: 1px solid var(--border); border-radius: 12px; background: #fafbfc; }
.detail-family p { margin: 7px 0 0; color: #334155; font-size: 0.875rem; }
.detail-dialog-foot { display: flex; justify-content: flex-end; padding: 14px 24px; border-top: 1px solid var(--border); background: #fafbfc; }
body.detail-open { overflow: hidden; }

/* ---------- Konfirmasi tindakan permanen ---------- */
.confirm-modal[hidden] { display: none; }
.confirm-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.confirm-backdrop { position: absolute; inset: 0; border: 0; background: rgba(15, 23, 42, 0.62); backdrop-filter: blur(7px); cursor: pointer; }
.confirm-dialog { position: relative; width: min(100%, 440px); overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: var(--shadow-pop); animation: fade-up 0.18s ease both; }
.confirm-dialog-body { display: grid; grid-template-columns: 44px 1fr; gap: 4px 14px; padding: 24px; }
.confirm-icon { grid-row: span 2; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid #fecaca; border-radius: 12px; background: #fef2f2; color: #b91c1c; font-size: 1.35rem; font-weight: 700; }
.confirm-dialog-body h2 { margin: 2px 0 0; font-size: 1.15rem; }
.confirm-dialog-body p { grid-column: 2; margin: 8px 0 0; color: var(--muted-fg); font-size: 0.9rem; }
.confirm-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: #f8fafc; }
.btn-danger.confirm-delete { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger.confirm-delete:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.confirm-dialog button:focus-visible { outline: 3px solid rgba(2, 132, 199, 0.35); outline-offset: 2px; }

/* ---------- Halaman login (dua panel, sama dgn Login.tsx) ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #0f172a; }
.login-wrap {
  display: grid; grid-template-columns: 1.1fr 1fr; max-width: 1040px; width: 100%;
  margin: 24px; border-radius: 24px; overflow: hidden; background: #fff;
  box-shadow: var(--shadow-pop);
}
.login-brand {
  background:
    radial-gradient(1200px 400px at -10% 0%, rgba(2, 132, 199, 0.35), transparent 60%),
    linear-gradient(160deg, #0f172a 0%, #13203a 100%);
  color: #f8fafc; padding: 48px 44px;
}
.login-brand .brand-badge { margin-bottom: 20px; }
.login-brand h1 { font-size: 2rem; color: #fff; margin: 0 0 8px; }
.login-brand h1 span { color: var(--sidebar-active); }
.login-brand p { color: #94a3b8; font-size: 0.9rem; }
.login-brand ul { padding-left: 18px; color: #cbd5e1; font-size: 0.85rem; margin-top: 24px; }
.login-brand li { margin: 10px 0; }
.login-card { background: #fff; padding: 48px 44px; display: flex; flex-direction: column; justify-content: center; }
.login-card h2 { font-size: 1.35rem; margin-bottom: 4px; }
.login-card > p { margin-top: 0; color: var(--muted-fg); font-size: 0.875rem; }
.demo { margin-top: 22px; padding: 14px 16px; background: var(--background); border: 1px solid var(--border); border-radius: 12px; font-size: 0.78rem; color: #475569; }

.user-edit-modal .detail-dialog { width: min(100%, 560px); }
.edit-user-fields { display: grid; gap: 4px; }
.edit-user-fields label { margin: 4px 0; }
.edit-user-fields .muted { font-weight: 400; }

/* ---------- Animasi masuk halaman ---------- */
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.container > * { animation: fade-up 0.35s ease both; }

/* ---------- Responsif ---------- */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  .content { margin-left: 0; }
  body.nav-open .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 35; border: 0; background: rgba(15, 23, 42, 0.62); backdrop-filter: blur(8px); cursor: pointer; }
  .topbar { padding: 0 16px; }
  .container { padding: 20px 16px 56px; }
}
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { padding: 32px 28px; }
  .login-card { padding: 32px 28px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .table-wrap { margin: 0 -22px; }
}

@media (max-width: 560px) {
  .detail-dialog { max-height: calc(100vh - 24px); }
  .detail-dialog-head, .detail-dialog-body { padding: 20px; }
  .detail-dialog-foot { padding: 12px 20px; }
  .detail-grid { grid-template-columns: 1fr; gap: 14px; }
}
