/* ============================================================================
   CB Chat — widget de atendimento por IA (canto inferior ESQUERDO; o WhatsApp
   fica no direito). Namespace .cb-chat. Paleta A: azul royal #1E5FD8 + ambar.
   ========================================================================= */

.cb-chat-btn {
  position: fixed;
  left: 16px;
  bottom: var(--cb-chat-bottom, 16px);
  transition: bottom 0.18s ease;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 999px;
  background: #1e5fd8;
  color: #fff;
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 6px 18px rgba(30, 95, 216, 0.35);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.cb-chat-btn:hover,
.cb-chat-btn:focus-visible { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(30, 95, 216, 0.4); }
.cb-chat-btn:focus-visible { outline: 3px solid #f59e0b; outline-offset: 3px; }
.cb-chat-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cb-chat-btn .cb-chat-btn__dot {
  position: absolute; top: -3px; right: -3px; width: 14px; height: 14px; border-radius: 50%;
  background: #f59e0b; border: 2px solid #fff; display: none;
}
.cb-chat-btn.has-new .cb-chat-btn__dot { display: block; }
.cb-chat--open .cb-chat-btn { display: none; }

.cb-chat {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 1300;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 32px));
  display: none;
  flex-direction: column;
  background: #fff;
  color: #14213d;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(11, 28, 63, 0.28);
  overflow: hidden;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.cb-chat--open .cb-chat { display: flex; }

.cb-chat__head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 16px;
  background: linear-gradient(135deg, #1e5fd8, #164bb0);
  color: #fff;
}
.cb-chat__avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #f59e0b; color: #14213d;
  display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none;
}
.cb-chat__title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.cb-chat__sub { font-size: 12px; opacity: 0.85; }
.cb-chat__close {
  margin-left: auto; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.cb-chat__close:hover { background: rgba(255,255,255,0.28); }

.cb-chat__msgs {
  flex: 1; overflow-y: auto; padding: 14px 12px; background: #f4f7fc;
  display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth;
}
.cb-chat__msg {
  max-width: 86%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.cb-chat__msg--user { align-self: flex-end; background: #1e5fd8; color: #fff; border-bottom-right-radius: 4px; }
.cb-chat__msg--bot { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; }
.cb-chat__msg--admin { align-self: flex-start; background: #fff7e6; border-left: 3px solid #f59e0b; border-bottom-left-radius: 4px; }
.cb-chat__msg a { color: #1e5fd8; text-decoration: underline; }
.cb-chat__meta { font-size: 11px; color: #6b7a99; margin-top: 3px; }
.cb-chat__typing { align-self: flex-start; color: #6b7a99; font-size: 12px; padding: 4px 8px; }
.cb-chat__typing i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: #9aa8c7; animation: cbchatdot 1.2s infinite; }
.cb-chat__typing i:nth-child(2) { animation-delay: .2s; } .cb-chat__typing i:nth-child(3) { animation-delay: .4s; }
@keyframes cbchatdot { 0%,80%,100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.cb-chat__notice { text-align: center; font-size: 12px; color: #6b7a99; padding: 4px 8px; }

.cb-chat__form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e6eaf3; background: #fff; }
.cb-chat__input {
  flex: 1; resize: none; max-height: 110px; min-height: 42px; padding: 10px 12px;
  border: 1px solid #cfd8ea; border-radius: 12px; font: inherit; color: inherit; outline: none;
}
.cb-chat__input:focus { border-color: #1e5fd8; box-shadow: 0 0 0 3px rgba(30,95,216,0.15); }
.cb-chat__send {
  width: 44px; height: 42px; border: 0; border-radius: 12px; background: #1e5fd8; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.cb-chat__send:disabled { opacity: 0.5; cursor: default; }
.cb-chat__send svg { width: 20px; height: 20px; fill: currentColor; }
.cb-chat__foot { font-size: 11px; color: #6b7a99; text-align: center; padding: 0 10px 8px; background: #fff; }
.cb-chat__foot a { color: #1e5fd8; }

@media (max-width: 480px) {
  .cb-chat { left: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; }
  .cb-chat-btn { padding: 0 14px; }
  .cb-chat-btn span { display: none; }
}

/* ---- pre-chat (nome + WhatsApp) e status online ------------------------- */
.cb-chat__online { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #34d399; margin-right: 6px; box-shadow: 0 0 0 2px rgba(52,211,153,0.35); }
.cb-chat__ini { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 22px 18px; background: #f4f7fc; overflow-y: auto; }
.cb-chat__ini-title { font-size: 18px; font-weight: 800; color: #14213d; }
.cb-chat__ini-sub { font-size: 13px; color: #4b5a7a; margin-top: -4px; }
.cb-chat__lbl { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: #4b5a7a; }
.cb-chat__field { padding: 11px 12px; border: 1px solid #cfd8ea; border-radius: 12px; font: 14px/1.2 inherit; color: #14213d; background: #fff; outline: none; }
.cb-chat__field:focus { border-color: #1e5fd8; box-shadow: 0 0 0 3px rgba(30,95,216,0.15); }
.cb-chat__ini-err { min-height: 16px; font-size: 12px; color: #c0392b; }
.cb-chat__ini-btn { padding: 12px; border: 0; border-radius: 12px; background: #1e5fd8; color: #fff; font: 700 14px/1 inherit; cursor: pointer; }
.cb-chat__ini-btn:disabled { opacity: 0.6; cursor: default; }
.cb-chat__ini-legal { font-size: 11px; color: #6b7a99; line-height: 1.4; }
.cb-chat__ini-legal a { color: #1e5fd8; }
.cb-chat__notice strong { color: #14213d; }
