/* Graficos do painel de Veiculos (issue #70).
   Substitui o dump textual do resumo (consumo por combustivel saia como
   "gasolina: 12,3 · etanol: 8,5", ilegivel) por graficos SVG proprios.
   A LEGENDA e INTEGRADA ao hover: nao ha lista solta num canto — ao passar
   o mouse (ou focar via teclado) numa fatia/barra, um tooltip mostra o
   marcador de cor + rotulo + valor + percentual, tudo junto.
   Sem JS inline (CSP): o posicionamento do tooltip sai do veiculos.js via
   CSSOM (element.style), que a CSP nao intercepta. */

.vg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.25rem;
}

.vg-chart-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.vg-chart-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.vg-chart-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin: -0.25rem 0 0;
}

.vg-plot {
  position: relative;
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vg-plot svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 240px;
  display: block;
}

.vg-plot .vg-donut { max-width: 210px; margin: 0 auto; }

/* Elementos interativos: reagem ao hover/focus destacando a propria fatia. */
.vg-plot [data-vg] {
  cursor: pointer;
  transition: opacity 0.15s ease, filter 0.15s ease;
  outline: none;
}
.vg-plot:hover [data-vg] { opacity: 0.55; }
.vg-plot [data-vg]:hover,
.vg-plot [data-vg]:focus-visible,
.vg-plot [data-vg].is-ativo {
  opacity: 1;
  filter: brightness(1.08);
}

.vg-axis { font-size: 9px; fill: var(--muted); }
.vg-center-val { font-size: 13px; font-weight: 700; fill: var(--text); }
.vg-center-sub { font-size: 9px; fill: var(--muted); }
.vg-baseline { stroke: var(--border); stroke-width: 1; }

/* --- Tooltip = legenda integrada ao hover ------------------------------- */
.vg-tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  min-width: 130px;
  max-width: 240px;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  background: var(--surface, #0f172a);
  color: var(--text, #e2e8f0);
  border: 1px solid var(--border, #334155);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.8rem;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.vg-tooltip.is-visivel { opacity: 1; transform: translateY(0); }

.vg-tt-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}
.vg-tt-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: 0 0 auto;
  display: inline-block;
}
.vg-tt-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted, #94a3b8);
}
.vg-tt-row strong { color: var(--text, #e2e8f0); font-weight: 600; }

.vg-vazio {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

@media (max-width: 640px) {
  .vg-grid { grid-template-columns: 1fr; }
}
