/* ════════════════════════════════════════════════════════════
   CENTRAL DE ÁNGELES — COMPONENTS · Contenedores: cards, panel, stat-cards, tabs, side-panel, feed, charts, section-title
   ⚠ Consume css/tokens.css. Parte del set de componentes por dominio.
   Ver css/components/_index.css para el mapa completo.
   ════════════════════════════════════════════════════════════ */

/* ── CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card.is-active {
  border-color: var(--gps);
  background: var(--gps-light);
  box-shadow: var(--shadow-gps);
}
.card-ico {
  width: 40px;
  height: 40px;
  background: var(--gps-light);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  margin-bottom: 14px;
}
.card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}
.card-desc { font-size: var(--text-md); color: var(--text-3); line-height: 1.6; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--sp-4);
}

/* Panel/Section container con header + body (filtros, criterios) */
.panel {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-2);
}
.panel-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-1);
}
.panel-body { padding: 18px; }
.panel-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-2);
  background: var(--surface-2);
}

/* ── STAT CARDS ────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-3);
}
.stats-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stats-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stats-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) {
  .stats-row,
  .stats-row.cols-4,
  .stats-row.cols-3 { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  cursor: default;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card.is-alert { border-color: var(--danger-border); background: var(--danger-light); }
.stat-card.is-live  { border-color: var(--success-border); }

.stat-lbl {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 8px;
}
.stat-val {
  font-family: var(--font-display);
  font-size: var(--display-md);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-1);
  margin-bottom: 6px;
}
.stat-val.green { color: var(--success); }
.stat-val.red   { color: var(--danger); }
.stat-val.blue  { color: var(--electric-text); }
.stat-val .unit { font-size: var(--text-lg); color: var(--text-4); }

.stat-trend {
  font-size: var(--text-xs);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}
.stat-trend.up   { color: var(--success-text); }
.stat-trend.down { color: var(--danger-text); }
.stat-trend.flat { color: var(--text-4); }


/* ── TABS ──────────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border-1);
  padding: 0 12px;
  overflow-x: auto;
}
.tab {
  padding: 12px 18px;
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--text-1); }
.tab.active {
  color: var(--success-text);
  border-bottom-color: var(--gps);
  font-weight: 600;
}
.tab-panel {
  padding: 18px;
  background: var(--surface-2);
}
.tab-panel:not(.active) { display: none; }

/* ── STATUS LIST ITEMS (rastreador con pulse) ──────────── */
.status-stack { display: flex; flex-direction: column; gap: var(--sp-2); }
.status-row-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
}
.status-row-item:hover { box-shadow: var(--shadow-md); }
.status-row-item .sn { font-size: var(--text-md); font-weight: 600; color: var(--text-1); flex: 1; }
.status-row-item .sd { font-size: var(--text-sm); color: var(--text-3); }


/* ── SIDE PANEL (mapa + panel) ─────────────────────────── */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* Resumen widget */
.resumen-card {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.resumen-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-2);
}
.resumen-tab {
  flex: 1;
  padding: 10px;
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all 0.15s ease;
  font-family: var(--font-body);
}
.resumen-tab.active { color: var(--success-text); border-bottom-color: var(--gps); }
.resumen-body { padding: 14px; }
.resumen-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-3);
}
.resumen-row:last-child { border-bottom: none; }
.resumen-label {
  font-size: var(--text-sm);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.resumen-val {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-1);
}
.resumen-total {
  text-align: center;
  padding: 12px;
  border-top: 1px solid var(--border-2);
  font-family: var(--font-display);
  font-size: var(--text-base);
  color: var(--text-3);
}
.resumen-total b { color: var(--text-1); font-size: var(--text-xl); }

/* Alert feed */
.alert-feed {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  flex: 1;
}
.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-2);
}
.feed-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-1);
}
.feed-link {
  font-size: var(--text-xs);
  color: var(--electric-text);
  cursor: pointer;
  font-weight: 600;
  background: transparent;
  border: none;
  font-family: var(--font-body);
}
.feed-link:hover { opacity: 0.75; }
.feed-items {
  overflow-y: auto;
  max-height: 220px;
}
.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-3);
  transition: background 0.12s ease;
  cursor: pointer;
}
.feed-item:last-child { border-bottom: none; }
.feed-item:hover { background: var(--surface-3); }
.feed-ico {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  flex-shrink: 0;
  margin-top: 1px;
}
.feed-ico.d { background: var(--danger-light); }
.feed-ico.w { background: var(--warning-light); }
.feed-ico.s { background: var(--success-light); }
.feed-ico.i { background: var(--info-light); }
.feed-text { flex: 1; min-width: 0; }
.feed-msg {
  font-size: var(--text-sm);
  color: var(--text-1);
  font-weight: 500;
  line-height: 1.4;
}
.feed-time {
  font-size: var(--text-2xs);
  color: var(--text-4);
  margin-top: 2px;
}
.feed-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-4);
  font-size: var(--text-base);
}

/* ── CHART STUBS (placeholders para gráficas reales luego) ── */
.chart-card {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-height: 240px;
}
.chart-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-1);
}
.chart-sub {
  font-size: var(--text-xs);
  color: var(--text-4);
  font-family: var(--font-mono);
}
.chart-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 150px;
}
.chart-bars {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 0;
}
.chart-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--electric), var(--electric-light));
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: filter 0.15s ease;
}
.chart-bar:hover { filter: brightness(1.1); }
.chart-bar.gps { background: linear-gradient(180deg, var(--gps), var(--gps-light)); }
.chart-bar.warn { background: linear-gradient(180deg, var(--warning), var(--warning-light)); }
.chart-bar.danger { background: linear-gradient(180deg, var(--danger), var(--danger-light)); }

/* Eje X — SIEMPRE debajo de las barras. Por defecto horizontal (para pocas
   etiquetas cortas, ej. horas); cada etiqueta en una sola línea con elipsis. */
.chart-axis {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-4);
  padding-top: 6px;
  border-top: 1px solid var(--border-3);
}
.chart-axis > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Variante vertical: una etiqueta por barra, rotada, una línea, elipsis si es
   larga. Para gráficas con muchos nombres largos (unidades).
   Markup: <div class="chart-axis is-vertical"><span><span class="ax-lbl">Nombre</span></span>… */
.chart-axis.is-vertical {
  justify-content: flex-start;
  align-items: stretch;
  height: 68px;
}
.chart-axis.is-vertical > span {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  justify-content: center;
  overflow: visible;
}
.chart-axis.is-vertical .ax-lbl {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}

/* Donut chart — el % de cada tramo se calcula en el servidor y se pasa
   como conic-gradient inline (mismo criterio que las barras: valor de
   dato, no estilo). Markup:
   <div class="chart-donut" style="background:conic-gradient(var(--gps) 0% 38%, var(--electric) 38% 100%)"></div> */
.chart-donut-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-5);
}
.chart-donut {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.chart-donut::after {
  content: '';
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  background: var(--surface-2);
}
.chart-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.chart-donut-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--text-xs);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-donut-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chart-donut-legend-val { margin-left: auto; font-family: var(--font-mono); color: var(--text-2); font-weight: 600; padding-left: 10px; }


/* ── SECTION-TITLE ── */
.section-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: var(--sp-1);
}

