/* =========================================================================
   BLIPEI ASSISTENTE — chat guiado (BP-ASSISTENTE-001, 24/11/2026)
   Cores LITERAIS de propósito: o painel tem fundo próprio (claro) e não muda
   com o tema escuro do site — token de texto que clareia no escuro sumiria.
   Contraste: texto #0f172a sobre #f1f5f9 e branco sobre #1e40af (AAA).
   Mudou este arquivo? Subir ASSETS_VERSION no .env (local e produção).
   ========================================================================= */
/* Sem position/z-index na raiz DE PROPÓSITO: um z-index aqui criaria um contexto de empilhamento e
   prenderia o painel (10000) abaixo do botão de acessibilidade (9998), que cobria o botão de enviar. */
.bp-as{ --bp-as-base: 16px; font-family: var(--bp-font-body, system-ui, sans-serif); }

/* ------------------------------ balão ------------------------------------ */
.bp-as-balao{
  position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: calc(var(--bp-as-base) + env(safe-area-inset-bottom));
  z-index: 9997; display: inline-flex; align-items: center; gap: .55rem;
  min-height: 56px; padding: 0 1.15rem 0 1rem; border: 0; border-radius: 99px; cursor: pointer;
  background: #15803d; color: #fff; font: 700 1rem/1 var(--bp-font-body, system-ui, sans-serif);
  box-shadow: 0 8px 26px rgba(15,23,42,.32); transition: transform .15s ease, background .15s ease, bottom .2s ease;
}
.bp-as-balao:hover{ background: #166534; transform: translateY(-2px); }
.bp-as-balao:focus-visible{ outline: 3px solid #fbbf24; outline-offset: 3px; }
.bp-as-balao i{ font-size: 1.35rem; }
.bp-as-selo{
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px; box-sizing: border-box;
  border-radius: 99px; background: #b91c1c; color: #fff; font-size: .78rem; font-weight: 700; line-height: 22px; text-align: center;
  border: 2px solid #fff;
}
.bp-as[data-aberto="1"] .bp-as-balao{ display: none; }
@media (prefers-reduced-motion: no-preference){
  .bp-as-balao.bp-as-pulso{ animation: bpAsPulso 2.4s ease-out 2; }
}
@keyframes bpAsPulso{
  0%{ box-shadow: 0 8px 26px rgba(15,23,42,.32), 0 0 0 0 rgba(21,128,61,.55); }
  70%{ box-shadow: 0 8px 26px rgba(15,23,42,.32), 0 0 0 18px rgba(21,128,61,0); }
  100%{ box-shadow: 0 8px 26px rgba(15,23,42,.32), 0 0 0 0 rgba(21,128,61,0); }
}
html.bp-no-motion .bp-as-balao.bp-as-pulso{ animation: none; }

/* ------------------------------ convite ---------------------------------- */
.bp-as-convite{
  position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: calc(var(--bp-as-base) + 68px + env(safe-area-inset-bottom));
  z-index: 9997; width: min(320px, calc(100vw - 32px)); box-sizing: border-box;
  padding: .95rem 2.2rem .95rem 1rem; border-radius: 16px 16px 16px 4px;
  background: #fff; color: #0f172a; border: 1px solid #d1d5db; box-shadow: 0 12px 34px rgba(15,23,42,.28);
  font-size: .95rem; line-height: 1.45;
}
.bp-as-convite[hidden]{ display: none; }
.bp-as-convite-t strong{ display: block; margin-bottom: .2rem; font-family: var(--bp-font-display, inherit); font-size: 1.02rem; }
.bp-as-convite-x{
  position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: #374151; font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.bp-as-convite-x:hover{ background: #f1f5f9; color: #0f172a; }
.bp-as-convite-ir{
  margin-top: .7rem; min-height: 44px; padding: 0 1rem; border: 0; border-radius: 10px; cursor: pointer;
  background: #f59e0b; color: #0f172a; font: 700 .95rem/1 var(--bp-font-body, system-ui, sans-serif);
}
.bp-as-convite-ir:hover{ background: #fbbf24; }
.bp-as-convite-ir:empty{ display: none; }
@media (prefers-reduced-motion: no-preference){
  .bp-as-convite:not([hidden]){ animation: bpAsEntra .35s cubic-bezier(.2,.7,.2,1) both; }
}
@keyframes bpAsEntra{ from{ opacity: 0; transform: translate3d(0, 14px, 0) scale(.97); } to{ opacity: 1; transform: none; } }

/* ------------------------------ painel ----------------------------------- */
.bp-as-painel{
  position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 10000; display: flex; flex-direction: column; overflow: hidden;
  width: min(390px, calc(100vw - 32px)); height: min(620px, calc(100dvh - 32px));
  background: #fff; color: #0f172a; border-radius: 18px; border: 1px solid #cbd5e1;
  box-shadow: 0 24px 60px rgba(15,23,42,.38);
}
.bp-as-painel[hidden]{ display: none; }
@media (prefers-reduced-motion: no-preference){
  .bp-as-painel:not([hidden]){ animation: bpAsEntra .28s cubic-bezier(.2,.7,.2,1) both; }
}
.bp-as-topo{ display: flex; align-items: center; gap: .7rem; padding: .8rem .7rem .8rem 1rem; background: linear-gradient(135deg, #1e40af, #0f172a); color: #fff; }
.bp-as-avatar{ flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: #f59e0b; color: #0f172a; font-size: 1.1rem; }
.bp-as-id{ flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.bp-as-id strong{ font-family: var(--bp-font-display, inherit); font-size: 1rem; color: #fff; }
.bp-as-id span{ font-size: .8rem; color: #dbeafe; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-as-icone{ flex: 0 0 auto; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 1.05rem; cursor: pointer; }
.bp-as-icone:hover, .bp-as-icone:focus-visible{ background: rgba(255,255,255,.18); }

.bp-as-log{ flex: 1; overflow-y: auto; padding: 1rem .9rem .5rem; background: #f8fafc; display: flex; flex-direction: column; gap: .45rem; overscroll-behavior: contain; }
.bp-as-log:focus-visible{ outline: 2px solid #1e40af; outline-offset: -2px; }
.bp-as-msg{ max-width: 86%; padding: .6rem .8rem; border-radius: 14px; font-size: .97rem; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-line; }
.bp-as-msg.bot{ align-self: flex-start; background: #e2e8f0; color: #0f172a; border-bottom-left-radius: 4px; }
.bp-as-msg.eu{ align-self: flex-end; background: #1e40af; color: #fff; border-bottom-right-radius: 4px; }
.bp-as-msg small{ display: block; margin-top: .2rem; font-size: .7rem; opacity: .75; text-align: right; }
@media (prefers-reduced-motion: no-preference){
  .bp-as-msg, .bp-as-cartao{ animation: bpAsMsg .22s ease-out both; }
}
@keyframes bpAsMsg{ from{ opacity: 0; transform: translate3d(0, 8px, 0); } to{ opacity: 1; transform: none; } }

.bp-as-digitando{ align-self: flex-start; display: inline-flex; gap: 4px; padding: .7rem .85rem; border-radius: 14px; border-bottom-left-radius: 4px; background: #e2e8f0; }
.bp-as-digitando span{ width: 7px; height: 7px; border-radius: 50%; background: #475569; }
@media (prefers-reduced-motion: no-preference){
  .bp-as-digitando span{ animation: bpAsPonto 1s infinite ease-in-out; }
  .bp-as-digitando span:nth-child(2){ animation-delay: .15s; }
  .bp-as-digitando span:nth-child(3){ animation-delay: .3s; }
}
@keyframes bpAsPonto{ 0%, 60%, 100%{ transform: translateY(0); opacity: .5; } 30%{ transform: translateY(-4px); opacity: 1; } }

.bp-as-cartao{ align-self: flex-start; max-width: 92%; box-sizing: border-box; padding: .75rem .85rem; border-radius: 14px; background: #fff; color: #0f172a; border: 1px solid #cbd5e1; font-size: .93rem; line-height: 1.45; }
.bp-as-cartao strong{ display: block; margin-bottom: .2rem; font-size: .98rem; }
.bp-as-cartao a, .bp-as-link{
  display: inline-flex; align-items: center; gap: .4rem; margin-top: .55rem; min-height: 40px; padding: 0 .85rem; box-sizing: border-box;
  border-radius: 10px; background: #1e40af; color: #fff; font-weight: 700; font-size: .92rem; text-decoration: none;
}
.bp-as-cartao a:hover, .bp-as-link:hover{ background: #1e3a8a; color: #fff; }
.bp-as-cartao a.wa{ background: #15803d; }
.bp-as-cartao a.wa:hover{ background: #166534; }
.bp-as-cartao dl{ display: grid; grid-template-columns: max-content 1fr; gap: .15rem .6rem; margin: .3rem 0 0; }
.bp-as-cartao dt{ font-weight: 700; color: #334155; }
.bp-as-cartao dd{ margin: 0; overflow-wrap: anywhere; }

.bp-as-opcoes{ display: flex; flex-wrap: wrap; gap: .45rem; padding: .55rem .9rem; background: #f8fafc; max-height: 38%; overflow-y: auto; }
.bp-as-opcoes:empty{ display: none; }
.bp-as-opcao{
  min-height: 42px; padding: .45rem .85rem; box-sizing: border-box; border-radius: 99px; cursor: pointer; text-align: left;
  border: 2px solid #1e40af; background: #fff; color: #1e3a8a; font: 700 .92rem/1.2 var(--bp-font-body, system-ui, sans-serif);
  transition: background .12s ease, color .12s ease;
}
.bp-as-opcao:hover, .bp-as-opcao:focus-visible{ background: #1e40af; color: #fff; }
.bp-as-opcao.sec{ border-color: #94a3b8; color: #334155; font-weight: 600; }
.bp-as-opcao.sec:hover, .bp-as-opcao.sec:focus-visible{ background: #334155; border-color: #334155; color: #fff; }

.bp-as-form{ display: flex; gap: .5rem; padding: .6rem .7rem calc(.6rem + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #e2e8f0; }
.bp-as-form[hidden]{ display: none; }
.bp-as .bp-as-form input{
  flex: 1; min-width: 0; width: auto; height: 46px; padding: 0 .9rem; box-sizing: border-box; display: block;
  border: 2px solid #94a3b8; border-radius: 99px; background: #fff; color: #0f172a; font-size: 16px; /* 16px: o iPhone não dá zoom */
}
.bp-as .bp-as-form input:focus{ border-color: #1e40af; outline: none; box-shadow: 0 0 0 3px rgba(30,64,175,.2); }
.bp-as .bp-as-form input::placeholder{ color: #475569; }
.bp-as-form button{ flex: 0 0 46px; height: 46px; border: 0; border-radius: 50%; cursor: pointer; background: #1e40af; color: #fff; font-size: 1rem; }
.bp-as-form button:hover{ background: #1e3a8a; }
.bp-as-form button:disabled{ background: #94a3b8; cursor: default; }

/* ------------------------------ celular ---------------------------------- */
@media (max-width: 640px){
  .bp-as-balao{ min-height: 52px; padding: 0 1rem 0 .9rem; }
  .bp-as-painel{ inset: 0; left: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; border: 0; }
  .bp-as-topo{ padding-top: calc(.8rem + env(safe-area-inset-top)); }
  .bp-as-msg{ max-width: 88%; }
}
/* Com o painel aberto no celular, a página de trás não rola. */
html.bp-as-travado, html.bp-as-travado body{ overflow: hidden; }
