/* creative.css — kit de interfaz de Creative Stack (componentes.js y graficos.js).
   Reusa tokens y clases del molde (styles.css): .chip, .vacio, .grafico-*, .btn-*. Prefijo cr- para lo nuevo. */

:root {
  --azul: #7dd3fc;
  --violeta: #c4b5fd;
  --ambar: #fcd34d;
}

select, input, textarea { font-family: inherit; }

/* ---------- tonos (texto / acento de componentes) ---------- */
.cr-t-acc { --tono: var(--acc-soft); }
.cr-t-verde { --tono: var(--verde); }
.cr-t-azul { --tono: var(--azul); }
.cr-t-violeta { --tono: var(--violeta); }
.cr-t-ambar { --tono: var(--ambar); }
.cr-t-rojo { --tono: var(--rojo); }
.cr-t-gris { --tono: var(--muted); }

/* ---------- cabecera de pantalla ---------- */
.cr-cab { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 6px 0 14px; }
.cr-cab h1 { font-size: 1.25rem; margin: 0 0 4px; font-weight: 600; letter-spacing: -.35px; }
.cr-cab p { color: var(--muted); font-size: .8125rem; margin: 0; }
.cr-cab-acc { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; }
.cr-cab > * { min-width: 0; max-width: 100%; }

/* ---------- cargando / vacío / error ---------- */
.cr-cargando { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 46px 20px; color: var(--muted); font-size: .8438rem; }
.cr-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--acc); animation: cr-gira .8s linear infinite; }
@keyframes cr-gira { to { transform: rotate(360deg); } }
.cr-vacio-ic { color: var(--muted2); margin-bottom: 8px; display: flex; justify-content: center; }
.cr-vacio-tt { margin: 0 0 4px; color: var(--text); font-weight: 600; }
.cr-vacio-tx { margin: 0; }
.cr-error .cr-vacio-ic { color: var(--rojo); }

/* ---------- tarjeta y KPI ---------- */
.cr-tarjeta { border: 1px solid var(--border); border-radius: 13px; background: var(--panel2); padding: 16px; min-width: 0; }
.cr-tarjeta-tt { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: .6875rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted2); font-weight: 700; }
.cr-tarjeta-tt svg { color: var(--acc-soft); flex: 0 0 auto; }
.cr-tarjeta-pie { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border-soft); font-size: .75rem; color: var(--muted); }

.cr-kpi { border: 1px solid var(--border); border-radius: 13px; background: var(--panel2); padding: 15px 16px; min-width: 0; }
.cr-kpi-et { font-size: .6875rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.cr-kpi-v { font-size: 1.5rem; font-weight: 700; letter-spacing: -.4px; color: var(--tono, var(--acc-soft)); line-height: 1.15; }
.cr-kpi-sub { font-size: .7188rem; color: var(--muted2); margin-top: 6px; }

/* ---------- chips de estado del pedido (CONTRATO §1.5) ---------- */
.chip.est-aprobado { background: #14331f; color: var(--verde); border-color: #86efac4d; }
.chip.est-pedido { background: #14232e; color: var(--azul); border-color: #7dd3fc4d; }
.chip.est-entregado { background: #221c33; color: var(--violeta); border-color: #c4b5fd4d; }
.chip.est-tomado, .chip.est-en_proceso { background: #2c2410; color: var(--ambar); border-color: #fcd34d4d; }
.chip.est-cambios { background: #331414; color: var(--rojo); border-color: #f871714d; }
.chip.est-borrador, .chip.est-cancelado, .chip.est-desconocido { background: #232328; color: var(--muted); border-color: #9a9aa24d; }

/* ---------- chip de tipo de recurso ---------- */
.chip.cr-tipo { background: #1c1c21; color: var(--acc-soft); border-color: var(--acc-borde); }

/* ---------- gráficos ---------- */
.cr-grafico-titulo { font-size: .6875rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted2); font-weight: 700; margin-bottom: 10px; }
.cr-grafico-vacio { text-align: center; color: var(--muted); font-size: .8438rem; }
.cr-grafico-vacio p { margin: 0; padding: 18px 0; }
.cr-sparkline { width: 100%; max-width: 160px; height: 32px; display: block; }

.cr-barra-cuota { min-width: 0; }
.cr-barra-pista { display: flex; height: 14px; border-radius: 8px; overflow: hidden; background: #26262c; }
.cr-barra-vacia .cr-barra-pista { background: repeating-linear-gradient(45deg, #26262c, #26262c 6px, #202025 6px, #202025 12px); }
.cr-seg { display: block; height: 100%; min-width: 2px; }
.cr-seg-acc { background: var(--acc); }
.cr-seg-verde { background: var(--verde); }
.cr-seg-azul { background: var(--azul); }
.cr-seg-violeta { background: var(--violeta); }
.cr-seg-ambar { background: var(--ambar); }
.cr-seg-rojo { background: var(--rojo); }
.cr-seg-gris { background: #4b4b54; }
.cr-barra-leyenda { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .75rem; color: var(--muted); }
.cr-barra-leyenda strong { color: var(--text); font-variant-numeric: tabular-nums; }
.cr-punto { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: baseline; }
.cr-barra-nota { margin: 8px 0 0; font-size: .75rem; color: var(--muted2); }
.cr-exceso .cr-barra-nota { color: var(--verde); }

@media (max-width: 720px) {
  .cr-kpi-v { font-size: 1.25rem; }
  .cr-barra-leyenda { gap: 6px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .cr-spinner { animation: none; }
}

/* === previa (compartido) === */
.cr-previa {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0c0c0e;
  cursor: pointer;
  transition: border-color .15s var(--ease);
}

.cr-previa__poster,
.cr-previa__video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.cr-previa__poster {
  z-index: 0;
  transition: opacity .15s var(--ease);
}

.cr-previa__video {
  z-index: 0;
}

.cr-previa__fondo {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted2);
  background: linear-gradient(145deg, #16161a 0%, #0c0c0e 100%);
}

.cr-previa__fondo svg {
  display: block;
  width: 34px;
  height: 34px;
}

.cr-previa__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid var(--acc-borde);
  border-radius: 50%;
  background: rgba(12, 12, 14, .72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: var(--acc-soft);
  cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease), opacity .15s var(--ease);
}

.cr-previa__play:hover {
  background: var(--acc-fondo);
  color: var(--acc);
}

.cr-previa__play:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

.cr-previa__play:disabled {
  opacity: .4;
  cursor: default;
}

.cr-previa__play:disabled:hover {
  background: rgba(12, 12, 14, .72);
  color: var(--acc-soft);
}

.cr-previa__i-play,
.cr-previa__i-pausa {
  line-height: 0;
}

.cr-previa__i-play {
  display: inline-flex;
}

.cr-previa__i-pausa {
  display: none;
}

.cr-previa__i-play svg,
.cr-previa__i-pausa svg {
  display: block;
  width: 18px;
  height: 18px;
}

.cr-previa__play[aria-pressed="true"] .cr-previa__i-play {
  display: none;
}

.cr-previa__play[aria-pressed="true"] .cr-previa__i-pausa {
  display: inline-flex;
}

.cr-previa--a916:not(.cr-previa--grande) .cr-previa__poster,
.cr-previa--a916:not(.cr-previa--grande) .cr-previa__video {
  object-fit: contain;
}

.cr-previa--grande {
  width: 100%;
  max-width: 100%;
  max-height: 70vh;
  aspect-ratio: 16 / 9;
  height: auto;
}

.cr-previa--grande.cr-previa--a169 {
  aspect-ratio: 16 / 9;
}

.cr-previa--grande.cr-previa--a916 {
  width: min(100%, calc(70vh * 9 / 16));
  aspect-ratio: 9 / 16;
}

.cr-previa--grande.cr-previa--a11 {
  width: min(100%, 70vh);
  aspect-ratio: 1 / 1;
}

.cr-previa--sonando .cr-previa__poster {
  opacity: 0;
}

.cr-previa--sonando .cr-previa__video {
  opacity: 1;
}

.cr-previa--video.cr-previa--sonando .cr-previa__play {
  opacity: .35;
}

.cr-previa--video.cr-previa--sonando:hover .cr-previa__play,
.cr-previa--video.cr-previa--sonando .cr-previa__play:hover,
.cr-previa--video.cr-previa--sonando .cr-previa__play:focus-visible {
  opacity: 1;
}

.cr-previa--audio.cr-previa--sonando .cr-previa__play {
  opacity: 1;
  border-color: var(--acc);
}

.cr-previa--vacia {
  cursor: default;
}

.cr-previa--vacia .cr-previa__play {
  opacity: .4;
  cursor: default;
}

.cr-previa__nada {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  z-index: 1;
  text-align: center;
  font-size: .6875rem;
  color: var(--muted2);
  pointer-events: none;
  overflow-wrap: anywhere;
}

.cr-entrega {
  display: block;
  width: 100%;
  min-width: 0;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #000;
}

/* Caja del video entregado: el botón de play propio flota encima (sin controles nativos, que rompen WebKit). */
.cr-entrega-caja {
  position: relative;
  width: 100%;
  min-width: 0;
  cursor: pointer;
}

.cr-entrega-caja.cr-previa--sonando .cr-previa__play {
  opacity: .35;
}

.cr-entrega-caja.cr-previa--sonando:hover .cr-previa__play,
.cr-entrega-caja.cr-previa--sonando .cr-previa__play:focus-visible {
  opacity: 1;
}

.cr-entrega--vacia {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--panel2);
  font-size: .8125rem;
}

@media (prefers-reduced-motion: reduce) {
  .cr-previa,
  .cr-previa *,
  .cr-entrega {
    transition: none;
    animation: none;
  }
}
/* === fin previa === */
