/* ============================================================
   Charts — database "Charts" view (light + dark)
   All classes are prefixed `dbchart-` to avoid collisions.
   Rendering is inline SVG; this file is just the chrome:
   wrapper, empty state, legend, and the config popover panel.
   Theming uses the app's CSS custom properties throughout.
   ============================================================ */

.dbchart-root {
  width: 100%;
  color: var(--text);
  font-family: var(--font);
  padding: 8px 4px;
  box-sizing: border-box;
}

.dbchart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* Text drawn inside the SVG (labels inherit `currentColor`). */
.dbchart-axis-label {
  font-size: 11px;
  fill: var(--text-light);
}
.dbchart-value-label {
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-light);
}
.dbchart-slice-label {
  font-size: 11px;
  font-weight: 600;
}
.dbchart-donut-total {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-display, var(--font));
}
.dbchart-donut-cap {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  fill: var(--text-faint);
}

/* ---- Pie / donut layout: chart beside legend --------------- */
.dbchart-pie-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}
.dbchart-pie-wrap .dbchart-svg {
  width: auto;
  max-width: 260px;
  flex: 0 0 auto;
}

/* ---- Legend ------------------------------------------------ */
.dbchart-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 150px;
  flex: 1 1 150px;
}
.dbchart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1.3;
  color: var(--text);
}
.dbchart-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.dbchart-legend-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dbchart-legend-val {
  flex: 0 0 auto;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

/* ---- Empty state ------------------------------------------- */
.dbchart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  padding: 24px;
  text-align: center;
  color: var(--text-faint);
}
.dbchart-root.is-compact .dbchart-empty {
  min-height: 130px;
}
.dbchart-empty-glyph {
  color: var(--text-faint);
  opacity: 0.7;
}
.dbchart-empty-msg {
  font-size: 13.5px;
  color: var(--text-light);
  max-width: 260px;
}

/* ============================================================
   Config panel (mounted inside the integrator's popover)
   ============================================================ */

.dbchart-cfg {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px;
  min-width: 260px;
  font-family: var(--font);
  color: var(--text);
}

.dbchart-cfg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dbchart-cfg-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-light);
  flex: 0 0 auto;
}
.dbchart-cfg-field {
  flex: 1 1 auto;
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}
.dbchart-cfg-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Small selects, consistent with a settings popover. */
.dbchart-select {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-input, var(--bg));
  border: 1px solid var(--border-strong, var(--border));
  border-radius: var(--radius-ctl, 8px);
  padding: 5px 26px 5px 9px;
  max-width: 160px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.12s ease;
}
.dbchart-select:hover {
  border-color: var(--accent-soft, var(--accent));
}
.dbchart-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.2);
}

/* Toggle buttons (Values / Legend / Descending). */
.dbchart-toggle {
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-light);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl, 8px);
  padding: 5px 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.dbchart-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong, var(--border));
}
.dbchart-toggle.is-on {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.dbchart-toggle.is-on:hover {
  background: var(--accent-hover, var(--accent));
}
