/* ==========================================================================
   MKM Consultoria em Seguros — widget de chat (assistente virtual)
   Herda o design system do site: azuis --purple-*, gradiente --grad,
   Poppins/Inter, radius 18/26. Empilhados à DIREITA: launcher acima do .wa-float (discreto).
   ========================================================================== */

.chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 82px; /* acima do botao verde .wa-float */
  z-index: 970;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--grad);
  color: var(--white);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform .15s ease, filter .15s ease;
}
.chat-launcher:hover { filter: brightness(1.07); transform: translateY(-1px); }
.chat-launcher:focus-visible { outline: 2px solid var(--purple-600); outline-offset: 2px; }
.chat-launcher .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(7, 225, 227, .25);
}
.chat-launcher[hidden] { display: none; }

/* ------------------------------------------------------------------ painel */

.chat-panel {
  position: fixed;
  right: 22px;
  bottom: 82px;
  z-index: 990;
  display: flex;
  flex-direction: column;
  width: min(392px, calc(100vw - 32px));
  height: min(600px, calc(100dvh - 110px));
  border: 1px solid var(--lav-100);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  font-family: var(--font-body);
}
.chat-panel[hidden] { display: none; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--purple-950);
  color: var(--white);
}
.chat-head img { height: 30px; width: auto; background: var(--white); border-radius: 8px; padding: 3px 6px; }
.chat-head .who { display: flex; flex-direction: column; line-height: 1.25; }
.chat-head .who b { font-family: var(--font-head); font-size: 14.5px; letter-spacing: .01em; }
.chat-head .who span { font-size: 12px; color: var(--lav-100); opacity: .85; }
.chat-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--lav-100);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
}
.chat-close:hover { color: var(--white); }
.chat-close:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--lav-50);
}

.chat-msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-msg.bot {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--lav-100);
  color: var(--ink);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
}
.chat-msg.bot a { color: var(--purple-900); font-weight: 600; text-decoration: underline; }
.chat-msg.user {
  align-self: flex-end;
  background: var(--purple-800);
  color: var(--white);
  border-bottom-right-radius: 6px;
}
.chat-msg.err {
  align-self: center;
  background: var(--lav-100);
  color: var(--ink);
  font-size: 13px;
}
.chat-msg.err a { color: var(--purple-900); font-weight: 600; }

/* indicador "digitando" */
.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--lav-100);
  border-radius: var(--radius);
  border-bottom-left-radius: 6px;
}
.chat-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--purple-600);
  animation: chatPulse 1.1s infinite ease-in-out;
}
.chat-typing i:nth-child(2) { animation-delay: .18s; }
.chat-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes chatPulse {
  0%, 70%, 100% { opacity: .3; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}

/* sugestões iniciais */
.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--lav-50);
}
.chat-quick button {
  border: 1px solid var(--lav-100);
  background: var(--white);
  color: var(--purple-900);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.chat-quick button:hover { background: var(--lav-100); border-color: var(--purple-600); }
.chat-quick button:focus-visible { outline: 2px solid var(--purple-600); outline-offset: 2px; }

/* entrada */
.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--lav-100);
  background: var(--white);
}
.chat-form input {
  flex: 1;
  border: 1px solid var(--lav-100);
  border-radius: 12px;
  background: var(--lav-50);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  padding: 10px 14px;
}
.chat-form input::placeholder { color: var(--muted); }
.chat-form input:focus-visible { outline: 2px solid var(--purple-600); outline-offset: 1px; }
.chat-form button {
  border: 0;
  border-radius: 12px;
  background: var(--grad);
  color: var(--white);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14px;
  padding: 0 18px;
  cursor: pointer;
  transition: filter .15s ease;
}
.chat-form button:hover { filter: brightness(1.07); }
.chat-form button:disabled { opacity: .55; cursor: default; }
.chat-form button:focus-visible { outline: 2px solid var(--purple-950); outline-offset: 2px; }

.chat-lgpd {
  padding: 8px 14px 10px;
  background: var(--white);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.chat-lgpd a { text-decoration: underline; }

/* --------------------------------------------------------------- mobile */

@media (max-width: 560px) {
  .chat-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: min(88dvh, 640px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .chat-launcher { right: 16px; bottom: 78px; padding: 12px 14px; }
}
