/* --- CSS Variables & Reset --- */
:root {
  --primary-color: #2c3e50;
  --accent-color: #3498db;
  --bg-color: #f8f9fa;
  --card-bg: #ffffff;
  --text-color: #333333;
  --text-muted: #6c757d;
  --border-color: #e9ecef;
  --danger-color: #e74c3c;
  --success-color: #27ae60;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --radius: 8px;
  --shadow: 0 2px 4px rgba(0,0,0,0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.5;
  font-size: 16px;
}

/* --- Layout & Container --- */
#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  padding: var(--spacing-md);
  flex: 1;
}

/* --- Typography --- */
h1, h2, h3 {
  color: var(--primary-color);
  margin-bottom: var(--spacing-md);
  font-weight: 600;
}

h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

.text-muted { color: var(--text-muted); font-size: 0.9rem; }

/* --- Navigation --- */
.nav-bar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-md);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary-color);
  text-decoration: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  margin-left: var(--spacing-md);
  font-size: 0.95rem;
  font-weight: 500;
}

.nav-links a.active {
  color: var(--accent-color);
}

/* --- Cards & Lists --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) 0;
  border-bottom: 1px solid var(--border-color);
}

.list-item:last-child { border-bottom: none; }

.item-info { flex: 1; }
.item-title { font-weight: 600; display: block; }
.item-subtitle { font-size: 0.85rem; color: var(--text-muted); }

/* --- Forms --- */
.form-group { margin-bottom: var(--spacing-md); }

label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
  font-size: 0.9rem;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--card-bg);
  transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-color);
}

textarea { resize: vertical; min-height: 80px; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.1s;
  gap: 6px;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--accent-color); color: white; }
.btn-success { background: var(--success-color); color: white; }
.btn-danger { background: var(--danger-color); color: white; }
.btn-secondary { background: var(--border-color); color: var(--text-color); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 0.85rem; }

/* --- Family Tree Specific --- */
.tree-node {
  margin-left: var(--spacing-lg);
  border-left: 2px solid var(--border-color);
  padding-left: var(--spacing-md);
  margin-top: var(--spacing-sm);
}

.tree-connector {
  position: relative;
}

.tree-connector::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--spacing-md) - 1px);
  top: 12px;
  width: var(--spacing-md);
  height: 2px;
  background: var(--border-color);
}

/* --- Utilities --- */
.loading-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: var(--spacing-lg);
  color: var(--text-muted);
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mt-2 { margin-top: var(--spacing-md); }
.mb-2 { margin-bottom: var(--spacing-md); }
/* --- D3 Tree Specific Styles --- */
#d3-tree-container {
  cursor: grab;
}
#d3-tree-container:active {
  cursor: grabbing;
}
.link {
  transition: stroke-width 0.2s;
}
.node:hover circle {
  stroke: #3498db;
  stroke-width: 3px;
  cursor: pointer;
}
/* --- Penyesuaian Teks Pohon D3 --- */
.node text {
  /* Memastikan teks panjang tetap terbaca dan tidak terpotong tajam */
  paint-order: stroke fill;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Kembalikan warna fill asli agar teks tetap terbaca di atas garis stroke putih */
.node text[style*="fill: #333"] { stroke: #ffffff; }
.node text[style*="fill: #6c757d"] { stroke: #ffffff; }