/* ── SHARED CSS — table-deps frontend ────────────────────── */

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

:root {
  --bg:         #0d1117;
  --surface:    #161b22;
  --surface2:   #21262d;
  --border:     #30363d;
  --text:       #e6edf3;
  --muted:      #8b949e;
  --accent:     #58a6ff;
  --green:      #3fb950;
  --orange:     #d29922;
  --red:        #f85149;
  --purple:     #bc8cff;
  --cte:        #a78bfa;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── HEADER ─────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
header h1 { font-size: 16px; font-weight: 700; font-family: 'SF Mono','Fira Code',monospace; color: var(--accent); }
header span { font-size: 12px; color: var(--muted); }
header .spacer { flex: 1; }
header .tip {
  font-size: 11px; color: var(--muted);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 8px;
}

/* ── LAYOUT ──────────────────────────────── */
main { display: flex; flex: 1; overflow: hidden; }

/* ── SIDEBAR ─────────────────────────────── */
#sidebar {
  width: 280px; min-width: 240px;
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; display: flex; flex-direction: column;
}
.section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--muted); margin-bottom: 10px;
}

/* ── BUTTONS ─────────────────────────────── */
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
button {
  cursor: pointer; border: none; border-radius: 6px;
  font-size: 12px; font-weight: 600; padding: 7px 14px;
  transition: opacity 0.15s, transform 0.1s;
}
button:hover { opacity: 0.85; }
button:active { transform: scale(0.97); }

/* ── STATS ───────────────────────────────── */
.stats-row { display: flex; gap: 8px; }
.stat-card {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; text-align: center;
}
.stat-card .num { font-size: 20px; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-card .lbl { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ── TABLE LIST (base) ───────────────────── */
#table-list {
  list-style: none; display: flex; flex-direction: column;
  gap: 3px; max-height: 320px; overflow-y: auto;
}
#table-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 4px;
  font-size: 11px; font-family: 'SF Mono',monospace;
  color: var(--text); background: var(--surface2);
  cursor: default; transition: background 0.1s;
}
#table-list li:hover { background: var(--border); }
#table-list li .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── LEGEND ──────────────────────────────── */
.legend-grid { display: flex; flex-direction: column; gap: 5px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.legend-swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.legend-rect   { width: 16px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.legend-line   { width: 22px; height: 2px; border-radius: 1px; flex-shrink: 0; }

/* ── GRAPH CANVAS ────────────────────────── */
#graph-container {
  flex: 1; position: relative; overflow: hidden;
  background: #f5f0eb;
}
#graph { width: 100%; height: 100%; }
#graph-container::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle, #1a1a1a 1px, transparent 1px);
  background-size: 28px 28px; opacity: 0.18; pointer-events: none;
}

/* ── EMPTY STATE ─────────────────────────── */
#empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: var(--muted); pointer-events: none; z-index: 1;
}
#empty-state .icon { font-size: 40px; opacity: 0.3; }
#empty-state p { font-size: 14px; }
#empty-state small { font-size: 11px; opacity: 0.6; text-align: center; max-width: 300px; line-height: 1.6; }

/* ── TOOLTIP ─────────────────────────────── */
#tooltip {
  display: none; position: absolute;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; font-size: 12px;
  pointer-events: none; z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); min-width: 160px;
}
#tooltip .tt-name { font-weight: 700; font-family: monospace; color: var(--text); margin-bottom: 6px; }
#tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 11px; margin-top: 2px; }
#tooltip .tt-val { color: var(--text); font-weight: 600; }

/* ── GRAPH CONTROLS ──────────────────────── */
#graph-controls {
  position: absolute; bottom: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 4px; z-index: 10;
}
.ctrl-btn {
  width: 32px; height: 32px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s;
}
.ctrl-btn:hover { background: var(--surface2); }

/* ── SCROLLBAR ───────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
