/* =====================================================================
   ESTUDIO ANIMADO WEB — estilo.css
   Tema oscuro del contrato: fondo #0f1115, paneles #171a21,
   ámbar #ffb454 (acciones que GASTAN), violeta #b58cff (animado).
   Móvil primero: el equipo usa el teléfono.
   ===================================================================== */

:root {
  --fondo: #0f1115;
  --panel: #171a21;
  --panel2: #1d212b;
  --borde: #262b36;
  --texto: #e8e8e8;
  --suave: #9aa3b2;
  --ambar: #ffb454;
  --violeta: #b58cff;
  --error: #ff6b6b;
  --bien: #6bd68b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--fondo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.oculto { display: none !important; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; margin-bottom: .7rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; }
.suave { color: var(--suave); }
.pequeno { font-size: .85rem; }
.centrado { text-align: center; margin-top: .4rem; }
.texto-error { color: var(--error); font-size: .92rem; }

/* ---------------- Cabecera ---------------- */

header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  padding: .55rem .8rem;
  background: rgba(15, 17, 21, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--borde);
}
.marca { font-weight: 700; white-space: nowrap; }
.chip-saldo {
  font-size: .78rem;
  color: var(--ambar);
  background: rgba(255, 180, 84, .1);
  border: 1px solid rgba(255, 180, 84, .35);
  border-radius: 999px;
  padding: .12rem .6rem;
  white-space: nowrap;
}
/* Interruptor "estoy trabajando": apagado gris, encendido VERDE vivo.
   Mientras esté verde, la fábrica Ivana deja Grok libre para el equipo. */
.btn-trabajando {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  min-height: 36px;                 /* tamaño táctil para el móvil */
  padding: .3rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--borde);
  background: var(--panel2);
  color: var(--suave);
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, box-shadow .2s;
}
.btn-trabajando:hover:not(:disabled) { filter: brightness(1.1); }
.btn-trabajando:disabled { opacity: .55; cursor: wait; }
.btn-trabajando.encendido {
  background: var(--bien);
  border-color: var(--bien);
  color: #0b2413;
  box-shadow: 0 0 0 1px var(--bien), 0 0 14px rgba(107, 214, 139, .55);
}
#menu { display: flex; gap: .25rem; margin-left: auto; }
#menu button {
  background: none;
  border: 1px solid transparent;
  color: var(--suave);
  padding: .35rem .6rem;
  border-radius: 999px;
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
  white-space: nowrap;
}
#menu button.activo {
  color: var(--texto);
  background: var(--panel2);
  border-color: var(--borde);
}
#btn-salir {
  background: none;
  border: 1px solid var(--borde);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--suave);
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .marca span { display: none; }
}

/* ---------------- Estructura ---------------- */

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem .8rem calc(4rem + env(safe-area-inset-bottom));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.panel-centrado {
  max-width: 420px;
  margin: 10vh auto 0;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  text-align: center;
}
.panel-centrado label { text-align: left; font-weight: 600; margin-bottom: -.4rem; }

.fila-titulo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .7rem;
}
.fila-titulo h2 { margin-bottom: 0; }
.fila-estado {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: .3rem;
}

/* ---------------- Formularios ---------------- */

input, select, textarea {
  width: 100%;
  background: var(--fondo);
  color: var(--texto);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: .65rem .8rem;
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--violeta);
  outline-offset: 1px;
  border-color: var(--violeta);
}
label { user-select: none; }
.campo { margin-bottom: .95rem; }
.campo > label {
  display: block;
  font-weight: 600;
  margin-bottom: .35rem;
  font-size: .95rem;
}

/* ---------------- Botones ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: none;
  border-radius: 12px;
  padding: .65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--texto);
  background: var(--panel2);
  transition: filter .15s, transform .05s;
  text-decoration: none;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* ÁMBAR = acciones que gastan créditos KIE */
.btn-ambar { background: var(--ambar); color: #241a05; }
/* VIOLETA = animado / acciones gratis */
.btn-violeta { background: var(--violeta); color: #1d1030; }
.btn-fantasma { background: transparent; border: 1px solid var(--borde); color: var(--texto); }
.btn-grande { width: 100%; padding: .85rem 1rem; font-size: 1.05rem; }
.btn-gigante {
  width: 100%;
  padding: 1.1rem 1rem;
  font-size: 1.1rem;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(181, 140, 255, .25);
}
.btn-chico { padding: .4rem .6rem; font-size: .85rem; flex: 1; }

.fila-botones { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-opcion {
  flex: 1;
  background: var(--fondo);
  border: 1px solid var(--borde);
  color: var(--suave);
  border-radius: 10px;
  padding: .6rem .4rem;
  font: inherit;
  font-size: .92rem;
  cursor: pointer;
}
.btn-opcion.activo {
  border-color: var(--violeta);
  color: var(--texto);
  background: rgba(181, 140, 255, .12);
}

/* Contador de planos */
.paso { display: flex; align-items: center; gap: 1.1rem; }
.btn-paso {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--borde);
  background: var(--panel2);
  color: var(--texto);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
#num-planos {
  font-size: 1.5rem;
  font-weight: 700;
  min-width: 2ch;
  text-align: center;
}

/* ---------------- Chips de personajes ---------------- */

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-personaje {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .28rem .75rem .28rem .3rem;
  background: var(--fondo);
  border: 1px solid var(--borde);
  border-radius: 999px;
  color: var(--texto);
  font: inherit;
  font-size: .92rem;
  cursor: pointer;
}
.chip-personaje img,
.chip-personaje .chip-cara {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chip-personaje.activo {
  border-color: var(--ambar);
  background: rgba(255, 180, 84, .12);
  box-shadow: 0 0 0 1px var(--ambar);
}

/* ---------------- Tarjetas de sinopsis ---------------- */

#tarjetas { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  #tarjetas { grid-template-columns: repeat(2, 1fr); }
}
.tarjeta {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.tarjeta h3 { color: var(--violeta); }
.logline { font-style: italic; color: var(--suave); }
.detalles {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  font-size: .9rem;
}
.pastilla {
  display: inline-block;
  background: var(--panel2);
  border: 1px solid var(--borde);
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .8rem;
  margin: .1rem 0;
}
.tarjeta .btn { margin-top: auto; }

/* ---------------- Rejilla de planos ---------------- */

.rejilla { display: grid; gap: .8rem; }
.rejilla-v { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.rejilla-h { grid-template-columns: 1fr; }
@media (min-width: 560px) {
  .rejilla-v { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .rejilla-h { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

.plano {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.marco { position: relative; width: 100%; background: #0a0c10; }
.rejilla-v .marco { aspect-ratio: 9 / 16; }
.rejilla-h .marco { aspect-ratio: 16 / 9; }
.marco img { width: 100%; height: 100%; object-fit: cover; display: block; }
.marco-espera {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  color: var(--suave);
  font-size: .9rem;
  text-align: center;
  padding: .5rem;
}
.marco-fallo { color: var(--error); }
.chip-clip {
  position: absolute;
  left: .4rem;
  bottom: .4rem;
  background: rgba(10, 12, 16, .85);
  border-radius: 999px;
  padding: .18rem .6rem;
  font-size: .78rem;
  backdrop-filter: blur(2px);
}
.chip-listo { color: var(--bien); }
.chip-animando { color: var(--violeta); }
.chip-revision { color: var(--ambar); }
.chip-fallo { color: var(--error); }
.chip-pendiente { color: var(--suave); }

.plano-info {
  padding: .6rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  flex: 1;
}
.plano-info .fila-botones { margin-top: auto; }
.dialogos { font-size: .85rem; white-space: pre-line; }
.nota { font-size: .8rem; color: var(--ambar); }

/* ---------------- Insignias de estado ---------------- */

.insignia {
  display: inline-block;
  padding: .18rem .7rem;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--borde);
  font-size: .85rem;
  white-space: nowrap;
}
.insignia-lista { color: var(--bien); border-color: rgba(107, 214, 139, .4); }
.insignia-error { color: var(--error); border-color: rgba(255, 107, 107, .4); }
.insignia-animando,
.insignia-montaje,
.insignia-guion { color: var(--violeta); border-color: rgba(181, 140, 255, .4); }
.insignia-fotos,
.insignia-revision_fotos,
.insignia-revision { color: var(--ambar); border-color: rgba(255, 180, 84, .4); }

/* ---------------- Barra de progreso ---------------- */

.progreso { margin-top: .7rem; }
.progreso-barra {
  height: 8px;
  border-radius: 999px;
  background: var(--fondo);
  border: 1px solid var(--borde);
  overflow: hidden;
  margin-bottom: .3rem;
}
.progreso-relleno {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--violeta), var(--ambar));
  transition: width .6s ease;
}

/* ---------------- Zona de animar y video final ---------------- */

#zona-animar { margin-bottom: 1rem; }
#zona-video { text-align: center; }
#video-final {
  width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  background: #000;
  margin: .6rem 0;
}
#btn-volver-lista { margin-bottom: .8rem; }

/* ---------------- Lista de producciones ---------------- */

#lista-producciones { display: flex; flex-direction: column; gap: .6rem; }
.fila-prod {
  display: flex;
  align-items: center;
  gap: .8rem;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: .6rem;
  color: var(--texto);
  font: inherit;
  cursor: pointer;
}
.fila-prod:hover { border-color: var(--violeta); }
.mini {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: #0a0c10;
  flex-shrink: 0;
}
.mini-vacia {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}
.fila-prod-info {
  display: flex;
  flex-direction: column;
  gap: .18rem;
  min-width: 0;
  align-items: flex-start;
}
.fila-prod-info h4 {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flecha { margin-left: auto; color: var(--suave); font-size: 1.5rem; flex-shrink: 0; }

/* ---------------- Modales, telón y avisos ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 6, 9, .72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-caja {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  margin-bottom: 0;
}
.modal .fila-botones { justify-content: flex-end; }
.aviso-gasto {
  background: rgba(255, 180, 84, .1);
  border: 1px solid rgba(255, 180, 84, .4);
  color: var(--ambar);
  border-radius: 10px;
  padding: .5rem .7rem;
  font-size: .88rem;
}

.telon-caja {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  padding: 1.5rem;
}
#telon-texto { white-space: pre-line; max-width: 320px; }

.ruedita {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--borde);
  border-top-color: var(--violeta);
  animation: girar 1s linear infinite;
}
.ruedita.grande { width: 48px; height: 48px; border-width: 4px; }
@keyframes girar { to { transform: rotate(360deg); } }

.aviso {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: min(92vw, 480px);
  padding: .7rem 1rem;
  border-radius: 12px;
  font-size: .95rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
.aviso-error { background: #3a1520; border: 1px solid var(--error); color: #ffd7d7; }
.aviso-bien { background: #12301c; border: 1px solid var(--bien); color: #d3f5de; }

/* ---------------- Panel de gastos ---------------- */

/* Aviso ROJO de presupuesto (en CREAR y en la pantalla de gastos) */
.aviso-presupuesto {
  background: #3a1520;
  border: 1px solid var(--error);
  color: #ffd7d7;
  border-radius: 12px;
  padding: .7rem .9rem;
  margin-bottom: 1rem;
  font-size: .95rem;
}
/* Variante ámbar: 80 % del presupuesto consumido */
.aviso-presupuesto-80 {
  background: rgba(255, 180, 84, .1);
  border-color: rgba(255, 180, 84, .5);
  color: var(--ambar);
}

.gastos-tarjetas {
  display: grid;
  gap: .8rem;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 1rem;
}
@media (min-width: 700px) {
  .gastos-tarjetas { grid-template-columns: repeat(4, 1fr); }
}
.tarjeta-gasto {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 14px;
  padding: .9rem .6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  text-align: center;
}
.tarjeta-gasto .tg-titulo { font-weight: 600; font-size: .9rem; }
.tarjeta-gasto .cifra { font-size: 1.55rem; font-weight: 700; line-height: 1.2; }
.tarjeta-gasto .dinero { color: var(--ambar); font-weight: 600; font-size: .95rem; }

/* Barra de presupuesto: verde <80 %, ámbar 80–99 %, rojo ≥100 % */
.presu-verde { background: var(--bien); }
.presu-ambar { background: var(--ambar); }
.presu-rojo { background: var(--error); }

/* Top de producciones del mes */
.fila-top {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--borde);
  font-size: .88rem;
}
.fila-top:last-child { border-bottom: none; }
.fila-top-nombre {
  flex: 1 1 40%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fila-top-barra {
  flex: 1 1 30%;
  height: 8px;
  border-radius: 999px;
  background: var(--fondo);
  border: 1px solid var(--borde);
  overflow: hidden;
}
.fila-top-barra > div { height: 100%; background: var(--violeta); }
.fila-top-n { color: var(--suave); white-space: nowrap; font-size: .8rem; }

/* Tabla de últimos gastos */
.tabla-scroll { overflow-x: auto; }
.tabla-gastos { width: 100%; border-collapse: collapse; font-size: .85rem; }
.tabla-gastos th, .tabla-gastos td {
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--borde);
  text-align: left;
  white-space: nowrap;
}
.tabla-gastos td:last-child { white-space: normal; min-width: 180px; }
.tabla-gastos th { color: var(--suave); font-weight: 600; }

/* ---------------- Series (miniseries y novelas) ---------------- */

/* Espera de la biblia (ruedita + texto) */
.serie-espera {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .7rem;
  color: var(--suave);
  font-size: .95rem;
}
.insignia-biblia { color: var(--violeta); border-color: rgba(181, 140, 255, .4); }

/* Tarjetas de ideas de serie (clicables) */
#ideas-serie { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  #ideas-serie { grid-template-columns: repeat(2, 1fr); }
}
.tarjeta-idea { cursor: pointer; transition: border-color .15s; }
.tarjeta-idea:hover { border-color: var(--violeta); }
.tarjeta-idea.elegida {
  border-color: var(--ambar);
  box-shadow: 0 0 0 1px var(--ambar);
}

/* Filas de episodio en la vista de una serie */
.fila-ep {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: .7rem .8rem;
  margin-bottom: .6rem;
}
.fila-ep.ep-siguiente {
  border-color: var(--ambar);
  box-shadow: 0 0 0 1px var(--ambar);
}
.ep-num {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--panel2);
  border: 1px solid var(--borde);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.ep-cuerpo {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.ep-cuerpo h4 .insignia { margin-left: .3rem; font-weight: 400; }
.ep-gancho { color: var(--ambar); font-size: .85rem; }
.ep-acciones {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  align-items: stretch;
  flex-shrink: 0;
  min-width: 130px;
}
.ep-acciones .btn { flex: none; }
@media (max-width: 560px) {
  .fila-ep { flex-wrap: wrap; }
  .ep-acciones { flex-direction: row; width: 100%; min-width: 0; }
  .ep-acciones .btn { flex: 1; }
}

/* Video del maratón */
.centrado-panel { text-align: center; }
.video-maraton {
  width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  background: #000;
  margin: .6rem 0;
}
#zona-maraton-btn { margin-bottom: 1rem; }
#btn-serie-volver { margin-bottom: .8rem; }
#btn-serie-ideas { margin-top: .55rem; }

/* ---------------- Añadir personaje ---------------- */

#btn-anadir-personaje { margin-top: .55rem; flex: none; }
.personaje-preview {
  width: 130px;
  height: 130px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--borde);
  align-self: center;
  background: var(--fondo);
}
