/* ============================================================
   CRM portátil — Widget de captura (público). Tema ROO3 dark/neon.
   Tudo escopado em .crmw- para não colidir com o CSS da página.
   ============================================================ */
:root {
  --crmw-neon: #a3ff47;
  --crmw-black: #0a0a0a;
  --crmw-card: #141414;
  --crmw-border: rgba(255,255,255,0.10);
  --crmw-white: #f5f5f5;
  --crmw-dim: rgba(245,245,245,0.62);
  --crmw-wa: #25d366;
}

.crmw-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}
.crmw-overlay.is-open { opacity: 1; visibility: visible; }

.crmw-modal {
  position: relative;   /* o botão fechar persiste entre o formulário e o chat */
  width: 100%; max-width: 440px;
  background: linear-gradient(180deg, #161616 0%, var(--crmw-black) 100%);
  border: 1px solid var(--crmw-border);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(163,255,71,0.06);
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--crmw-white);
  transform: translateY(18px) scale(0.98);
  transition: transform .28s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
.crmw-overlay.is-open .crmw-modal { transform: translateY(0) scale(1); }

.crmw-head {
  padding: 26px 26px 0;
  position: relative;
}
.crmw-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; margin-bottom: 14px;
  background: rgba(163,255,71,0.09);
  border: 1px solid rgba(163,255,71,0.28);
  border-radius: 100px;
  font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--crmw-neon);
}
.crmw-badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--crmw-neon); box-shadow: 0 0 8px var(--crmw-neon);
}
.crmw-title {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1.4rem; font-weight: 700; line-height: 1.2;
  letter-spacing: -0.02em; margin: 0 0 6px;
}
.crmw-title b { color: var(--crmw-neon); font-weight: 700; }
.crmw-context {
  font-size: .9rem; color: var(--crmw-dim); margin: 0;
}
.crmw-close {
  position: absolute; top: 18px; right: 18px; z-index: 10; /* acima do .crmw-head, senão o header come o clique do X */
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--crmw-border);
  color: var(--crmw-dim); font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s ease;
}
.crmw-close:hover { background: rgba(255,255,255,0.1); color: var(--crmw-white); }

.crmw-form { padding: 20px 26px 26px; }
.crmw-field { margin-bottom: 14px; }
.crmw-field label {
  display: block; font-size: .8rem; font-weight: 600;
  color: var(--crmw-dim); margin-bottom: 6px;
}
.crmw-field input {
  width: 100%; box-sizing: border-box;
  padding: 13px 15px; font-size: 16px; font-family: inherit; /* 16px evita o auto-zoom do iOS ao focar */
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--crmw-border); border-radius: 11px;
  color: var(--crmw-white); transition: border-color .2s ease, background .2s ease;
}
.crmw-field input::placeholder { color: rgba(245,245,245,0.32); }
.crmw-field input:focus {
  outline: none; border-color: var(--crmw-neon);
  background: rgba(163,255,71,0.04);
}
/* honeypot escondido sem jogar conteudo pra fora da tela (evita scroll lateral no mobile) */
.crmw-hp { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); border: 0; white-space: nowrap; }
.crmw-turnstile { margin: 2px 0 12px; min-height: 1px; }

.crmw-submit {
  width: 100%; margin-top: 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 15px 20px; font-size: .98rem; font-weight: 700; font-family: inherit;
  background: var(--crmw-neon); color: var(--crmw-black);
  border: none; border-radius: 12px; cursor: pointer;
  transition: box-shadow .25s ease, transform .15s ease, opacity .2s ease;
}
.crmw-submit:hover { box-shadow: 0 0 28px rgba(163,255,71,0.45); transform: translateY(-1px); }
.crmw-submit:disabled { opacity: .6; cursor: default; transform: none; box-shadow: none; }

.crmw-msg {
  font-size: .85rem; margin: 12px 0 0; min-height: 1px;
  text-align: center; line-height: 1.5;
}
.crmw-msg.is-error { color: #ff6b6b; }
.crmw-msg.is-ok { color: var(--crmw-neon); }

.crmw-note {
  font-size: .76rem; color: rgba(245,245,245,0.4);
  text-align: center; margin: 12px 0 0; line-height: 1.5;
}
.crmw-note svg { vertical-align: -2px; margin-right: 3px; }

/* ============ Chat de atendimento (Rodrigo IA) ============ */
.crmw-chat { position: relative; display: flex; flex-direction: column; height: 540px; max-height: 80vh; }
.crmw-chat[hidden] { display: none; }   /* [hidden] perde pro display:flex sem isto */

.crmw-chat-head {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 26px 14px; border-bottom: 1px solid var(--crmw-border);
}
.crmw-chat-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 42px;
  background: var(--crmw-neon); color: var(--crmw-black);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.15rem; font-family: 'Space Grotesk', 'Inter', sans-serif;
  box-shadow: 0 0 16px rgba(163,255,71,0.4);
}
.crmw-chat-name { font-weight: 700; font-size: .98rem; display: flex; align-items: center; gap: 7px; }
.crmw-chat-role {
  font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--crmw-neon); background: rgba(163,255,71,0.1);
  border: 1px solid rgba(163,255,71,0.28); padding: 2px 7px; border-radius: 100px;
}
.crmw-chat-status { font-size: .76rem; color: var(--crmw-dim); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.crmw-chat-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--crmw-neon); box-shadow: 0 0 7px var(--crmw-neon); }

.crmw-chat-msgs {
  flex: 1; overflow-y: auto; padding: 18px 22px;
  display: flex; flex-direction: column; gap: 10px;
}
.crmw-bubble {
  max-width: 84%; padding: 11px 14px; border-radius: 15px;
  font-size: .92rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
  animation: crmw-pop .25s ease;
}
@keyframes crmw-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.crmw-bubble--assistant {
  align-self: flex-start; background: rgba(255,255,255,0.06);
  border: 1px solid var(--crmw-border); border-bottom-left-radius: 5px;
}
.crmw-bubble--user {
  align-self: flex-end; background: var(--crmw-neon); color: var(--crmw-black);
  border-bottom-right-radius: 5px; font-weight: 500;
}
.crmw-typing { display: flex; gap: 5px; align-items: center; }
.crmw-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--crmw-dim); animation: crmw-bounce 1.2s infinite; }
.crmw-typing span:nth-child(2) { animation-delay: .18s; }
.crmw-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes crmw-bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.crmw-chat-foot { border-top: 1px solid var(--crmw-border); padding: 12px 16px 14px; }
/* botão do WhatsApp discreto, no fim, sem roubar foco do chat */
.crmw-chat-wa {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin: 10px auto 0; padding: 6px 12px;
  background: none; border: none; cursor: pointer; font-family: inherit;
  color: var(--crmw-dim); font-size: .8rem; font-weight: 500;
  transition: color .2s ease;
}
.crmw-chat-wa:hover { color: var(--crmw-wa); }
.crmw-chat-wa svg { opacity: .85; }
.crmw-chat-form { display: flex; gap: 8px; align-items: flex-end; }

/* alerta ao tentar ir pro WhatsApp sem interagir */
.crmw-chat-gate {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(0,0,0,0.66); backdrop-filter: blur(3px);
}
.crmw-chat-gate[hidden] { display: none; }
.crmw-chat-gate__box {
  background: var(--crmw-card); border: 1px solid var(--crmw-border);
  border-radius: 14px; padding: 20px; max-width: 320px; text-align: center;
}
.crmw-chat-gate__box p { margin: 0 0 16px; font-size: .92rem; line-height: 1.55; color: var(--crmw-white); }
.crmw-chat-gate__btns { display: flex; flex-direction: column; gap: 8px; }
.crmw-chat-gate__go {
  padding: 11px; background: var(--crmw-wa); color: #fff; border: none;
  border-radius: 11px; font-weight: 700; font-size: .9rem; cursor: pointer; font-family: inherit;
}
.crmw-chat-gate__go:hover { filter: brightness(1.06); }
.crmw-chat-gate__stay {
  padding: 9px; background: none; border: 1px solid var(--crmw-border);
  color: var(--crmw-dim); border-radius: 11px; font-size: .86rem; cursor: pointer; font-family: inherit;
}
.crmw-chat-gate__stay:hover { color: var(--crmw-white); }

/* botão de WhatsApp dentro da conversa (quando a IA oferece) */
.crmw-cta-wa {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; background: var(--crmw-wa); color: #fff; border: none;
  border-radius: 12px; font-weight: 700; font-size: .9rem; cursor: pointer; font-family: inherit;
  box-shadow: 0 4px 16px rgba(37,211,102,0.3); animation: crmw-pop .25s ease;
  transition: filter .2s ease, transform .15s ease;
}
.crmw-cta-wa:hover { filter: brightness(1.06); transform: translateY(-1px); }
.crmw-chat-input {
  flex: 1; box-sizing: border-box; resize: none; max-height: 120px;
  padding: 11px 14px; font-family: inherit; font-size: 16px; line-height: 1.4; /* 16px evita o auto-zoom do iOS ao focar */
  background: rgba(255,255,255,0.04); border: 1px solid var(--crmw-border);
  border-radius: 12px; color: var(--crmw-white);
}
.crmw-chat-input:focus { outline: none; border-color: var(--crmw-neon); }
.crmw-chat-input::placeholder { color: rgba(245,245,245,0.32); }
.crmw-chat-send {
  flex: 0 0 44px; width: 44px; height: 44px; border: none; border-radius: 12px; cursor: pointer;
  background: var(--crmw-neon); color: var(--crmw-black);
  display: flex; align-items: center; justify-content: center;
  transition: box-shadow .2s ease, opacity .2s ease;
}
.crmw-chat-send:hover { box-shadow: 0 0 18px rgba(163,255,71,0.45); }
.crmw-chat-send:disabled, .crmw-chat-input:disabled, .crmw-chat-wa.is-busy { opacity: .55; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .crmw-bubble, .crmw-typing span, .crmw-cta-wa { animation: none; }
}

/* no celular: tela cheia, sem bordas nem cantos, cara de app de conversa */
@media (max-width: 560px) {
  .crmw-overlay { padding: 0; }
  .crmw-modal {
    display: flex; flex-direction: column;
    max-width: none; width: 100%; height: 100%; max-height: none;
    border: none; border-radius: 0; box-shadow: none;
  }
  .crmw-chat { height: auto; max-height: none; flex: 1 1 auto; min-height: 0; }
}
