/* Paleta de la interfaz (el cartelón tiene sus propios colores en poster.css / SVG) */
:root {
  --primary: #1F8296;        /* teal principal */
  --primary-dark: #186876;   /* hover */
  --primary-deep: #0F2F35;   /* teal muy oscuro */
  --ink-dark: #0D1F24;       /* fondo oscuro / overlays */
  --primary-light: #CFEAF0;
  --primary-soft: #E6F5F7;   /* fondos teal claro */
  --secondary: #843993;      /* morado */
  --accent: #B92970;         /* magenta */
  --accent-dark: #932158;
  --accent-soft: #FDEAF2;    /* rosa claro */
  --amber: #F59E0B;          /* acento puntual */
  --text: #1D1E1C;
  --text-dim: #6E6B69;
  --bg: #F5F5F4;
  --white: #FFFFFF;
  --line: #E1E0DE;           /* borde neutro derivado del fondo */
  --radius: 14px;
}

* { box-sizing: border-box; }

/* Los display:flex/grid de abajo anularían el atributo hidden sin esta regla. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  min-height: 100vh;
}

button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--primary-dark); outline-offset: 2px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px; display: grid; place-items: center; font-size: 24px;
  border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: var(--white);
}
.brand h1 { font-size: 20px; margin: 0; color: var(--primary-deep); }
.brand-sub { margin: 0; font-size: 12.5px; color: var(--text-dim); }
.topbar-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.date-picker { display: flex; flex-direction: column; gap: 4px; }
.date-picker label, .field label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.date-picker input {
  background: var(--white); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 9px; color-scheme: light;
}
.date-picker input:hover { border-color: var(--primary); }
.mode-toggle { display: flex; background: var(--primary-soft); border: 1px solid var(--primary-light); border-radius: 10px; padding: 4px; gap: 4px; }
.mode-btn { border: none; background: transparent; color: var(--primary-dark); padding: 8px 16px; border-radius: 7px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.mode-btn:hover:not(.active) { background: var(--primary-light); }
.mode-btn.active { background: var(--primary); color: var(--white); }

/* Layout */
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr) 320px; gap: 22px; padding: 26px 28px; align-items: start; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; position: sticky; top: 92px; box-shadow: 0 1px 2px rgba(13, 31, 36, 0.04); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.panel-head h2 { font-size: 14px; margin: 0; color: var(--primary-deep); }
.panel-hint { font-size: 12.5px; color: var(--text-dim); margin: 2px 0 12px; line-height: 1.45; }
.chip { font-size: 11px; font-weight: 700; background: var(--primary-soft); border: 1px solid var(--primary-light); padding: 3px 9px; border-radius: 20px; color: var(--primary-dark); }

/* Filtros y lista */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filter { border: 1px solid var(--line); background: var(--white); color: var(--text-dim); padding: 5px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; cursor: pointer; }
.filter:hover { border-color: var(--primary); color: var(--primary-dark); }
.filter.active { background: var(--primary-deep); color: var(--white); border-color: var(--primary-deep); }

.events-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 62vh; overflow-y: auto; }
.event-item {
  border: 1px solid var(--line); background: var(--white); border-radius: 11px; padding: 10px 12px;
  cursor: pointer; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start;
}
.event-item:hover { border-color: var(--primary); }
.event-item.used { border-color: var(--primary); background: var(--primary-soft); }
.event-item.picked { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.event-item input { margin-top: 3px; accent-color: var(--accent); }
.event-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.event-year { font-size: 12px; font-weight: 800; color: var(--primary-dark); }
.badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; background: var(--bg); color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.badge.warn { background: #FDE9C3; color: var(--text); box-shadow: inset 0 0 0 1px var(--amber); }
.event-text { grid-column: 2; font-size: 12.5px; line-height: 1.4; margin: 0; }
.events-list.readonly .event-item { cursor: default; }

/* Stage */
.stage { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stage-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.status-pill { font-size: 12.5px; font-weight: 600; background: var(--white); border: 1px solid var(--line); padding: 7px 13px; border-radius: 20px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 8px; }
.status-pill.working { color: var(--primary-dark); border-color: var(--primary-light); background: var(--primary-soft); }
.status-pill.working::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse 1s infinite; }
.status-pill.error { color: var(--accent-dark); border-color: var(--accent); background: var(--accent-soft); }
@keyframes pulse { 50% { opacity: 0.3; } }

.preview { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: var(--ink-dark); box-shadow: 0 14px 40px rgba(13, 31, 36, 0.22); }
.scaler { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; transform-origin: top left; }
.preview-loader { position: absolute; inset: 0; background: rgba(13, 31, 36, 0.78); backdrop-filter: blur(4px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 3; }
.preview-loader p { margin: 0; font-size: 14px; color: var(--white); }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.2); border-top-color: var(--amber); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meta { margin: 0; font-size: 12px; color: var(--text-dim); }

/* Botones */
.btn { border: 1px solid var(--line); background: var(--white); color: var(--text); padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 13.5px; font-weight: 600; transition: transform 0.12s, background 0.12s, border-color 0.12s; }
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--primary-dark); border-color: var(--primary); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Panel de edición */
.auto-note p { font-size: 13px; line-height: 1.55; color: var(--text-dim); background: var(--primary-soft); border: 1px solid var(--primary-light); border-left: 3px solid var(--secondary); padding: 12px 14px; border-radius: 10px; margin: 6px 0 0; }
.auto-note em { color: var(--primary-deep); font-style: normal; font-weight: 600; }
.manual-controls { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input, .field textarea, .field select { background: var(--white); border: 1px solid var(--line); color: var(--text); padding: 9px 10px; border-radius: 9px; font-size: 13px; resize: vertical; width: 100%; }
.field input:hover, .field textarea:hover, .field select:hover { border-color: var(--primary); }
.item-group { border: 1px solid var(--line); border-radius: 11px; padding: 12px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; background: var(--bg); }
.item-group h3 { margin: 0; font-size: 12px; color: var(--secondary); }
.color-grid { display: flex; flex-direction: column; gap: 8px; }
.color-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.color-row label { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
.color-row input[type="color"] { width: 44px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--white); cursor: pointer; }
.color-row input[type="range"] { width: 140px; padding: 0; accent-color: var(--primary); }
.typo-grid { display: flex; flex-direction: column; gap: 12px; }
.typo-row { display: flex; flex-direction: column; gap: 4px; }
.typo-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.typo-head label { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
.typo-value { font-size: 12px; color: var(--primary-dark); font-weight: 600; font-variant-numeric: tabular-nums; }
.typo-row input[type="range"] { width: 100%; padding: 0; accent-color: var(--primary); }
.typo-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.typo-check input { accent-color: var(--primary); width: auto; }
.btn-small { padding: 6px 12px; font-size: 12.5px; align-self: flex-start; }
.color-block { display: flex; flex-direction: column; gap: 6px; }
.palette { display: flex; flex-wrap: wrap; gap: 5px; }
.palette-chip { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; padding: 0; transition: transform 0.12s; }
.palette-chip:hover { transform: scale(1.18); }
.palette-chip.active { box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--primary-deep); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--white); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--primary-deep); }

.footer { text-align: center; padding: 18px; color: var(--text-dim); font-size: 12px; border-top: 1px solid var(--line); background: var(--white); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .events-list { max-height: 280px; }
}

/* Agente IA */
.date-row { display: flex; gap: 8px; align-items: stretch; }
.agent-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 0 16px 0 13px;
  border: 1.5px solid transparent; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font-size: 13px; font-weight: 700; letter-spacing: 0.2px; color: var(--primary-deep);
  /* relleno claro + borde degradado teal > morado > magenta */
  background: linear-gradient(var(--white), var(--white)) padding-box,
              linear-gradient(135deg, var(--primary), var(--secondary) 55%, var(--accent)) border-box;
  box-shadow: 0 3px 10px rgba(132, 57, 147, 0.18);
  transition: transform 0.15s, box-shadow 0.25s;
}
.agent-btn::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 0; opacity: 0.1; transition: opacity 0.2s;
  background: linear-gradient(135deg, var(--primary), var(--secondary) 55%, var(--accent));
}
.agent-btn > * { position: relative; z-index: 1; }
.agent-icon { color: var(--secondary); }
.agent-icon .spark-2 { fill: var(--amber); }
.agent-btn:hover { transform: translateY(-1px); box-shadow: 0 0 0 4px rgba(132, 57, 147, 0.14), 0 6px 16px rgba(132, 57, 147, 0.28); }
.agent-btn:hover::before { opacity: 0.2; }
.agent-btn:active { transform: translateY(0); }
@media (prefers-reduced-motion: no-preference) {
  .agent-icon { animation: agent-twinkle 2.8s ease-in-out infinite; transform-origin: center; }
}
@keyframes agent-twinkle { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.14) rotate(10deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.agent-dialog { width: min(560px, 92vw); background: var(--white); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 24px 60px rgba(13, 31, 36, 0.35); }
.agent-dialog::backdrop { background: rgba(13, 31, 36, 0.62); backdrop-filter: blur(3px); }
.agent-head { display: flex; justify-content: space-between; align-items: center; }
.agent-head h2 { margin: 0; font-size: 17px; color: var(--primary-deep); }
.agent-close { background: transparent; border: none; color: var(--text-dim); font-size: 26px; line-height: 1; cursor: pointer; }
.agent-close:hover { color: var(--accent); }
.agent-hint { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; margin: 8px 0 12px; }
#agentInput { width: 100%; background: var(--white); border: 1px solid var(--line); color: var(--text); padding: 10px; border-radius: 9px; font-size: 14px; resize: vertical; margin-bottom: 10px; }
#agentInput:hover, #agentInput:focus { border-color: var(--primary); }
.agent-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.agent-examples button { background: var(--primary-soft); border: 1px solid var(--primary-light); color: var(--primary-dark); font-size: 12px; padding: 5px 10px; border-radius: 16px; cursor: pointer; }
.agent-examples button:hover { background: var(--primary-light); border-color: var(--primary); }
.agent-steps { margin: 14px 0 0; padding-left: 20px; font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 5px; }
.agent-steps li.error { color: var(--accent-dark); }
.agent-steps:empty { display: none; }
.pick-actions { display: flex; gap: 8px; margin-top: 10px; }
.pick-actions .btn { flex: 1; padding: 9px 10px; }
.pick-actions[hidden] { display: none; }
