/* =========================================================
   TOOGO — Assistente de compras (widget)
   ========================================================= */
.as { --as-ease: cubic-bezier(.16, 1, .3, 1); --as-bottom: 24px; font-family: var(--fonte-corpo); }
.as .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.as svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* botão flutuante */
.as-fab {
  position: fixed; z-index: 85; right: 24px; bottom: var(--as-bottom);
  display: inline-flex; align-items: center; gap: 10px; height: 54px; padding: 0 22px 0 8px;
  border: 0; border-radius: 999px; background: var(--tinta); color: #fff; cursor: pointer;
  font: 600 14px/1 var(--fonte-corpo); letter-spacing: -.005em;
  box-shadow: 0 18px 38px -14px rgba(20, 22, 20, .55), 0 0 0 1px rgba(255, 255, 255, .06) inset;
  transition: transform .35s var(--as-ease), box-shadow .35s var(--as-ease), opacity .25s, bottom .35s var(--as-ease);
  animation: asIn .7s var(--as-ease) .4s both;
}
.as-fab:hover { transform: translateY(-2px); box-shadow: 0 22px 44px -14px rgba(20, 22, 20, .6), 0 0 0 1px rgba(255, 255, 255, .08) inset; }
.as-fab:focus-visible { outline: 3px solid var(--cor-foco); outline-offset: 3px; }
.as-fab__icon {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--gradiente-marca); color: var(--tinta);
}
.as-fab__icon svg { width: 20px; height: 20px; stroke-width: 2; animation: asTwinkle 4.5s ease-in-out 2s infinite; }
.as-open .as-fab { opacity: 0; pointer-events: none; transform: scale(.9); }
@keyframes asIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes asTwinkle { 0%, 88%, 100% { transform: none; } 93% { transform: rotate(18deg) scale(1.12); } }

/* convite */
.as-tease {
  position: fixed; z-index: 85; right: 24px; bottom: calc(var(--as-bottom) + 66px);
  display: flex; align-items: center; gap: 4px; max-width: min(320px, calc(100vw - 48px));
  padding: 6px 6px 6px 16px; border: 1px solid var(--linha); border-radius: 16px 16px 4px 16px;
  background: #fff; box-shadow: 0 18px 40px -18px rgba(20, 22, 20, .35);
  animation: asIn .6s var(--as-ease) both;
}
.as-tease[hidden] { display: none; }
.as-tease__body { padding: 6px 0; border: 0; background: none; color: var(--tinta); font: 500 13.5px/1.35 var(--fonte-corpo); text-align: left; cursor: pointer; }
.as-tease__x { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 10px; background: none; color: var(--texto-suave); cursor: pointer; }
.as-tease__x:hover { background: var(--areia); }
.as-tease__x svg { width: 15px; height: 15px; }

/* painel */
.as-panel {
  position: fixed; z-index: 95; right: 24px; bottom: 24px;
  display: flex; flex-direction: column; width: 400px; height: min(640px, calc(100dvh - 48px));
  overflow: hidden; border: 1px solid rgba(20, 22, 20, .08); border-radius: 24px; background: var(--off-white);
  box-shadow: 0 40px 90px -30px rgba(20, 22, 20, .45), 0 12px 30px -18px rgba(20, 22, 20, .25);
  opacity: 0; transform: translateY(18px) scale(.97); transform-origin: bottom right;
  transition: opacity .26s ease, transform .4s var(--as-ease);
}
.as-panel[hidden] { display: none; }
.as-panel.is-open { opacity: 1; transform: none; }

.as-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px;
  background: var(--tinta); color: #fff; position: relative;
}
.as-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--gradiente-marca); opacity: .9; }
.as-head__avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: #fff; flex: none; }
.as-head__avatar img { width: 28px; height: auto; }
.as-head__who { display: grid; gap: 3px; min-width: 0; margin-right: auto; }
.as-head__who strong { font: 600 15.5px/1.1 var(--fonte-titulo); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-head__who small { display: flex; align-items: center; gap: 6px; color: var(--cor-texto-suave-sobre-escuro); font-size: 12px; }
.as-head__who i { width: 7px; height: 7px; border-radius: 50%; background: var(--verde-lima); box-shadow: 0 0 0 3px rgba(178, 203, 62, .2); }
.as-head__btn { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 12px; background: transparent; color: #DCE0D6; cursor: pointer; transition: background .2s; }
.as-head__btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.as-head__btn:focus-visible { outline: 2px solid var(--verde-lima); outline-offset: 1px; }

/* mensagens */
.as-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }
.as-msg { max-width: 88%; animation: asMsg .45s var(--as-ease) both; }
.as-msg > p { margin: 0; padding: 11px 14px; border-radius: 18px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.as-msg--bot { align-self: flex-start; max-width: 100%; }
.as-msg--bot > p { max-width: 88%; background: #fff; border: 1px solid var(--linha); border-bottom-left-radius: 6px; color: var(--tinta); }
.as-msg--user { align-self: flex-end; }
.as-msg--user p { background: var(--tinta); color: #fff; border-bottom-right-radius: 6px; }
.as-msg--error > p { border-color: #EBCBC3; background: #FBEDEA; color: #8A2F19; }
@keyframes asMsg { from { opacity: 0; transform: translateY(8px); } }

.as-typing { display: flex; gap: 5px; width: max-content; padding: 14px 16px; border: 1px solid var(--linha); border-radius: 18px 18px 18px 6px; background: #fff; }
.as-typing span { width: 7px; height: 7px; border-radius: 2px; background: var(--verde-medio); animation: asDot 1.1s ease-in-out infinite; }
.as-typing span:nth-child(2) { animation-delay: .15s; background: var(--verde-lima); }
.as-typing span:nth-child(3) { animation-delay: .3s; background: var(--verde-folha); }
@keyframes asDot { 0%, 70%, 100% { transform: none; opacity: .45; } 35% { transform: translateY(-4px); opacity: 1; } }

.as-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.as-chips button {
  padding: 8px 12px; border: 1px solid #D5DBC6; border-radius: 999px; background: rgba(255, 255, 255, .7);
  color: var(--tinta); font: 500 12.5px/1.2 var(--fonte-corpo); cursor: pointer; transition: border-color .2s, background .2s, transform .2s;
}
.as-chips button:hover { border-color: var(--verde-medio); background: #fff; transform: translateY(-1px); }
.as-chips button:focus-visible { outline: 2px solid var(--cor-foco); outline-offset: 2px; }

/* cartões de produto */
.as-cards { display: grid; gap: 8px; margin-top: 10px; }
.as-card {
  display: grid; grid-template-columns: 68px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 8px 10px 8px 8px; border: 1px solid var(--linha); border-radius: 16px; background: #fff;
  transition: border-color .2s, box-shadow .3s var(--as-ease), transform .3s var(--as-ease);
  animation: asMsg .5s var(--as-ease) both;
}
.as-card:nth-child(2) { animation-delay: .05s; } .as-card:nth-child(3) { animation-delay: .1s; } .as-card:nth-child(4) { animation-delay: .15s; }
.as-card:hover { border-color: #CFD6C1; box-shadow: 0 14px 28px -22px rgba(20, 22, 20, .45); }
.as-card__media { position: relative; display: block; width: 68px; height: 68px; overflow: hidden; border-radius: 11px; background: var(--areia); }
.as-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s var(--as-ease); }
.as-card:hover .as-card__media img { transform: scale(1.06); }
.as-card__ph { display: grid; place-items: center; height: 100%; color: var(--verde-folha); font: 600 24px var(--fonte-titulo); }
.as-card__tag { position: absolute; left: 4px; bottom: 4px; padding: 2px 6px; border-radius: 999px; background: var(--tinta); color: var(--verde-lima); font-size: 10px; font-weight: 700; }
.as-card__body { display: grid; gap: 2px; min-width: 0; }
.as-card__name { overflow: hidden; color: var(--tinta); font-size: 13px; font-weight: 600; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.as-card__name:hover { text-decoration: underline; text-underline-offset: 2px; }
.as-card__price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin: 2px 0 0; white-space: nowrap; }
.as-card__price strong { font: 600 15px/1.2 var(--fonte-titulo); }
.as-card__price del { color: var(--cor-metadata); font-size: 11.5px; }
.as-card__pix { margin: 0; overflow: hidden; color: var(--verde-texto-acessivel); font-size: 11.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.as-card__add {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 12px;
  border: 0; border-radius: 11px; background: var(--areia); color: var(--tinta); cursor: pointer;
  font: 600 12.5px var(--fonte-corpo); white-space: nowrap; transition: background .2s, color .2s, transform .2s;
}
.as-card__add svg { width: 16px; height: 16px; }
.as-card__add:hover { background: var(--verde-lima); }
.as-card__add:active { transform: scale(.96); }
.as-card__add.is-done { background: var(--tinta); color: var(--verde-lima); }
.as-card__add:focus-visible { outline: 2px solid var(--cor-foco); outline-offset: 2px; }
.as-card__out { color: var(--cor-metadata); font-size: 12px; font-weight: 600; }
.as-flash { margin: 0 12px; padding: 8px 12px; border-radius: 12px; background: var(--tinta); color: #fff; font-size: 12px; line-height: 1.4; animation: asMsg .35s var(--as-ease) both; }
.as-flash[hidden] { display: none; }

/* campo */
.as-form { display: flex; align-items: flex-end; gap: 8px; margin: 6px 12px 0; padding: 6px 6px 6px 14px; border: 1px solid var(--linha); border-radius: 18px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.as-form:focus-within { border-color: var(--verde-medio); box-shadow: 0 0 0 4px rgba(138, 180, 63, .14); }
.as-form textarea { flex: 1; min-height: 40px; max-height: 120px; padding: 10px 0; border: 0; outline: 0; resize: none; background: none; color: var(--tinta); font: 14px/1.4 var(--fonte-corpo); }
.as-form textarea::placeholder { color: #8B9088; }
.as-send { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 13px; background: var(--tinta); color: var(--verde-lima); cursor: pointer; transition: transform .2s, opacity .2s; flex: none; }
.as-send:hover { transform: translateX(2px); }
.as-send:disabled { opacity: .45; cursor: default; transform: none; }
.as-note { margin: 0; padding: 8px 16px 12px; color: var(--cor-metadata); font-size: 11px; line-height: 1.4; text-align: center; }

/* celular */
@media (max-width: 767px) {
  .as { --as-bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  .as-fab { right: 16px; height: 52px; padding: 0 7px; }
  .as-fab__label { display: none; }
  .as-tease { right: 16px; }
  .as-panel { inset: 0; width: auto; height: auto; max-height: none; border: 0; border-radius: 0; transform: translateY(24px); }
  .as-head { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .as-note { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .as-form textarea { font-size: 16px; }
  .as-card__add { width: 40px; padding: 0; }
  .as-card__add span { display: none; }
  .as-card__add.is-done span { display: inline; }
  .as-card__add.is-done { width: auto; padding: 0 10px; }
  .as-open body { overflow: hidden; }
}
/* página de produto: sem menu inferior; sobe acima da barra fixa de compra quando ela aparece */
@media (max-width: 767px) { .as.as--pdp { --as-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); } }
@media (max-width: 640px) { body:has(.pdp-bar.is-visible) .as.as--pdp { --as-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); } }

@media (prefers-reduced-motion: reduce) {
  .as *, .as-fab, .as-panel { animation: none !important; transition: none !important; }
}
@media print { .as { display: none !important; } }
