/* ==========================================================================
   IA-WIDGET.CSS — Widget de chat da "IA Blumenau" (layout novo / staging)
   - Botão flutuante ÚNICO no canto INFERIOR ESQUERDO (o WhatsApp flutuante foi
     removido; a IA passa a ocupar o canto em bottom:20).
   - On-brand: azul da Blumenau (--primary) + dourado (--accent).
   - 100% escopado no prefixo .iaw- para nao colidir com site.css.
   - Nao toca em site.css. Variaveis com fallback caso o token nao exista.
   ========================================================================== */

:root {
  --iaw-blue:      var(--primary, #003d7a);
  --iaw-blue-dark: var(--primary-dark, #002850);
  --iaw-blue-lite: var(--primary-light, #0056a8);
  --iaw-gold:      var(--accent, #fdcb6e);
  --iaw-ink:       var(--text-dark, #2d3436);
  --iaw-ink-soft:  var(--text-medium, #636e72);
  --iaw-border:    var(--border-color, #dfe6e9);
  --iaw-surface:   #ffffff;
  --iaw-bot-bg:    #eef2f7;
  --iaw-z-launch:  1000;
  --iaw-z-panel:   9000;
}

/* ===================== LAUNCHER (botao flutuante) ===================== */
.iaw-launcher {
  position: fixed;
  left: 20px;
  bottom: 20px;                 /* canto inferior esquerdo (WhatsApp flutuante removido) */
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 25px;
  background: linear-gradient(135deg, var(--iaw-blue-lite) 0%, var(--iaw-blue) 55%, var(--iaw-blue-dark) 100%);
  box-shadow: 0 8px 22px rgba(0, 61, 122, 0.42);
  z-index: var(--iaw-z-launch);
  transition: transform .2s ease, box-shadow .25s ease, opacity .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.iaw-launcher:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 12px 28px rgba(0, 61, 122, 0.5); }
.iaw-launcher:active { transform: scale(0.97); }
.iaw-launcher:focus-visible { outline: 3px solid var(--iaw-gold); outline-offset: 3px; }
.iaw-launcher.is-hidden { display: none; }

/* anel dourado sutil + micro pulso */
.iaw-launcher::after {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--iaw-gold);
  opacity: .45;
  animation: iawPulse 2.6s ease-out infinite;
  pointer-events: none;
}
/* selo "IA" dourado no canto do botao */
.iaw-launcher__seal {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--iaw-gold);
  color: var(--iaw-blue-dark);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .5px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
@keyframes iawPulse {
  0%   { transform: scale(1);   opacity: .45; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ===================== PAINEL DE CHAT ===================== */
.iaw-panel {
  position: fixed;
  left: 20px;
  bottom: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--iaw-surface);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 40, 80, 0.28), 0 6px 18px rgba(0,0,0,.12);
  z-index: var(--iaw-z-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(.98);
  transform-origin: bottom left;
  transition: opacity .22s ease, transform .22s cubic-bezier(.16,1,.3,1), visibility .22s;
}
.iaw-panel.is-open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

/* Cabecalho on-brand */
.iaw-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--iaw-blue) 0%, var(--iaw-blue-dark) 100%);
  position: relative;
  flex-shrink: 0;
}
.iaw-head::after {   /* fio dourado sob o cabecalho */
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--iaw-gold), transparent);
}
.iaw-avatar {
  width: 42px; height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--iaw-blue-dark);
  background: linear-gradient(135deg, #ffe8a3 0%, var(--iaw-gold) 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.iaw-head__meta { flex: 1; min-width: 0; line-height: 1.25; }
.iaw-head__title { font-size: 15px; font-weight: 800; letter-spacing: -0.2px; }
.iaw-head__status { font-size: 11px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.iaw-head__dot { width: 7px; height: 7px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 0 3px rgba(46,204,113,.28); }
.iaw-close {
  width: 32px; height: 32px;
  border: none; cursor: pointer;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #fff; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: background .18s ease;
  flex-shrink: 0;
}
.iaw-close:hover { background: rgba(255,255,255,.28); }
.iaw-close:focus-visible { outline: 2px solid var(--iaw-gold); outline-offset: 2px; }

/* Corpo / lista de mensagens */
.iaw-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 8px;
  background: #f6f8fb;
  scroll-behavior: smooth;
}
.iaw-body::-webkit-scrollbar { width: 8px; }
.iaw-body::-webkit-scrollbar-thumb { background: #cfd8e3; border-radius: 8px; }

.iaw-msg { display: flex; margin-bottom: 12px; }
.iaw-msg--user { justify-content: flex-end; }
.iaw-msg--bot  { justify-content: flex-start; }
.iaw-bubble {
  max-width: 84%;
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.5;
  border-radius: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: iawIn .18s ease both;
}
.iaw-msg--bot .iaw-bubble {
  background: var(--iaw-surface);
  color: var(--iaw-ink);
  border: 1px solid var(--iaw-border);
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.iaw-msg--user .iaw-bubble {
  background: linear-gradient(135deg, var(--iaw-blue-lite) 0%, var(--iaw-blue) 100%);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.iaw-prodlink {
  color: var(--iaw-blue);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.iaw-msg--user .iaw-prodlink { color: #fff; }
@keyframes iawIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Indicador de "digitando" */
.iaw-typing { display: inline-flex; align-items: center; gap: 4px; padding: 12px 14px; }
.iaw-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--iaw-ink-soft);
  opacity: .5;
  animation: iawBlink 1.2s infinite ease-in-out both;
}
.iaw-typing span:nth-child(2) { animation-delay: .18s; }
.iaw-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes iawBlink { 0%, 80%, 100% { transform: scale(.7); opacity: .35; } 40% { transform: scale(1); opacity: .9; } }

/* Rodape: input + enviar */
.iaw-foot {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--iaw-border);
  background: var(--iaw-surface);
  flex-shrink: 0;
}
.iaw-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--iaw-border);
  border-radius: 14px;
  padding: 10px 13px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--iaw-ink);
  background: #f7f9fb;
  max-height: 110px;
  min-height: 42px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.iaw-input:focus { border-color: var(--iaw-blue); background: #fff; box-shadow: 0 0 0 3px rgba(0,61,122,.12); }
.iaw-input::placeholder { color: var(--iaw-ink-soft); }
.iaw-send {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border: none; cursor: pointer;
  border-radius: 12px;
  color: #fff; font-size: 16px;
  background: linear-gradient(135deg, var(--iaw-blue-lite) 0%, var(--iaw-blue) 100%);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
  box-shadow: 0 4px 12px rgba(0,61,122,.28);
}
.iaw-send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,61,122,.38); }
.iaw-send:disabled { opacity: .5; cursor: default; }
.iaw-send:focus-visible { outline: 2px solid var(--iaw-gold); outline-offset: 2px; }

/* Rodape "powered" discreto */
.iaw-hint {
  font-size: 10.5px;
  color: var(--iaw-ink-soft);
  text-align: center;
  padding: 0 12px 8px;
  background: var(--iaw-surface);
  flex-shrink: 0;
}

/* Card de convite (deslogado) */
.iaw-login { text-align: center; padding: 28px 22px; }
.iaw-login__icon {
  width: 62px; height: 62px; margin: 0 auto 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--iaw-blue-dark);
  background: linear-gradient(135deg, #ffe8a3 0%, var(--iaw-gold) 100%);
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.iaw-login__title { font-size: 16px; font-weight: 800; color: var(--iaw-ink); margin-bottom: 8px; }
.iaw-login__text { font-size: 13px; color: var(--iaw-ink-soft); line-height: 1.55; margin-bottom: 18px; }
.iaw-login__btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; cursor: pointer;
  padding: 11px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--iaw-blue) 0%, var(--iaw-blue-dark) 100%);
  box-shadow: 0 4px 14px rgba(0,61,122,.3);
  transition: transform .15s ease, box-shadow .2s ease;
}
.iaw-login__btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,61,122,.4); }

/* Botao inline (ex.: "Entrar" numa resposta de 401) */
.iaw-inline-btn {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 8px;
  border: none; cursor: pointer;
  padding: 8px 14px; border-radius: 10px;
  font-size: 12.5px; font-weight: 700; color: #fff;
  background: var(--iaw-blue);
  transition: background .18s ease;
}
.iaw-inline-btn:hover { background: var(--iaw-blue-dark); }

/* ===================== MOBILE ===================== */
@media (max-width: 560px) {
  .iaw-launcher { left: 16px; bottom: 16px; width: 54px; height: 54px; font-size: 23px; }
  .iaw-panel {
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 88vh;
    height: 88dvh;
    max-height: none;
    border-radius: 18px 18px 0 0;
    transform-origin: bottom center;
  }
}

/* ===================== ACESSIBILIDADE / IMPRESSAO ===================== */
@media (prefers-reduced-motion: reduce) {
  .iaw-launcher::after { animation: none; }
  .iaw-typing span { animation-duration: 0s; }
  .iaw-bubble, .iaw-panel { animation: none; transition: none; }
}
@media print {
  .iaw-launcher, .iaw-panel { display: none !important; }
}
