/* The Lab — v0.1 (grid + ficha) — estilo industrial oscuro, zero-dep */

:root {
  --bg: #0b0f17;
  --panel: #111827;
  --panel2: #0f172a;
  --line: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --ok: #34d399;
  --warn: #fbbf24;
}

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

body {
  background: radial-gradient(1200px 600px at 70% -10%, #16233f 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; backdrop-filter: blur(12px); background: rgba(11,15,23,.8); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand-badge {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed); font-size: 14px; font-weight: 800;
}
.brand-sub { color: var(--muted); font-weight: 400; font-size: 13px; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 14px; margin-left: 18px; }
.topbar nav a:hover { color: var(--text); }

.hero { max-width: 1080px; margin: 0 auto; padding: 64px 24px 28px; text-align: center; }
.hero h1 { font-size: clamp(32px, 6vw, 58px); font-weight: 800; letter-spacing: -1.5px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero-sub { color: var(--muted); max-width: 620px; margin: 14px auto 22px; font-size: 17px; line-height: 1.55; }
.hero-meta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
  font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px;
}
.pill.live { color: var(--ok); border-color: rgba(52,211,153,.35); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.grid {
  max-width: 1080px; margin: 0 auto; padding: 18px 24px 40px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px;
}
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: 16px; padding: 18px;
  cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.card-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}
.avatar.big { width: 64px; height: 64px; font-size: 26px; border-radius: 16px; }
.idline h2 { font-size: 17px; font-weight: 700; }
.role { color: var(--muted); font-size: 12.5px; display: block; margin-top: 2px; }
.status { width: 10px; height: 10px; border-radius: 50%; margin-left: auto; flex-shrink: 0; }
.status.online { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status.soon { background: var(--warn); }
.specialty { font-size: 13.5px; color: var(--text); line-height: 1.5; }
.personality { font-size: 12.5px; color: var(--muted); font-style: italic; line-height: 1.45; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.voice { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121f; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.primary.big { padding: 13px 26px; font-size: 16px; border-radius: 12px; }
.btn.ghost { width: 38px; padding: 8px 0; }

.lab-note { max-width: 760px; margin: 0 auto 60px; padding: 0 24px; }
.lab-note h2 { font-size: 20px; margin-bottom: 14px; }
.lab-note ol { list-style: none; counter-reset: step; display: grid; gap: 10px; }
.lab-note li { counter-increment: step; display: flex; gap: 12px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.lab-note li::before {
  content: counter(step); width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

footer { border-top: 1px solid var(--line); padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }
footer a { color: var(--accent); text-decoration: none; }

/* Modal */
.modal {
  border: 1px solid var(--line); border-radius: 18px; background: var(--panel);
  color: var(--text); padding: 0; max-width: 460px; width: 92%;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal::backdrop { background: rgba(2,6,14,.72); backdrop-filter: blur(4px); }
.modal-inner { padding: 26px; position: relative; display: grid; gap: 14px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; background: none; border: none;
  color: var(--muted); font-size: 17px; cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-head { display: flex; align-items: center; gap: 16px; }
.modal-specialty { font-size: 14.5px; line-height: 1.55; }
.modal-personality { color: var(--muted); font-style: italic; font-size: 13.5px; }
.modal-voice { color: var(--muted); font-size: 13px; }
.modal-hint { font-size: 12px; color: var(--warn); line-height: 1.5; }
.passcode {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; color: var(--text); font-size: 13.5px; outline: none;
}
.passcode:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 12px; margin-top: 6px; }

/* Overlay de llamada */
#call-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(2, 6, 14, .86); backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 20px;
}
.call-panel {
  width: min(680px, 100%); background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: 20px; padding: 22px;
  display: grid; gap: 16px; box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
}
.call-head { display: flex; align-items: center; gap: 14px; }
.call-live { font-size: 13px; color: var(--ok); display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.call-timer { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; font-weight: 700; }
.call-hangup {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: #ef4444; color: #fff; font-size: 17px; transition: transform .15s;
}
.call-hangup:hover { transform: scale(1.08); }
.call-transcript {
  height: 300px; overflow-y: auto; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; display: grid; gap: 8px; align-content: start;
  font-size: 14px; line-height: 1.5;
}
.call-transcript p { margin: 0; }
.call-empty { color: var(--muted); font-style: italic; }
.t-user { color: var(--text); }
.t-agent { color: var(--accent); }
.call-note { font-size: 12px; color: var(--muted); text-align: center; }

/* toast de feedback (samples sin claves) */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1a1a1a; border: 1px solid var(--accent); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 1100;
  box-shadow: 0 4px 24px rgba(0,0,0,.5); animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 💬 panel de chat de texto */
.chat-panel {
  position: fixed; right: 20px; bottom: 20px; width: 340px; max-width: calc(100vw - 40px);
  background: #141414; border: 1px solid #2a2a2a; border-radius: 14px; z-index: 800;
  display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,.6); overflow: hidden;
}
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #1a1a1a; border-bottom: 1px solid #2a2a2a; font-weight: 600; font-size: 13px; }
.chat-close { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; }
.chat-body { height: 260px; overflow-y: auto; padding: 12px 14px; font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #2a2a2a; }
.chat-form input { flex: 1; background: #1a1a1a; border: 1px solid #2a2a2a; color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.chat-form .btn { padding: 8px 12px; }

/* estados disabled + botón de descarga */
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.call-download {
  background: none; border: 1px solid #2a2a2a; color: var(--muted); border-radius: 8px;
  width: 34px; height: 34px; font-size: 15px; cursor: pointer; margin-right: 6px;
  transition: border-color .2s, color .2s;
}
.call-download:hover { border-color: var(--accent); color: var(--text); }

/* El atributo hidden debe ganar SIEMPRE (los display:grid/flex de autor lo pisaban y el overlay/chat se veían al cargar) */
[hidden] { display: none !important; }

/* ⏳ estado de tarea asíncrona en el chat */
.t-task { color: var(--muted); font-size: 12.5px; font-style: italic; padding: 6px 10px; margin: 4px 0; border-left: 2px solid var(--accent); background: rgba(255,255,255,.03); border-radius: 6px; }

/* ── Fix Safari/iOS ───────────────────────────────────────────
   1) inputs con font-size >= 16px → sin zoom automático al enfocar
   2) touch-action: manipulation → sin doble-tap zoom ni delay de 300ms
   3) text-size-adjust fijo → sin reflow de texto en landscape/rotación */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
input, select, textarea { font-size: 16px !important; }
button, .card, .btn, a, .chat-close, .call-hangup, .call-download { touch-action: manipulation; }
