/* ============================================================
   CRIATech · Centro de Noticias — Panel Profesional
   ============================================================ */

/* ---------- Reset y base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #0b1220;
  color: #e6edf3;
  -webkit-font-smoothing: antialiased;
}

:root {
  --surface-0: #0b1220;
  --surface-1: #0f172a;
  --surface-2: #151e33;
  --border: #1f2a40;
  --text: #eaf0f8;
  --muted: #7a8fa8;
  --accent: #00d4aa;
  --accent-2: #7dd3fc;
  --danger: #f87171;
  --ok: #22c55e;
  --warn: #facc15;
  --err: #ef4444;
  --topbar-h: 52px;
}

a { color: var(--accent-2); text-decoration: none; }

/* ---------- Layout principal ---------- */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11,18,32,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
}

.topbar-inner {
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .1px;
  color: var(--text);
}

.brand .badge {
  color: var(--accent);
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.statusbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Pulse dot ---------- */
.pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.pulse.on  { background: var(--ok);  animation: pulseAnim 1.6s infinite; }
.pulse.run { background: var(--warn); animation: pulseAnim 1.1s infinite; }
.pulse.err { background: var(--err); }

@keyframes pulseAnim {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
  70%  { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ---------- Main: 3 columnas ---------- */
.main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 20px 24px;
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .main { grid-template-columns: 1fr; }
}

/* ---------- Sidebars ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar.right {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #243049 transparent;
  padding-right: 2px;
}

/* ---------- Panel ---------- */
.panel {
  background: linear-gradient(160deg, #111c30 0%, #0f1729 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.panel h3 {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel h3::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 10px;
  background: var(--accent);
  border-radius: 2px;
}

/* ---------- Form fields ---------- */
.field { margin-bottom: 14px; }

.field > label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.field input,
.field select {
  width: 100%;
  background: var(--surface-0);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}

.field input:focus,
.field select:focus { border-color: var(--accent-2); }

.toggle-row { display: flex; gap: 8px; flex-wrap: wrap; }

.status-pill {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--surface-0);
  color: var(--muted);
}
.status-pill.ok { border-color: rgba(34,197,94,.3); color: var(--ok); }

.actions { margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(160deg, #00d4aa 0%, #00a884 100%);
  color: #052e24;
  border-color: #00a884;
}

/* ---------- Stage ---------- */
.stage {
  background: linear-gradient(180deg, #0d1826 0%, #0b1220 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- Office scene ---------- */
.office {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 7;
  background: linear-gradient(180deg, #0e1c32 0%, #0b1523 60%, #0d1a2e 100%);
  overflow: hidden;
}

/* Subtle grid overlay */
.office::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(100,160,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100,160,255,.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

/* Window decoration */
.decor { position: absolute; }
.window {
  top: 8%; left: 8%;
  width: 20%; aspect-ratio: 0.75;
  background: linear-gradient(160deg, #0d2040 0%, #1a3a6a 100%);
  border: 2px solid #1f3050;
  border-radius: 8px;
  overflow: hidden;
}
.glass {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(120,180,255,.08) 0%, rgba(255,255,255,0) 60%);
}

/* Window city lights */
.window::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 35%;
  background:
    radial-gradient(3px 3px at 20% 70%, rgba(255,220,80,.6) 0%, transparent 100%),
    radial-gradient(2px 2px at 45% 85%, rgba(100,180,255,.5) 0%, transparent 100%),
    radial-gradient(3px 3px at 65% 75%, rgba(255,180,60,.5) 0%, transparent 100%),
    radial-gradient(2px 2px at 80% 65%, rgba(150,220,255,.4) 0%, transparent 100%),
    linear-gradient(180deg, transparent 0%, rgba(10,20,40,.8) 100%);
}

/* Desk */
.desk {
  position: absolute;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 50%; height: 52%;
  background: linear-gradient(180deg, #2a1a0a 0%, #1e1208 100%);
  border-top: 2px solid #3a2010;
  border-left: 2px solid #3a2010;
  border-right: 2px solid #3a2010;
  border-radius: 10px 10px 0 0;
}

/* Monitor on desk */
.monitor {
  position: absolute;
  top: -50%; left: 50%; transform: translateX(-50%);
  width: 55%; height: 80%;
  background: #080e1a;
  border: 2px solid #1a2840;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(0,180,255,.08), inset 0 0 10px rgba(0,0,0,.5);
}

.screen {
  position: absolute; inset: 5%;
  background: #030a10;
  border-radius: 5px;
  padding: 8px 10px;
  color: #22c55e;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  line-height: 1.4;
  overflow: hidden;
}

.scanline {
  position: absolute; left: 0; right: 0; height: 1px;
  background: rgba(34,197,94,.2);
  animation: scan 3.5s linear infinite;
  pointer-events: none;
}

@keyframes scan {
  0%   { top: 0; }
  100% { top: 100%; }
}

.prompt { position: relative; z-index: 1; white-space: pre-wrap; }

/* ---------- Pipeline bar (agentes FUERA del office) ---------- */
.pipeline {
  padding: 14px 20px 16px;
  background: linear-gradient(180deg, #0b1523 0%, #0d1829 100%);
  border-top: 1px solid var(--border);
}

.agents {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0;
}

.agent {
  flex: 1;
  text-align: center;
  min-width: 0;
  position: relative;
}

/* Flow arrow between agents */
.pipe-arrow {
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  font-size: 20px;
  color: var(--border);
  transition: color .3s;
  line-height: 1;
  margin-top: -6px;
}

/* Agent sphere */
.agent .sprite {
  width: 40px;
  height: 40px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(125,211,252,.4), #0f172a);
  border: 2px solid rgba(125,211,252,.4);
  box-shadow: 0 0 12px rgba(14,165,233,.15), inset 0 0 10px rgba(0,0,0,.4);
  transition: border-color .3s, box-shadow .3s, transform .2s;
}

/* Agent-specific colors */
.agent.scout   .sprite { border-color: rgba(125,211,252,.5); background: radial-gradient(circle at 35% 35%, rgba(125,211,252,.3), #0a1020); }
.agent.ciso    .sprite { border-color: rgba(192,132,252,.5); background: radial-gradient(circle at 35% 35%, rgba(192,132,252,.3), #0a1020); }
.agent.editor  .sprite { border-color: rgba(251,191,36,.5);  background: radial-gradient(circle at 35% 35%, rgba(251,191,36,.3), #0a1020); }
.agent.qa      .sprite { border-color: rgba(34,197,94,.5);   background: radial-gradient(circle at 35% 35%, rgba(34,197,94,.3), #0a1020); }
.agent.distributor .sprite { border-color: rgba(0,212,170,.5); background: radial-gradient(circle at 35% 35%, rgba(0,212,170,.3), #0a1020); }

/* Active state (set by JS) */
.agent.active .sprite {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(14,165,233,.5), inset 0 0 12px rgba(14,165,233,.1);
}
.agent.active.scout    .sprite { border-color: #7dd3fc; box-shadow: 0 0 20px rgba(125,211,252,.5); }
.agent.active.ciso     .sprite { border-color: #c084fc; box-shadow: 0 0 20px rgba(192,132,252,.5); }
.agent.active.editor   .sprite { border-color: #fbbf24; box-shadow: 0 0 20px rgba(251,191,36,.5); }
.agent.active.qa       .sprite { border-color: #22c55e; box-shadow: 0 0 20px rgba(34,197,94,.5); }
.agent.active.distributor .sprite { border-color: #00d4aa; box-shadow: 0 0 20px rgba(0,212,170,.5); }

.agent.active + .pipe-arrow { color: var(--accent); }

/* Blink animation */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
.sprite.blink { animation: blink 2.4s ease-in-out infinite; }
.agent.active .sprite.blink { animation: none; }

/* Agent label */
.agent .name {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .3px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent.active .name { color: var(--text); }

/* Progress bar */
.bar {
  margin: 0 auto;
  width: 80%;
  height: 3px;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ok), var(--accent-2));
  border-radius: 999px;
  transition: width .4s ease;
}

/* ---------- Right sidebar items ---------- */
.runs, .reports, .files-list {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #243049 transparent;
  padding-right: 2px;
}

.empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px 0;
  text-align: center;
}

/* .item — rendered by app.js (was missing CSS entirely) */
.item {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(15,23,42,.6);
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text);
  transition: border-color .15s;
}
.item:hover { border-color: rgba(100,160,255,.25); }
.item:last-child { margin-bottom: 0; }

.item .meta {
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
  line-height: 1.4;
  word-break: break-all;
}

.item .actions {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}

.item .actions button {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.item .actions button:hover { filter: brightness(1.2); }

/* Run status badge inline */
.item .status-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.item .status-badge.success { background: rgba(34,197,94,.12); color: var(--ok); border: 1px solid rgba(34,197,94,.25); }
.item .status-badge.error   { background: rgba(239,68,68,.12); color: var(--err); border: 1px solid rgba(239,68,68,.25); }
.item .status-badge.running { background: rgba(250,204,21,.12); color: var(--warn); border: 1px solid rgba(250,204,21,.25); }

/* ---------- Unused/legacy (kept for compat) ---------- */
.canvas-wrap { display: none; }
.run-item, .report-item { display: none; }
.wall, .floor, .stand, .keyboard, .mouse, .skyline { display: none; }

/* ---------- Scrollbar global ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #243049; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #2f3f5f; }
