/* ════════════════════════════════════════════════════════════════════════════
   PUI — Componentes UI: Cards, Tabla, Badges, Filtros, Paginación,
         Modal, Toasts, Gráficas, Actividad, Spinner, Estados vacíos
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Cards de estadísticas ───────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
  border: 1px solid #e8ecf0;
  display: flex; align-items: flex-start; gap: 1rem;
  height: 100%;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.verde   { background: #ecfdf5; color: var(--pui-verde); }
.stat-icon.rojo    { background: #fff1f2; color: var(--pui-rojo); }
.stat-icon.azul    { background: #eff6ff; color: #2563eb; }
.stat-icon.naranja { background: #fff7ed; color: #ea580c; }
.stat-icon.violeta { background: #faf5ff; color: #7c3aed; }
.stat-icon.gris    { background: #f8fafc; color: #64748b; }

.stat-info { flex: 1; min-width: 0; }

.stat-value {
  font-size: 1.7rem; font-weight: 700;
  line-height: 1; color: #1a202c;
}

.stat-label {
  font-size: .8rem; color: var(--pui-gris);
  margin-top: .25rem;
}

@media (max-width: 575.98px) {
  .stat-value { font-size: 1.4rem; }
}

/* ── Tarjetas de sección ─────────────────────────────────── */
.section-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
  border: 1px solid #e8ecf0;
  overflow: hidden;
}

.section-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid #f0f4f8;
}

.section-card-title {
  font-size: .95rem; font-weight: 600;
  display: flex; align-items: center; gap: .5rem;
  color: #1a202c; margin: 0;
}

.section-card-body { padding: 0; }

/* ── Tabla ───────────────────────────────────────────────── */
.table-pui { margin: 0; font-size: .875rem; }

.table-pui thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  padding: .75rem 1rem;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.table-pui tbody td {
  padding: .75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #f0f4f8;
  color: #374151;
}

.table-pui tbody tr:hover td { background: #f8fffe; }
.table-pui tbody tr:last-child td { border-bottom: none; }

/* ── Badges de estado ────────────────────────────────────── */
.badge-estado {
  font-size: .72rem; font-weight: 600;
  padding: .28rem .7rem;
  border-radius: 99px;
  white-space: nowrap;
}

.estado-activo     { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.estado-inactivo   { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.estado-procesando { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.estado-finalizado { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.estado-prueba     { background: #faf5ff; color: #6d28d9; border: 1px solid #ddd6fe; }

/* ── Badges de nivel log ─────────────────────────────────── */
.nivel-INFO     { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.nivel-WARNING  { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.nivel-ERROR    { background: #fff1f2; color: #b91c1c; border: 1px solid #fecaca; }
.nivel-CRITICAL { background: #fff1f2; color: #7f1d1d; border: 1px solid #fca5a5; }
.nivel-DEBUG    { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }

/* ── Filtros ─────────────────────────────────────────────── */
.filters-bar {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid #f0f4f8;
  background: #fafbfc;
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end;
}

.filters-bar .form-label {
  font-size: .75rem; font-weight: 600;
  color: #64748b; margin-bottom: .2rem;
}

.filters-bar .form-control,
.filters-bar .form-select {
  font-size: .85rem;
  border-color: #d1d5db;
  padding: .35rem .7rem;
}

.filters-bar .form-control:focus,
.filters-bar .form-select:focus {
  border-color: var(--pui-verde);
  box-shadow: 0 0 0 .15rem rgba(0, 104, 71, .2);
}

/* ── Paginación ──────────────────────────────────────────── */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.4rem;
  border-top: 1px solid #f0f4f8;
  font-size: .82rem;
  color: var(--pui-gris);
  flex-wrap: wrap; gap: .5rem;
}

.pagination .page-link {
  font-size: .82rem;
  padding: .3rem .65rem;
  color: var(--pui-verde);
  border-color: #d1d5db;
}

.pagination .page-item.active .page-link {
  background: var(--pui-verde);
  border-color: var(--pui-verde);
}

.pagination .page-item.disabled .page-link { color: #adb5bd; }

/* ── Modal detalle ───────────────────────────────────────── */
.detail-group { margin-bottom: 1rem; }

.detail-label {
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--pui-gris); margin-bottom: .2rem;
}

.detail-value {
  font-size: .9rem; color: #1a202c;
  word-break: break-word;
}

.detail-value.empty { color: #adb5bd; font-style: italic; }

/* ── Barra de confianza ──────────────────────────────────── */
.confidence-bar {
  height: 6px; background: #e2e8f0;
  border-radius: 99px; overflow: hidden; margin-top: .3rem;
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pui-verde), #00a86b);
  border-radius: 99px;
  transition: width .4s ease;
}

/* ── Estado vacío ────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3.5rem 1rem;
  color: var(--pui-gris);
}

.empty-state i { font-size: 3rem; margin-bottom: .75rem; opacity: .4; }
.empty-state p { font-size: .9rem; margin: 0; }

/* ── Spinner overlay ─────────────────────────────────────── */
.spinner-overlay {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, .7);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; border-radius: 12px;
}

/* ── Gráfica de barras ───────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: .6rem; padding: 1.25rem 1.4rem; }

.bar-row { display: flex; align-items: center; gap: .75rem; }

.bar-label {
  width: 80px; font-size: .78rem;
  color: #374151; text-align: right;
  flex-shrink: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

.bar-track {
  flex: 1; height: 18px; background: #f1f5f9;
  border-radius: 99px; overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pui-verde), #00a86b);
  border-radius: 99px;
  transition: width .6s ease;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: .4rem;
}

.bar-fill span {
  font-size: .65rem; font-weight: 700; color: #fff;
}

.bar-count {
  width: 30px; font-size: .78rem;
  font-weight: 600; color: var(--pui-verde);
  flex-shrink: 0;
}

/* ── Leyenda tipo donut ──────────────────────────────────── */
.donut-legend { padding: 1rem 1.4rem; }

.legend-item {
  display: flex; align-items: center; gap: .6rem;
  font-size: .82rem; margin-bottom: .5rem;
}

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

.legend-count { margin-left: auto; font-weight: 600; color: #1a202c; }

/* ── Toast container ─────────────────────────────────────── */
.toast-container-custom {
  position: fixed; top: 1.25rem; right: 1.25rem;
  z-index: 9999;
}

/* ── Actividad reciente ──────────────────────────────────── */
.activity-list { list-style: none; padding: 0; margin: 0; }

.activity-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .85rem 1.4rem;
  border-bottom: 1px solid #f0f4f8;
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: .3rem; flex-shrink: 0;
}

.dot-verde   { background: var(--pui-verde); }
.dot-rojo    { background: var(--pui-rojo); }
.dot-azul    { background: #2563eb; }
.dot-naranja { background: #ea580c; }
.dot-gris    { background: #94a3b8; }

.activity-text { font-size: .84rem; color: #374151; }
.activity-time { font-size: .75rem; color: #94a3b8; }

/* ── Folio y CURP ────────────────────────────────────────── */
.folio-code {
  font-family: 'Courier New', monospace;
  font-size: .82rem;
  background: #f1f5f9;
  padding: .15rem .5rem;
  border-radius: 5px;
  color: #1e40af;
  white-space: nowrap;
}

.curp-code {
  font-family: 'Courier New', monospace;
  font-size: .82rem;
  color: #374151;
  letter-spacing: .5px;
}

/* ── Título de sección en modal de detalle ──────────────── */
.detail-section-title {
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--pui-gris);
  margin-bottom: .75rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid #f0f4f8;
}

/* ── Fase badge ──────────────────────────────────────────── */
.fase-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 6px;
  background: #f8fafc; color: #475569;
  border: 1px solid #e2e8f0;
}
