/* ==========================================================================
   Gestión de Cobranzas — pestaña "Gráficos Analíticos"
   Barra de acciones (igual que la del Tablero) con "Cambiar filtros", el mes de corte y los filtros de la Lista que se
   usan, la moneda, el contador de cobros y los botones Excel / PDF; debajo, tres gráficos: barras (meta vs. real) y dona
   arriba, tendencia a todo lo ancho abajo. Cada gráfico tiene altura fija para que ECharts siempre mida un lienzo real,
   y el diseño se adapta al ancho del panel sin cortar ni desbordar.
   ========================================================================== */
/* La pestaña toma su altura natural (no se encoge para caber en la pantalla): la página hace scroll y ningún gráfico se
   sale de su tarjeta. */
#cobranzasPaneGraficos.cobranzas-pane.active,
#cobranzasPaneGraficos .facturas-tab-panel.active { flex: 0 0 auto; }

/* El contenedor no pinta nada: la barra y cada gráfico son sus propias tarjetas. */
.cobranzas-body .facturas-results-card.cobranzas-graficos-card,
.cobranzas-graficos-card {
  background: transparent;
  border: 0;
  box-shadow: none;
  flex: 0 0 auto;
  margin-bottom: 18px;
  container-name: graficos;
  container-type: inline-size;
  gap: 8px;
  height: auto;
  overflow: visible;
  padding: 0;
}

.grf-encabezado {
  align-items: center;
  background: #fff;
  border: 1px solid #dfe8f4;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(16, 42, 86, 0.06);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
}

/* Pastillas, iguales a los contadores de las demás pestañas. */
.grf-periodo,
.grf-moneda,
.grf-hasta,
.grf-filtros,
.grf-contador {
  align-items: center;
  background: #f4f8ff;
  border: 1px solid #d3e4fb;
  border-radius: 999px;
  box-sizing: border-box;
  color: #3f5872;
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  height: 31px;
  padding: 0 12px;
  white-space: nowrap;
}

.grf-periodo i,
.grf-moneda i { color: #256ee8; }

.grf-periodo select,
.grf-moneda select {
  appearance: auto;
  background: transparent;
  border: 0;
  color: #0f172a;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  min-width: 0;
  outline: 0;
  padding: 2px;
}

.grf-periodo select:focus-visible,
.grf-moneda select:focus-visible {
  border-radius: 6px;
  box-shadow: 0 0 0 3px rgba(47, 125, 242, 0.25);
}

.grf-moneda select:disabled { cursor: default; opacity: 1; }

.grf-hasta i { color: #27ae60; }
.grf-hasta strong { color: #1d5fc4; font-weight: 800; }
.grf-filtros i { color: #256ee8; }

.grf-separador {
  background: #cbd5e1;
  height: 18px;
  width: 1px;
}

.grf-contador { margin-left: auto; }
.grf-contador i { color: #256ee8; }
.grf-contador strong { color: #1d5fc4; font-size: 13px; font-weight: 800; }

.grf-acciones {
  display: flex;
  gap: 8px;
}

.grf-acciones .facturas-btn:disabled { cursor: not-allowed; opacity: .5; }

.grf-estado {
  align-items: center;
  background: #fff;
  border: 1px solid #dfe8f4;
  border-radius: 16px;
  color: #475569;
  display: flex;
  font-size: 14px;
  gap: 10px;
  justify-content: center;
  min-height: 220px;
  text-align: center;
}

.grf-estado.error { color: #b42318; }

/* ----- Cuerpo: barras (60 %) y dona (40 %) arriba; tendencia abajo a todo lo ancho ----- */
.grf-cuerpo {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  transition: opacity .15s ease;
}

.grf-cuerpo.actualizando { opacity: .55; pointer-events: none; }

/* Cada gráfico en una tarjeta como las del Tablero: franja de color, tinte suave e ícono. */
.grf-panel {
  --grf-acento: #1e6fd0;
  --grf-acento-claro: #56a8f5;
  --grf-tinte: #eef5fe;
  background: linear-gradient(180deg, var(--grf-tinte) 0, #fff 78px);
  border: 1px solid #dfe8f4;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(16, 42, 86, 0.04), 0 14px 28px -18px rgba(16, 42, 86, 0.28);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 16px 18px 12px;
  position: relative;
  transition: box-shadow .2s ease;
}

.grf-panel::before {
  background: linear-gradient(90deg, var(--grf-acento), var(--grf-acento-claro));
  content: "";
  height: 4px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.grf-panel:hover { box-shadow: 0 1px 2px rgba(16, 42, 86, 0.05), 0 22px 38px -18px rgba(16, 42, 86, 0.36); }

.grf-panel-dona { --grf-acento: #6d28d9; --grf-acento-claro: #a276ff; --grf-tinte: #f4eefe; }
.grf-panel-tendencia { --grf-acento: #e08600; --grf-acento-claro: #ffc04d; --grf-tinte: #fff6e5; grid-column: 1 / -1; }

.grf-panel h3 {
  align-items: center;
  color: #12294a;
  display: flex;
  font-size: 15.5px;
  font-weight: 800;
  gap: 11px;
  line-height: 1.25;
  margin: 0;
}

.grf-panel h3::before {
  align-items: center;
  background: linear-gradient(145deg, var(--grf-acento-claro), var(--grf-acento));
  border-radius: 11px;
  box-shadow: 0 9px 16px -8px var(--grf-acento);
  color: #fff;
  content: "\f080";
  display: inline-flex;
  flex: 0 0 34px;
  font-family: "Font Awesome 6 Free";
  font-size: 15px;
  font-weight: 900;
  height: 34px;
  justify-content: center;
}

.grf-panel-dona h3::before { content: "\f200"; }
.grf-panel-tendencia h3::before { content: "\f201"; }

.grf-subtitulo {
  color: #6e8199;
  font-size: 12px;
  line-height: 1.4;
  margin: 3px 0 8px 45px;
}

.grf-lienzo {
  height: 320px;
  min-width: 0;
  position: relative;
  width: 100%;
}

.grf-panel-dona .grf-lienzo { height: 340px; }

.grf-vacio {
  align-items: center;
  background: #f8fafd;
  border: 1px dashed #d5e0ee;
  border-radius: 14px;
  box-sizing: border-box;
  color: #6e8199;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  gap: 10px;
  height: 100%;
  justify-content: center;
  padding: 0 16px;
  text-align: center;
}

.grf-vacio i { color: #9fb1c8; font-size: 34px; }

/* Panel angosto (menú abierto, pantallas pequeñas): un gráfico por fila. */
@container graficos (max-width: 820px) {
  .grf-cuerpo { grid-template-columns: minmax(0, 1fr); }
  .grf-contador { margin-left: 0; }
  .grf-lienzo,
  .grf-panel-dona .grf-lienzo { height: 300px; }
}

@media (max-width: 759px) {
  .grf-cuerpo { grid-template-columns: minmax(0, 1fr); }
  .grf-contador { margin-left: 0; }
  .grf-subtitulo { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .grf-panel, .grf-cuerpo { transition: none; }
}
