/* Vigía Faena — sobre yoy-brand.css (yoy_sky_glass). */

:root {
  --lvl-ok: #00BFA6;
  --lvl-revisar: #FFB020;
  --lvl-alerta: #ff4d4f;
  --lvl-critico: #ff1f3d;
  --lvl-idle: #92D3F4;
  --ink-deep: #082a44;
  --glass-strong: rgba(8, 42, 68, 0.55);
  --gutter: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Montserrat', system-ui, sans-serif;
  background: var(--gradient-background);
  background-attachment: fixed;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
a.yoy-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
a { color: var(--palette-info); }

/* ── Barra superior ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px var(--gutter);
  background: rgba(8, 42, 68, 0.35);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand img { height: 26px; }
.brand-name { font-weight: 800; letter-spacing: 0.3px; font-size: 1.05rem; }
.brand-name span { color: var(--palette-primary); }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary); white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.chip.on .dot { background: var(--lvl-ok); box-shadow: 0 0 8px var(--lvl-ok); }
.chip.warn .dot { background: var(--lvl-revisar); box-shadow: 0 0 8px var(--lvl-revisar); }
.chip.off .dot { background: var(--lvl-alerta); }
.chip strong { color: #fff; letter-spacing: 1px; }
.icon-btn {
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff; border-radius: 10px; padding: 7px 11px; cursor: pointer; font-size: 0.85rem; font-weight: 600;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); }
.icon-btn.active { background: var(--palette-primary); border-color: var(--palette-primary); }

/* ── Pantalla dividida ──────────────────────────────────────────── */
.split {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: var(--gutter); padding: var(--gutter);
  height: calc(100vh - 58px); min-height: 560px;
}
@media (max-width: 960px) {
  .split { grid-template-columns: 1fr; height: auto; }
}

.stage {
  position: relative; border-radius: 18px; overflow: hidden;
  background: #04121e;
  border: 2px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  transition: border-color 0.35s, box-shadow 0.35s;
  display: flex; align-items: center; justify-content: center;
  min-height: 300px;
}
.stage canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage[data-level="ok"] { border-color: rgba(0, 191, 166, 0.55); box-shadow: 0 0 0 1px rgba(0,191,166,.2), 0 20px 60px rgba(0, 0, 0, 0.35); }
.stage[data-level="revisar"] { border-color: var(--lvl-revisar); }
.stage[data-level="alerta"], .stage[data-level="critico"] {
  border-color: var(--lvl-alerta);
  animation: stage-alarm 1s ease-in-out infinite;
}
@keyframes stage-alarm {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.0), inset 0 0 0 0 rgba(255,77,79,0); }
  50% { box-shadow: 0 0 40px 6px rgba(255, 77, 79, 0.55), inset 0 0 80px 10px rgba(255,31,61,0.35); }
}

.stage-banner {
  position: absolute; top: 14px; left: 14px; right: 14px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px;
  background: rgba(4, 18, 30, 0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-weight: 700; font-size: 0.95rem;
  border-left: 5px solid var(--lvl-idle);
  transition: border-color 0.3s, background 0.3s;
}
.stage-banner[data-level="ok"] { border-left-color: var(--lvl-ok); }
.stage-banner[data-level="revisar"] { border-left-color: var(--lvl-revisar); }
.stage-banner[data-level="alerta"], .stage-banner[data-level="critico"] { border-left-color: var(--lvl-alerta); background: rgba(120, 10, 20, 0.7); }
.stage-banner .rec { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--text-secondary); font-weight: 600; }
.stage-banner .rec::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #ff3b3b; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

.hud {
  position: absolute; bottom: 12px; left: 12px; right: 12px;
  display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none;
}
.hud .chip { background: rgba(4, 18, 30, 0.65); }

.scan {
  position: absolute; left: 0; right: 0; height: 3px; top: 0;
  background: linear-gradient(90deg, transparent, rgba(255,102,0,0.9), transparent);
  box-shadow: 0 0 16px rgba(255, 102, 0, 0.8);
  opacity: 0; pointer-events: none;
}
.stage.analyzing .scan { opacity: 1; animation: scan 1.3s linear infinite; }
@keyframes scan { from { top: 0; } to { top: 100%; } }

.flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 31, 61, 0.55) 100%);
}
.flash.go { animation: flash 0.9s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* Emparejamiento (sin cámara) */
.pairing {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center;
  background: radial-gradient(ellipse at center, rgba(31, 111, 159, 0.35), rgba(4, 18, 30, 0.95));
}
.pairing[hidden] { display: none; }
.pairing h2 { margin: 0; font-size: 1.4rem; font-weight: 800; }
.pairing p { margin: 0; color: var(--text-secondary); max-width: 420px; font-size: 0.9rem; }
.qr { background: #fff; padding: 12px; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,0.4); }
.qr img, .qr svg { display: block; width: 190px; height: 190px; }
.room-code { font-size: 2rem; font-weight: 800; letter-spacing: 6px; color: var(--palette-primary); }
.pairing .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pairing .yoy-btn { width: auto; }

/* ── Panel derecho ──────────────────────────────────────────────── */
.panel { display: flex; flex-direction: column; gap: var(--gutter); min-height: 0; overflow: auto; padding-right: 2px; }
.panel > * { flex-shrink: 0; }
.card {
  background: var(--panel-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px; padding: 16px;
}
.card h3 {
  margin: 0 0 10px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-secondary); font-weight: 700;
}

.status {
  position: relative; overflow: hidden;
  border-radius: 18px; padding: 22px 22px 20px;
  display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: center;
  background: rgba(146, 211, 244, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  transition: background 0.35s, border-color 0.35s, transform 0.2s;
}
.status .glyph {
  grid-row: span 2; width: 74px; height: 74px; border-radius: 50%;
  display: grid; place-items: center; font-size: 2.2rem; font-weight: 900;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.35s, box-shadow 0.35s;
}
.status .title { font-size: clamp(1.4rem, 2.6vw, 2.2rem); font-weight: 900; letter-spacing: 0.5px; line-height: 1.05; }
.status .sub { color: var(--text-secondary); font-size: 0.92rem; font-weight: 500; min-height: 1.2em; }
.status .pending {
  position: absolute; top: 12px; right: 12px;
  font-size: 0.7rem; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: rgba(255, 176, 32, 0.2); color: #ffd27a; border: 1px solid rgba(255, 176, 32, 0.5);
  opacity: 0; transform: translateY(-4px); transition: opacity 0.2s, transform 0.2s;
}
.status .pending.show { opacity: 1; transform: none; }

.status[data-level="ok"] { background: linear-gradient(135deg, rgba(0, 191, 166, 0.35), rgba(0, 191, 166, 0.12)); border-color: rgba(0, 191, 166, 0.6); }
.status[data-level="ok"] .glyph { background: var(--lvl-ok); box-shadow: 0 0 30px rgba(0, 191, 166, 0.6); }
.status[data-level="revisar"] { background: linear-gradient(135deg, rgba(255, 176, 32, 0.35), rgba(255, 176, 32, 0.1)); border-color: rgba(255, 176, 32, 0.7); }
.status[data-level="revisar"] .glyph { background: var(--lvl-revisar); color: var(--ink-deep); }
.status[data-level="alerta"], .status[data-level="critico"] {
  background: linear-gradient(135deg, rgba(255, 31, 61, 0.75), rgba(160, 10, 30, 0.55));
  border-color: #ff6b6d;
  animation: status-pulse 1s ease-in-out infinite;
}
.status[data-level="alerta"] .glyph, .status[data-level="critico"] .glyph { background: #fff; color: var(--lvl-critico); box-shadow: 0 0 30px rgba(255, 255, 255, 0.6); }
@keyframes status-pulse { 50% { transform: scale(1.012); box-shadow: 0 0 40px rgba(255, 31, 61, 0.55); } }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gutter); }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.epp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.epp-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 11px; border-radius: 10px; background: rgba(4, 18, 30, 0.25);
  font-weight: 600; font-size: 0.88rem;
  transition: background 0.3s;
}
.badge { font-size: 0.7rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.6px; }
.badge.cumple { background: rgba(0, 191, 166, 0.25); color: #6ff0dd; }
.badge.falta { background: var(--lvl-alerta); color: #fff; }
.badge.no_visible { background: rgba(255, 176, 32, 0.22); color: #ffd27a; }
.badge.sin_personas, .badge.espera { background: rgba(255, 255, 255, 0.1); color: var(--text-secondary); }
.epp-list li.falta { background: rgba(255, 77, 79, 0.25); }
.epp-list li.optional { opacity: 0.55; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { padding: 8px 10px; border-radius: 10px; background: rgba(4, 18, 30, 0.25); }
.metric .k { font-size: 0.66rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; }
.metric .v { font-size: 1.1rem; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metric.wide { grid-column: span 2; }
.metric .v small { font-size: 0.7rem; color: var(--text-secondary); font-weight: 600; }

.insight-text { font-size: 1.02rem; font-weight: 600; line-height: 1.4; margin: 0; }
.insight-text.empty { color: var(--text-muted); font-weight: 500; }
.risks { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.risks li { font-size: 0.85rem; padding: 7px 10px; border-radius: 9px; background: rgba(4, 18, 30, 0.3); border-left: 4px solid var(--lvl-revisar); }
.risks li.alta { border-left-color: var(--lvl-alerta); }
.risks li.baja { border-left-color: var(--lvl-idle); }
.risks li b { display: block; font-size: 0.8rem; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.timeline li {
  display: grid; grid-template-columns: 72px 1fr; gap: 10px; align-items: center;
  padding: 7px; border-radius: 10px; background: rgba(4, 18, 30, 0.28);
  animation: slide-in 0.35s ease-out;
}
.timeline li img { width: 72px; height: 44px; object-fit: cover; border-radius: 6px; display: block; }
.timeline li .t { font-size: 0.7rem; color: var(--text-muted); font-weight: 700; }
.timeline li .d { font-size: 0.85rem; font-weight: 700; }
.timeline li.alerta .d, .timeline li.critico .d { color: #ff9a9b; }
.timeline li.ok .d { color: #6ff0dd; }
.timeline .empty { color: var(--text-muted); font-size: 0.85rem; display: block; background: none; padding: 0; animation: none; }
@keyframes slide-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* ── Diálogos ───────────────────────────────────────────────────── */
dialog {
  border: 1px solid rgba(255,255,255,0.18); border-radius: 18px; padding: 0;
  background: rgba(13, 63, 99, 0.92); color: #fff; width: min(440px, calc(100vw - 32px));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
dialog::backdrop { background: rgba(4, 18, 30, 0.6); backdrop-filter: blur(3px); }
dialog form, dialog .body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0; font-size: 1.15rem; }
dialog p { margin: 0; color: var(--text-secondary); font-size: 0.88rem; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field select { appearance: auto; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checks label, .toggle {
  display: flex; align-items: center; gap: 8px; font-size: 0.88rem; font-weight: 600;
  padding: 8px 10px; border-radius: 10px; background: rgba(4, 18, 30, 0.3); cursor: pointer;
}
.checks input, .toggle input { accent-color: var(--palette-primary); width: 18px; height: 18px; }
.err { color: #ffb3b4; font-size: 0.85rem; font-weight: 600; min-height: 1em; }
.row-end { display: flex; gap: 10px; justify-content: flex-end; }
.row-end .yoy-btn { width: auto; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(4, 18, 30, 0.9); padding: 10px 16px; border-radius: 12px; font-size: 0.88rem; font-weight: 600;
  opacity: 0; transition: opacity 0.25s, transform 0.25s; z-index: 50; max-width: calc(100vw - 32px);
  border: 1px solid rgba(255,255,255,0.15);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ── Modo Procedimiento ─────────────────────────────────────────── */
.seg { display: inline-flex; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; padding: 2px; }
.seg-btn { background: none; border: 0; color: var(--text-secondary); font-weight: 700; font-size: 0.8rem; padding: 6px 11px; border-radius: 8px; cursor: pointer; }
.seg-btn.active { background: var(--palette-primary); color: #fff; }
.panel[hidden] { display: none; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 11px; border-radius: 10px; background: rgba(4, 18, 30, 0.25); font-weight: 600; font-size: 0.88rem;
  transition: background 0.3s;
}
.steps .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; background: rgba(255,255,255,0.1); }
.steps .t { font-size: 0.72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.steps li.done { background: rgba(0, 191, 166, 0.22); }
.steps li.done .ico { background: var(--lvl-ok); }
.steps li.now { background: rgba(146, 211, 244, 0.18); box-shadow: inset 0 0 0 1px rgba(146,211,244,0.45); }
.steps li.now .ico { background: var(--palette-info); color: var(--ink-deep); animation: blink 1.2s infinite; }
.steps li.warn { background: rgba(255, 176, 32, 0.25); }
.steps li.warn .ico { background: var(--lvl-revisar); color: var(--ink-deep); }
.steps li.fail { background: rgba(255, 77, 79, 0.3); }
.steps li.fail .ico { background: var(--lvl-alerta); }
.ok-text { color: #6ff0dd; }
.bad-text { color: #ff9a9b; }
.zone-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toggle.mini { padding: 6px 10px; font-size: 0.8rem; }
.hint { margin: 8px 0; color: var(--text-muted); font-size: 0.8rem; }
.rule { resize: vertical; font-size: 0.85rem; min-height: 54px; }
.stage.editing { cursor: crosshair; }
.stage.editing .stage-banner { pointer-events: none; opacity: 0.5; }
.timeline li .ia { font-size: 0.75rem; font-weight: 700; margin-top: 2px; color: var(--text-secondary); }
.timeline li .ia.agree { color: #6ff0dd; }
.timeline li .ia.disagree { color: #ffd27a; }
.timeline li.wide img { width: 120px; height: 56px; }
.timeline li.wide { grid-template-columns: 120px 1fr; }
.timeline li.gris .d { color: var(--text-secondary); }

@media (prefers-reduced-motion: reduce) {
  .stage[data-level], .status[data-level], .scan, .flash.go { animation: none !important; }
}
