.site-avatar-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.site-avatar {
  position: fixed;
  z-index: 55;
  left: 16px;
  top: 40%;
  width: 96px;
  height: 120px;
  pointer-events: none;
}

.site-avatar.is-aberto {
  z-index: 9500;
}

.site-avatar [hidden] {
  display: none !important;
}

/* ── Robô ──────────────────────────────────────────────────── */
.site-avatar-robo {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.site-avatar-robo:focus {
  outline: none;
}

.site-avatar-robo:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 4px;
  border-radius: 14px;
}

.site-avatar-figura {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.18s ease;
}

.site-avatar.is-esquerda .site-avatar-figura {
  transform: scaleX(-1);
}

.site-avatar-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 6px 8px rgba(15, 23, 42, 0.22));
}

.ra-sombra {
  fill: #0f172a;
  opacity: 0.16;
}

.ra-boneco,
.ra-cabeca,
.ra-perna,
.ra-braco,
.ra-olhos,
.ra-logo {
  transform-box: fill-box;
}

.ra-logo {
  transform-origin: 50% 50%;
}

.site-avatar.is-esquerda .ra-logo {
  transform: scaleX(-1);
}

.ra-boneco {
  transform-origin: 50% 100%;
  animation: ra-respirar 2.4s ease-in-out infinite;
}

.ra-cabeca {
  transform-origin: 50% 100%;
}

.ra-perna {
  transform-origin: 41% 4%;
}

.ra-braco {
  transform-origin: 50% 4%;
  animation: ra-balanco 2.4s ease-in-out infinite;
}

.ra-braco--dir {
  animation-direction: reverse;
}

.ra-olhos {
  transform-origin: 50% 50%;
  animation: ra-piscar 4.6s ease-in-out infinite;
}

.ra-antena {
  animation: ra-antena 1.8s ease-in-out infinite;
}

.site-avatar.is-andando .ra-boneco {
  animation: ra-passada 0.26s ease-in-out infinite;
}

.site-avatar.is-andando .ra-perna--esq,
.site-avatar.is-andando .ra-braco--dir {
  animation: ra-perna 0.52s ease-in-out infinite;
}

.site-avatar.is-andando .ra-perna--dir,
.site-avatar.is-andando .ra-braco--esq {
  animation: ra-perna 0.52s ease-in-out -0.26s infinite;
}

.site-avatar.is-andando .ra-braco {
  animation-name: ra-braco;
}

.site-avatar.is-aberto .ra-braco--dir {
  animation: ra-acenar 0.55s ease-in-out infinite alternate;
}

.site-avatar.is-aberto .ra-cabeca {
  animation: ra-inclinar 2.6s ease-in-out infinite;
}

.site-avatar.is-recolhido .ra-boneco {
  animation: ra-espiar 3.2s ease-in-out infinite;
}

.site-avatar.is-recolhido .ra-braco {
  animation: none;
}

.site-avatar.is-recolhido .ra-sombra {
  display: none;
}

/* ── Placa: só com o robô parado ──────────────────────────── */
.site-avatar-placa {
  position: absolute;
  bottom: calc(100% - 10px);
  left: 62%;
  padding: 5px 11px;
  border: 2px solid #1d4ed8;
  border-radius: 14px;
  background: #fff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(29, 78, 216, 0.18);
  pointer-events: none;
  transform-origin: 14px 100%;
  transition: opacity 0.22s ease 0.12s, transform 0.22s ease 0.12s, visibility 0s linear 0.12s;
}

.site-avatar-placa::after {
  content: "";
  position: absolute;
  left: 12px;
  bottom: -7px;
  width: 10px;
  height: 10px;
  border-right: 2px solid #1d4ed8;
  border-bottom: 2px solid #1d4ed8;
  background: #fff;
  transform: rotate(45deg);
}

.site-avatar.is-placa-esquerda .site-avatar-placa {
  left: auto;
  right: 62%;
  transform-origin: calc(100% - 14px) 100%;
}

.site-avatar.is-placa-esquerda .site-avatar-placa::after {
  left: auto;
  right: 12px;
}

.site-avatar.is-andando .site-avatar-placa,
.site-avatar.is-aberto .site-avatar-placa,
.site-avatar.is-recolhido .site-avatar-placa {
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px) scale(0.85);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0s linear 0.12s;
}

/* ── Painel de ajuda ──────────────────────────────────────── */
.site-avatar-fundo {
  display: none;
}

.site-avatar-painel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: min(560px, calc(100vh - 320px));
  min-height: 300px;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.06);
  pointer-events: auto;
  overflow: hidden;
  transform-origin: 24px 100%;
  animation: sap-abrir 0.18s ease-out;
}

.sap-topo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: #fff;
}

.sap-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

.sap-btn:hover,
.sap-btn:focus-visible {
  background: rgba(255, 255, 255, 0.26);
  outline: none;
}

.sap-btn svg,
.sap-busca svg,
.sap-icone svg,
.sap-seta svg,
.sap-carrinho svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sap-btn svg {
  width: 18px;
  height: 18px;
}

.sap-mini {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
}

.sap-mini svg {
  width: 30px;
  height: 22px;
}

.sap-id {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.sap-id strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sap-id small {
  font-size: 12px;
  opacity: 0.85;
}

.sap-busca {
  position: relative;
  padding: 12px 14px 6px;
}

.sap-busca svg {
  position: absolute;
  left: 26px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  color: #64748b;
  transform: translateY(-50%);
  pointer-events: none;
}

.sap-busca input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
  font: inherit;
  font-size: 14px;
}

.sap-busca input:focus {
  border-color: #2563eb;
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.sap-corpo {
  flex: 1 1 auto;
  min-height: 0;
  padding: 2px 8px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sap-corpo.is-entrando {
  animation: sap-entrar 0.16s ease-out;
}

.sap-grupo {
  margin: 12px 8px 4px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sap-linha {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sap-linha:hover,
.sap-linha:focus-visible {
  background: #f1f5f9;
  outline: none;
}

.sap-linha.is-atual {
  background: #eff6ff;
}

.sap-icone {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
}

.sap-icone svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.8;
}

.sap-texto {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.sap-texto strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sap-texto small {
  overflow: hidden;
  color: #64748b;
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sap-linha.is-atual .sap-texto small {
  color: #1d4ed8;
  font-weight: 600;
}

.sap-seta {
  color: #94a3b8;
}

.sap-seta svg {
  width: 16px;
  height: 16px;
}

.sap-vazio {
  margin: 0;
  padding: 18px 10px;
  color: #64748b;
  font-size: 14px;
  text-align: center;
}

.sap-rodape {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid #eef2f7;
  background: #fff;
}

.sap-carrinho {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #1d4ed8;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.sap-carrinho:hover,
.sap-carrinho:focus-visible {
  background: #1e40af;
  outline: none;
}

.sap-carrinho svg {
  width: 18px;
  height: 18px;
}

.sap-qtd {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.sap-agora {
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.sap-agora:hover,
.sap-agora:focus-visible {
  color: #0f172a;
  text-decoration: underline;
  outline: none;
}

.site-avatar-destaque {
  outline: 3px solid #2563eb !important;
  outline-offset: 3px;
  animation: site-avatar-pulso 1.1s ease-in-out infinite;
}

/* ── Animações ────────────────────────────────────────────── */
@keyframes ra-respirar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.5px); }
}

@keyframes ra-passada {
  0%, 100% { transform: translateY(0) rotate(5deg); }
  50% { transform: translateY(-3px) rotate(5deg); }
}

@keyframes ra-perna {
  0%, 100% { transform: rotate(26deg); }
  50% { transform: rotate(-26deg); }
}

@keyframes ra-braco {
  0%, 100% { transform: rotate(34deg); }
  50% { transform: rotate(-34deg); }
}

@keyframes ra-balanco {
  0%, 100% { transform: rotate(3deg); }
  50% { transform: rotate(-3deg); }
}

@keyframes ra-acenar {
  from { transform: rotate(-155deg); }
  to { transform: rotate(-118deg); }
}

@keyframes ra-inclinar {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

@keyframes ra-espiar {
  0%, 70%, 100% { transform: translateY(0); }
  80% { transform: translateY(-4px); }
  90% { transform: translateY(0); }
}

@keyframes ra-piscar {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.15); }
}

@keyframes ra-antena {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes sap-abrir {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes sap-subir {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@keyframes sap-entrar {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes site-avatar-pulso {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
}

/* ── Celular: painel vira gaveta inferior ─────────────────── */
@media (max-width: 800px) {
  .site-avatar {
    width: 68px;
    height: 85px;
  }

  .site-avatar-placa {
    padding: 4px 9px;
    font-size: 11px;
  }

  .site-avatar.is-aberto .site-avatar-fundo {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(15, 23, 42, 0.45);
    pointer-events: auto;
  }

  .site-avatar.is-aberto .site-avatar-robo {
    visibility: hidden;
  }

  .site-avatar-painel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: 82vh;
    max-height: 82dvh;
    min-height: 0;
    border-radius: 20px 20px 0 0;
    animation: sap-subir 0.22s ease-out;
  }

  .sap-topo {
    padding-top: 16px;
  }

  .sap-busca input {
    font-size: 16px;
  }

  .sap-rodape {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-avatar,
  .site-avatar *,
  .site-avatar-destaque {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .site-avatar { display: none !important; }
}
