/* ---------- Builder do chatbot — complementos (sem box-shadow!) ---------- */

/* Nome inline no cabeçalho */
.bot-name-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bot-name-input { width: min(360px, 100%); font-weight: 700; font-size: 16px; }

/* Cartão raiz destacado */
.bot-card--root { background: #fbfefc; }
.bot-card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.bot-start-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--green-tonal); color: var(--green-strong);
  border: 1px solid var(--green);
  border-radius: var(--r-full);
  padding: 4px 13px;
  font-size: 12.5px; font-weight: 700;
}

/* Prefixo "quando tocar em:" do rótulo da opção */
.bot-when { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bot-when__pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-tonal); color: var(--primary);
  border-radius: var(--r-full);
  padding: 5px 12px;
  font-size: 12.5px; font-weight: 700;
  white-space: nowrap;
}
.bot-when__pill svg { width: 13px; height: 13px; }
.bot-when .input { flex: 1; min-width: 150px; width: auto; }

/* Link que revela as variações da mensagem */
.bot-reveal {
  display: inline-flex; align-items: center;
  color: var(--primary);
  font-size: 13px; font-weight: 650;
  cursor: pointer;
  user-select: none;
}
.bot-reveal:hover { text-decoration: underline; }
.bot-reveal input { position: absolute; opacity: 0; pointer-events: none; }

/* Respiro dentro dos cartões */
.bot-card form .field { margin-bottom: 12px; }
.bot-card form { margin-bottom: 2px; }
.bot-tree > .bot-step > .bot-card { margin-bottom: 4px; }

/* Coluna do celular: sticky no wrapper para a legenda acompanhar */
#bot-phone { position: sticky; top: 24px; }
#bot-phone .phone-wrap { position: static; }
.bot-phone-legend { text-align: center; font-size: 12.5px; color: var(--text-2); margin-top: 10px; }
@media (max-width: 1100px) { .split #bot-phone { display: none; } }

/* ---------- Canvas de fluxo (caixas + conectores + drag) ---------- */

.flow-canvas {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  /* grade pontilhada de canvas de fluxo */
  background-color: #fafbfc;
  background-image: radial-gradient(var(--border-strong) 1.1px, transparent 1.1px);
  background-size: 22px 22px;
  padding: 28px 20px 40px;
  overflow-x: auto;
}
.flow-canvas__inner { min-width: max-content; margin: 0 auto; width: fit-content; }

.flow-node { display: flex; flex-direction: column; align-items: center; }

.flow-card {
  width: 340px;
  background: var(--bg);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 14px;
  transition: border-color .15s ease;
}
.flow-card:focus-within { border-color: var(--primary); }
.flow-card--root { border-color: var(--green); background: #fbfefc; }

.flow-card__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.flow-btn-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--primary-tonal); color: var(--primary);
  border-radius: var(--r-full);
  padding: 4px 11px;
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
  flex: none;
}
.flow-btn-pill svg { width: 12px; height: 12px; }
.flow-option-input { flex: 1; min-width: 0; font-weight: 650; }

.flow-body { resize: vertical; }
.flow-card .field { margin-bottom: 10px; }
.flow-card .var-chips { margin-top: 6px; }

.flow-card__foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.flow-card__push { flex: 1; }

/* conector: pai → trilho dos filhos */
.flow-stub { width: 2px; height: 22px; background: var(--border-strong); }

.flow-children { display: flex; align-items: flex-start; gap: 22px; }

.flow-branch { position: relative; padding-top: 34px; display: flex; flex-direction: column; align-items: center; }
/* linha vertical de cada ramo */
.flow-branch::before {
  content: "";
  position: absolute; top: 0; left: 50%;
  transform: translateX(-1px);
  width: 2px; height: 12px;
  background: var(--border-strong);
}
/* trilho horizontal (metades nos extremos) */
.flow-branch::after {
  content: "";
  position: absolute; top: 0; left: -11px; right: -11px;
  height: 2px;
  background: var(--border-strong);
}
.flow-branch:first-child::after { left: 50%; }
.flow-branch:last-child::after { right: 50%; }
.flow-branch:only-child::after { display: none; }

/* pill do botão = etiqueta do conector + alça de drag */
.flow-branch__pill {
  position: absolute; top: 6px; left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 300px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--bg);
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: var(--r-full);
  padding: 3px 12px;
  font-size: 12.5px; font-weight: 700;
  cursor: grab;
  user-select: none;
}
.flow-branch__pill:active { cursor: grabbing; }
.flow-branch__grip { opacity: .55; font-size: 11px; letter-spacing: -1px; }

.flow-branch--dragging { opacity: .45; }
.flow-branch--dragging .flow-card { border-style: dashed; }

.flow-config-note { display: flex; align-items: end; padding-bottom: 8px; }

@media (max-width: 760px) {
  .flow-card { width: min(320px, 84vw); }
  .flow-children { gap: 14px; }
}

/* ---- Navegação do canvas: zoom, pan e scroll sempre visível ---- */

/* Fluxos grandes rolam DENTRO da caixa (não estouram a página) */
.flow-canvas {
  max-height: 72vh;
  overflow: auto;
  cursor: grab;
  scrollbar-width: thin;                            /* Firefox */
  scrollbar-color: var(--border-strong) transparent;
}
.flow-canvas--panning { cursor: grabbing; user-select: none; }

/* Scrollbar aparente e elegante (WebKit) */
.flow-canvas::-webkit-scrollbar { width: 11px; height: 11px; }
.flow-canvas::-webkit-scrollbar-track { background: transparent; }
.flow-canvas::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 3px solid #fafbfc; /* mesma cor do fundo do canvas */
}
.flow-canvas::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
.flow-canvas::-webkit-scrollbar-corner { background: transparent; }

/* Zoom via CSS var no wrapper (sobrevive ao replace do turbo_stream) */
.flow-canvas__inner {
  transform: scale(var(--flow-zoom, 1));
  transform-origin: top center;
}

.flow-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flow-toolbar__hint { margin-right: 6px; }
.flow-zoom-btn {
  min-width: 30px; height: 30px;
  padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  background: var(--bg);
  font-size: 15px; font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.flow-zoom-btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.flow-zoom-btn--fit { font-size: 12.5px; font-weight: 650; }
.flow-zoom-label {
  min-width: 44px;
  text-align: center;
  font-size: 12.5px; font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
