/* ============================================================
   demo-stage.css — moldura de demonstração (chrome de dispositivo)
   Envolve o portal (carregado em iframe ?embed=1) num navegador
   (desktop) ou aparelho (telefone), com a barra de controles do
   protótipo. Funciona fora do Claude Design.
   ============================================================ */

.stage {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  min-height: 100vh; overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -12%, var(--green-200), transparent 60%),
    radial-gradient(130% 120% at 92% 8%, color-mix(in srgb, var(--lime-300) 55%, transparent), transparent 55%),
    linear-gradient(180deg, var(--green-50), var(--stone-100) 58%, var(--stone-200));
  font-family: var(--font-body);
}

/* ---- Barra de controles do protótipo (topo) ---- */
.stage-bar {
  flex: none; display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4) var(--space-6) var(--space-3);
  width: 100%; box-sizing: border-box; flex-wrap: wrap;
}
.stage-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0; }
.stage-brand-row { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.stage-brand img { width: 30px; height: 30px; flex: none; display: block; }
.stage-brand-tx { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.stage-brand-tx b {
  font-family: var(--font-heading); font-weight: 700; font-size: var(--text-base);
  color: var(--green-900); letter-spacing: -.01em; white-space: nowrap;
}
.stage-brand-tx span {
  font-family: var(--font-heading); font-size: 11px; font-weight: 600;
  letter-spacing: .04em; color: var(--green-700); white-space: nowrap;
}
.stage-badge {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  margin-left: var(--space-2); padding: 3px 9px; border-radius: var(--radius-pill);
  background: var(--green-700); color: var(--stone-50);
  font-family: var(--font-heading); font-weight: 700; font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase;
}
.stage-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--lime-300); }

/* Botão "voltar ao início" — logo abaixo da marca/badge do protótipo */
.stage-tostart {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 6px 12px 6px 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--green-200); background: var(--green-50);
  color: var(--green-800); font-family: var(--font-heading);
  font-size: var(--text-sm); font-weight: 600; letter-spacing: -.005em;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
.stage-tostart svg { width: 15px; height: 15px; }
.stage-tostart:hover { background: var(--green-100); border-color: var(--green-300); color: var(--green-900); }
.stage-tostart:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

.stage-bar-spacer { flex: 1; }
.stage-controls { display: flex; align-items: center; gap: var(--space-3); flex: none; }

/* ============================================================
   Painel de Ajustes próprio — sheet lateral à direita
   ============================================================ */
.cfg-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 26, 16, .14);
}

.cfg-sheet {
  position: fixed; top: 0; right: 0; z-index: 61;
  width: 392px; max-width: 94vw; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -18px 0 60px -12px rgba(20, 30, 16, .35);
  transform: none;
}

.cfg-hd {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.cfg-hd-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cfg-hd-tx b { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-h4, 1.2rem); color: var(--green-900); }
.cfg-hd-tx span { font-size: var(--text-sm); color: var(--color-text-muted); }
.cfg-close {
  flex: none; width: 34px; height: 34px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text-muted); font-size: 16px; line-height: 1; cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.cfg-close:hover { background: var(--stone-100); color: var(--color-text); }

.cfg-body {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-5);
  scrollbar-width: thin; scrollbar-color: var(--stone-300) transparent;
}
.cfg-body::-webkit-scrollbar { width: 9px; }
.cfg-body::-webkit-scrollbar-thumb { background: var(--stone-300); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }

.cfg-group { display: flex; flex-direction: column; gap: var(--space-2); }
.cfg-group-t {
  margin: 0; font-family: var(--font-heading); font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em; color: var(--green-700);
}
.cfg-group-hint { margin: 0 0 2px; font-size: var(--text-xs); color: var(--color-text-muted); line-height: var(--leading-snug); }

/* switch segmentado (o "bonitinho" do toggle de dispositivo) */
.cfg-seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; padding: 4px;
  border-radius: 14px; background: color-mix(in srgb, var(--stone-200) 50%, transparent);
  border: 1px solid var(--color-border);
}
.cfg-seg--wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
.cfg-seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-width: 0; padding: 9px 10px; border: 0; border-radius: 10px;
  background: transparent; font-family: var(--font-heading); font-weight: 600; font-size: 13px;
  color: var(--color-text-muted); cursor: pointer; white-space: nowrap;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.cfg-seg button svg { width: 15px; height: 15px; flex: none; }
.cfg-seg button:hover { color: var(--green-800); }
.cfg-seg button.on { background: var(--green-700); color: var(--stone-50); box-shadow: 0 1px 2px rgba(30, 33, 24, .25); }

/* stepper vertical selecionável (jornada de cadastro) */
.cfg-stepper { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; }
.cfg-step-btn {
  display: flex; gap: 12px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 0; cursor: pointer; font-family: var(--font-heading); -webkit-tap-highlight-color: transparent;
}
.cfg-step-rail { position: relative; flex: none; width: 26px; display: flex; justify-content: center; }
.cfg-step:not(:last-child) .cfg-step-rail::before {
  content: ""; position: absolute; top: 24px; bottom: -6px; left: 50%; transform: translateX(-50%);
  width: 2px; background: var(--color-border); transition: background var(--dur-fast);
}
.cfg-step.is-done .cfg-step-rail::before { background: var(--green-600); }
.cfg-step-node {
  position: relative; z-index: 1; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--color-border); background: var(--color-surface);
  font-size: 12px; font-weight: 700; color: var(--color-text-muted);
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.cfg-step-node svg { width: 14px; height: 14px; }
.cfg-step.is-done .cfg-step-node { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.cfg-step.is-current .cfg-step-node {
  border-color: var(--green-700); color: var(--green-800);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green-600) 22%, transparent);
}
.cfg-step-tx { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 16px; min-width: 0; }
.cfg-step-tx b { font-size: 13px; font-weight: 600; color: var(--color-text-muted); transition: color var(--dur-fast); }
.cfg-step-tx span { font-size: 11px; color: var(--color-text-faint); line-height: 1.35; }
.cfg-step.is-done .cfg-step-tx b { color: var(--color-text); }
.cfg-step.is-current .cfg-step-tx b { color: var(--green-900); }
.cfg-step-btn:hover .cfg-step-tx b { color: var(--green-800); }
.cfg-step-btn:hover .cfg-step.is-todo .cfg-step-node,
.cfg-step.is-todo .cfg-step-btn:hover .cfg-step-node { border-color: var(--green-300); }

/* swatches de cor da marca */
.cfg-swatches { display: flex; gap: 8px; }
.cfg-swatch {
  width: 46px; height: 38px; border-radius: 10px; border: 2px solid transparent;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform var(--dur-fast), box-shadow var(--dur-fast);
}
.cfg-swatch:hover { transform: translateY(-1px); }
.cfg-swatch.on { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--green-700); }
.cfg-swatch svg { width: 16px; height: 16px; color: #fff; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }

/* toggle (microfone real) */
.cfg-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--color-border);
  background: var(--color-surface); cursor: pointer; width: 100%;
  font-family: var(--font-heading); font-weight: 600; font-size: 13px; color: var(--color-text);
}
.cfg-toggle-sw { flex: none; position: relative; width: 40px; height: 23px; border-radius: 999px; background: var(--stone-300); transition: background var(--dur-fast); }
.cfg-toggle-sw i { position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform var(--dur-fast); }
.cfg-toggle.on .cfg-toggle-sw { background: var(--green-600); }
.cfg-toggle.on .cfg-toggle-sw i { transform: translateX(17px); }

/* botão de ação */
.cfg-btn {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  padding: 10px 16px; border-radius: var(--radius-pill); border: 1px solid var(--color-border-strong);
  background: var(--color-surface); font-family: var(--font-heading); font-weight: 600; font-size: 13px;
  color: var(--color-text-muted); cursor: pointer; transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
.cfg-btn svg { width: 15px; height: 15px; }
.cfg-btn:hover { color: var(--green-800); border-color: var(--green-300); background: var(--green-50); }

@media (max-width: 720px) {
  .cfg-sheet { width: 100vw; max-width: 100vw; }
}

/* segmentado de dispositivo */
.stage-seg {
  display: flex; padding: 3px; border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--stone-0, #fff) 70%, transparent);
  border: 1px solid var(--color-border); box-shadow: var(--shadow-xs);
}
.stage-seg button {
  display: inline-flex; align-items: center; gap: 7px; border: 0; cursor: pointer;
  padding: 7px 14px; border-radius: var(--radius-pill); background: transparent;
  font-family: var(--font-heading); font-weight: 600; font-size: var(--text-sm);
  color: var(--color-text-muted); transition: color var(--dur-fast), background var(--dur-fast);
}
.stage-seg button svg { width: 16px; height: 16px; }
.stage-seg button:hover { color: var(--green-800); }
.stage-seg button.on {
  background: var(--green-700); color: var(--stone-50);
  box-shadow: 0 1px 2px rgba(30,33,24,.25);
}

/* botão Tweaks */
.stage-tweaks {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 16px; border-radius: var(--radius-pill);
  border: 1px solid var(--color-border); background: var(--stone-900); color: var(--stone-50);
  font-family: var(--font-heading); font-weight: 600; font-size: var(--text-sm);
  box-shadow: var(--shadow-sm); transition: transform var(--dur-fast), box-shadow var(--dur-fast), opacity var(--dur-fast);
}
.stage-tweaks svg { width: 16px; height: 16px; }
.stage-tweaks:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stage-tweaks.on { background: var(--green-700); }
.stage-tweaks[disabled] { opacity: .5; cursor: default; transform: none; box-shadow: var(--shadow-xs); }

/* ---- Palco do dispositivo ---- */
.stage-viewport {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  padding: 0 var(--space-4) var(--space-2);
  transition: padding-right var(--dur-base) var(--ease-out);
}

.stage-frame { position: relative; display: flex; flex-direction: column; max-height: 100%; }

/* Com o painel de Ajustes aberto, o aparelho (telefone) é recentralizado no
   espaço livre à esquerda do painel, em vez de ficar escondido atrás dele.
   Reduzimos a área de centragem do viewport (padding‑right = largura do painel). */
@media (min-width: 721px) {
  .stage.is-cfg-open[data-device="telefone"] .stage-viewport {
    padding-right: 392px;
  }
}

/* — modo navegador (desktop): SEM chrome — o app ocupa a área inteira,
   sem moldura de janela (sem barra de URL, sem cantos arredondados). — */
.stage-frame[data-device="desktop"] {
  width: 100%;
  height: 100%;
  background: var(--color-surface);
  border: 0;
  border-radius: 0; overflow: hidden;
  box-shadow: none;
}
.stage-frame[data-device="desktop"] .frame-bar { display: none; }

/* sem chrome no desktop, o palco preenche todo o espaço disponível */
.stage[data-device="desktop"] .stage-viewport { padding: 0; }
.frame-bar {
  flex: none; display: flex; align-items: center; gap: var(--space-3);
  height: 46px; padding: 0 var(--space-4);
  background: linear-gradient(180deg, var(--stone-50), var(--color-surface));
  border-bottom: 1px solid var(--color-border);
}
.frame-dot {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: var(--stone-300); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.frame-omni {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  max-width: 520px; margin: 0 auto; height: 30px; padding: 0 14px;
  border-radius: var(--radius-pill); background: var(--stone-100);
  border: 1px solid var(--color-border);
  font-family: var(--font-body); font-size: var(--text-sm); color: var(--color-text-muted);
}
.frame-omni svg { width: 13px; height: 13px; flex: none; color: var(--green-600); }
.frame-omni span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame-omni b { color: var(--color-text); font-weight: 500; font-family: inherit; }
.frame-bar-tail { width: 36px; flex: none; display: flex; justify-content: flex-end; }
.frame-bar-tail svg { width: 16px; height: 16px; color: var(--color-text-faint); }

/* notch só aparece no telefone */
.frame-notch { display: none; }

/* host = "tela" do dispositivo: rola por dentro e emula um viewport.
   --app-vh é medido por JS (altura útil) p/ neutralizar os 100vh do portal. */
.frame-screen-wrap {
  flex: 1; min-height: 0; position: relative; background: var(--color-bg);
  overflow-y: auto; overflow-x: hidden;
  --app-vh: 100%;
  /* query container: o portal responde à largura da "tela" do dispositivo
     (não do viewport real). transform: vira bloco de contagem p/ os overlays
     position:fixed do portal (drawer, modais, console) ficarem contidos na
     moldura, em vez de vazarem para a janela inteira. */
  container: portal / inline-size;
  transform: translateZ(0);
  scrollbar-width: thin; scrollbar-color: var(--stone-300) transparent;
}
.frame-screen-wrap::-webkit-scrollbar { width: 9px; }
.frame-screen-wrap::-webkit-scrollbar-thumb { background: var(--stone-300); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }

/* o portal preenche a tela e rola por dentro dela, não pela janela real */
.stage-host > .root-app { min-height: var(--app-vh); }
.stage-host .app-shell { min-height: var(--app-vh); }
.stage-host .app-sidebar { height: var(--app-vh); }
.stage-host .login-screen { min-height: var(--app-vh); }
.stage-host .onb-screen { min-height: var(--app-vh); }
.stage-host .chat { height: calc(var(--app-vh) - 128px); }
body[data-density="compacta"] .stage-host .chat { height: calc(var(--app-vh) - 112px); }

/* — modo telefone — */
.stage-frame[data-device="telefone"] {
  height: min(900px, calc(100vh - 124px));
  aspect-ratio: 23 / 50;            /* proporção de iPhone (incluindo a moldura) */
  width: auto; max-width: calc(100vw - 24px);
  padding: 13px; background: var(--stone-900);
  border-radius: 50px; overflow: visible;
  box-shadow: 0 0 0 2px var(--stone-800), 0 0 0 7px color-mix(in srgb, var(--stone-900) 55%, transparent),
    var(--shadow-lg), 0 44px 90px -44px rgba(30,40,24,.55);
}
.stage-frame[data-device="telefone"] .frame-bar { display: none; }
.stage-frame[data-device="telefone"] .frame-notch {
  display: block; position: absolute; top: 13px; left: 50%; transform: translateX(-50%);
  width: 132px; height: 30px; background: var(--stone-900); border-radius: 0 0 18px 18px;
  z-index: 4;
}
.stage-frame[data-device="telefone"] .frame-screen-wrap {
  border-radius: 38px; overflow: hidden; overflow-y: auto;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.6);
}

/* ---- Rodapé do palco ---- */
.stage-foot {
  flex: none; display: flex; align-items: center; justify-content: flex-start; gap: var(--space-5);
  padding: var(--space-2) var(--space-6) var(--space-5); flex-wrap: wrap;
}
@media (max-width: 720px) {
  .stage-foot { justify-content: center; }
}
.stage-hint {
  display: inline-flex; align-items: center; gap: 8px; margin: 0;
  font-family: var(--font-heading); font-size: var(--text-sm); font-weight: 600;
  color: var(--green-800);
}
.stage-hint svg { width: 16px; height: 16px; color: var(--green-600); flex: none; }
.stage-hint b { color: var(--green-900); }
.stage-dot-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--green-300); }
.stage-restart {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 7px 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-strong); background: color-mix(in srgb, var(--stone-0, #fff) 65%, transparent);
  font-family: var(--font-heading); font-weight: 600; font-size: var(--text-sm); color: var(--color-text-muted);
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
.stage-restart svg { width: 15px; height: 15px; }
.stage-restart:hover { color: var(--green-800); border-color: var(--green-300); background: var(--green-50); }

@media (max-width: 720px) {
  .stage-bar { flex-wrap: wrap; gap: var(--space-3); padding-bottom: var(--space-2); }
  .stage-bar-spacer { display: none; }
  .stage-controls { width: 100%; justify-content: space-between; }
  .stage-frame[data-device="desktop"] { height: 100%; }
  .stage-foot { gap: var(--space-3); }
  .stage-dot-sep { display: none; }
}

/* ============================================================
   Telefone REAL (viewport estreito) — sem moldura: o app ocupa a tela
   inteira na sua versão de telefone, e a barra superior (com o botão
   Ajustes) fica fixa no topo, sempre acessível.
   ============================================================ */
.stage.is-real-phone { background: var(--color-bg); }

/* barra superior compacta, numa única linha, fixa (não rola junto) */
.stage.is-real-phone .stage-bar {
  flex-wrap: nowrap; gap: var(--space-3);
  padding: 10px 14px; background: var(--color-surface);
  border-bottom: 1px solid var(--color-border); box-shadow: var(--shadow-xs);
}
.stage.is-real-phone .stage-bar-spacer { display: block; flex: 1; }
.stage.is-real-phone .stage-controls { width: auto; }
.stage.is-real-phone .stage-badge { display: none; }
.stage.is-real-phone .stage-tostart { display: none; }
.stage.is-real-phone .stage-brand { flex-direction: row; align-items: center; gap: var(--space-3); }
.stage.is-real-phone .stage-brand-tx span { display: none; }
.stage.is-real-phone .stage-brand img { width: 26px; height: 26px; }
.stage.is-real-phone .stage-tweaks { padding: 8px 14px; }

/* viewport sem respiro; moldura vira tela cheia */
.stage.is-real-phone .stage-viewport { padding: 0; }
.stage.is-real-phone .stage-frame[data-device] {
  width: 100%; height: 100%; max-width: none;
  aspect-ratio: auto; padding: 0;
  background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
.stage.is-real-phone .frame-bar,
.stage.is-real-phone .frame-notch { display: none; }
.stage.is-real-phone .frame-screen-wrap { border-radius: 0; box-shadow: none; }
/* foot vira barra inferior fixa só com o botão Ajustes (única chrome restante) */
.stage.is-real-phone .stage-foot {
  display: flex; flex: none; justify-content: center; gap: 0;
  padding: 8px 14px; background: var(--color-surface);
  border-top: 1px solid var(--color-border); box-shadow: var(--shadow-xs);
}
.stage.is-real-phone .stage-hint,
.stage.is-real-phone .stage-restart,
.stage.is-real-phone .stage-dot-sep { display: none; }
