/* ===========================================================
   NODO Shell — Chart (SVG vanilla, tema-aware, sin librerías)
   ===========================================================
   Tipos: bar · line · area · pie/donut · stackedBar · groupedBar
          sparkline · gauge · funnel · heatmap · dynamic (wrapper)
   Paleta tema-aware, escucha themechange para re-render automático.
   Gradientes verticales en bar/area.
   =========================================================== */

.nc-chart {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 200px;
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
}
.nc-chart__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  color: var(--ofc-blue-900);
  padding: 4px 8px 6px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  text-align: left;
}
.nc-chart__viewport {
  flex: 1;
  position: relative;
  min-height: 0;
}
.nc-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}
.nc-chart text {
  font-family: var(--font-ui);
  fill: var(--text);
  font-size: 10px;
}
.nc-chart .nc-axis-label  { fill: var(--text-muted); font-size: 9px; }
.nc-chart .nc-axis-line   { stroke: var(--border-strong); stroke-width: 1; }
.nc-chart .nc-grid-line   { stroke: var(--border); stroke-width: 0.5; stroke-dasharray: 2 3; }
.nc-chart .nc-bar         { cursor: pointer; transition: filter var(--t-fast); }
.nc-chart .nc-bar:hover   { filter: brightness(1.12); }
.nc-chart .nc-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.nc-chart .nc-area { opacity: 1; }
.nc-chart .nc-dot {
  cursor: pointer;
  transition: r var(--t-fast);
  stroke: var(--bg-ribbon);
  stroke-width: 1.5;
}
.nc-chart .nc-dot:hover { r: 5; }
.nc-chart .nc-pie-slice {
  cursor: pointer;
  stroke: var(--bg-ribbon);
  stroke-width: 2;
  transition: filter var(--t-fast), transform var(--t-fast);
  transform-origin: center;
}
.nc-chart .nc-pie-slice:hover { filter: brightness(1.08); transform: scale(1.02); }

.nc-chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 6px 8px;
  font-size: var(--fs-xs);
  color: var(--text);
  border-top: 1px solid var(--border);
  background: var(--sil-50);
}
.nc-chart__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  padding: 2px 4px;
  border-radius: 2px;
  transition: background var(--t-fast);
}
.nc-chart__legend-item:hover { background: var(--bg-hover); }
.nc-chart__legend-item.is-disabled { opacity: 0.4; }
.nc-chart__legend-swatch {
  width: 12px; height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}
.nc-chart__legend-value {
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-left: 2px;
}

.nc-chart__tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(20,30,46,0.96);
  color: #fff;
  padding: 6px 9px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font-ui);
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: 10;
  line-height: 1.5;
}
.nc-chart__tooltip.is-visible { opacity: 1; }
.nc-chart__tooltip strong { color: #ffd700; font-family: var(--font-mono); }
.nc-chart__tooltip .nc-tt-label { color: rgba(255,255,255,0.75); margin-right: 6px; }
.nc-chart__tooltip .nc-tt-row { display: flex; justify-content: space-between; gap: 8px; }

/* ============================================================
   SPARKLINE — mini gráfico inline
   ============================================================ */
.nc-spark {
  display: inline-block;
  vertical-align: middle;
  height: 18px;
  width: 80px;
}
.nc-spark--lg { height: 28px; width: 120px; }

/* ============================================================
   GAUGE / Progress radial
   ============================================================ */
.nc-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 4px;
}
.nc-gauge-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--ofc-blue-900);
  font-family: var(--font-mono);
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  margin-top: -50px;
  pointer-events: none;
}
.nc-gauge-label { font-size: 11px; color: var(--text-muted); margin-top: -4px; }
.nc-gauge-track { stroke: var(--sil-300); }

/* ============================================================
   HEATMAP
   ============================================================ */
.nc-hm-cell { transition: filter var(--t-fast); cursor: pointer; }
.nc-hm-cell:hover { filter: brightness(1.15); stroke: var(--ofc-blue-900); stroke-width: 1.5; }

/* ============================================================
   FUNNEL
   ============================================================ */
.nc-funnel-segment {
  cursor: pointer;
  transition: filter var(--t-fast);
}
.nc-funnel-segment:hover { filter: brightness(1.1); }

/* ============================================================
   DYNAMIC chart wrapper (con filtros + KPIs + selector tipo)
   ============================================================ */
.nc-dyn {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-ribbon, #fff);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  font-family: var(--font-ui);
  min-height: 360px;
}
.nc-dyn__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(180deg, #eef3fa 0%, #d6dfed 100%);
  border-bottom: 1px solid var(--border-strong);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.nc-dyn__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--ofc-blue-900);
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  flex: 1;
  min-width: 180px;
}
.nc-dyn__filters {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.nc-dyn__filter {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nc-dyn__filter > label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: var(--fw-semi);
  letter-spacing: 0.3px;
  margin: 0;
}
.nc-dyn__type-switch {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  overflow: hidden;
  height: 22px;
}
.nc-dyn__type-switch button {
  padding: 0 8px;
  font-size: 11px;
  background: linear-gradient(180deg, #fdfdfe 0%, #e6ecf3 100%);
  color: var(--text);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}
.nc-dyn__type-switch button:last-child { border-right: none; }
.nc-dyn__type-switch button:hover { background: var(--bg-hover); }
.nc-dyn__type-switch button[aria-selected="true"] {
  background: linear-gradient(180deg, var(--ofc-blue-500) 0%, var(--ofc-blue-700) 100%);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.3);
  font-weight: var(--fw-semi);
}

.nc-dyn__kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.nc-dyn__kpi {
  background: linear-gradient(180deg, #fdfdfe 0%, #f4f7fb 100%);
  padding: 8px 12px;
}
.nc-dyn__kpi-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: var(--fw-semi);
}
.nc-dyn__kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ofc-blue-900);
  font-family: var(--font-mono);
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  line-height: 1.2;
}
.nc-dyn__kpi-delta { font-size: 10px; margin-top: 1px; font-family: var(--font-mono); }
.nc-dyn__kpi-delta--up   { color: var(--success); }
.nc-dyn__kpi-delta--down { color: var(--danger); }

.nc-dyn__body {
  flex: 1;
  min-height: 0;
  position: relative;
}
.nc-dyn__footer {
  font-size: 10px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--sil-50);
  border-top: 1px solid var(--border);
  text-align: right;
}

/* =============================================================
   THEME OVERRIDES
   ============================================================= */
[data-theme="bloomberg"] .nc-chart__title { color: #e8c084; text-shadow: 0 1px 0 rgba(0,0,0,0.4); }
[data-theme="bloomberg"] .nc-chart__legend { background: #1a1a1a; border-top-color: #3a3a3a; color: #e8e8e8; }
[data-theme="bloomberg"] .nc-chart .nc-axis-line { stroke: #4a4a4a; }
[data-theme="bloomberg"] .nc-chart .nc-grid-line { stroke: #2a2a2a; }
[data-theme="bloomberg"] .nc-chart text { fill: #c0c0c0; }
[data-theme="bloomberg"] .nc-chart .nc-axis-label { fill: #888; }
[data-theme="bloomberg"] .nc-chart .nc-pie-slice { stroke: #232323; }
[data-theme="bloomberg"] .nc-chart .nc-dot { stroke: #232323; }
[data-theme="bloomberg"] .nc-chart__tooltip { background: rgba(212,167,106,0.96); color: #1a1a1a; }
[data-theme="bloomberg"] .nc-chart__tooltip strong { color: #4a2a14; }
[data-theme="bloomberg"] .nc-chart__tooltip .nc-tt-label { color: rgba(26,26,26,0.65); }
[data-theme="bloomberg"] .nc-gauge-value { color: #e8c084; text-shadow: 0 1px 0 rgba(0,0,0,0.4); }
[data-theme="bloomberg"] .nc-gauge-track { stroke: #3a3a3a; }
[data-theme="bloomberg"] .nc-dyn { background: #232323; border-color: #3a3a3a; }
[data-theme="bloomberg"] .nc-dyn__header { background: linear-gradient(180deg, #353535 0%, #2a2a2a 100%); border-bottom-color: #4a4a4a; }
[data-theme="bloomberg"] .nc-dyn__title { color: #e8c084; }
[data-theme="bloomberg"] .nc-dyn__filter > label { color: #a0a0a0; }
[data-theme="bloomberg"] .nc-dyn__type-switch button {
  background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
  color: #e8e8e8;
  border-right-color: #3a3a3a;
}
[data-theme="bloomberg"] .nc-dyn__type-switch button[aria-selected="true"] {
  background: linear-gradient(180deg, #d4a76a 0%, #b8761a 100%);
  color: #1a1a1a;
}
[data-theme="bloomberg"] .nc-dyn__kpis { background: #3a3a3a; border-bottom-color: #4a4a4a; }
[data-theme="bloomberg"] .nc-dyn__kpi {
  background: linear-gradient(180deg, #2e2e2e 0%, #262626 100%);
}
[data-theme="bloomberg"] .nc-dyn__kpi-label { color: #a0a0a0; }
[data-theme="bloomberg"] .nc-dyn__kpi-value { color: #e8c084; text-shadow: 0 1px 0 rgba(0,0,0,0.4); }
[data-theme="bloomberg"] .nc-dyn__footer { background: #1a1a1a; border-top-color: #3a3a3a; color: #888; }

[data-theme="slate"] .nc-chart__title { color: #1b4332; }
[data-theme="slate"] .nc-dyn__title { color: #1b4332; }
[data-theme="slate"] .nc-dyn__type-switch button[aria-selected="true"] {
  background: linear-gradient(180deg, #52b788 0%, #2d6a4f 100%);
  color: #fff;
}
[data-theme="slate"] .nc-gauge-value { color: #1b4332; }
