/* ============================================================
   PROJET MIDDLE-TRACKING — Charts & Reporting
   Heatmap SVG, Jauges, Graphiques analytiques
   ============================================================ */

/* ── Heatmap Couverture ─────────────────────────────────── */
.heatmap-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  overflow-x: auto;
}

.heatmap-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.heatmap-grid {
  display: grid;
  gap: 2px;
}

.heatmap-header-row {
  display: flex;
  gap: 2px;
}

.heatmap-corner {
  width: 100px;
  flex-shrink: 0;
}

.heatmap-slot-header {
  flex: 1;
  min-width: 36px;
  text-align: center;
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 2px 0;
  white-space: nowrap;
}

.heatmap-row {
  display: flex;
  gap: 2px;
  align-items: center;
}

.heatmap-manager-label {
  width: 100px;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: right;
  padding-right: var(--space-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heatmap-cell {
  flex: 1;
  min-width: 36px;
  height: 28px;
  border-radius: 3px;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.heatmap-cell:hover {
  transform: scale(1.1);
  z-index: 5;
  box-shadow: var(--shadow-md);
}

/* Niveaux de couverture */
.heatmap-cell[data-level="0"] { background: rgba(30,42,58,0.6); }
.heatmap-cell[data-level="1"] { background: rgba(59,130,246,0.25); }
.heatmap-cell[data-level="2"] { background: rgba(59,130,246,0.5); }
.heatmap-cell[data-level="3"] { background: rgba(16,185,129,0.45); }
.heatmap-cell[data-level="4"] { background: rgba(16,185,129,0.65); }
.heatmap-cell[data-level="5"] { background: rgba(16,185,129,0.85); }

/* Cellule "absent" */
.heatmap-cell[data-status="absent"]   { background: rgba(239,68,68,0.25); }
.heatmap-cell[data-status="bureau"]   { background: rgba(124,58,237,0.25); }
.heatmap-cell[data-status="terrain"]  { background: rgba(16,185,129,0.5); }
.heatmap-cell[data-status="vide"]     { background: rgba(30,42,58,0.3); border: 1px dashed var(--border-subtle); }

/* Tooltip heatmap */
.heatmap-cell::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  white-space: nowrap;
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.heatmap-cell:hover::after { opacity: 1; }

/* Légende heatmap */
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.heatmap-legend-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

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

.heatmap-legend-swatch {
  width: 16px; height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Gauge circulaire CSS ───────────────────────────────── */
.gauge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.gauge {
  position: relative;
  width: 120px; height: 120px;
}

.gauge svg {
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 10;
}

.gauge-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}

.gauge-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.gauge-number {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.gauge-unit {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}

.gauge-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Couleurs des jauges */
.gauge-fill.violet { stroke: var(--accent-violet-light); }
.gauge-fill.green  { stroke: var(--accent-green); }
.gauge-fill.amber  { stroke: var(--accent-amber); }
.gauge-fill.red    { stroke: var(--accent-red); }
.gauge-fill.blue   { stroke: var(--accent-blue); }

/* ── Chart Barres (SVG) ─────────────────────────────────── */
.bar-chart-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.bar-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.bar-chart-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

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

.chart-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* SVG Charts */
.chart-svg {
  width: 100%;
  overflow: visible;
}

.chart-bar {
  transition: opacity var(--transition-fast);
  cursor: pointer;
}

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

.chart-bar-bg { fill: var(--bg-elevated); }
.chart-bar-planifie { fill: var(--accent-blue); }
.chart-bar-realise  { fill: var(--accent-green); }
.chart-bar-imposes  { fill: var(--accent-red); opacity: 0.8; }
.chart-bar-imprevu  { fill: var(--accent-amber); opacity: 0.8; }

.chart-axis-text {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: 'Inter', sans-serif;
}

.chart-grid-line {
  stroke: var(--border-subtle);
  stroke-dasharray: 4 4;
}

/* ── Anneau Répartition temps ───────────────────────────── */
.donut-chart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.donut-center {
  position: absolute;
  text-align: center;
}

.donut-center-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.donut-center-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Tableau récap ──────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.data-table th {
  padding: var(--space-2) var(--space-4);
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: var(--bg-hover); }

/* ── Sparkline ──────────────────────────────────────────── */
.sparkline {
  display: inline-block;
}

.sparkline-path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ── Reporting Grid ─────────────────────────────────────── */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-5);
}

.report-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.report-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Stat Row ───────────────────────────────────────────── */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.stat-row:last-child { border-bottom: none; }

.stat-row-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stat-row-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Indicateur seuil ───────────────────────────────────── */
.threshold-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: visible;
  position: relative;
  margin: var(--space-2) 0;
}

.threshold-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
  position: relative;
}

.threshold-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 14px;
  background: var(--accent-amber);
  border-radius: 1px;
  transform: translateX(-50%);
}

.threshold-marker::after {
  content: attr(data-label);
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--accent-amber);
  white-space: nowrap;
  font-weight: 700;
}
