﻿:root {
  --verde: #25d366;
  --verde-escuro: #128c7e;
  --cinza: #667781;
  --fundo: #f0f2f5;
  --card: #ffffff;
  --borda: #e0e0e0;
  --texto: #111b21;
  --erro: #d93025;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  padding-bottom: 90px;
}

header {
  background: var(--verde-escuro);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
header h1 { font-size: 18px; margin: 0; }
header small { opacity: 0.85; }

.badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.badge-conectado { background: var(--verde); color: #fff; }
.badge-qr { background: #ffb300; color: #000; }
.badge-autenticado { background: #42a5f5; color: #fff; }
.badge-desconectado { background: var(--erro); color: #fff; }
.badge-desconhecido, .badge-iniciando { background: #9e9e9e; color: #fff; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #fff;
  padding: 8px 20px 0;
  border-bottom: 1px solid var(--borda);
  position: sticky;
  top: 0;
  z-index: 5;
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  color: var(--cinza);
}
.tab-btn.active {
  color: var(--verde-escuro);
  border-bottom-color: var(--verde);
  font-weight: 600;
}

main { padding: 20px; max-width: 760px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.aba-explica {
  background: #eef7f4;
  border-left: 4px solid var(--verde);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: #2c4a43;
  margin: 0 0 18px;
  line-height: 1.5;
}
.aba-explica code { background: #dcefe6; }

h2 { font-size: 18px; margin-top: 0; }
h3 { font-size: 15px; color: var(--cinza); }

.card {
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 14px;
  margin-bottom: 12px;
  font-weight: 500;
}
input[type="text"], input[type="number"], textarea {
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
textarea { resize: vertical; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.switch-row input { width: auto; margin: 0; }

.muted { color: var(--cinza); }
.small { font-size: 12.5px; }
code {
  background: #eef1f3;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

.btn-primary {
  background: var(--verde);
  color: #fff;
  border: none;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--verde-escuro); }
.btn-secondary {
  background: #fff;
  color: var(--verde-escuro);
  border: 1px solid var(--verde);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn-remove {
  background: transparent;
  border: none;
  color: var(--erro);
  cursor: pointer;
  font-size: 13px;
}

.save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--borda);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}
.msg { font-size: 14px; }
.msg.ok { color: var(--verde-escuro); }
.msg.erro { color: var(--erro); }

/* Conexao */
.conexao-card { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.qr-area img { width: 260px; height: 260px; border-radius: 8px; }
.qr-area { text-align: center; }

/* Blocos dinamicos (FAQ, opcoes) */
.item-bloco {
  background: var(--card);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.item-bloco .linha-topo {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Area de submenu aninhada */
.op-submenu {
  margin-top: 8px;
  padding: 10px 12px;
  border-left: 3px solid var(--verde);
  background: #f4faf7;
  border-radius: 6px;
}
.op-submenu-opcoes { margin-bottom: 8px; }

/* Area de fluxo de perguntas */
.op-fluxo {
  margin-top: 8px;
  padding: 10px 12px;
  border-left: 3px solid #ffb300;
  background: #fff9ec;
  border-radius: 6px;
}
.etapa-item {
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.etapa-item.arrastando { opacity: 0.5; border-style: dashed; }
.drag-handle {
  cursor: grab;
  color: var(--cinza);
  font-size: 16px;
  margin-right: 8px;
  user-select: none;
}
.etapa-escolha {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid #42a5f5;
  background: #f1f8fe;
  border-radius: 6px;
}
.etapa-opcao-item {
  background: #fff;
  border: 1px dashed #90caf9;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
}

/* Organograma (preview em arvore do fluxo) */
.op-fluxo-preview { margin-top: 10px; }
.org-arvore {
  background: #fafafa;
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
}
.org-no {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin: 4px 0;
  border: 1px solid var(--borda);
  background: #fff;
  position: relative;
}
.org-inicio { background: var(--verde); color: #fff; border-color: var(--verde); }
.org-fim { background: #455a64; color: #fff; border-color: #455a64; }
.org-pergunta { background: #e3f2fd; border-color: #90caf9; }
.org-escolha { background: #fff3e0; border-color: #ffb74d; font-weight: 600; }
.org-vazio { background: #f5f5f5; color: var(--cinza); font-style: italic; }
/* linha vertical conectando os nos em sequencia */
.org-arvore > .org-no::before,
.org-ramo > .org-no::before { content: none; }
.org-arvore .org-no { display: block; width: fit-content; }
.org-ramos {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin: 4px 0 4px 20px;
  padding-left: 14px;
  border-left: 2px dashed #ffb74d;
}
.org-ramo {
  flex: 1;
  min-width: 180px;
  background: #fffdf7;
  border: 1px solid #ffe0b2;
  border-radius: 8px;
  padding: 8px 10px;
}
.org-ramo-rotulo {
  font-size: 12.5px;
  font-weight: 600;
  color: #e65100;
  margin-bottom: 4px;
}

.horario-dias { margin-bottom: 12px; }
.dia-linha {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}
.dia-linha .dia-nome { width: 110px; }
.dia-linha input[type="time"] { padding: 6px; border: 1px solid var(--borda); border-radius: 6px; }
.dia-linha input[disabled] { opacity: 0.4; }

.conversa-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

/* Seletor de modo de conexao */
.modo-seletor { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.modo-opcao {
  flex: 1;
  min-width: 240px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 2px solid var(--borda);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  margin: 0;
}
.modo-opcao input { margin-top: 3px; }
.modo-opcao p { margin: 4px 0 0; }

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
}
.tag-free { background: #e6f4ea; color: #137333; }
.tag-pro { background: #e8f0fe; color: #1a56db; }

.tabela-comparativa {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-top: 8px;
}
.tabela-comparativa th, .tabela-comparativa td {
  border: 1px solid var(--borda);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.tabela-comparativa thead th { background: #f7f9fa; }
.tabela-comparativa td:first-child { font-weight: 600; color: var(--cinza); width: 140px; }

.webhook-box {
  background: #f7f9fa;
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
}
.webhook-box code { display: inline-block; margin: 4px 0; word-break: break-all; }

.aviso-banimento {
  display: none;
}

/* Tooltip do asterisco (risco de bloqueio) */
.info-tip {
  position: relative;
  color: var(--verde-escuro);
  font-weight: 700;
  cursor: help;
  margin-left: 2px;
}
.info-tip .tip-conteudo {
  display: none;
  position: absolute;
  left: 0;
  top: 140%;
  width: 280px;
  background: #fff;
  color: var(--texto);
  border: 1px solid var(--borda);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 400;
  z-index: 20;
  line-height: 1.4;
}
.info-tip:hover .tip-conteudo,
.info-tip:focus .tip-conteudo {
  display: block;
}
.info-tip .tip-conteudo ul { margin: 6px 0 4px; padding-left: 18px; }
.info-tip .tip-conteudo li { margin-bottom: 3px; }

/* ========== Tela de login (fundo PNG limpo + conteudo escrito por cima) ========== */
.auth-overlay {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between;
  background: url('/login-fundo.png') center top / cover no-repeat;
  background-color: #0e3a2f;
  font-family: 'Segoe UI', 'Inter', 'Manrope', system-ui, sans-serif;
}

/* Lado esquerdo: apresentacao na faixa escura livre (abaixo do logo do fundo). */
.auth-left {
  flex: 0 1 30%; max-width: 30%;
  display: flex; flex-direction: column; gap: 16px;
  padding: 0 24px 40px 60px; color: #eafff4;
}
.auth-hero-title { font-size: clamp(22px, 2vw, 34px); line-height: 1.2; margin: 0; font-weight: 800; letter-spacing: -.5px; color: #fff; }
.auth-hero-title span { color: #25d366; }
.auth-hero-desc { color: #d3efe2; font-size: clamp(13px, 1vw, 15px); line-height: 1.55; margin: 0; }
.auth-benefits { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.auth-benefits li { display: flex; align-items: center; gap: 11px; font-size: clamp(12.5px, .95vw, 14.5px); color: #eafff4; font-weight: 600; }
.auth-benefits .b-icon {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: rgba(37,211,102,.18); border: 1px solid rgba(37,211,102,.45); font-size: 15px;
}

/* Lado direito: card de login sobre o espaco livre da arte. */
.auth-right { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; padding: 40px 72px 40px 40px; }
.auth-card {
  background: #fff; border-radius: 20px; padding: 36px 34px;
  width: 100%; max-width: 410px; box-shadow: 0 22px 60px rgba(0,0,0,.28);
  display: flex; flex-direction: column;
}
.auth-tabs { display: flex; gap: 6px; margin-bottom: 20px; background: #eef4f1; padding: 5px; border-radius: 10px; }
.auth-tab { flex: 1; padding: 10px; border: none; border-radius: 7px; cursor: pointer; background: transparent; color: #4a5c54; font-weight: 700; font-size: 14px; transition: all .15s; }
.auth-tab.active { background: #fff; color: #0e8a46; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-title { margin: 0; font-size: 23px; color: #12302a; font-weight: 800; }
.auth-subtitle { margin: -5px 0 4px; font-size: 13.5px; color: #6b7d75; line-height: 1.5; }
.auth-form > label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 700; color: #33443d; }
.input-ic { position: relative; display: block; }
.input-ic .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .55; }
.input-ic input {
  width: 100%; box-sizing: border-box; padding: 13px 14px 13px 40px;
  border: 1px solid #d6e2db; border-radius: 10px; font-size: 15px; background: #fbfdfc;
}
.input-ic input:focus { outline: none; border-color: #25d366; box-shadow: 0 0 0 3px rgba(37,211,102,.18); background: #fff; }
.btn-entrar {
  margin-top: 6px; padding: 14px; font-size: 16px; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #25d366, #0ea65a); border: none; border-radius: 10px;
  box-shadow: 0 6px 16px rgba(37,211,102,.35); transition: transform .1s, box-shadow .15s;
}
.btn-entrar:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(37,211,102,.45); }
#authMsg { margin: 10px 0 0; font-size: 13px; text-align: center; }
.auth-cta { text-align: center; font-size: 13.5px; color: #6b7d75; margin: 14px 0 0; }
.link-verde { color: #0e8a46; font-weight: 700; text-decoration: none; }
.link-verde:hover { text-decoration: underline; }

.header-dir { display: flex; align-items: center; gap: 12px; }

/* Balão flutuante do WhatsApp na tela de login */
.wa-flutuante {
  position: absolute; right: 26px; bottom: 26px; z-index: 1200;
  display: inline-flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, #25d366, #0ea65a); color: #fff;
  padding: 13px 20px; border-radius: 30px; text-decoration: none; font-weight: 700; font-size: 15px;
  box-shadow: 0 8px 24px rgba(37,211,102,.5); transition: transform .15s, box-shadow .2s;
  animation: wa-pulse 2.4s infinite;
}
.wa-flutuante:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 12px 30px rgba(37,211,102,.6); }
.wa-flutuante .wa-ic { font-size: 20px; }
@keyframes wa-pulse {
  0%   { box-shadow: 0 8px 24px rgba(37,211,102,.5), 0 0 0 0 rgba(37,211,102,.5); }
  70%  { box-shadow: 0 8px 24px rgba(37,211,102,.5), 0 0 0 14px rgba(37,211,102,0); }
  100% { box-shadow: 0 8px 24px rgba(37,211,102,.5), 0 0 0 0 rgba(37,211,102,0); }
}
@media (max-width: 600px) {
  .wa-flutuante .wa-txt { display: none; }
  .wa-flutuante { padding: 15px; border-radius: 50%; }
}

/* O balão no painel é fixo na viewport (acompanha a rolagem). */
.wa-painel { position: fixed; }
/* Quando a barra "Salvar configurações" aparece, sobe o balão para não cobri-la. */
body.com-savebar .wa-painel { bottom: 82px; }

/* Faixa de ajuda / pedir função (sempre visível no topo do painel) */
.faixa-ajuda {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 0; padding: 12px 20px;
  background: linear-gradient(135deg, #e8fbef, #d6f7e2);
  border-bottom: 1px solid #b6ecca; color: #0e5a36; font-size: 14px;
}
.faixa-ajuda .fa-ic { font-size: 20px; flex: none; }
.faixa-ajuda .fa-txt { flex: 1 1 320px; line-height: 1.4; }
.faixa-ajuda .fa-btn {
  flex: none; background: linear-gradient(135deg, #25d366, #0ea65a); color: #fff;
  text-decoration: none; font-weight: 700; font-size: 13.5px; padding: 9px 16px; border-radius: 8px;
  box-shadow: 0 4px 12px rgba(37,211,102,.35); white-space: nowrap;
}
.faixa-ajuda .fa-btn:hover { filter: brightness(1.05); }
.faixa-ajuda button.fa-btn { border: none; cursor: pointer; }

/* Modal de pedido de função */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1500; background: rgba(6,40,28,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  position: relative; background: #fff; border-radius: 16px; padding: 30px 28px;
  width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.modal-fechar { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 18px; cursor: pointer; color: #889; }
.modal-titulo { margin: 0 0 6px; font-size: 20px; color: #12302a; font-weight: 800; }
.modal-sub { margin: 0 0 18px; font-size: 14px; color: #6b7d75; line-height: 1.5; }
#formPedido { display: flex; flex-direction: column; gap: 14px; }
#formPedido label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: #33443d; }
#formPedido input, #formPedido textarea {
  padding: 12px; border: 1px solid #d6e2db; border-radius: 10px; font-size: 14px; font-family: inherit; resize: vertical;
}
#formPedido input:focus, #formPedido textarea:focus { outline: none; border-color: #25d366; box-shadow: 0 0 0 3px rgba(37,211,102,.15); }
#pedidoMsg { margin: 4px 0 0; font-size: 13px; text-align: center; }

/* Responsivo: telas estreitas escondem a apresentacao e mostram so o card. */
@media (max-width: 900px) {
  .auth-left { display: none; }
  .auth-right { flex: 1 1 100%; }
}

/* Banner de plano/trial */
.banner-plano {
  display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; font-size: 14px; font-weight: 600;
  background: linear-gradient(135deg, #fff4d6, #ffe9ad); color: #7a5b00; border-bottom: 1px solid #f0d98a;
}
.banner-plano.expirado { background: linear-gradient(135deg, #ffe0e0, #ffcccc); color: #a12020; border-bottom-color: #f0a0a0; }
.banner-plano .bp-btn {
  background: linear-gradient(135deg, #25d366, #0ea65a); color: #fff; border: none; cursor: pointer;
  padding: 8px 16px; border-radius: 8px; font-weight: 700; font-size: 13.5px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(37,211,102,.35);
}
.banner-plano .bp-btn:hover { filter: brightness(1.05); }

/* Modal de upgrade: card de plano */
#upgradeMsg { margin: 4px 0 0; font-size: 13px; text-align: center; }
.plano-card { background: #f4faf6; border: 1px solid #cdeedd; border-radius: 14px; padding: 20px; margin: 4px 0 16px; text-align: center; }
.plano-nome { font-size: 15px; font-weight: 700; color: #0e7a46; }
.plano-preco { font-size: 36px; font-weight: 800; color: #12302a; margin: 4px 0 12px; }
.plano-preco span { font-size: 15px; font-weight: 600; color: #6b7d75; }
.plano-itens { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; font-size: 14px; color: #33443d; }
.btn-entrar:disabled { background: #cdd8d2; color: #8a988f; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-wa-assinar { display: block; text-align: center; text-decoration: none; margin-top: 10px; }
