/* =============================================
   ESTILOS UNIFICADOS — base compartida (módulos públicos)
   Paleta Unidad de Flagrancia: azul marino + rojo
   Tipografía: BebasNeueBold (títulos) · BebasNeue (subtítulos)
               Barlow (contenido) · BarlowBold (resaltados) · Inter (fallback)
   ============================================= */

@font-face {
  font-family: 'Inter';
  src: url('../fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'BebasNeueBold';
  src: url('../fonts/BebasNeueBold.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'BebasNeue';
  src: url('../fonts/BebasNeue.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Barlow';
  src: url('../fonts/BarlowCondensedRegular.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'BarlowBold';
  src: url('../fonts/BarlowCondensedBold.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* =============================================
   TOKENS
   ============================================= */

:root {
  --primary: #0D1F3C;
  --secondary: #1A4A8A;
  --especialista: #64748b;
  --accent: #B91C1C;
  --accent-dark: #991B1B;
  --bg: #F0F4F8;
  --surface: #ffffff;
  --text: #1F2937;
  --text-muted: #64748b;
  --border: #D8E0E9;
  --grad-primary: linear-gradient(135deg, #0D1F3C, #1A4A8A 55%, #B91C1C);
  --font-base: 'Barlow', 'Inter', 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif;
  --font-bold: 'BarlowBold', 'Barlow', 'Inter', 'Segoe UI', sans-serif;
  --font-display: 'BebasNeueBold', 'BebasNeue', 'Inter', sans-serif;
  --font-display-alt: 'BebasNeue', 'Inter', sans-serif;
  --font-clasico: 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(13, 31, 60, 0.12);
  --transition: 0.3s ease;
  --white: #ffffff;
}

/* =============================================
   RESET
   ============================================= */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* =============================================
   TIPOGRAFÍA
   ============================================= */

body {
  font-family: var(--font-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Negritas y resaltados → BarlowBold (se anula la negrita sintética).
   Va antes de los títulos para que las utilidades Bootstrap !important
   no pisen a los títulos display. */
b,
strong,
.fw-bold,
.fw-bolder,
.fw-semibold,
.fw-medium,
.campo-label,
.tabla-estadisticas th:not(.titulo-tabla),
.tabla-estadisticas tr.fila-pie td,
.tabla-resumen th,
.modal-titulo-container .modal-titulo-principal {
  font-family: var(--font-bold) !important;
}

/* Títulos */
h1,
.reportes-titulo {
  font-family: var(--font-display) !important;
  letter-spacing: 0.045em;
}

h2,
h3,
h4,
h5,
h6,
.subtitulo,
.titulo-tabla {
  font-family: var(--font-display-alt);
  letter-spacing: 0.045em;
}

a {
  transition: color var(--transition);
}

/* =============================================
   LAYOUT BASE
   ============================================= */

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-base);
}

body {
  display: flex;
  flex-direction: column;
}

/* Páginas «pantalla completa» (reportes de gráficos y TV) */
body.reportes-app {
  overflow: hidden;
  background: var(--grad-primary);
}

.estadistica_body {
  justify-content: flex-start !important;
  align-items: flex-start !important;
  min-height: 100vh;
  height: auto;
  padding: 20px;
}

/* =============================================
   COMPONENTES COMUNES - TARJETAS
   ============================================= */

.tarjeta,
.tarjeta-principal,
.principal .tarjeta {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.principal .tarjeta {
  max-width: 80% !important;
  width: 80% !important;
  margin: 0 auto;
}

.tarjeta .boton-regresar {
  width: 400px;
  max-width: 100%;
  transition: transform 0.3s;
}

.tarjeta .boton-regresar:hover {
  transform: scale(1.05);
}

/* =============================================
   COMPONENTES COMUNES - BOTONES
   ============================================= */

.boton-actualizar {
  background: #0C1011;
  color: var(--white);
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 20px;
}

.boton-actualizar:hover {
  background: #303434;
  color: var(--white);
}

.boton-actualizar:active {
  background: #153d6e;
  color: var(--white);
}

.boton-descargar {
  --bs-btn-color: var(--white);
  --bs-btn-hover-color: var(--white);
  --bs-btn-active-color: var(--white);
  --bs-btn-disabled-color: var(--white);
  transition: transform 0.3s;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--white);
}

.boton-descargar:hover {
  transform: scale(1.05);
}

/* Iconos FontAwesome en botones (equivalen al SVG 20x20 previo) */
.boton-regresar i,
.boton-descargar i {
  font-size: 20px;
  line-height: 1;
}

.btn-portal {
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.btn-portal::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn-portal:hover::after {
  left: 100%;
}

.btn-portal:hover {
  transform: scale(1.08);
}

.categoria {
  transition: border-color 0.3s ease;
}

.categoria:hover {
  border-color: rgba(26, 74, 138, 0.15) !important;
}

/* =============================================
   COMPONENTES COMUNES - FORMULARIOS / SELECTS
   ============================================= */

.select-ano {
  border: 1px solid #CBD5E0;
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  padding: 12px 18px;
  width: 100%;
}

.select-ano option {
  color: var(--text);
  background: #fff;
}

.select-ano:hover {
  border-color: var(--secondary);
}

.select-ano:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(26, 74, 138, 0.1);
}

.selector-ano-wrapper {
  min-width: 200px;
  position: relative;
}

/* Caret del select con FontAwesome (sin SVG) */
.selector-ano-wrapper::after {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  content: "\f078";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #64748B;
  font-size: 14px;
  line-height: 1;
}

/* =============================================
   SECCIONES / CATEGORÍAS
   ============================================= */

.categoria-box {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border-color: rgba(26, 74, 138, 0.08);
}

.categoria-titulo {
  color: var(--primary);
  font-size: 14px;
  letter-spacing: 2px;
}

.accent-line {
  width: 36px;
  height: 3px;
  background: var(--accent);
  border-radius: 3px;
}

/* Título de página tipo «estadística» (audiencias/indicadores) */
.pagina-reportes {
  background: #fff;
}

.pagina-reportes h1 {
  color: var(--primary);
  font-size: 22px;
  letter-spacing: -0.5px;
}

.principal .contenedor-secciones {
  width: 100%;
}

.principal .seccion {
  width: 100%;
}

.seccion {
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
  border: 1px solid #E2E8F0;
}

.icono-seccion {
  color: var(--secondary);
  background: linear-gradient(135deg, #e8f0fe 0%, #d4e4fc 100%);
  min-width: 45px;
  text-align: center;
  font-size: 26px;
}

.encabezado-seccion h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.titulo-tabla {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
}

.contenedor-tabla {
  overflow-x: auto;
}

.contenedor-tabla:last-child {
  margin-bottom: 0;
}

/* =============================================
   TABLAS (genéricas de la parte pública)
   ============================================= */

.tabla-estadisticas {
  min-width: 1000px;
}
.tabla-estadisticas th {
  background: var(--secondary);
  color: #ffffff;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  vertical-align: middle;
  position: sticky;
  top: 0;
  z-index: 2;
}
.tabla-estadisticas td {
  border: 1px solid #E2E8F0;
  font-size: 12px;
  font-weight: 300;
  font-family: var(--font-clasico);
  text-align: center;
  vertical-align: middle;
}
.tabla-estadisticas th:first-child,
.tabla-estadisticas td:first-child {
  width: 350px;
  min-width: 350px;
  max-width: 350px;
  text-align: left;
}
.tabla-estadisticas td a.enlace-detalle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 5px 4px;
  min-width: 40px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #e8f0fe 0%, #d4e4fc 100%);
  border-radius: 8px;
  border: 1px solid #1A4A8A;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.tabla-estadisticas td a.enlace-detalle:hover {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  color: white;
  border-color: var(--primary);
}
.tabla-estadisticas tr.fila-pie td {
  background: var(--secondary);
  color: #ffffff;
  font-weight: 700;
  text-align: center;
  border-color: rgba(255, 255, 255, 0.15);
}
.tabla-estadisticas tr.fila-pie td:first-child {
  text-align: center;
}
.tabla-estadisticas tr:nth-child(even) td {
  background-color: #F1F7FF;
}
.tabla-estadisticas tbody tr:hover td {
  background-color: #e8f0fe;
}

/* Tabla detalle */
.tabla-detalle th,
.tabla-detalle td {
  text-align: center;
  vertical-align: middle;
}
.tabla-detalle {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}
.tabla-detalle.tabla-estadisticas { min-width: 100%; cursor: default; }
.tabla-detalle.tabla-estadisticas th:first-child,
.tabla-detalle.tabla-estadisticas td:first-child { width: 40px; min-width: 40px; max-width: 40px; text-align: center; }
.tabla-detalle.tabla-estadisticas th { font-size: 12px; padding: 6px 5px; line-height: 1.1; }
.tabla-detalle.tabla-estadisticas td { font-size: 12px; font-weight: 300; font-family: var(--font-clasico); padding: 4px 5px; line-height: 1.4; }
.tabla-detalle.tabla-estadisticas .col-detalle-juzgado { text-align: left; }
.tabla-detalle .col-detalle-expediente { width: 170px; }
.tabla-detalle .col-detalle-fecha { width: 90px; }
.tabla-detalle .col-detalle-estado { width: 90px; }
.tabla-detalle .col-detalle-mes { width: 45px; }
.tabla-detalle .col-detalle-fin-semana { width: 90px; }
.tabla-detalle .col-detalle-fuera-horario { width: 105px; }

/* Tabla resumen */
.tabla-resumen th {
  position: sticky;
  top: 0;
}
.tabla-resumen td:first-child {
  color: var(--especialista);
}
.tabla-resumen tbody tr:last-child td {
  border-bottom: none;
}

/* Gráficos */
.contenedor-grafico canvas {
  width: 100% !important;
  height: 350px !important;
}

/* =============================================
   MODAL (título genérico)
   ============================================= */

.modal-titulo-container {
  display: block;
  text-align: left;
  line-height: 1;
}
.modal-titulo-container .modal-titulo-principal {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 18px;
  color: var(--primary);
  display: block;
}
.modal-titulo-container .modal-subtitulo {
  font-weight: 400;
  font-size: 14px;
  color: #64748b;
  display: block;
  padding-top: 6px;
}
.modal-titulo-container .modal-total {
  font-weight: 400;
  font-size: 13px;
  color: var(--secondary);
  display: block;
  padding-top: 4px;
}

/* Tablas dentro de modales: reutilizan el look de audiencias
   (.tabla-estadisticas) pero sin sus anchos fijos, para columnas dinámicas. */
.modal .tabla-estadisticas {
  min-width: 0;
  table-layout: auto;
}
.modal .tabla-estadisticas th:first-child,
.modal .tabla-estadisticas td:first-child {
  width: auto;
  min-width: 0;
  max-width: none;
  text-align: center;
}

/* =============================================
   NOTIFICACIÓN
   ============================================= */

.notificacion {
  position: fixed;
  top: 20px;
  right: 20px;
  transform: translateY(-80px);
  z-index: 999;
  transition: transform 0.3s;
}

.notificacion.mostrar {
  transform: translateY(0);
}

/* =============================================
   ANIMACIONES
   ============================================= */

@keyframes shimmer {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
  100% { filter: brightness(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* =============================================
   PRELOADER ÚNICO
   ============================================= */

.precargador {
  background: rgba(255, 255, 255, 0.85);
  z-index: 9999;
}

.logo-precargador {
  width: 80px;
  height: 80px;
  animation: pulse 1.5s infinite;
}

.spinner-precargador {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top: 4px solid var(--secondary);
  animation: spin 1s linear infinite;
}

/* =============================================
   LOGOS COMPARTIDOS
   ============================================= */

.logo-img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

/* =============================================
   REPORTES / TV — LAYOUT COMPARTIDO
   (usado por reportes de gráficos y tv/reportes)
   ============================================= */

.reportes-page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.25rem;
}

.reportes-logo {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  margin-bottom: 0.25rem;
}

.reportes-logo-img {
  height: 70px;
}

.reportes-titulo {
  font-size: 2.35rem;
  letter-spacing: 0.02em;
  line-height: 1;
}

.categoria-bloque {
  margin-bottom: 0.25rem;
}

.categoria-bloque:last-child {
  margin-bottom: 0;
}

.categoria-mitad {
  flex: 1;
  min-width: 0;
}

.minh-0 {
  min-height: 0;
}

.alerta-flotante {
  z-index: 9999;
  min-width: 320px;
}

/* =============================================
   UTILIDADES
   ============================================= */

.text-muted {
  color: var(--text-muted) !important;
}

/* Fondo degradado anclado al viewport (reutilizable) */
.fondo-degradado-fijo {
  min-height: 100vh;
  background: linear-gradient(135deg, #000, #6b1d5e, #c84b31);
  background-attachment: fixed;
}

/* =============================================
   RESPONSIVE (genérico)
   ============================================= */

@media (max-width: 1300px) {
  .tabla-estadisticas {
    font-size: 12px;
    min-width: 1000px;
  }
  .contenedor-grafico canvas {
    height: 250px !important;
  }
}

@media (max-width: 480px) {
  .encabezado-seccion {
    flex-direction: column;
    text-align: center;
  }
  .icono-seccion {
    font-size: 28px;
  }
  .tabla-estadisticas {
    font-size: 11px;
    min-width: 900px;
  }
  .contenedor-grafico canvas {
    height: 200px !important;
  }
}

/* =============================================
   PORTADAS
   ============================================= */

.pagina-index {
  color: #1e293b;
}

.pagina-index .contenedor-wrap {
  max-width: 800px;
}

.pagina-index h1 {
  color: var(--primary);
  font-size: 28px;
  letter-spacing: -1px;
}

.pagina-index .desc-texto {
  font-size: 14px;
  line-height: 1.1;
}

.pagina-index .btn-portal {
  font-size: 17px;
}

.pagina-index .btn-portal:hover {
  transform: scale(1.05);
}

.pagina-index .btn-portal i {
  font-size: 28px;
}

@media (max-width: 576px) {
  .pagina-index .btn-portal {
    font-size: 15px !important;
  }
  .pagina-index .btn-portal i {
    font-size: 24px;
  }
}
