/* EPP en Vivo — demo comercial · myFuture-AI × nirvai
   Dark operational UI (control room). Brand gradient only as accent. */

:root {
  --bg: #10182a;
  --bg-2: #1a2439;
  --bg-3: #223050;
  --navy: #1e2947;
  --paper: #f5f3ee;
  --ink: #e8eaf2;
  --ink-dim: #9aa5bd;
  --ink-faint: #5d6a85;
  --line: rgba(245, 243, 238, 0.09);

  --g-pink: #e86fa6;
  --g-violet: #9a64d8;
  --g-blue: #3e7be0;
  --g-cyan: #41c6f2;
  --gradient: linear-gradient(90deg, var(--g-pink), var(--g-violet), var(--g-blue), var(--g-cyan));

  --alert-red: #e5484d;
  --alert-red-bg: rgba(229, 72, 77, 0.12);
  --ok-green: #30c48d;
  --ok-green-bg: rgba(48, 196, 141, 0.10);

  --font-ui: "Archivo", "Manrope", -apple-system, "Helvetica Neue", system-ui, sans-serif;
  --font-body: "Manrope", "Archivo", -apple-system, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  --radius: 12px;
  --topbar-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== Top bar ===== */
#topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--navy);
  border-bottom: 1px solid var(--line);
  position: relative;
}
#topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--gradient);
  opacity: 0.85;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--gradient);
  flex: 0 0 auto;
}
.brand-name {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
  color: var(--paper);
  white-space: nowrap;
}
.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink);
  white-space: nowrap;
}
.pill-unit { color: var(--ink-faint); font-size: 10px; margin-left: 2px; }

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex: 0 0 auto;
}
#pill-live.is-live .live-dot {
  background: var(--alert-red);
  box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5);
  animation: livepulse 1.6s ease-out infinite;
}
#pill-live.is-live #live-label { color: var(--paper); }
@keyframes livepulse {
  0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(229, 72, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); }
}

.badge-backend { color: var(--ink-dim); }
.badge-backend[data-backend="webgpu"] {
  color: #0d1526;
  background: linear-gradient(90deg, var(--g-blue), var(--g-cyan));
  border-color: transparent;
}
.badge-backend[data-backend="wasm"] {
  color: #0d1526;
  background: linear-gradient(90deg, var(--g-violet), var(--g-blue));
  border-color: transparent;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink-dim);
  cursor: pointer;
}
.icon-btn:hover, .icon-btn:active { color: var(--paper); background: var(--bg-3); }

/* ===== Main split ===== */
#main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 65fr) minmax(300px, 35fr);
  gap: 12px;
  padding: 12px;
}

/* ===== Camera stage ===== */
#stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
#video, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#video { object-fit: cover; background: #000; }
#video.mirrored { transform: scaleX(-1); }
#overlay { pointer-events: none; }
#overlay.mirrored { transform: scaleX(-1); }

.stage-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 24, 42, 0.75);
  z-index: 3;
}
.stage-msg[hidden] { display: none; }
.stage-msg-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 26px 34px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 80%;
  text-align: center;
  color: var(--ink-dim);
  font-size: 14px;
}
.spinner {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 3px solid var(--bg-3);
  border-top-color: var(--g-cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage-hud {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  gap: 6px;
  z-index: 2;
}
.hud-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--ink-dim);
  background: rgba(16, 24, 42, 0.72);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ===== Alerts panel ===== */
#panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  flex: 0 0 auto;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--paper);
}
.panel-counters {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-dim);
}
.counter b { font-weight: 700; }
.counter-pending b { color: var(--alert-red); }
.counter-resolved b { color: var(--ok-green); }

.alert-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--ink-faint);
  padding: 20px;
}
.empty-state p:first-child { color: var(--ink-dim); font-weight: 600; margin-bottom: 6px; }
.empty-sub { font-size: 12px; }
.empty-sub b { color: var(--ink-dim); }

/* Alert card */
.alert-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.alert-card.is-pending {
  border-color: rgba(229, 72, 77, 0.45);
  background: var(--alert-red-bg);
}
.alert-card.is-resolved {
  border-color: rgba(48, 196, 141, 0.35);
  background: var(--ok-green-bg);
}

.alert-thumb {
  width: 64px; height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-3);
  border: 1px solid var(--line);
  display: block;
}
.alert-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 9px;
}

.alert-info { min-width: 0; }
.alert-type {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.05em;
}
.is-pending .alert-type { color: var(--alert-red); }
.is-resolved .alert-type { color: var(--ok-green); }
.alert-meta {
  display: flex;
  gap: 8px;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.alert-note { color: var(--ok-green); }

.alert-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.estado {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.is-pending .estado { color: var(--alert-red); }
.is-resolved .estado { color: var(--ok-green); }

.btn-resolve {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink-dim);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 9px;
  cursor: pointer;
}
.btn-resolve:hover, .btn-resolve:active { color: var(--paper); }

/* Panel actions + footer */
.panel-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.action-btn:hover, .action-btn:active {
  border-color: transparent;
  background: linear-gradient(var(--bg-3), var(--bg-3)) padding-box,
              var(--gradient) border-box;
  border: 1px solid transparent;
}
.action-btn.is-active {
  background: linear-gradient(90deg, rgba(232, 111, 166, 0.18), rgba(65, 198, 242, 0.18));
  border-color: var(--g-violet);
}

.panel-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.footer-brand { color: var(--ink-dim); }
.footer-brand .x {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

/* ===== Settings drawer ===== */
#drawer[hidden], #drawer-scrim[hidden] { display: none; }

#drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 20, 0.55);
  z-index: 20;
}
#drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(340px, 88vw);
  z-index: 21;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.45);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h3 {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--paper);
}
.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.field label {
  display: block;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
}
.field label .mono { color: var(--g-cyan); margin-left: 6px; }
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field-row label { margin-bottom: 0; }

input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--gradient);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--navy);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  transition: background 0.15s ease;
}
.switch-track::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--ink-dim);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .switch-track {
  background: linear-gradient(90deg, var(--g-violet), var(--g-blue));
  border-color: transparent;
}
.switch input:checked + .switch-track::before {
  transform: translateX(20px);
  background: var(--paper);
}

select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
}

.drawer-footer {
  flex: 0 0 auto;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--ink-faint);
  text-align: center;
  letter-spacing: 0.05em;
}

/* ===== Responsive: portrait / narrow ===== */
@media (max-width: 900px), (orientation: portrait) {
  #main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 55fr) minmax(0, 45fr);
  }
  .brand-tag { display: none; }
}
@media (max-width: 560px) {
  #pill-fps { display: none; }
  .brand-name { font-size: 14px; }
}
