/* ============================================================
   VOTODATA — Cloudflare-style analytics components
   Stat cards · area sparklines · ranked spark rows · choropleth
   Depende de ds/tokens.css. Lógica em ds/dataviz.js.
   ============================================================ */

/* ---------- STAT CARD (overview tile) ---------- */
.vd-cf-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
@media (max-width: 980px) { .vd-cf-grid { grid-template-columns: repeat(2, 1fr); } }

.vd-cf-stat {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5) 0;
  overflow: hidden;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--dur) var(--ease-out);
}
.vd-cf-stat:hover { border-color: var(--border-soft); }
.vd-cf-stat__label { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.vd-cf-stat__label .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex: none; }
.vd-cf-stat__row { display: flex; align-items: baseline; gap: var(--space-3); margin-top: var(--space-3); }
.vd-cf-stat__value { font-family: var(--font-display); font-weight: 700; font-size: 32px; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.vd-cf-stat__delta { font-size: var(--text-xs); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.vd-cf-stat__delta--up { color: var(--vd-success); }
.vd-cf-stat__delta--down { color: var(--vd-danger); }
.vd-cf-stat__delta--flat { color: var(--text-muted); }
.vd-cf-stat__spark { margin: var(--space-4) -1px 0; height: 46px; }
.vd-cf-stat__spark svg { display: block; width: 100%; height: 100%; }

/* ---------- RANKED SPARK ROWS (geo / dimension list) ---------- */
.vd-spark-list { display: flex; flex-direction: column; }
.vd-spark-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 64px;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-out);
  cursor: default;
}
.vd-spark-row:hover, .vd-spark-row.is-hot { background: rgba(6,182,212,0.08); }
.vd-spark-row__name { font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vd-spark-row.is-hot .vd-spark-row__name { color: var(--text); }
.vd-spark-row__spark { height: 26px; }
.vd-spark-row__spark svg { display: block; width: 100%; height: 100%; }
.vd-spark-row__val { text-align: right; font-size: var(--text-sm); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- CHOROPLETH (Brazil) ---------- */
.vd-geo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 0;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
@media (max-width: 880px) { .vd-geo { grid-template-columns: 1fr; } }
.vd-geo__map { position: relative; padding: var(--space-5); background: var(--surface); display: flex; align-items: center; justify-content: center; }
.vd-geo__side { border-left: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 880px) { .vd-geo__side { border-left: none; border-top: 1px solid var(--border); } }
.vd-geo__head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5) var(--space-2); }
.vd-geo__head h4 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); margin: 0; color: var(--text); }
.vd-geo__head .meta { font-size: var(--text-xs); color: var(--text-muted); }
.vd-geo__scroll { overflow-y: auto; max-height: 360px; padding: var(--space-1) var(--space-2) var(--space-3); }

.vd-brazil { position: relative; width: 100%; max-width: 420px; }
.vd-brazil svg { display: block; width: 100%; height: auto; }
.vd-brazil .uf {
  stroke: var(--vd-ink-900);
  stroke-width: 1;
  transition: fill var(--dur) var(--ease-out), stroke var(--dur-fast) var(--ease-out);
  cursor: pointer;
}
.vd-brazil .uf.is-hot { stroke: var(--vd-cyan-200); stroke-width: 2; }
.vd-brazil__tip {
  position: absolute; transform: translate(-50%, calc(-100% - 12px));
  background: var(--vd-ink-850); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 7px 11px; font-size: var(--text-xs);
  color: var(--text-secondary); white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); box-shadow: var(--shadow-3); z-index: 5;
}
.vd-brazil__tip b { color: var(--text); font-weight: 600; }
.vd-brazil__tip span { color: var(--vd-cyan-300); font-weight: 600; font-variant-numeric: tabular-nums; }

/* legend */
.vd-geo__legend { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-5) var(--space-4); font-size: var(--text-2xs); color: var(--text-muted); }
.vd-geo__scale { display: flex; height: 8px; flex: 1; border-radius: var(--radius-full); overflow: hidden; }
.vd-geo__scale i { flex: 1; }

.vd-cf__loading { padding: var(--space-12); text-align: center; color: var(--text-muted); font-size: var(--text-sm); width: 100%; }

/* segmented control (Cloudflare-style range switch) */
.vd-seg { display: inline-flex; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 2px; gap: 2px; }
.vd-seg button {
  font-family: var(--font-body); font-size: var(--text-xs); font-weight: 600;
  color: var(--text-muted); background: none; border: none; cursor: pointer;
  padding: 5px 12px; border-radius: calc(var(--radius-md) - 3px); transition: all var(--dur-fast) var(--ease-out);
}
.vd-seg button:hover { color: var(--text-secondary); }
.vd-seg button.is-active { background: var(--surface-hover); color: var(--text); box-shadow: var(--shadow-1); }
