/* =============================================================
   Zap DS — design system do Zap MCP
   Tokens, base e componentes compartilhados por site, login,
   autorização, documentação e painel.
   ============================================================= */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,650;12..96,800&family=Instrument+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* marca */
  --ink: #0e2a22;          /* mata: texto forte, superfícies escuras */
  --ink-2: #1b4538;
  --ink-3: #2c5c4d;
  --volt: #ffd43b;         /* raio: destaque, ação em fundo escuro */
  --volt-2: #ffe27a;
  --volt-soft: #fff6d1;
  --volt-ink: #4a3b00;
  --leaf: #1f9d5a;         /* folha: conectado, sucesso */
  --leaf-ink: #136b3c;
  --leaf-soft: #e2f3e9;
  --danger: #c2412d;       /* brasa: erro, destrutivo */
  --danger-ink: #8a2a1b;
  --danger-soft: #fbe9e5;

  /* superfícies e texto */
  --bg: #f4f6ef;           /* papel */
  --surface: #ffffff;
  --surface-2: #f9faf6;
  --surface-3: #ebefe6;
  --line: #e0e6dc;
  --line-strong: #cdd6c9;
  --fg: #12221c;
  --fg-2: #3a4943;
  --fg-3: #67756f;
  --hover: #f0f3ec;
  --sel: #e7ece3;
  --on-ink: #e6efe9;
  --on-ink-2: #a8c1b5;
  --on-ink-line: rgba(255, 255, 255, .12);

  /* tipografia */
  --display: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --t-12: 12px; --t-13: 13px; --t-14: 14px; --t-16: 16px; --t-18: 18px; --t-22: 22px;
  --t-28: 28px; --t-36: clamp(30px, 3.4vw, 36px); --t-48: clamp(36px, 4.6vw, 48px);
  --t-64: clamp(42px, 6vw, 64px); --t-84: clamp(48px, 7.4vw, 84px);

  /* forma */
  --r-xs: 6px; --r-s: 10px; --r-m: 16px; --r-l: 28px; --r-pill: 999px;
  --bubble: 22px 22px 22px 6px;          /* assinatura: balão de conversa */
  --bubble-r: 22px 22px 6px 22px;

  /* profundidade */
  --shadow-1: 0 1px 2px rgba(14, 42, 34, .06);
  --shadow-2: 0 1px 2px rgba(14, 42, 34, .05), 0 10px 28px -14px rgba(14, 42, 34, .22);
  --shadow-3: 0 40px 80px -36px rgba(14, 42, 34, .55);

  --gutter: clamp(16px, 4vw, 40px);
  --focus: #2f7cf6;
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font: 16px/1.55 var(--sans); color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -.025em; line-height: 1.08; margin: 0; color: var(--ink); text-wrap: balance; }
p { margin: 0; }
code, pre, kbd { font-family: var(--mono); }
::selection { background: var(--volt); color: var(--ink); }
.muted { color: var(--fg-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack { display: grid; gap: 16px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); flex: none; }
.logo-mark { width: var(--logo, 30px); height: var(--logo, 30px); flex: none; }
.logo-mark .lb { fill: var(--ink); }
.logo-mark .lz { fill: var(--volt); }
.logo-word { font: 800 calc(var(--logo, 30px) * .74)/1 var(--display); letter-spacing: -.045em; display: inline-flex; align-items: baseline; gap: 5px; }
.logo-word b { font: 600 calc(var(--logo, 30px) * .4)/1 var(--mono); letter-spacing: 0; color: var(--fg-3); }
.logo.on-ink, .on-ink .logo { color: #fff; }
.logo.on-ink .lb, .on-ink .logo .lb { fill: var(--volt); }
.logo.on-ink .lz, .on-ink .logo .lz { fill: var(--ink); }
.logo.on-ink .logo-word b, .on-ink .logo .logo-word b { color: var(--on-ink-2); }

/* ---------- botões ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: var(--r-pill); border: 1px solid transparent; font-weight: 600; font-size: 15px; line-height: 1; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .1s; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button.primary { background: var(--ink); color: #fff; box-shadow: inset 0 -1px 0 rgba(0,0,0,.25); }
.button.primary:hover { background: var(--ink-2); }
.button.volt { background: var(--volt); color: var(--ink); box-shadow: inset 0 -2px 0 rgba(74, 59, 0, .18); }
.button.volt:hover { background: var(--volt-2); }
.button.secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); box-shadow: var(--shadow-1); }
.button.secondary:hover { background: var(--hover); }
.button.ghost { background: transparent; color: inherit; border-color: currentColor; }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:hover { background: #a93623; }
.button.small { min-height: 34px; padding: 0 14px; font-size: 13.5px; }
.button.large { min-height: 54px; padding: 0 28px; font-size: 16.5px; }
.button.wide { width: 100%; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: var(--r-s); border: 0; background: transparent; color: var(--fg-3); flex: none; transition: background .15s, color .15s; }
.icon-button:hover { background: var(--hover); color: var(--ink); }
.icon-button.danger-hover:hover { background: var(--danger-soft); color: var(--danger); }
.text-button { border: 0; background: none; padding: 0; color: var(--ink-2); font-weight: 600; font-size: inherit; display: inline-flex; gap: 6px; align-items: center; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.text-button:hover { text-decoration-color: currentColor; }

/* ---------- formulários ---------- */
label { display: grid; gap: 7px; font-size: 14px; font-weight: 600; color: var(--ink); }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; min-height: 44px; padding: 10px 13px; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: var(--surface); font-size: 15px; font-weight: 400; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #98a39d; }
input:hover:not(:focus):not([readonly]), select:hover:not(:focus) { border-color: #b7c2b3; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 4px rgba(44, 92, 77, .14); }
input[readonly] { background: var(--surface-2); font-family: var(--mono); font-size: 13px; color: var(--fg-2); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; flex: none; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
legend { font-weight: 600; font-size: 14px; color: var(--ink); margin-bottom: 8px; padding: 0; }
.check-label { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: var(--surface); font-weight: 400; cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: #b7c2b3; }
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--surface-2); }
.choice input { margin-top: 2px; }
.choice strong { display: block; font-weight: 600; color: var(--ink); }
.choice small { display: block; color: var(--fg-3); font-size: 13px; margin-top: 2px; }
.form-error { padding: 11px 14px; border-radius: var(--r-s); background: var(--danger-soft); color: var(--danger-ink); font-size: 14px; }
.field-hint { font-size: 13px; color: var(--fg-3); font-weight: 400; }
.copy-field { display: flex; gap: 6px; align-items: center; }
.copy-field input { flex: 1; min-width: 0; }
.copy-field .icon-button { width: 44px; height: 44px; border: 1px solid var(--line-strong); background: var(--surface); }
.oauth-choices { display: grid; gap: 6px; padding-left: 30px; }
.oauth-choices .check-label { padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); }
.oauth-choices small { color: var(--fg-3); margin-left: auto; font-weight: 400; }

/* ---------- código ---------- */
.code { position: relative; border-radius: var(--r-m); background: var(--ink); color: var(--on-ink); overflow: hidden; }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 8px 7px 16px; font-size: 13px; color: var(--on-ink-2); border-bottom: 1px solid var(--on-ink-line); }
.code-head .copy { border: 0; background: rgba(255,255,255,.08); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.code-head .copy:hover { background: rgba(255,255,255,.16); }
.code pre { margin: 0; padding: 16px; overflow-x: auto; font-size: 13px; line-height: 1.65; white-space: pre; }
.code .tk { color: var(--volt); }
code.inline { font-size: .88em; padding: 2px 6px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--ink); word-break: break-word; }

/* ---------- etiquetas e status ---------- */
.status-badge { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--fg-3); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status-badge > span { width: 7px; height: 7px; border-radius: 50%; background: #9aa8a1; }
.status-badge.connected { background: var(--leaf-soft); color: var(--leaf-ink); }
.status-badge.connected > span { background: var(--leaf); box-shadow: 0 0 0 3px rgba(31,157,90,.2); }
.status-badge.failed { background: var(--danger-soft); color: var(--danger-ink); }
.status-badge.failed > span { background: var(--danger); }
.status-badge.muted { background: var(--surface-2); color: var(--fg-3); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.volt { background: var(--volt); color: var(--ink); }
.tag.leaf { background: var(--leaf-soft); color: var(--leaf-ink); }
.notice { padding: 12px 14px; border-radius: var(--r-s); background: var(--volt-soft); color: var(--volt-ink); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice svg { flex: none; margin-top: 2px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-2); }

/* ---------- logos de agentes ---------- */
.agent-logo { width: var(--s); height: var(--s); border-radius: calc(var(--s) * .28); display: inline-grid; place-items: center; flex: none; background: #fff; border: 1px solid var(--line); color: var(--ink); font: 700 calc(var(--s) * .34)/1 var(--display); overflow: hidden; }
.agent-logo img { width: 64%; height: 64%; object-fit: contain; }
.monogram { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--ink); color: var(--volt); font: 700 14px/1 var(--display); }
.agent-picker { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.agent-picker button { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink); }
.agent-picker button[aria-pressed=true] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.agent-picker .agent-logo { border-radius: 50%; }

/* ---------- balão (assinatura) ---------- */
.bubble { border-radius: var(--bubble); }
.bubble.right { border-radius: var(--bubble-r); }

/* ---------- modais ---------- */
.modal { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: var(--r-l); background: var(--surface); color: var(--fg); box-shadow: var(--shadow-3); overflow: auto; }
.modal::backdrop { background: rgba(14, 42, 34, .5); backdrop-filter: blur(3px); }
.modal[open] { animation: rise .22s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.modal-inner { padding: 26px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.modal-inner > * { min-width: 0; }
.modal-inner:focus { outline: none; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.modal-head h2 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.modal-head p { color: var(--fg-3); margin-top: 4px; font-size: 14.5px; }
.modal-head .icon-button { margin: -6px -8px 0 0; }
.modal.compact { width: min(420px, calc(100vw - 32px)); }
.modal.modal-wide { width: min(640px, calc(100vw - 32px)); }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 12px; background: var(--surface-3); gap: 4px; }
.segmented button { border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--fg-3); display: inline-flex; gap: 8px; justify-content: center; align-items: center; }
.segmented button[aria-selected=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.snippet-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.snippet-tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-pill); padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--fg-3); }
.snippet-tabs button[aria-selected=true] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* conexão de WhatsApp */
.qr-box { aspect-ratio: 1; width: min(280px, 100%); justify-self: center; display: grid; place-items: center; text-align: center; padding: 14px; border-radius: var(--r-m); border: 1px solid var(--line); background: #fff; color: var(--fg-3); font-size: 14px; }
.qr-box img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.pair-code { display: flex; justify-content: center; gap: 6px; font: 700 clamp(26px, 8vw, 36px)/1 var(--mono); color: var(--ink); padding: 22px 10px; border-radius: var(--r-m); background: var(--surface-2); border: 1px solid var(--line); letter-spacing: .04em; }
.pair-code span:nth-child(5) { margin-left: 14px; }
.how { margin: 0; padding: 0; list-style: none; counter-reset: h; display: grid; gap: 10px; font-size: 15px; }
.how li { counter-increment: h; display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: baseline; }
.how li::before { content: counter(h); width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font: 700 12px/1 var(--sans); color: var(--ink); }
.how strong { color: var(--ink); }
.success { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 18px 0; }
.success .row-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--leaf); color: #fff; display: grid; place-items: center; }
.qr-status { text-align: center; font-size: 14px; color: var(--fg-3); }
.loader { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .modal { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r-l) var(--r-l) 0 0; }
  .modal.compact, .modal.modal-wide { width: 100vw; }
  .modal[open] { animation: sheet .26s ease; }
  .modal-inner { padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .confirm-actions .button { flex: 1; }
  .oauth-choices { padding-left: 0; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .4; } }
