/* Estilos generales */
body {
  margin: 0;
  font-family: "Poppins", sans-serif;
  background-color: #eef1f7;
  color: #333;
  overflow: hidden; /* Quita esta línea si quieres scroll en todo el body */
}

/* Encabezado */
header {
  display: flex;
  align-items: center;
  background: #ffffff;
  color: #333;
  padding: 15px 30px;
  border-bottom: 3px solid #ccc;
}

header img {
  height: 50px;
}

/* Marquesina (tipo bolsa de valores) en el header */
.header-ticker {
  flex: 1;
  margin-left: 24px;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0; /* permite que el flex item se encoja */
}

.header-ticker__track {
  display: inline-flex;
  align-items: center;
  gap: 48px;
  will-change: transform;
  animation: ibi-ticker 55s linear infinite;
}

.header-ticker__text {
  font-size: 14px;
  color: #2a3b4e;
}

.header-ticker__sep {
  color: #7a8a9a;
  font-size: 14px;
}

.header-ticker:hover .header-ticker__track {
  animation-play-state: paused;
}

@keyframes ibi-ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .header-ticker__track {
    animation: none;
    transform: none;
  }
}

/* Contenedor principal */
main {
  display: flex;
  flex: 1;
  height: calc(100vh - 70px);
}

/* Barra lateral de filtros */
aside#filters {
  width: 16%;
  background: #2a3b4e;
  color: #fff;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto; /* Scroll en la barra lateral */
  border-radius: 10px 0 0 10px;
}

.filtro {
  margin-bottom: 20px;
}

.filtro label {
  display: block;
  font-size: 16px;
  margin: 8px 0 3px;
}

.filtro select {
  width: 100%;
  font-size: 16px;
  padding: 8px;
  box-sizing: border-box;
}

/* Ajustes para multiselección */
.filtro select[multiple] {
  height: auto;
  min-height: 40px;
  background: #fff;
  color: #333;
  border-radius: 5px;
  padding: 5px;
  overflow-y: auto;
}

/* Sección principal de reportes */
section#reports {
  flex: 1;
  padding: 20px;
  box-sizing: border-box;
  width: 84%;
  overflow-y: auto; /* Scroll en la sección principal */
}

/* Botón Imprimir Reporte */
#print-report-btn.print-button {
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  background-color: #28a745; /* verde */
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
}

#print-report-btn.print-button:hover {
  background-color: #218838;
}

/* Contenedor de reportes */
.report-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  margin-bottom: 30px;
}

/* Cada tarjeta de reporte */
.report {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  padding: 20px;
  transition: transform 0.2s ease-in-out;
  margin-bottom: 30px;
  overflow: visible;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.report:hover {
  transform: translateY(-5px);
}

.report h3 {
  margin-bottom: 15px;
  color: #2a3b4e;
  font-size: 18px;
  font-weight: bold;
}

/* Ajuste para reportes en una fila (2 reportes en la misma fila) */
.report-row:has(.report:nth-child(2)) .report {
  width: 50%;
}

/* Ajuste para reportes de una sola columna en la fila */
.report-row:has(.report:only-child) .report {
  width: 100%;
}

/* Espaciado entre gráficos y tablas dentro de .report */
.report div {
  margin-bottom: 20px;
}

/* Estilos para tablas en reportes */
table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  margin-top: 20px;
}

th, td {
  padding: 12px;
  border: 1px solid #ddd;
  text-align: center;
}

th {
  background-color: #2a3b4e;
  color: white;
  font-weight: bold;
  text-transform: uppercase;
}

tr:nth-child(even) {
  background-color: #eef1f7;
}

/* Ajustes para contenedor de gráficos Plotly */
.report div.plotly-graph {
  width: 100%;
  height: auto;
  min-height: 400px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  padding: 10px;
  position: relative;
}

/* Leyenda de Plotly con scroll y tipografía unificada */
.js-plotly-plot .legend {
  width: 20% !important;    /* Para no sobrepasar el 30% */
  max-height: 300px;        /* Ajusta según necesites */
  overflow-y: auto;         /* Scroll vertical si excede altura */
  pointer-events: auto;     /* Permite interactuar con la leyenda */
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  color: #333;
}

/* Reglas de impresión: mostrar solo el área de reportes */
@media print {
  body {
    background: #fff !important;
    overflow: visible !important;
  }
  /* Ocultar encabezado, filtros, JSON y widget de Gloria */
  header, aside#filters, #json-container, script, link,
  #_gloria-chat-script,
  .gloria-launcher, /* botón flotante */
  .gloria-widget,   /* contenedor del chat abierto */
  [src*="iamgloria.com"],
  iframe[src*="iamgloria.com"] {
    display: none !important;
  }
  @page {
    size: A4 portrait;
    margin: 12mm; /* márgenes de página */
  }
  main {
    display: block;
    height: auto;
  }
  section#reports {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }
  .report {
    box-shadow: none !important;
    page-break-inside: avoid;
  }
  .report-row {
    display: block !important;
  }
  /* Tablas a ancho completo y control de desbordes */
  table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    page-break-inside: auto;
  }
  th, td {
    word-wrap: break-word;
    white-space: normal;
    overflow: hidden;
  }
  /* Quitar sombras para impresión limpia */
  .report, .report div.plotly-graph, table {
    box-shadow: none !important;
  }
}
