* { box-sizing: border-box; }
/* ETAPA 2 (doc39, 2026-07-31 16:24hs), Tarea 1 -- bug real encontrado auditando el "cuadro
   vacío" que el usuario marcó en rojo: varios elementos de este demo se togglean con el
   atributo HTML `hidden` (clientWindow, clientTypingIndicator, agentThreadOpen,
   agentThreadEmpty, agentTypingIndicator, agentMultitab), pero sus propias clases (ej.
   .agent-multitab{display:flex}) tienen la MISMA especificidad que la regla `[hidden]
   {display:none}` del navegador -- y como el CSS del autor viene después en la cascada, le
   gana al agente de usuario aunque el atributo hidden esté presente. Resultado: esos
   elementos quedaban SIEMPRE visibles (vacíos, sin contenido) por más que JS pusiera
   `.hidden = true` -- exactamente el "cuadro vacío sobre el bloque de chat" reportado (el
   caso más notorio era .agent-multitab, pero el mismo bug afectaba a los otros 5). Fix
   estándar (el mismo patrón que usan Bootstrap/Tailwind preflight para este caso exacto). */
[hidden] { display: none !important; }
:root {
  --bg: #0b0f19;
  --panel: #111927;
  --panel-2: #161c2a;
  --border: rgba(255,255,255,.08);
  --accent: #00d9d9;
  --accent-ink: #06222a;
  --text: #f5f7fb;
  --text-soft: #a6b0c3;
  --green: #10b981;
  --amber: #ffca28;
}
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}
.back-link { color: var(--text-soft); text-decoration: none; font-size: .85rem; }
.back-link:hover { color: var(--accent); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .9rem; }
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 40px 24px 80px; }

.intro { max-width: 720px; margin: 0 auto 40px; text-align: center; }
.intro-eyebrow {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 10px;
}
.intro h1 { font-size: 1.9rem; margin: 0 0 14px; line-height: 1.25; }
.intro p { color: var(--text-soft); line-height: 1.6; font-size: .96rem; }
.intro-actions { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 24px; flex-wrap: wrap; }

.btn-play {
  background: linear-gradient(135deg, var(--accent), #00b8b8);
  color: var(--accent-ink); border: none; border-radius: 10px;
  padding: 13px 26px; font-weight: 700; font-size: .95rem; cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.btn-play:hover { transform: translateY(-1px); }
.btn-play:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.subtitle-toggle {
  display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--text-soft); cursor: pointer;
}
.subtitle-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ETAPA 2 Tarea 2: selector Escritorio/Mobile + botón de pantalla completa real (Fullscreen
   API), disponibles siempre en una pantalla de computadora. */
.mode-toggle { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.mode-btn {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-soft);
  border-radius: 8px; padding: 8px 14px; font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.mode-btn-fullscreen { margin-left: 6px; color: var(--text-soft); }
.mode-btn-fullscreen:hover { color: var(--accent); border-color: var(--accent); }

.stage-wrap { max-width: 1080px; margin: 0 auto; }
/* La API de Fullscreen real (Tarea 2) pinta el elemento fullscreen con el fondo por default
   del navegador (blanco) -- se fuerza el mismo fondo oscuro del resto del demo. */
.stage-wrap:fullscreen { background: var(--bg); display: flex; flex-direction: column; justify-content: center; padding: 24px; }

.stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--border);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 560px;
  transition: grid-template-columns .5s ease;
}
.stage.fullscreen-agent { grid-template-columns: 0fr 1fr; }
.stage.fullscreen-agent .stage-client { opacity: 0; pointer-events: none; }

/* ---------- Modo mobile (Tarea 2): mismo motor de simulación (script.js no cambia), el
   celular del cliente se presenta con un marco realista de teléfono, apilado arriba del
   panel del agente (lado a lado no entra con un teléfono alto y angosto). ---------- */
.stage[data-mode="mobile"] {
  display: flex; flex-direction: column; align-items: center; gap: 22px;
  background: transparent; border: none; padding: 20px 0; min-height: 0;
}
.stage[data-mode="mobile"] .stage-client {
  width: 320px; height: 640px; flex: none;
  border: 10px solid #1c2536; border-radius: 42px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px var(--border);
  position: relative;
}
.stage[data-mode="mobile"] .stage-client::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 120px; height: 22px; background: #1c2536; border-radius: 0 0 14px 14px; z-index: 2;
}
.stage[data-mode="mobile"] .stage-client .device-label { display: none; }
.stage[data-mode="mobile"] .stage-client .client-viewport { padding: 0; }
.stage[data-mode="mobile"] .stage-client .client-window { inset: 0; border-radius: 0; }
.stage[data-mode="mobile"] .stage-agent {
  width: 100%; max-width: 460px; border-radius: 16px; border: 1px solid var(--border);
  min-height: 460px;
}
.stage[data-mode="mobile"].fullscreen-agent .stage-client { display: none; }
.stage[data-mode="mobile"].fullscreen-agent .stage-agent { max-width: 620px; }

.stage-half { background: var(--panel); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.device-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft);
  padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}

/* ---------- Client side ---------- */
.client-viewport { position: relative; flex: 1; background: #05070c; display: flex; align-items: flex-end; justify-content: flex-end; padding: 20px; }
.client-bubble {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #00b8b8);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-ink); box-shadow: 0 8px 24px rgba(0,217,217,.35);
  transition: transform .2s ease, opacity .2s ease;
}
.client-bubble svg { width: 26px; height: 26px; }
.client-bubble.hidden-bubble { opacity: 0; transform: scale(.5); pointer-events: none; }

.client-window {
  position: absolute; inset: 20px;
  background: #0f1522; border: 1px solid var(--border); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.4);
  animation: popIn .25s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.client-window-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; background: var(--panel-2); border-bottom: 1px solid var(--border);
  font-size: .85rem; font-weight: 600;
}
.client-window-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.client-window-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.client-window-typing { padding: 0 14px 8px; font-size: .76rem; color: var(--text-soft); display: flex; align-items: center; gap: 8px; }
.client-window-input { border-top: 1px solid var(--border); padding: 10px; }
.client-window-input input {
  width: 100%; background: #0b0f19; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; color: var(--text); font-size: .85rem;
}

.msg { max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: .85rem; line-height: 1.45; animation: msgIn .2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-in  { align-self: flex-start; background: #1b2333; color: var(--text); border-bottom-left-radius: 3px; }
.msg-out { align-self: flex-end; background: linear-gradient(135deg, var(--accent), #00b8b8); color: var(--accent-ink); font-weight: 500; border-bottom-right-radius: 3px; }
.msg-system { align-self: center; color: var(--text-soft); font-size: .74rem; font-style: italic; }

.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- Agent side ---------- */
.agent-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.agent-multitab {
  display: flex; gap: 6px; padding: 8px 12px; background: var(--panel-2);
  border-bottom: 1px solid var(--border); overflow-x: auto; animation: msgIn .2s ease;
}
.agent-multitab-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px;
  background: #0f1522; border: 1px solid var(--border); font-size: .76rem; white-space: nowrap; color: var(--text-soft);
}
.agent-multitab-item.active { border-color: var(--accent); color: var(--text); }
.agent-multitab-item .flag { font-size: .7rem; }

.agent-body { flex: 1; display: grid; grid-template-columns: 220px 1fr; min-height: 0; }
.agent-sidebar { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.agent-sidebar-head { padding: 10px; border-bottom: 1px solid var(--border); }
.agent-search {
  width: 100%; background: #0b0f19; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; color: var(--text); font-size: .8rem;
}
.agent-chat-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.agent-chat-item {
  display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 9px; cursor: default;
  transition: background .15s ease; margin-bottom: 3px; position: relative;
}
.agent-chat-item.selected { background: rgba(0,217,217,.1); }
.agent-chat-item.entering { animation: itemPulse 1s ease; }
@keyframes itemPulse { 0% { background: rgba(0,217,217,.35); } 100% { background: transparent; } }
.agent-chat-item.filtered-out { display: none; }

.chat-avatar-circle {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 700; color: #fff;
}
.agent-chat-item-info { min-width: 0; flex: 1; }
.agent-chat-item-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.agent-chat-item-preview { font-size: .72rem; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.agent-thread { display: flex; flex-direction: column; min-height: 0; position: relative; }
.agent-thread-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-soft); font-size: .85rem; }
.agent-thread-open { flex: 1; display: flex; flex-direction: column; min-height: 0; animation: msgIn .2s ease; }
.agent-thread-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.agent-thread-name { font-size: .88rem; font-weight: 700; }
.agent-thread-status { font-size: .72rem; color: var(--amber); }
.agent-fullscreen-btn {
  margin-left: auto; background: transparent; border: 1px solid var(--border); border-radius: 7px;
  color: var(--text-soft); width: 30px; height: 30px; cursor: pointer; font-size: .9rem;
}
.agent-fullscreen-btn:hover { color: var(--accent); border-color: var(--accent); }
.agent-thread-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.agent-thread-typing { padding: 0 16px 8px; font-size: .76rem; color: var(--text-soft); display: flex; align-items: center; gap: 8px; }
.agent-thread-input { border-top: 1px solid var(--border); padding: 10px; position: relative; }
.agent-thread-input input {
  width: 100%; background: #0b0f19; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; color: var(--text); font-size: .85rem;
}
.macro-dropdown {
  position: absolute; left: 10px; right: 10px; bottom: 52px;
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 10px;
  padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: popIn .15s ease;
}
.macro-item { padding: 8px 10px; border-radius: 7px; display: flex; flex-direction: column; gap: 2px; background: rgba(0,217,217,.08); }
.macro-shortcut { font-size: .72rem; font-weight: 700; color: var(--accent); }
.macro-text { font-size: .78rem; color: var(--text-soft); }

/* ETAPA 2 (doc39, 2026-07-31 16:24hs), Tarea 1: scrollbar dark en las 3 áreas con scroll
   propio del demo (mismo criterio visual que la interfaz real de Aurell Connect). */
.client-window-body, .agent-chat-list, .agent-thread-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.25) transparent;
}
.client-window-body::-webkit-scrollbar, .agent-chat-list::-webkit-scrollbar, .agent-thread-messages::-webkit-scrollbar {
  width: 8px;
}
.client-window-body::-webkit-scrollbar-track, .agent-chat-list::-webkit-scrollbar-track, .agent-thread-messages::-webkit-scrollbar-track {
  background: transparent;
}
.client-window-body::-webkit-scrollbar-thumb, .agent-chat-list::-webkit-scrollbar-thumb, .agent-thread-messages::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,.25); border-radius: 8px;
}

/* ---------- Subtitles ---------- */
/* ETAPA 2 Tarea 1: pedido explícito -- en vez de una barra fija debajo del stage, un modal
   flotante semitransparente oscuro centrado un poco hacia arriba del centro de la pantalla,
   con position:fixed (no depende de dónde esté scrolleada la página ni empuja el layout). */
.subtitle-bar {
  position: fixed;
  left: 50%;
  top: 38vh;
  transform: translateX(-50%);
  z-index: 500;
  max-width: min(560px, 88vw);
  text-align: center;
  font-size: .9rem;
  line-height: 1.5;
  color: var(--text);
  background: rgba(10, 14, 22, .88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 14px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  animation: subtitleIn .2s ease;
}
@keyframes subtitleIn { from { opacity: 0; transform: translateX(-50%) translateY(6px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.replay-wrap { text-align: center; margin-top: 24px; }
.btn-replay { background: transparent; border: 1px solid var(--accent); color: var(--accent); }

.footnote { max-width: 720px; margin: 40px auto 0; text-align: center; }
.footnote p { color: var(--text-soft); font-size: .78rem; line-height: 1.6; }

@media (max-width: 860px) {
  .stage:not([data-mode="mobile"]) { grid-template-columns: 1fr; }
  .stage.fullscreen-agent { grid-template-columns: 1fr; }
  .agent-body { grid-template-columns: 150px 1fr; }
  .intro h1 { font-size: 1.5rem; }
}

/* ETAPA 2 Tarea 2, pedido explícito: "en el teléfono bueno se ve a pantalla completa solo esa
   opción" -- en un viewport de celular real se fuerza el modo mobile (el selector Escritorio
   ya no tiene sentido ahí) y el marco de teléfono se estira a lo que da el propio dispositivo
   en vez de mostrar un teléfono en miniatura dentro de otro teléfono. */
@media (max-width: 480px) {
  #btnModeDesktop { display: none; }
  .stage[data-mode="mobile"] .stage-client {
    width: 100%; max-width: 100%; height: 72vh; border-radius: 0; border-width: 6px;
  }
  .stage[data-mode="mobile"] .stage-agent { max-width: 100%; }
}
