/* ═══════════════════════════════════════════════════════════════════════
   Experience Studio 2026 — capa visual sobre design-tokens.css
   Voz: cabina de operaciones industriales. Inter habla, JetBrains Mono mide.
   Firma: context bar tipo instrumento + timeline "caja negra" de agentes.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* Modos de ejecución (semántica operacional) */
  --es-live: #34d399;
  --es-replay: #818cf8;
  --es-whatif: #ffb454;
  /* Ámbar industrial: decisiones de agente / atención */
  --es-amber: #ffb454;
  --es-amber-glow: rgba(255, 180, 84, 0.14);
  /* Superficies studio */
  --es-glass: linear-gradient(160deg, rgba(24, 32, 48, 0.72), rgba(13, 17, 26, 0.88));
  --es-ring: conic-gradient(from 180deg, var(--accent), #7dd3fc, var(--accent));
  --es-radius: 14px;
  --es-spring: cubic-bezier(0.22, 1.2, 0.36, 1);
}

/* ── Eyebrows mono: la voz de instrumento ─────────────────────────────── */
.es-eyebrow {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Context bar (firma): showcase ▸ sesión ▸ modo ────────────────────── */
.es-context-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 1.25rem;
  background: linear-gradient(90deg, rgba(0, 188, 212, 0.07), transparent 55%);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.68rem;
  min-height: 30px;
  overflow-x: auto;
  white-space: nowrap;
}
.es-context-bar:empty { display: none; }
.es-ctx-seg { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-secondary); }
.es-ctx-seg .es-eyebrow { color: var(--text-muted); }
.es-ctx-seg strong { color: var(--text-primary); font-weight: 500; }
.es-ctx-sep { color: var(--text-muted); opacity: 0.6; }
.es-ctx-idle { color: var(--text-muted); }

.es-mode-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 0 0 transparent;
}
.es-mode-dot[data-mode="live"]   { background: var(--es-live);   animation: es-pulse-live 2s infinite; }
.es-mode-dot[data-mode="replay"] { background: var(--es-replay); }
.es-mode-dot[data-mode="what_if"],
.es-mode-dot[data-mode="whatif"] { background: var(--es-whatif); animation: es-pulse-amber 2.6s infinite; }
@keyframes es-pulse-live  { 50% { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.12); } }
@keyframes es-pulse-amber { 50% { box-shadow: 0 0 0 5px var(--es-amber-glow); } }

.es-mode-chip {
  font-family: var(--font-mono, monospace);
  font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.1rem 0.5rem; border-radius: 999px;
  border: 1px solid var(--border-medium); color: var(--text-secondary);
  background: transparent; cursor: pointer; transition: all 0.15s ease;
}
.es-mode-chip:hover { border-color: var(--accent); color: var(--text-primary); }
.es-mode-chip.is-active[data-mode="live"]   { border-color: var(--es-live);   color: var(--es-live);   background: rgba(52,211,153,0.08); }
.es-mode-chip.is-active[data-mode="replay"] { border-color: var(--es-replay); color: var(--es-replay); background: rgba(129,140,248,0.08); }
.es-mode-chip.is-active[data-mode="what_if"] { border-color: var(--es-whatif); color: var(--es-whatif); background: var(--es-amber-glow); }

/* ── Nav: badges de salud por sección ─────────────────────────────────── */
.es-nav-badge {
  margin-left: auto; width: 7px; height: 7px; border-radius: 50%;
  background: var(--es-live); flex-shrink: 0; opacity: 0.85;
}
.es-nav-badge[data-state="degraded"] { background: var(--es-amber); }
.es-nav-badge[data-state="down"] { background: #f87171; }
.es-nav-badge[data-state="unknown"] { background: var(--text-muted); opacity: 0.4; }

/* ── Cards de catálogo ────────────────────────────────────────────────── */
.es-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.es-toolbar input[type="search"] {
  flex: 1 1 220px; min-width: 180px;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 0.45rem 0.75rem; color: var(--text-primary);
  font-family: var(--font); font-size: 0.8rem;
}
.es-toolbar input[type="search"]:focus { outline: none; border-color: var(--accent); }
.es-filter-chip {
  font-size: 0.68rem; padding: 0.25rem 0.65rem; border-radius: 999px;
  border: 1px solid var(--border-subtle); background: transparent;
  color: var(--text-secondary); cursor: pointer; transition: all 0.15s ease;
}
.es-filter-chip:hover { border-color: var(--accent); }
.es-filter-chip.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.es-card-grid {
  display: grid; gap: 0.9rem;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.es-card {
  background: var(--es-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--es-radius);
  padding: 1rem;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 0.5rem;
  transition: transform 0.25s var(--es-spring), border-color 0.2s ease, box-shadow 0.25s ease;
}
.es-card:hover, .es-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(0, 188, 212, 0.45);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 188, 212, 0.12);
  outline: none;
}
.es-card h4 { margin: 0; font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.es-card p { margin: 0; font-size: 0.72rem; line-height: 1.45; color: var(--text-secondary); }
.es-card-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: auto; }
.es-tag {
  font-family: var(--font-mono, monospace); font-size: 0.58rem; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 0.12rem 0.45rem; border-radius: 4px;
  background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border-subtle);
}
.es-tag--industry { color: var(--accent); border-color: rgba(0, 188, 212, 0.3); }
.es-tag--agent { color: var(--es-amber); border-color: rgba(255, 180, 84, 0.3); }

/* ── Preview drawer ───────────────────────────────────────────────────── */
.es-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(430px, 92vw); z-index: 220;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-medium);
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.5);
  transform: translateX(102%);
  transition: transform 0.32s var(--es-spring);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.es-drawer.is-open { transform: translateX(0); }
.es-drawer-head {
  padding: 1.1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; background: var(--bg-surface); z-index: 1;
}
.es-drawer-head h3 { margin: 0.25rem 0 0.35rem; font-size: 1.05rem; color: var(--text-primary); }
.es-drawer-body { padding: 1rem 1.25rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.es-drawer-close {
  position: absolute; top: 0.8rem; right: 0.9rem;
  background: transparent; border: 1px solid var(--border-subtle); border-radius: 8px;
  color: var(--text-secondary); width: 28px; height: 28px; cursor: pointer; font-size: 0.9rem;
}
.es-drawer-close:hover { border-color: var(--accent); color: var(--text-primary); }
.es-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 0.5rem; }
.es-kpi {
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 0.5rem 0.6rem;
}
.es-kpi b { display: block; font-family: var(--font-mono, monospace); font-size: 0.85rem; color: var(--text-primary); font-weight: 500; }
.es-kpi span { font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }

/* ── Session dock / launchers ─────────────────────────────────────────── */
.es-dock {
  border: 1px solid var(--border-subtle); border-radius: var(--es-radius);
  background: var(--es-glass); padding: 1rem; margin-top: 1rem;
}
.es-dock-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.es-launchers { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.es-launcher {
  flex: 1 1 130px; min-width: 128px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 0.65rem 0.75rem; cursor: pointer;
  color: var(--text-primary); font-family: var(--font); text-align: left;
  transition: border-color 0.15s ease, transform 0.2s var(--es-spring);
}
.es-launcher:hover { border-color: var(--accent); transform: translateY(-2px); }
.es-launcher small { color: var(--text-muted); font-size: 0.62rem; }
.es-qr-box { text-align: center; padding: 0.5rem; }
.es-qr-box img { border-radius: 8px; background: #fff; padding: 6px; max-width: 150px; }
.es-clients-live { margin-top: 0.75rem; font-size: 0.72rem; }
.es-clients-live li {
  list-style: none; display: flex; justify-content: space-between;
  padding: 0.25rem 0; border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono, monospace); font-size: 0.66rem;
}

/* ── Orchestration Studio ─────────────────────────────────────────────── */
.es-orch-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 1rem; }
@media (max-width: 1100px) { .es-orch-layout { grid-template-columns: 1fr; } }
.es-editor-wrap {
  border: 1px solid var(--border-subtle); border-radius: var(--es-radius);
  overflow: hidden; background: var(--bg-elevated);
}
.es-editor-wrap .CodeMirror { height: 380px; background: var(--bg-deep); color: var(--text-primary); font-size: 12.5px; }
.es-editor-wrap .CodeMirror-gutters { background: var(--bg-surface); border-right: 1px solid var(--border-subtle); }
.es-editor-fallback {
  width: 100%; height: 380px; resize: vertical; border: none;
  background: var(--bg-deep); color: var(--text-primary);
  font-family: var(--font-mono, monospace); font-size: 12.5px; padding: 0.75rem;
}
.es-editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  padding: 0.5rem; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface);
}
.es-errors { margin: 0.5rem 0 0; padding: 0; }
.es-errors li {
  list-style: none; font-family: var(--font-mono, monospace); font-size: 0.66rem;
  color: #fca5a5; padding: 0.25rem 0.5rem; border-left: 2px solid #f87171;
  background: rgba(248, 113, 113, 0.06); margin-bottom: 2px;
}
.es-banner {
  display: flex; gap: 0.5rem; align-items: center;
  border: 1px solid rgba(255, 180, 84, 0.35); background: var(--es-amber-glow);
  color: var(--es-amber); border-radius: 10px; padding: 0.5rem 0.75rem;
  font-size: 0.72rem; margin-bottom: 0.75rem;
}

/* Timeline "caja negra" de agentes */
.es-timeline {
  border: 1px solid var(--border-subtle); border-radius: var(--es-radius);
  background: var(--bg-deep); padding: 0.9rem; max-height: 440px; overflow-y: auto;
}
.es-tl-item {
  position: relative; padding: 0.35rem 0 0.35rem 1.4rem;
  border-left: 1px solid var(--border-medium); margin-left: 0.4rem;
  font-size: 0.7rem; color: var(--text-secondary);
}
.es-tl-item::before {
  content: ""; position: absolute; left: -4.5px; top: 0.62rem;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
}
.es-tl-item[data-node="plan"]::before    { background: var(--accent); }
.es-tl-item[data-node="act"]::before     { background: var(--es-amber); }
.es-tl-item[data-node="observe"]::before { background: var(--es-replay); }
.es-tl-item[data-node="reflect"]::before { background: var(--es-live); }
.es-tl-item .es-eyebrow { display: inline-block; margin-right: 0.5rem; }
.es-tl-item code {
  font-family: var(--font-mono, monospace); font-size: 0.64rem;
  color: var(--text-primary); background: var(--bg-hover);
  border-radius: 4px; padding: 0.05rem 0.3rem;
}
.es-tl-empty { color: var(--text-muted); font-size: 0.72rem; text-align: center; padding: 2rem 0.5rem; }

/* ── Asistente paso a paso ────────────────────────────────────────────── */
.es-steps { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.es-step-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: var(--font-mono, monospace); font-size: 0.6rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 0.25rem 0.6rem; border-radius: 999px; border: 1px solid var(--border-subtle);
}
.es-step-pill.is-current { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }
.es-step-pill.is-done { color: var(--es-live); border-color: rgba(52, 211, 153, 0.35); }
.es-assistant-body { min-height: 260px; }
.es-option-grid { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.es-option {
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: 10px; padding: 0.7rem; cursor: pointer; transition: border-color 0.15s ease;
}
.es-option:hover { border-color: var(--accent); }
.es-option.is-selected { border-color: var(--accent); background: var(--accent-glow); }
.es-option h5 { margin: 0 0 0.2rem; font-size: 0.78rem; color: var(--text-primary); }
.es-option p { margin: 0; font-size: 0.64rem; color: var(--text-secondary); line-height: 1.4; }
.es-assistant-nav { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 1rem; }

/* ── Ayuda / tour ─────────────────────────────────────────────────────── */
.es-help-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.es-help-card {
  background: var(--es-glass); border: 1px solid var(--border-subtle);
  border-radius: var(--es-radius); padding: 1rem;
}
.es-help-card ol { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.72rem; color: var(--text-secondary); }
.es-help-card ol li { margin-bottom: 0.3rem; line-height: 1.45; }
.es-help-card a { color: var(--accent); cursor: pointer; text-decoration: none; }
.es-help-card a:hover { text-decoration: underline; }
.es-tour-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(5, 8, 13, 0.78); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.es-tour-card {
  width: min(430px, 90vw); background: var(--bg-surface);
  border: 1px solid var(--border-medium); border-radius: var(--es-radius);
  padding: 1.4rem; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

/* ── Skeletons ────────────────────────────────────────────────────────── */
.es-skeleton {
  border-radius: 10px; min-height: 84px;
  background: linear-gradient(100deg, var(--bg-elevated) 40%, var(--bg-hover) 50%, var(--bg-elevated) 60%);
  background-size: 200% 100%;
  animation: es-shimmer 1.4s infinite linear;
}
@keyframes es-shimmer { to { background-position: -200% 0; } }

/* ── Estado degradado por sección ─────────────────────────────────────── */
.es-degraded-note {
  border: 1px dashed rgba(255, 180, 84, 0.4); border-radius: 10px;
  color: var(--es-amber); background: var(--es-amber-glow);
  font-size: 0.7rem; padding: 0.5rem 0.75rem; margin-bottom: 0.75rem;
}

/* ── Entrada de panel (momento orquestado único) ──────────────────────── */
.panel.active > .es-view { animation: es-enter 0.32s var(--es-spring); }
@keyframes es-enter { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  .es-card, .es-drawer, .es-launcher, .panel.active > .es-view { transition: none; animation: none; }
  .es-mode-dot, .es-skeleton { animation: none; }
}
