/* ============================================
   CHARTS — Chart.js & D3 specific styles
   ============================================ */

.chart-container {
  position: relative;
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.chart-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.chart-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.chart-canvas {
  position: relative;
  width: 100%;
  max-height: 400px;
}

/* Chart legend override */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-4);
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* SVG visualizations */
.viz-container {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  overflow: hidden;
}

.viz-container svg {
  width: 100%;
  height: auto;
}

/* Heatmap */
.heatmap-cell {
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.heatmap-cell:hover { opacity: 0.8; }

.heatmap-label {
  font-family: var(--font-body);
  font-size: 11px;
  fill: var(--text-secondary);
}

.heatmap-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  fill: white;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

/* Funnel */
.funnel-stage {
  transition: opacity var(--transition-fast);
}

.funnel-stage:hover { opacity: 0.85; }

.funnel-label {
  font-family: var(--font-body);
  font-size: 13px;
  /* fill always overridden by inline style="fill:white" in JS */
}

.funnel-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  /* fill always overridden by inline style="fill:white" in JS */
}

/* Tornado chart */
.tornado-bar {
  transition: opacity var(--transition-fast);
}

.tornado-bar:hover { opacity: 0.8; }

/* Map France */
.dept-path {
  stroke: var(--surface-0);
  stroke-width: 1;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.dept-path:hover { opacity: 0.8; }

.dept-path.target {
  stroke: var(--accent);
  stroke-width: 2;
}

.dept-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  fill: white;
  text-anchor: middle;
  pointer-events: none;
}

/* Gauge */
.gauge-arc {
  transition: all var(--transition-chart);
}

.gauge-value {
  font-family: var(--font-display);
  font-weight: 700;
  fill: var(--text-primary);
  text-anchor: middle;
}

.gauge-label {
  font-family: var(--font-body);
  font-size: 13px;
  fill: var(--text-secondary);
  text-anchor: middle;
}

/* Gantt */
.gantt-bar {
  rx: 4;
  ry: 4;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.gantt-bar:hover { opacity: 0.8; }

.gantt-label {
  font-family: var(--font-body);
  font-size: 12px;
  fill: var(--text-primary);
}

.gantt-milestone {
  fill: var(--warning);
  cursor: pointer;
}

/* Org chart */
.org-node {
  cursor: pointer;
}

.org-node rect {
  fill: var(--surface-1);
  stroke: var(--surface-2);
  stroke-width: 1;
  rx: 8;
  transition: all var(--transition-fast);
}

.org-node:hover rect {
  stroke: var(--accent);
  filter: drop-shadow(0 4px 12px rgba(0, 193, 213, 0.2));
}

.org-node text {
  font-family: var(--font-body);
  fill: var(--text-primary);
}

.org-link {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 1.5;
}

/* Waterfall */
.waterfall-bar-positive { fill: var(--positive); }
.waterfall-bar-negative { fill: var(--negative); }
.waterfall-bar-total { fill: var(--accent); }
.waterfall-connector {
  stroke: var(--text-secondary);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

/* Breakeven signature curve */
.breakeven-zone-negative {
  fill: rgba(239, 68, 68, 0.08);
}

.breakeven-zone-positive {
  fill: rgba(34, 197, 94, 0.08);
}

.breakeven-marker {
  stroke: var(--warning);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

/* Chart loading state */
.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-secondary);
}

.chart-loading::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Accessible alternative table for screen readers */
.chart-data-table {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
