/* ==========================================================================
   Chat de atendimento com IA — widget fixo no canto direito de todas as páginas
   Usa os tokens de cor de style.css (--gradiente, --superficie, --roxo-claro...).
   ========================================================================== */

.chat { position: fixed; right: 20px; bottom: 20px; z-index: 150; font-family: var(--fonte); }
.chat ~ .toasts { bottom: 100px; }

/* Botão flutuante */
.chat__botao { display: flex; align-items: center; gap: 12px; padding: 8px 20px 8px 8px; border: 0; border-radius: 999px; background: var(--gradiente); color: #fff; box-shadow: var(--sombra-glow), inset 0 0 0 1px rgba(255, 255, 255, 0.14); cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.chat__botao:hover { transform: translateY(-2px); box-shadow: 0 18px 38px rgba(108, 63, 232, 0.52), inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
.chat__botao:active { transform: translateY(0); }
.chat__botao:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.chat__botao-icone { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: rgba(13, 13, 26, 0.32); }
.chat__botao-icone .icone { width: 22px; height: 22px; }
.chat__botao-icone::after { content: ''; position: absolute; right: 1px; bottom: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--sucesso); border: 2px solid #5b55dd; }
.chat__botao-texto { display: grid; text-align: left; line-height: 1.2; }
.chat__botao-texto strong { font-size: 15px; letter-spacing: 0.01em; }
.chat__botao-texto small { font-size: 12px; opacity: 0.85; }
.chat--aberto .chat__botao-icone::after { display: none; }

/* Convite (uma vez por sessão) */
.chat__convite { position: absolute; right: 4px; bottom: 76px; width: max-content; max-width: 250px; padding: 10px 14px; border: 0; border-radius: 16px 16px 4px 16px; background: #fff; color: #1d1648; font: inherit; font-size: 13px; font-weight: 600; text-align: left; box-shadow: var(--sombra); cursor: pointer; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease; }
.chat--convite .chat__convite { opacity: 1; transform: none; pointer-events: auto; }

/* Painel */
.chat__painel { position: absolute; right: 0; bottom: 78px; display: flex; flex-direction: column; width: min(392px, calc(100vw - 32px)); height: min(600px, calc(100vh - 120px)); border-radius: 22px; border: 1px solid var(--borda-forte); background: linear-gradient(180deg, rgba(108, 63, 232, 0.16), rgba(108, 63, 232, 0) 150px), var(--bg-2); box-shadow: 0 26px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(155, 123, 255, 0.14); overflow: hidden; transform-origin: bottom right; animation: chat-abrir 0.22s ease; }
.chat__painel[hidden] { display: none; }
@keyframes chat-abrir { from { opacity: 0; transform: translateY(12px) scale(0.97); } }

.chat__topo { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px; border-bottom: 1px solid var(--borda); }
.chat__avatar { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; object-fit: cover; box-shadow: 0 0 0 2px rgba(155, 123, 255, 0.5), 0 6px 18px rgba(108, 63, 232, 0.4); }
.chat__identidade { flex: 1; min-width: 0; }
.chat__identidade h2 { margin: 0; font-size: 15px; color: #fff; }
.chat__identidade p { display: flex; align-items: center; gap: 6px; margin: 2px 0 0; font-size: 12px; color: var(--texto-3); }
.chat__online { width: 8px; height: 8px; border-radius: 50%; background: var(--sucesso); box-shadow: 0 0 8px var(--sucesso); }
.chat__acao { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border: 0; border-radius: 10px; background: transparent; color: var(--texto-2); cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.chat__acao:hover { background: var(--superficie-2); color: #fff; }
.chat__acao:focus-visible { outline: 2px solid var(--azul); outline-offset: 1px; }
.chat__acao .icone { width: 18px; height: 18px; }

/* Mensagens */
.chat__mensagens { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.chat__msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.chat__msg p { margin: 0; }
.chat__msg p + p, .chat__msg p + ul, .chat__msg p + ol, .chat__msg ul + p, .chat__msg ol + p { margin-top: 8px; }
.chat__msg ul, .chat__msg ol { margin: 6px 0 0; padding-left: 18px; }
.chat__msg li + li { margin-top: 3px; }
.chat__msg--assistant { align-self: flex-start; border: 1px solid var(--borda); border-bottom-left-radius: 6px; background: var(--superficie); color: var(--texto); }
.chat__msg--assistant strong { color: #fff; }
.chat__msg--user { align-self: flex-end; border-bottom-right-radius: 6px; background: var(--gradiente); color: #fff; white-space: pre-wrap; }
.chat__msg--erro { align-self: center; max-width: 100%; font-size: 13px; border: 1px solid rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.12); color: #fecaca; }
.chat__link { color: var(--roxo-claro); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.chat__link:hover { color: #fff; }
.chat__digitando { display: flex; gap: 5px; padding: 14px 16px; }
.chat__digitando span { width: 7px; height: 7px; border-radius: 50%; background: var(--roxo-claro); animation: chat-ponto 1.2s ease-in-out infinite; }
.chat__digitando span:nth-child(2) { animation-delay: 0.15s; }
.chat__digitando span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-ponto { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* Sugestões rápidas */
.chat__sugestoes { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.chat__sugestoes[hidden] { display: none; }
.chat__sugestoes button { padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(155, 123, 255, 0.45); background: rgba(108, 63, 232, 0.12); color: var(--texto); font: inherit; font-size: 12.5px; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.chat__sugestoes button:hover { border-color: var(--roxo-claro); background: rgba(108, 63, 232, 0.28); }
.chat__sugestoes button:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }

/* Campo de mensagem */
.chat__form { display: flex; align-items: flex-end; gap: 8px; margin: 0 12px; padding: 7px 7px 7px 14px; border-radius: 16px; border: 1px solid var(--borda-forte); background: var(--bg); transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.chat__form:focus-within { border-color: var(--roxo-claro); box-shadow: 0 0 0 3px rgba(108, 63, 232, 0.25); }
.chat__form textarea { flex: 1; min-height: 26px; max-height: 120px; padding: 8px 0; border: 0; background: transparent; color: var(--texto); font: inherit; font-size: 14px; line-height: 1.4; resize: none; outline: none; }
.chat__form textarea::placeholder { color: var(--texto-3); }
.chat__enviar { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border: 0; border-radius: 12px; background: var(--gradiente); color: #fff; cursor: pointer; transition: transform 0.15s ease, opacity 0.15s ease; }
.chat__enviar:hover { transform: scale(1.05); }
.chat__enviar:disabled { opacity: 0.5; cursor: progress; transform: none; }
.chat__enviar .icone { width: 18px; height: 18px; }
.chat__rodape { margin: 8px 16px 12px; font-size: 11px; text-align: center; color: var(--texto-3); }

/* Celular: botão redondo e painel em tela cheia */
@media (max-width: 560px) {
  .chat { right: 14px; bottom: 14px; }
  .chat ~ .toasts { bottom: 84px; }
  .chat__botao { padding: 6px; }
  .chat__botao-texto { display: none; }
  .chat__convite { bottom: 66px; }
  .chat__painel { position: fixed; inset: 0; width: auto; height: auto; border: 0; border-radius: 0; }
  .chat--aberto .chat__botao { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .chat__painel, .chat__digitando span { animation: none; }
  .chat__botao, .chat__convite, .chat__enviar { transition: none; }
}
