/* =============================================
   Dashboard Overview — layout compacto
   Render: js/admin/panels/dashboard_panel.js
   Gráficas: js/admin/panels/dashboard_charts.js
   Usa las variables de tema de admin.css (cárgalo después).
   ============================================= */

/* ── Encabezado ──────────────────────────────── */
.dsh-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dsh-head h3 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.15;
  color: var(--text);
}

.dsh-head p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dsh-head-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.dsh-head-pill .material-icons-outlined {
  font-size: 15px;
  color: var(--primary);
}

/* ── Banda "Requiere atención" ────────────────
   Una sola fila full-width con chips: sin columna
   vacía cuando hay pocos pendientes. */
.dsh-alert {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rose);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 11px 16px;
  margin-bottom: 14px;
}

.dsh-alert.is-ok {
  border-left-color: var(--green);
}

.dsh-alert-lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dsh-alert-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--rose-soft);
  color: var(--rose);
}

.dsh-alert.is-ok .dsh-alert-icon {
  background: var(--green-soft);
  color: var(--green);
}

.dsh-alert-icon .material-icons-outlined {
  font-size: 19px;
}

.dsh-alert-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.dsh-alert-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.dsh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}

.dsh-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px 5px 9px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--bg);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), color var(--transition);
}

.dsh-chip:hover {
  border-color: var(--chip);
  color: var(--text);
  transform: translateY(-1px);
}

.dsh-chip .material-icons-outlined {
  font-size: 15px;
  color: var(--chip);
}

.dsh-chip b {
  min-width: 20px;
  padding: 3px 6px;
  border-radius: 9999px;
  background: var(--chip);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

/* ── Pulso: actividad reciente en una sola tira
   segmentada (menos aire que 3 tarjetas sueltas) ── */
.dsh-pulse {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.dsh-pulse-card {
  padding: 12px 18px;
  border-left: 1px solid var(--border);
}

.dsh-pulse-card:first-child {
  border-left: 0;
}

.dsh-pulse-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
}

.dsh-pulse-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 5px;
}

.dsh-pulse-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.5px;
  color: var(--pulse, var(--primary));
}

.dsh-pulse-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.dsh-pulse-meta .material-icons-outlined {
  font-size: 15px;
  color: var(--pulse, var(--primary));
}

.dsh-pulse-bar {
  margin-top: 10px;
  height: 4px;
  border-radius: 9999px;
  background: var(--bg);
  overflow: hidden;
}

.dsh-pulse-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--pulse, var(--primary));
  transition: width .6s ease;
}

/* Pie de tarjeta: alterna con la barra para igualar altos */
.dsh-pulse-foot {
  margin-top: 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Etiqueta de sección ─────────────────────── */
.dsh-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.dsh-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── KPIs: una línea por sección
   (icono · etiqueta · total alineado a la derecha) ── */
.dsh-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.dsh-kpi {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 14px 9px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.dsh-kpi:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.dsh-kpi-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.dsh-kpi-icon .material-icons-outlined {
  font-size: 17px;
}

.dsh-kpi-label {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dsh-kpi-value {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.4px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── Gráficas ─────────────────────────────────
   .dash-chart-card lo reutiliza el panel de Rangos:
   el alto del canvas se limita solo dentro del grid
   del dashboard. */
.dash-charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-top: 20px;
}

.dash-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.dash-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  transition: box-shadow .2s ease;
}

.dash-chart-card:hover {
  box-shadow: var(--shadow-md);
}

.dash-chart-card .chart-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.dash-chart-card .chart-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.dash-charts-grid canvas,
.dash-charts-row canvas {
  max-height: 210px;
  width: 100% !important;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 1280px) {
  .dsh-kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 1080px) {
  .dash-charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .dsh-kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .dash-charts-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .dsh-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    padding-left: 44px;
    /* espacio para el toggle del sidebar */
  }

  .dsh-head h3 {
    font-size: 20px;
  }

  .dsh-chips {
    width: 100%;
    padding-left: 0;
    border-left: 0;
  }

  .dsh-pulse {
    grid-template-columns: 1fr;
    margin-bottom: 16px;
  }

  .dsh-pulse-card {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .dsh-pulse-card:first-child {
    border-top: 0;
  }

  .dash-charts-grid {
    gap: 12px;
    margin-top: 16px;
  }

  .dash-charts-row {
    gap: 12px;
    margin-top: 12px;
  }

  .dash-chart-card {
    padding: 16px;
  }
}

@media (max-width: 560px) {
  .dsh-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .dsh-head h3 {
    font-size: 18px;
  }

  .dsh-head p {
    font-size: 12px;
  }

  .dsh-kpi {
    padding: 8px 10px;
    gap: 8px;
  }

  .dsh-kpi-icon {
    width: 27px;
    height: 27px;
  }

  .dsh-kpi-icon .material-icons-outlined {
    font-size: 16px;
  }

  .dsh-kpi-value {
    font-size: 16px;
  }

  .dsh-kpi-label {
    font-size: 12px;
  }

  .dsh-pulse-value {
    font-size: 22px;
  }

  .dash-charts-grid canvas,
  .dash-charts-row canvas {
    max-height: 180px;
  }
}
