/* ============================================================
   BRANDTROPIC SYSTEM — paneles de datos

   Las piezas que pintan información: fila de métricas, gráfica de barras,
   lista de filas, tablero por columnas, hilo del asistente, línea de etapas
   del proyecto, y el par esqueleto/estado vacío para los módulos que
   todavía no tienen de dónde sacar datos.
   ============================================================ */

/* ---------- Fila de métricas ----------
   La cifra manda: grande, tabular, con la etiqueta debajo en pequeño. Es el
   único sitio del panel con tipografía de este tamaño, a propósito. */
.bjs-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3);
}

.bjs-stat {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--sp-4) var(--sp-5) var(--sp-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--bt-line);
  background: var(--bt-s1);
  box-shadow: var(--sh-panel);
  overflow: hidden;
}

.bjs-stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.bjs-stat-top .bjs-icon { color: var(--bt-tx-3); }

.bjs-stat-num {
  display: block;
  font-size: var(--fs-2xl);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--bt-tx-1);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.bjs-stat-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.3;
  color: var(--bt-tx-2);
}

/* ---------- Gráfica de barras ---------- */
.bjs-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.375rem;
  height: 108px;
}

.bjs-bars span {
  flex: 1;
  height: var(--h, 40%);
  min-height: 3px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--bt-accent), rgba(127, 194, 74, 0.3));
  transform-origin: bottom;
  animation: bjs-grow 900ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

@keyframes bjs-grow {
  from { transform: scaleY(0.15); opacity: 0; }
  to   { transform: scaleY(1); opacity: 1; }
}

/* ---------- Lista de filas ---------- */
.bjs-rows { list-style: none; display: grid; }

.bjs-rows li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-4);
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--bt-line);
  font-size: var(--fs-sm);
}

.bjs-rows li:first-child { padding-top: 0; }
.bjs-rows li:last-child { border-bottom: none; padding-bottom: 0; }
.bjs-rows li > :first-child { color: var(--bt-tx-1); min-width: 0; overflow-wrap: anywhere; }
.bjs-rows li > :last-child { color: var(--bt-tx-2); white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }

/* ---------- Tablero por columnas (esqueletos) ---------- */
.bjs-cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); }

.bjs-col {
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--bt-line);
  background: var(--bt-s2);
}

.bjs-col p { margin-bottom: 0.3125rem; font-size: var(--fs-xs); font-weight: 700; color: var(--bt-tx-1); }
.bjs-col span { display: block; font-size: var(--fs-xs); line-height: 1.45; color: var(--bt-tx-2); }

/* ---------- Hilo del asistente ---------- */
.bjs-chat { display: grid; gap: var(--sp-2); }
.bjs-chat p { font-size: var(--fs-sm); line-height: 1.45; }

.bjs-chat-user {
  justify-self: end;
  max-width: 78%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: 12px 12px 4px 12px;
  background: var(--bt-grad);
  color: var(--bt-on-accent);
}

.bjs-chat-bot {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  max-width: 84%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: 12px 12px 12px 4px;
  border: 1px solid var(--bt-line-2);
  color: var(--bt-tx-1);
}

.bjs-chat-bot .bjs-icon { flex: none; margin-top: 2px; color: var(--bt-accent); }

/* ============================================================
   Esqueleto y estado vacío

   Se enseña la forma real del módulo en gris y encima se dice, sin rodeos,
   que todavía no hay datos. La alternativa —números de ejemplo— convierte
   el panel en una demo y hace dudar de las cifras que sí son ciertas.
   ============================================================ */
.bjs-skeleton-wrap { position: relative; }

.bjs-skeleton-wrap > .bjs-stack { opacity: 0.45; filter: saturate(0.2); pointer-events: none; }

.bjs-bone {
  display: block;
  height: 0.5rem;
  border-radius: var(--radius-pill);
  background:
    linear-gradient(90deg, transparent, rgba(232, 240, 220, 0.12), transparent) 0 0 / 220% 100%,
    var(--bt-s3);
  animation: bjs-shimmer 1800ms linear infinite;
}

.bjs-bone.num { height: 1.5rem; width: 46%; margin-bottom: var(--sp-3); }
.bjs-bone.label { height: 0.5rem; width: 78%; }
.bjs-bone.row { height: 0.625rem; }

@keyframes bjs-shimmer {
  from { background-position: 180% 0, 0 0; }
  to   { background-position: -80% 0, 0 0; }
}

.bjs-bars.is-skeleton span {
  animation: none;
  background: var(--bt-s3);
}

.bjs-empty {
  display: grid;
  justify-items: start;
  gap: var(--sp-2);
  max-width: 48ch;
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 1.75rem);
  border-radius: var(--r-xl);
  background: var(--bt-s2);
  border: 1px solid var(--bt-line-2);
  box-shadow: var(--sh-float);
}

/* Flotando sobre el esqueleto en pantallas con sitio; en móvil se pone
   arriba y en el flujo, que superponer en 360px de ancho es ilegible. */
@media (min-width: 720px) {
  .bjs-skeleton-wrap .bjs-empty {
    position: absolute;
    inset-inline: 0;
    top: 50%;
    transform: translateY(-50%);
  }
}

@media (max-width: 719px) {
  .bjs-skeleton-wrap { display: flex; flex-direction: column-reverse; gap: var(--sp-4); }
}

.bjs-empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--sp-1);
  border-radius: var(--r-md);
  background: var(--bt-accent-soft);
  color: var(--bt-accent);
}

.bjs-empty h2 { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.015em; color: var(--bt-tx-1); }
.bjs-empty p { font-size: var(--fs-sm); color: var(--bt-tx-2); }
.bjs-empty .bjs-btn, .bjs-empty .crm-btn { margin-top: var(--sp-2); }

/* Estado vacío dentro de un panel: una línea, sin caja propia. */
.bjs-none { font-size: var(--fs-sm); color: var(--bt-tx-3); }

/* ============================================================
   Portal: línea de avance del proyecto

   La barra se dibuja con ::before sobre cada paso, no con un elemento
   aparte: el ancho lo reparte la rejilla y no hay que recalcular nada
   cuando cambie el número de etapas.
   ============================================================ */
.bj-stages {
  list-style: none;
  margin: 0 0 var(--sp-6);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  counter-reset: bj-stage;
}

.bj-stage { position: relative; text-align: center; padding-top: 1.75rem; }

.bj-stage::before {
  content: "";
  position: absolute;
  top: 0.4375rem;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--bt-line-2);
}

.bj-stage:first-child::before { display: none; }
.bj-stage.is-done::before, .bj-stage.is-current::before { background: var(--bt-grad); }

.bj-stage-dot {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--bt-s2);
  border: 2px solid var(--bt-line-2);
}

.bj-stage.is-done .bj-stage-dot { background: var(--bt-green); border-color: var(--bt-green); }

.bj-stage.is-current .bj-stage-dot {
  background: var(--bt-bg);
  border-color: var(--bt-accent);
  box-shadow: 0 0 0 5px var(--bt-accent-soft);
}

.bj-stage-label {
  display: block;
  padding-inline: var(--sp-1);
  font-size: var(--fs-sm);
  line-height: 1.3;
  color: var(--bt-tx-3);
}

.bj-stage.is-done .bj-stage-label { color: var(--bt-tx-2); }
.bj-stage.is-current .bj-stage-label { color: var(--bt-tx-1); font-weight: 600; }

.bj-wa {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--bt-accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

@media (hover: hover) and (pointer: fine) {
  .bj-wa:hover { color: var(--bt-lime); }
}

/* ---------- Adaptación ---------- */
@media (max-width: 1100px) {
  .bjs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 899px) {
  .bjs-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 559px) {
  .bjs-stats { gap: var(--sp-2); }
  .bjs-stat { padding: var(--sp-3) var(--sp-4); }
  .bjs-stat-num { font-size: 1.75rem; }
  .bjs-cols { grid-template-columns: minmax(0, 1fr); }
  .bjs-bars { height: 76px; }
  .bjs-bars span:nth-child(n + 9) { display: none; }

  /* Cinco etiquetas en fila no caben en 360px sin partir palabras. */
  .bj-stages { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
  .bj-stage { text-align: left; padding: 0 0 0 1.875rem; }
  .bj-stage::before { top: auto; bottom: 50%; right: auto; left: 0.4375rem; width: 2px; height: 100%; }
  .bj-stage-dot { top: 0.125rem; left: 0; transform: none; }
  .bj-stage-label { padding-inline: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bjs-bars span { animation: none; }
  .bjs-bone { animation: none; }
}
