/* ============================================================
   Genealogy SaaS — Family Tree Visualization Styles
   D3.js SVG-based interactive tree
   ============================================================ */

/* ── Tree Container ────────────────────────────────────────── */
.tree-container {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 600px;
}

.tree-toolbar {
  position: absolute;
  top: var(--sp-4);
  left: var(--sp-4);
  z-index: 10;
  display: flex;
  gap: var(--sp-2);
}

.tree-controls {
  position: absolute;
  bottom: var(--sp-4);
  right: var(--sp-4);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.tree-control-btn {
  width: 36px; height: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1.1rem;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.tree-control-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--color-primary);
}

/* ── SVG Canvas ────────────────────────────────────────────── */
#family-tree-svg {
  width: 100%;
  min-height: 600px;
  cursor: grab;
}
#family-tree-svg:active { cursor: grabbing; }
#family-tree-svg.is-empty { cursor: default; }

/* ── Tree Nodes ────────────────────────────────────────────── */
.tree-node { cursor: pointer; }

.tree-node__card {
  rx: 12px;
  ry: 12px;
  fill: var(--bg-elevated);
  stroke: var(--border);
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.08));
  transition: stroke var(--transition);
}
.tree-node.is-selected .tree-node__card {
  stroke: var(--color-primary);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px rgba(79,70,229,.3));
}
.tree-node:hover .tree-node__card {
  stroke: var(--color-primary);
  filter: drop-shadow(0 4px 12px rgba(79,70,229,.2));
}

.tree-node__photo-bg {
  fill: var(--color-primary-light);
}
.tree-node__photo-bg--female { fill: #FDF2F8; }
.tree-node__photo-bg--male   { fill: #EFF6FF; }

.tree-node__initial {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 14px;
  fill: var(--color-primary);
  text-anchor: middle;
  dominant-baseline: central;
}

.tree-node__name {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  fill: var(--text-primary);
  text-anchor: middle;
}

.tree-node__dates {
  font-family: var(--font-sans);
  font-size: 10px;
  fill: var(--text-muted);
  text-anchor: middle;
}

.tree-node__gender-dot {
  rx: 5px;
}
.tree-node__gender-dot--male   { fill: #3B82F6; }
.tree-node__gender-dot--female { fill: #EC4899; }
.tree-node__gender-dot--other  { fill: var(--text-muted); }

/* ── Tree Links (edges) ────────────────────────────────────── */
.tree-link {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
}
.tree-link--spouse { stroke: #EC4899; stroke-dasharray: 6 3; stroke-width: 1.5; }
.tree-link--parent { stroke: var(--color-primary); opacity: 0.5; }
.tree-link--sibling { stroke: var(--color-success); stroke-dasharray: 4 4; opacity: 0.5; }

/* ── Add member button (+ on node) ────────────────────────── */
.tree-node__add-btn {
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition);
}
.tree-node:hover .tree-node__add-btn { opacity: 1; }
.tree-node__add-btn circle { fill: var(--color-primary); }
.tree-node__add-btn text { fill: white; font-size: 14px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }

/* ── Empty state ───────────────────────────────────────────── */
.tree-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  color: var(--text-muted);
  text-align: center;
  padding: var(--sp-8);
}
.tree-empty__icon { font-size: 4rem; opacity: 0.5; }
.tree-empty__title { font-size: var(--text-xl); font-weight: 600; color: var(--text-secondary); }
.tree-empty__desc  { font-size: var(--text-sm); max-width: 320px; }

/* ── Tooltip ───────────────────────────────────────────────── */
.tree-tooltip {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-4);
  font-size: var(--text-sm);
  pointer-events: none;
  z-index: 20;
  min-width: 200px;
  animation: fade-in 0.15s ease;
}
.tree-tooltip__name { font-weight: 700; color: var(--text-primary); margin-bottom: var(--sp-1); }
.tree-tooltip__meta { color: var(--text-muted); font-size: var(--text-xs); }

/* ── Legend ────────────────────────────────────────────────── */
.tree-legend {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  font-size: var(--text-xs);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.tree-legend__item { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); }
.tree-legend__line { width: 24px; height: 2px; }
.tree-legend__line--parent  { background: var(--color-primary); }
.tree-legend__line--spouse  { background: #EC4899; border-top: 2px dashed #EC4899; background: none; }
.tree-legend__line--sibling { background: var(--color-success); border-top: 2px dashed var(--color-success); background: none; }

/* ── Mini map ──────────────────────────────────────────────── */
.tree-minimap {
  position: absolute;
  bottom: var(--sp-4);
  left: var(--sp-4);
  width: 140px;
  height: 90px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  opacity: 0.85;
}
.tree-minimap svg { width: 100%; height: 100%; }
