/* =====================================================
   Silsilah Keluarga — Stylesheet
   Palet "Pohon Beringin": hijau lumut dalam, gading
   hangat, dan aksen kunyit — nuansa arsip keluarga
   Nusantara, bukan template dashboard generik.
   ===================================================== */
:root {
  --ink:        #1f2a24;   /* teks utama */
  --moss:       #2f5d50;   /* hijau lumut - identitas */
  --moss-deep:  #22443b;
  --moss-soft:  #e3efe9;
  --ivory:      #f7f4ec;   /* latar gading */
  --turmeric:   #d99a2b;   /* aksen kunyit */
  --clay:       #b4552d;   /* peringatan/hapus */
  --line:       #dcd6c6;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 42, 36, .08);
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--ivory);
  color: var(--ink);
}
h1, h2, h3, .display-font { font-family: 'Lora', Georgia, serif; }

/* ---------- Navbar ---------- */
.app-navbar {
  background: linear-gradient(120deg, var(--moss-deep), var(--moss));
  box-shadow: 0 2px 14px rgba(34, 68, 59, .35);
}
.app-navbar .navbar-brand { color: #fff; font-weight: 700; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--turmeric); color: var(--moss-deep); font-size: 1.05rem;
}
.brand-text { font-family: 'Lora', serif; letter-spacing: .2px; }
.app-navbar .nav-link { color: rgba(255,255,255,.82); border-radius: 8px; padding: .45rem .8rem; }
.app-navbar .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.app-navbar .nav-link.active { color: var(--moss-deep); background: var(--ivory); font-weight: 600; }
.user-chip { color: rgba(255,255,255,.9); font-size: .9rem; align-items: center; }
.role-badge { background: var(--turmeric); color: var(--moss-deep); }

/* ---------- Kartu & tombol ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0 !important; font-weight: 600; }
.btn-primary { background: var(--moss); border-color: var(--moss); }
.btn-primary:hover, .btn-primary:focus { background: var(--moss-deep); border-color: var(--moss-deep); }
.btn-outline-primary { color: var(--moss); border-color: var(--moss); }
.btn-outline-primary:hover { background: var(--moss); border-color: var(--moss); }
.btn-accent { background: var(--turmeric); border: none; color: var(--moss-deep); font-weight: 600; }
.btn-accent:hover { filter: brightness(.95); color: var(--moss-deep); }
a { color: var(--moss); }
.text-accent { color: var(--turmeric); }

/* ---------- Statistik dashboard ---------- */
.stat-card { display: flex; align-items: center; gap: 1rem; padding: 1.15rem 1.25rem; }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.4rem;
}
.stat-icon.total  { background: var(--moss-soft); color: var(--moss); }
.stat-icon.male   { background: #e3ecf5; color: #33608d; }
.stat-icon.female { background: #f7e6ea; color: #a3446a; }
.stat-icon.out    { background: #f8ecd7; color: #a9761f; }
.stat-value { font-family: 'Lora', serif; font-size: 1.7rem; font-weight: 600; line-height: 1; }
.stat-label { font-size: .82rem; color: #6c7a72; }

/* ---------- Badge status kawin keluar ---------- */
.badge-married-out {
  background: var(--turmeric); color: var(--moss-deep);
  font-weight: 700; letter-spacing: .03em;
}

/* ---------- Avatar inisial ---------- */
.avatar {
  display: inline-grid; place-items: center;
  border-radius: 50%; background: var(--moss-soft); color: var(--moss);
  font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 40px; height: 40px; font-size: .85rem; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.8rem; }

/* ---------- Tabel ---------- */
.table { --bs-table-hover-bg: var(--moss-soft); }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: #6c7a72; border-bottom: 2px solid var(--line); }

/* ---------- Halaman Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1100px 500px at 85% -10%, rgba(217,154,43,.14), transparent),
  radial-gradient(900px 600px at -10% 110%, rgba(47,93,80,.16), transparent),
  var(--ivory);
}
.login-card { width: 100%; max-width: 420px; }
.login-emblem {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--moss), var(--moss-deep));
  color: var(--turmeric); display: grid; place-items: center; font-size: 1.7rem;
  box-shadow: var(--shadow);
}

/* ---------- Halaman Tree (layar penuh) ---------- */
.page-tree { overflow: hidden; }
.tree-main { height: calc(100vh - 62px); position: relative; }
#treeContainer { width: 100%; height: 100%; background:
  radial-gradient(circle at 20% 10%, rgba(217,154,43,.06), transparent 40%),
  var(--ivory);
}
.tree-toolbar {
  position: absolute; top: 14px; left: 14px; right: 14px; z-index: 20;
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; pointer-events: none;
}
.tree-toolbar > * { pointer-events: auto; }
.tree-search { position: relative; min-width: 240px; max-width: 340px; flex: 1; }
.tree-search input {
  border-radius: 999px; border: 1px solid var(--line);
  padding-left: 2.4rem; box-shadow: var(--shadow); background: #fff;
}
.tree-search .bi-search { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: #8a958e; }
.tree-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); max-height: 300px; overflow: auto; display: none;
}
.tree-search-results.show { display: block; }
.tree-search-results button {
  display: flex; width: 100%; text-align: left; gap: .6rem; align-items: center;
  border: 0; background: none; padding: .55rem .9rem;
}
.tree-search-results button:hover { background: var(--moss-soft); }

/* Node FamilyTree.js (template kustom) */
#treeContainer svg { font-family: 'Plus Jakarta Sans', sans-serif; }

/* ---------- Offcanvas detail ---------- */
.detail-row { display: flex; gap: .75rem; padding: .5rem 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.detail-row:last-child { border-bottom: 0; }
.detail-row i { color: var(--moss); width: 20px; text-align: center; }
.detail-label { color: #6c7a72; min-width: 110px; }

/* ---------- Offcanvas responsif ---------- */
#memberDetail { --bs-offcanvas-width: min(380px, 100vw); }

/* ---------- Optimasi Mobile ---------- */
@media (max-width: 767.98px) {
  /* Cegah auto-zoom iOS saat fokus input */
  input, select, textarea { font-size: 16px !important; }

  .card-body.p-4 { padding: 1.1rem !important; }
  .stat-card { padding: .9rem 1rem; gap: .75rem; }
  .stat-icon { width: 44px; height: 44px; font-size: 1.15rem; border-radius: 12px; }
  .stat-value { font-size: 1.4rem; }
  .detail-label { min-width: 92px; }

  /* Toolbar pohon: pencarian penuh di baris pertama, tombol rapat di bawahnya */
  .tree-toolbar { top: 10px; left: 10px; right: 10px; gap: .4rem; }
  .tree-search { min-width: 100%; max-width: 100%; order: -1; }
  .tree-search input { font-size: 16px !important; }
  .tree-toolbar .btn { padding: .35rem .55rem; font-size: .85rem; }
  .tree-toolbar .btn-label { display: none; }      /* sembunyikan teks PNG/PDF, sisakan ikon */
  .tree-toolbar .btn-add-label { display: none; }  /* tombol tambah jadi ikon saja */
  .tree-toolbar .ms-auto { margin-left: 0 !important; }
}

@media (max-width: 575.98px) {
  h1.h3 { font-size: 1.25rem; }
  .btn-lg { padding: .5rem .9rem; font-size: 1rem; }
  .breadcrumb { font-size: .85rem; }
}

/* Sentuhan: target sentuh lebih lega untuk hasil pencarian pohon */
@media (pointer: coarse) {
  .tree-search-results button { padding: .8rem 1rem; }
  .btn-group-sm > .btn { padding: .45rem .65rem; }
}

/* ---------- Footer ---------- */
.app-footer { color: #8a958e; }

/* ---------- Cetak ---------- */
@media print {
  .app-navbar, .tree-toolbar, .app-footer { display: none !important; }
  .tree-main { height: auto; }
  body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
