/* ==========================================================================
   CENTINELA — CHARTS
   Styling for hand-rolled inline-SVG charts rendered by assets/js/charts.js.
   The SVG markup carries structural/positional attributes only; visual
   treatment lives here so charts theme consistently with the rest of the app.
   ========================================================================== */

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5, 1.25rem);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chart-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.chart-card__title {
  font: var(--text-h3);
}

.chart-card__subtitle {
  font: var(--text-caption);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
}
.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: var(--text-caption);
  color: var(--color-text-secondary);
}
.chart-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* SVG text defaults — charts.js renders plain <text>, this carries the type */
.chart-svg text {
  font-family: var(--font-body);
  fill: var(--color-text-muted);
}
.chart-svg .chart-axis-line {
  stroke: var(--color-border);
  stroke-width: 1;
}
.chart-svg .chart-gridline {
  stroke: var(--graphite-100);
  stroke-width: 1;
}
.chart-svg .chart-value-label {
  font-family: var(--font-mono);
  font-weight: 600;
  fill: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}
.chart-svg .chart-bar {
  transition: opacity var(--duration-fast) var(--ease-standard);
}
.chart-svg .chart-bar:hover {
  opacity: 0.85;
  cursor: pointer;
}
.chart-svg .chart-line-path {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-svg .chart-line-dot {
  cursor: pointer;
}
.chart-svg .chart-sparkline-path {
  fill: none;
  stroke-width: 2;
}

/* Horizontal-scroll-snap wrapper — weekly stacked chart on mobile rather
   than compressing 8–12 weeks into a narrow viewport */
.chart-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding-bottom: var(--space-2);
}
.chart-scroll-x > svg {
  scroll-snap-align: start;
}

/* Floating tooltip — one shared element, positioned via JS on hover/touch */
.chart-tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  background: var(--graphite-950);
  color: var(--white);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font: var(--text-caption);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-standard);
  box-shadow: var(--shadow-md);
  max-width: 220px;
}
.chart-tooltip.is-visible {
  opacity: 1;
}
.chart-tooltip__title {
  font-weight: 600;
  margin-bottom: 2px;
}
.chart-tooltip__row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.chart-tooltip__swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-12) var(--space-4);
  color: var(--color-text-muted);
  font: var(--text-small);
}
.chart-empty svg {
  width: 32px;
  height: 32px;
  color: var(--graphite-300);
}

/* Ranking / horizontal-bar-list rows (acts-vs-conditions, scorecard mini-bars) */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
}
.rank-row__label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.rank-row__name {
  font: var(--text-small);
  font-weight: 600;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-row__bar-track {
  height: 8px;
  background: var(--graphite-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.rank-row__bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
}
.rank-row__value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-primary);
  text-align: right;
  white-space: nowrap;
}

/* Compliance heatmap (vendor x week) */
.heatmap {
  display: grid;
  gap: 3px;
  overflow-x: auto;
}
.heatmap-cell {
  aspect-ratio: 1;
  min-width: 20px;
  border-radius: 3px;
}
.heatmap-row-label {
  font: var(--text-caption);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  padding-right: var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Calendar-style day-density heatmap (reporting activity over the year) */
.day-heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  overflow-x: auto;
}
.day-heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
}
