/* ============================================================
   Interactive Chart Builder — Tool-specific styles
   ============================================================ */

/* ── Chart Selector ─────────────────────────────────────── */

#chart-selector {
  background: linear-gradient(180deg, #f9fafb 0%, #fff 100%);
}

.chart-card {
  cursor: pointer;
  transition: all 0.15s ease;
}
.chart-card:hover {
  transform: translateY(-2px);
}
.chart-card:active {
  transform: translateY(0);
}

/* ── Chart Switcher bar ─────────────────────────────────── */

/* Override dvz-common grid to account for #chart-switcher row */
#dvz-chart {
  grid-template-rows: auto auto minmax(0, 1fr) auto auto !important;
}

#chart-switcher {
  flex-shrink: 0;
}

#chart-back-btn {
  transition: color 0.15s;
}

/* ── SVG template (dvz-template-svg) ────────────────────── */
/* Shared styles for all SVG-based charts.                  */
/* Applied when templateType='svg' in chart-registry.       */

.dvz-template-svg {
  position: relative;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}
.dvz-template-svg svg { width: 100%; height: auto; display: block; }

/* ── Empty state ────────────────────────────────────────── */

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 400px;
  color: #999; font-size: 15px; gap: 12px;
}
.empty-state .icon { font-size: 48px; opacity: 0.4; }

/* ── Streamgraph styles ─────────────────────────────────── */

.stream-layer {
  transition: opacity 0.2s;
  cursor: pointer;
}
.dimmed .stream-layer { opacity: 0.15; }
.dimmed .stream-layer.highlighted { opacity: 1; }

.x-axis path, .x-axis line { stroke: #ccc; }
.x-axis text { fill: #666; font-size: 11px; }

.stream-tooltip {
  position: absolute; pointer-events: none;
  background: rgba(40,40,40,0.94); color: #fff;
  padding: 8px 12px; border-radius: 6px;
  font-size: 12px; line-height: 1.5;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  z-index: 100; white-space: nowrap;
  opacity: 0; transition: opacity 0.12s ease;
}
.stream-tooltip .tooltip-swatch {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; margin-right: 6px; vertical-align: middle;
}

/* ── Bump Chart styles ──────────────────────────────────── */

.chart-container {
  background: #fff; border-radius: 8px; padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.chart-container svg { width: 100%; height: auto; display: block; }

.bump-line { fill: none; stroke-width: 2.5; transition: opacity 0.2s; cursor: pointer; }
.bump-circle { stroke: #fff; stroke-width: 2; transition: opacity 0.2s; cursor: pointer; }
.bump-label { font-size: 12px; font-weight: 600; transition: opacity 0.2s; }
.axis-label { font-size: 12px; fill: #666; }
.rank-label { font-size: 11px; fill: #999; }
.grid-line { stroke: #eee; stroke-width: 1; }

.dimmed .bump-line, .dimmed .bump-circle, .dimmed .bump-label { opacity: 0.1; }
.dimmed .bump-line.highlighted, .dimmed .bump-circle.highlighted, .dimmed .bump-label.highlighted { opacity: 1; }
.dimmed .bump-line.highlighted { stroke-width: 4; }

.bump-tooltip {
  position: fixed; pointer-events: none;
  background: rgba(0,0,0,0.8); color: #fff;
  padding: 6px 10px; border-radius: 4px;
  font-size: 0.75rem; line-height: 1.4;
  white-space: nowrap; opacity: 0;
  transition: opacity 0.15s; z-index: 100;
}
.bump-tooltip.visible { opacity: 1; }

/* ── Bee Swarm Plot styles ──────────────────────────────── */

circle.dot { transition: opacity 0.15s ease; }
.legend-group text { user-select: none; }

.bee-tooltip {
  position: absolute; pointer-events: none;
  background: rgba(40,40,40,0.94); color: #fff;
  padding: 8px 12px; border-radius: 6px;
  font-size: 12px; line-height: 1.5;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  z-index: 100; max-width: 260px; white-space: nowrap;
  opacity: 0; transition: opacity 0.12s ease;
}
.bee-tooltip .tooltip-title { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.bee-tooltip .tooltip-row { display: flex; gap: 6px; }
.bee-tooltip .tooltip-key { color: #aaa; }

/* ── Venn / Euler Diagram styles ─────────────────────────── */

.venn-circle path {
  fill-opacity: 0.55; stroke-width: 2; stroke: #fff;
  transition: fill-opacity 0.2s ease;
}
.venn-circle text { font-size: 15px; font-weight: 700; fill: #333; pointer-events: none; }
.venn-intersection text { pointer-events: none; }
.venn-intersection path { fill-opacity: 0; stroke: none; transition: fill-opacity 0.2s ease; }

/* ── Timeseries Scatterplot styles ──────────────────────── */

#chartBlock svg { width: 100%; height: auto; }
.axis path, .axis line { stroke: #ccc; shape-rendering: crispEdges; }
.axis text { fill: #999; font-size: 10px; font-family: sans-serif; }
.year-ticker {
  font-size: 64px; font-weight: 800; fill: #e8e8ed;
  font-variant-numeric: tabular-nums; pointer-events: none;
}

/* ── Circle Packing styles ──────────────────────────────── */

.group-label { font-size: 0.88rem; font-weight: 700; fill: #4a4232; text-anchor: middle; }
.group-label tspan:last-child { font-weight: 500; fill: #6d634f; }
.node { cursor: pointer; transition: opacity 150ms ease; }
.node.is-faded { opacity: 0.2; }

.control-chip-group {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px; border-radius: 999px; background: #ece5d8;
}
.control-chip {
  border: 1px solid transparent; background: transparent; color: #4a4232;
  padding: 6px 10px; border-radius: 999px; font-weight: 600; font-size: 0.78rem;
  line-height: 1; white-space: nowrap; cursor: pointer; transition: 180ms ease;
}
.control-chip.is-active { background: #fff; color: #1f3926; border-color: #d0c7b8; }

.summary-grid { display: inline-flex; align-items: center; gap: 8px; margin-left: 8px; }
.summary-item {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #d9d1c2; border-radius: 10px;
  padding: 5px 9px; white-space: nowrap;
}
.summary-item .label { color: #6f6654; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; }
.summary-item .value { font-size: 0.9rem; line-height: 1; font-weight: 700; }

.side-chip {
  border: 1px solid #d1d5db; background: #fff; color: #374151;
  padding: 7px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.side-chip.is-active { border-color: #4f81bd; color: #1d4e89; background: #eff6ff; }

/* ── Bar Chart Filter styles ────────────────────────────── */

.dashboard-grid {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,0.9fr); gap: 14px;
}
.chart-column-stack { display: flex; flex-direction: column; gap: 14px; }
.chart-card, .table-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05); padding: 14px;
}
.chart-card-head, .table-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px;
}
.chart-card-title { margin: 0; color: #6b7280; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.chart-slot { min-height: 180px; }
.table-scroll { overflow-x: auto; }
.table-paging { margin-top: 12px; display: flex; justify-content: flex-end; gap: 8px; }
div.dc-chart { float: none !important; }
.dc-chart g.row text { fill: #374151; font-size: 11px; }
.dc-chart g.row rect { rx: 2; }
.dc-data-table thead th { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 2px solid #e5e7eb; font-size: 0.75rem; font-weight: 700; color: #6b7280; text-transform: uppercase; }
.dc-data-table tbody td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #f3f4f6; }
.dc-data-table tbody tr:hover td { background-color: #eff6ff; }
.dc-data-table .dc-table-group td { background-color: #f3f4f6; font-weight: 700; font-size: 0.75rem; color: #6b7280; }
.reset {
  display: inline-flex; align-items: center; padding: 0.25rem 0.625rem;
  font-size: 0.6875rem; color: #4f81bd; background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 9999px; cursor: pointer; transition: background-color 0.15s;
}
.reset:hover { background: #dbeafe; }
.reset.hidden { display: none; }
.btn-reset-all {
  display: inline-block; margin-left: 0.5rem; padding: 0.3rem 0.875rem;
  font-size: 0.75rem; font-weight: 600; color: #fff; background: #4f81bd;
  border: none; border-radius: 0.375rem; cursor: pointer;
}
.btn-reset-all:hover { background: #3b6da1; }
.btn-paging {
  display: inline-block; padding: 0.375rem 1rem; font-size: 0.75rem; font-weight: 600;
  color: #374151; background: #f9fafb; border: 1px solid #d1d5db;
  border-radius: 0.375rem; cursor: pointer;
}
.btn-paging:hover { background: #f3f4f6; }
.btn-paging[disabled] { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .chart-column-stack { grid-column: span 2; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
}
@media (max-width: 860px) {
  .dashboard-grid, .chart-column-stack { grid-template-columns: minmax(0,1fr); }
}

/* ── WebGL template (dvz-template-webgl) ────────────────── */
/* Shared styles for all WebGL/canvas-based charts.         */
/* Applied when templateType='webgl' in chart-registry.     */

.dvz-template-webgl {
  position: relative;
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  overflow: hidden;
}

.dvz-template-webgl canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.dvz-template-webgl .axis-label {
  position: absolute;
  font-size: 0.7rem;
  color: #666;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.1s;
}
.dvz-template-webgl .axis-label.vertical {
  writing-mode: vertical-rl;
  white-space: nowrap;
  font-size: 0.6rem;
}
.dvz-template-webgl .axis-label.title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #444;
}

.dvz-template-webgl .view-btn { transition: all 0.15s; }
.dvz-template-webgl .view-btn.active {
  background: #333 !important; color: #fff !important; border-color: #333 !important;
}

.dvz-template-webgl.dragover { outline: 3px dashed #6a6; outline-offset: -3px; }

.dvz-template-webgl #drop-overlay {
  display: none; position: absolute; inset: 0; background: rgba(106,170,106,0.15);
  z-index: 50; pointer-events: none; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #363; font-weight: 600;
}
.dvz-template-webgl.dragover #drop-overlay { display: flex; }

.dvz-template-webgl #legend {
  display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 0.8rem; color: #666;
}
.dvz-template-webgl #legend canvas { border-radius: 3px; border: 1px solid #ddd; }
.dvz-template-webgl #legend .legend-label { min-width: 30px; }
.dvz-template-webgl #data-info { font-size: 0.75rem; color: #999; margin-top: 8px; }

/* ── Embed mode ─────────────────────────────────────────── */

.dvz-embed #chart-selector { display: none !important; }
.dvz-embed #chart-switcher { display: none !important; }
