/* Assistente virtual da Petstyle · bolha e painel de chat.
   Carregado em todas as páginas por /assets/js/atendente.js.
   Regras: só transform e opacity animam; tudo desliga com prefers-reduced-motion. */

.ia-bubble {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 45;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: var(--cocoa);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform .25s var(--ease), opacity .25s, background .2s;
}
.ia-bubble:hover { transform: scale(1.06); background: #24150f; }
.ia-bubble:focus-visible { outline: 3px solid var(--rose); outline-offset: 3px; }
.ia-bubble svg { width: 28px; height: 28px; }
.ia-bubble .ia-ponto {
  position: absolute; top: 6px; right: 6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--rose); border: 2px solid var(--paper);
}
.ia-bubble[data-novo="1"]::after {
  content: "1";
  position: absolute; top: -4px; right: -4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--rose); color: #fff; font: 700 .8rem/22px var(--font-body); text-align: center;
}
.cookie-open .ia-bubble { opacity: 0; pointer-events: none; }

.ia-painel {
  position: fixed;
  right: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 70;
  width: min(392px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 112px));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.ia-painel[hidden] { display: none; }
.ia-painel.is-aberto { opacity: 1; transform: none; pointer-events: auto; }

.ia-topo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--cocoa);
  color: #fff;
}
.ia-topo .ia-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--blush); color: var(--cocoa);
  display: grid; place-items: center; flex: none;
}
.ia-topo .ia-avatar svg { width: 20px; height: 20px; }
.ia-topo strong { display: block; font: 600 1rem/1.2 var(--font-body); }
.ia-topo span { display: block; font-size: .8rem; color: #e5d6cb; }
.ia-fechar {
  margin-left: auto; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12);
  color: #fff; cursor: pointer; display: grid; place-items: center;
}
.ia-fechar:hover { background: rgba(255,255,255,.22); }
.ia-fechar svg { width: 18px; height: 18px; }

.ia-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, #fffdf9, var(--cream));
  overscroll-behavior: contain;
  min-height: 200px;
}
.ia-msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: .95rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.ia-msg--bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); color: var(--cocoa); border-bottom-left-radius: 4px; }
.ia-msg--eu { align-self: flex-end; background: var(--cocoa); color: #fff; border-bottom-right-radius: 4px; }
.ia-msg--erro { align-self: flex-start; background: var(--error-bg); color: var(--error); border: 1px solid #f3c9c4; }

.ia-a-escrever { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.ia-a-escrever i { width: 7px; height: 7px; border-radius: 50%; background: var(--cocoa-2); opacity: .5; animation: ia-pisca 1.1s infinite; }
.ia-a-escrever i:nth-child(2) { animation-delay: .15s; }
.ia-a-escrever i:nth-child(3) { animation-delay: .3s; }
@keyframes ia-pisca { 0%, 60%, 100% { opacity: .25; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.ia-sugestoes { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; background: var(--cream); }
.ia-sugestoes button {
  border: 1px solid var(--line); background: #fff; color: var(--cocoa); border-radius: 999px;
  padding: 9px 14px; font: 600 .85rem/1 var(--font-body); cursor: pointer; min-height: 40px;
}
.ia-sugestoes button:hover { border-color: var(--rose); color: var(--rose-dark); }

.ia-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--paper); align-items: flex-end; }
.ia-form textarea {
  flex: 1 1 auto; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
  font: 500 .95rem/1.35 var(--font-body); color: var(--cocoa); background: #fff; max-height: 96px; min-height: 44px;
}
.ia-form textarea:focus { outline: 2px solid var(--rose); outline-offset: 1px; }
.ia-enviar {
  flex: none; width: 46px; height: 46px; border-radius: 12px; border: 0; background: var(--rose); color: #fff;
  display: grid; place-items: center; cursor: pointer; transition: background .2s, opacity .2s;
}
.ia-enviar:hover { background: var(--rose-dark); }
.ia-enviar[disabled] { opacity: .5; cursor: progress; }
.ia-enviar svg { width: 20px; height: 20px; }

.ia-rodape { padding: 9px 16px 12px; font-size: .74rem; line-height: 1.4; color: var(--muted); background: var(--paper); }
.ia-rodape a { color: var(--muted); text-decoration: underline; }
.ia-rodape strong { font-weight: 700; color: var(--cocoa-2); }

.ia-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 560px) {
  .ia-painel {
    right: 0; left: 0; bottom: 0; width: 100%;
    height: 100vh; height: 100dvh;
    max-height: 100vh; max-height: 100dvh;
    border-radius: 0; border: 0;
  }
  .ia-painel.is-aberto { transform: none; }
  .ia-log { min-height: 0; }
  .ia-bubble { width: 56px; height: 56px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .site-footer { padding-bottom: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  .ia-bubble, .ia-painel, .ia-a-escrever i { transition: none; animation: none; }
}

/* Botões que substituem o WhatsApp no site */
.btn--ia { background: var(--rose); color: #fff; box-shadow: var(--shadow-sm); }
.btn--ia:hover { background: var(--rose-dark); color: #fff; }
button.link-tap { background: none; border: 0; padding: 0; cursor: pointer; color: var(--rose-dark); text-decoration: underline; }
button.footer-link { background: none; border: 0; padding: 0; cursor: pointer; color: #f3e6dc; font: inherit; min-height: 44px; text-align: left; }
button.footer-link:hover { text-decoration: underline; color: #fff; }
