/* Pantalla «Qué arreglar» (analitica.js): las cifras del periodo, las columnas por día y la lista para revisar. */

/* Un color por resultado, el mismo en las cifras, las columnas, la leyenda y la lista. Validados para daltonismo en
   claro y en oscuro; el amarillo de «Abandonadas» en claro no llega a 3:1 con el fondo: lo acompañan su nombre, la
   leyenda y la tabla. */
body.espacio {
  --an-resolved: #0ca30c;
  --an-handedOff: #2a78d6;
  --an-abandoned: #eda100;
  --an-failed: #d03b3b;
}
html[data-theme="dark"] body.espacio {
  --an-handedOff: #3987e5;
  --an-abandoned: #c98500;
}
.is-resolved { --an-color: var(--an-resolved); }
.is-handedOff { --an-color: var(--an-handedOff); }
.is-abandoned { --an-color: var(--an-abandoned); }
.is-failed { --an-color: var(--an-failed); }

[data-shown="analytics"] > main.wide { max-width: 72rem; }

.an-filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin: 1rem 0; }
.an-filters label { display: flex; flex-direction: column; gap: 0.25rem; min-width: 10rem; }
.an-filters select { max-width: 100%; }

.an-swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 3px; background: var(--an-color); flex: none; }

/* ---------- Cifras ---------- */
.an-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.an-tile { padding: 0.75rem 0.9rem; border: 1px solid var(--borde); border-radius: 10px; background: var(--superficie); }
.an-tile p { margin: 0; }
.an-tile-label { display: flex; align-items: center; gap: 0.4rem; color: var(--texto-suave); font-size: 0.9em; }
.an-tile-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--texto); }
.an-tile-detail { color: var(--texto-suave); font-size: 0.85em; }

/* ---------- Columnas por día ---------- */
.an-chart { margin-bottom: 1.5rem; }
.an-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-bottom: 0.6rem; font-size: 0.9em; color: var(--texto-suave); }
.an-legend > span { display: inline-flex; align-items: center; gap: 0.35rem; }
.an-plot-wrap { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem; height: 12rem; }
.an-axis { display: flex; flex-direction: column; justify-content: space-between; text-align: right; font-size: 0.8em;
  color: var(--texto-suave); font-variant-numeric: tabular-nums; transform: translateY(-0.5em); }
.an-axis > span:last-child { transform: translateY(0.5em); }
/* Las líneas guía (arriba, al medio y la base) van de fondo; la base, un poco más marcada. */
.an-plot {
  position: relative; display: flex; align-items: flex-end; gap: 2px; min-width: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--texto) 35%, transparent);
  background: linear-gradient(to bottom, var(--borde) 1px, transparent 1px) top / 100% 50% repeat-y;
}
/* Cada día ocupa toda la altura: el puntero lo encuentra aunque tenga pocas conversaciones. */
.an-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.an-col:hover { background: var(--encima); }
.an-stack { width: 100%; display: flex; flex-direction: column-reverse; gap: 2px; min-height: 0; }
.an-seg { background: var(--an-color); min-height: 2px; }
/* Solo el extremo de arriba de la columna va redondeado; la base queda pegada al eje. */
.an-stack > .an-seg:last-child { border-radius: 4px 4px 0 0; }
.an-tooltip {
  position: absolute; top: 0.25rem; transform: translateX(-50%); z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; gap: 0.15rem; min-width: 9rem; padding: 0.5rem 0.65rem; border-radius: 8px;
  background: var(--superficie); color: var(--texto); border: 1px solid var(--borde); box-shadow: 0 6px 20px -8px #0006;
  font-size: 0.85em; white-space: nowrap;
}
.an-tooltip[hidden] { display: none; }
.an-tip-row { display: inline-flex; align-items: center; gap: 0.35rem; }
.an-dates { display: flex; justify-content: space-between; margin-left: 2.5rem; font-size: 0.8em; color: var(--texto-suave); }
.an-table { margin-top: 0.6rem; }
.an-table table { font-size: 0.9em; font-variant-numeric: tabular-nums; }
.an-table th, .an-table td { padding: 0.2rem 0.6rem; text-align: right; }
.an-table th:first-child, .an-table td:first-child { text-align: left; }
.an-empty { padding: 2rem 0; }

/* ---------- Para revisar ---------- */
.an-list { display: flex; flex-direction: column; border-top: 1px solid var(--borde); }
.an-row {
  display: grid; grid-template-columns: 8.5rem minmax(8rem, 1fr) minmax(10rem, 1.2fr); gap: 0.2rem 0.75rem;
  align-items: baseline; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--borde);
}
.an-chip { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9em; }
.an-contact { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-meta { color: var(--texto-suave); font-size: 0.9em; text-align: right; }
.an-reason, .an-quote, .an-exec { grid-column: 2 / -1; overflow-wrap: anywhere; }
.an-reason.is-error { color: oklch(0.52 0.19 25); }
html[data-theme="dark"] .an-reason.is-error { color: oklch(0.75 0.15 25); }
.an-quote { color: var(--texto-suave); font-style: italic; }
.an-exec { justify-self: start; }
#an-more { margin-top: 0.75rem; }

.an-misses { padding-left: 1.2rem; }
.an-misses li { margin: 0.3rem 0; }

@media (max-width: 720px) {
  .an-filters label { min-width: calc(50% - 0.5rem); flex: 1; }
  /* Una columna: el resultado, el cliente, el bot y la fecha, y el motivo, uno debajo del otro. */
  .an-row { grid-template-columns: minmax(0, 1fr); }
  .an-row > * { grid-column: 1; }
  .an-meta { text-align: left; }
  .an-plot-wrap { height: 9rem; }
}
