/* JERSEY MATRIX — MATRIX AI (balão e janela do assistente com IA) */
.ai { --ai-r: 22px; font-family: var(--body); }

/* ---------- balão flutuante ---------- */
.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 70; width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center; animation: aiFloat 4.2s ease-in-out infinite;
  transition: transform .35s var(--ease), opacity .3s;
  -webkit-tap-highlight-color: transparent;
}
.ai-fab .ai-orb { transition: transform .35s var(--ease); }
.ai-fab:hover .ai-orb { transform: scale(1.08); }
.ai-fab:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 4px; }
.ai.is-open .ai-fab { transform: scale(.92); animation: none; }
@keyframes aiFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* orbe: anel dourado girando + núcleo escuro com brilho */
.ai-orb { position: relative; width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; }
.ai-orb__ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, #9a6d25, #fff0c2, #e3b866, #5b3d10, #f7dfa2, #9a6d25);
  animation: aiSpin 3.4s linear infinite;
  box-shadow: 0 10px 34px rgba(215, 166, 79, .38), 0 0 0 1px rgba(255, 240, 194, .25);
}
.ai-orb__ring::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; background: inherit; filter: blur(14px); opacity: .45; z-index: -1; }
.ai-orb__core {
  position: absolute; inset: 3px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 28%, #2a2418 0%, #0d0c0a 55%, #050505 100%);
  box-shadow: inset 0 0 18px rgba(215, 166, 79, .28);
}
.ai-orb__core svg { animation: aiTwinkle 2.6s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(247, 223, 162, .55)); }
@keyframes aiSpin { to { transform: rotate(360deg); } }
@keyframes aiTwinkle { 0%, 100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.12) rotate(14deg); } }

/* ondas que saem do balão */
.ai-fab__waves { position: absolute; inset: 0; pointer-events: none; }
.ai-fab__waves i { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(227, 184, 102, .55); animation: aiWave 3.2s ease-out infinite; }
.ai-fab__waves i:nth-child(2) { animation-delay: 1.6s; }
@keyframes aiWave { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(1.75); opacity: 0; } }

/* partículas orbitando */
.ai-fab__orbit { position: absolute; inset: -9px; pointer-events: none; animation: aiSpin 6s linear infinite reverse; }
.ai-fab__orbit i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--gold-hi); box-shadow: 0 0 8px 2px rgba(247, 223, 162, .8); }
.ai-fab__orbit i:nth-child(1) { left: 50%; top: 0; margin-left: -2.5px; }
.ai-fab__orbit i:nth-child(2) { right: 4px; bottom: 14px; width: 4px; height: 4px; opacity: .8; }
.ai-fab__orbit i:nth-child(3) { left: 6px; bottom: 10px; width: 3px; height: 3px; opacity: .7; }

/* selo "AI" */
.ai-fab__tag {
  position: absolute; top: -4px; right: -8px; height: 21px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center; font: 800 11px/1 var(--display); letter-spacing: .08em; color: #111;
  background: var(--gold-grad); background-size: 200% 100%; animation: aiShine 3s linear infinite;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .45), 0 0 0 2px var(--bg);
}
@keyframes aiShine { to { background-position: -200% 0; } }
.ai-fab__dot { position: absolute; left: 6px; bottom: 6px; width: 12px; height: 12px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 2.5px var(--bg); }
.ai-fab__dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: #3ddc84; animation: aiPing 2s ease-out infinite; }
@keyframes aiPing { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(2.6); opacity: 0; } }

/* convite ao lado do balão */
.ai-hint {
  position: fixed; right: 102px; bottom: 40px; z-index: 70; max-width: 220px; padding: 10px 14px; border-radius: 14px 14px 4px 14px;
  background: rgba(17, 17, 17, .96); border: 1px solid rgba(215, 166, 79, .45); color: var(--text); font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5); opacity: 0; transform: translateX(10px) scale(.96); pointer-events: none;
  transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.ai-hint.show { opacity: 1; transform: none; }

/* ---------- janela da conversa ---------- */
.ai-panel {
  position: fixed; right: 22px; bottom: 104px; z-index: 90; width: 400px; height: min(640px, calc(100vh - 140px));
  display: flex; flex-direction: column; border-radius: var(--ai-r); overflow: hidden;
  background: linear-gradient(180deg, rgba(20, 18, 14, .98), rgba(8, 8, 8, .985));
  border: 1px solid rgba(215, 166, 79, .32);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .03), 0 0 60px rgba(215, 166, 79, .08);
  opacity: 0; transform: translateY(16px) scale(.97); transform-origin: 100% 100%;
  transition: opacity .25s var(--ease), transform .3s var(--ease);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.ai-panel.is-open { opacity: 1; transform: none; }
.ai-panel::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--gold-grad); background-size: 200% 100%; animation: aiShine 4s linear infinite; }

.ai-head { display: flex; align-items: center; gap: 12px; padding: 16px 14px 14px 16px; border-bottom: 1px solid var(--line); }
.ai-orb--sm { width: 40px; height: 40px; flex: none; }
.ai-orb--sm .ai-orb__core { inset: 2px; }
.ai-orb--sm svg { width: 18px; height: 18px; }
.ai-head__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ai-head__txt b { font: 800 16px/1.1 var(--display); letter-spacing: .06em; background: var(--gold-grad); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: aiShine 5s linear infinite; }
.ai-head__txt span { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.ai-head__txt em { font-style: normal; }
.ai-live { width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 8px #3ddc84; flex: none; }
.ai-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); transition: background .2s, color .2s; flex: none; }
.ai-ico:hover { background: rgba(255, 255, 255, .07); color: var(--text); }

.ai-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; overscroll-behavior: contain; }
.ai-log::-webkit-scrollbar { width: 6px; }
.ai-log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 6px; }

.ai-msg { display: flex; flex-direction: column; max-width: 88%; animation: aiIn .35s var(--ease) both; }
.ai-msg--me { align-self: flex-end; align-items: flex-end; }
.ai-msg--bot { align-self: flex-start; max-width: 94%; }
@keyframes aiIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ai-msg__b { padding: 11px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.ai-msg--bot .ai-msg__b { background: #171512; border: 1px solid rgba(255, 255, 255, .07); border-top-left-radius: 6px; color: var(--text); }
.ai-msg--me .ai-msg__b { background: linear-gradient(135deg, #e9c071, #c48f3a); color: #141006; font-weight: 500; border-top-right-radius: 6px; }
.ai-msg__b b { color: var(--gold-hi); font-weight: 700; }
.ai-msg--me .ai-msg__b b { color: inherit; }
.ai-msg__b ul { margin: 6px 0 2px; padding-left: 18px; }
.ai-msg__b li { margin: 2px 0; }
.ai-msg__b li::marker { color: var(--gold); }
.ai-msg__b a { color: var(--gold-hi); text-decoration: underline; text-underline-offset: 2px; }
.ai-msg__b--err { border-color: rgba(255, 120, 100, .3) !important; }
.ai-caret { display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--gold); border-radius: 2px; animation: aiBlink 1s steps(2) infinite; }
@keyframes aiBlink { 50% { opacity: 0; } }
.ai-wa { align-self: flex-start; margin-top: 8px; padding: 9px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 700; color: #08130c; background: #3ddc84; }

.ai-typing { display: inline-flex; align-items: center; gap: 5px; padding: 12px 14px; border-radius: 18px; border-top-left-radius: 6px; background: #171512; border: 1px solid rgba(255, 255, 255, .07); }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: aiDot 1.2s ease-in-out infinite; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
.ai-typing span { margin-left: 6px; font-size: 13px; color: var(--muted); }
@keyframes aiDot { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-4px); opacity: 1; } }

/* cartões das camisas que a IA indica */
.ai-cards { display: flex; gap: 10px; overflow-x: auto; padding: 10px 2px 6px; margin-top: 2px; scroll-snap-type: x mandatory; max-width: 100%; }
.ai-cards::-webkit-scrollbar { height: 5px; }
.ai-cards::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 5px; }
.ai-card {
  flex: none; width: 150px; scroll-snap-align: start; text-align: left; display: flex; flex-direction: column; gap: 3px;
  padding: 8px 8px 10px; border-radius: 14px; background: #121110; border: 1px solid rgba(255, 255, 255, .08);
  transition: border-color .2s, transform .25s var(--ease);
}
.ai-card:hover { border-color: rgba(215, 166, 79, .6); transform: translateY(-2px); }
.ai-card__img { display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #1c1b19; margin-bottom: 5px; }
.ai-card__img img { width: 100%; height: 100%; object-fit: cover; }
.ai-card__name { font-size: 12.5px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ai-card__meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-card__price { font: 800 14px/1.2 var(--display); color: var(--gold-hi); margin-top: 2px; }
.ai-card__price small { font: 500 10.5px var(--body); color: var(--muted); }
.ai-card__go { font-size: 11.5px; font-weight: 700; color: var(--gold); }

.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; animation: aiIn .4s .1s var(--ease) both; }
.ai-chip { padding: 8px 13px; border-radius: 999px; font-size: 13px; border: 1px solid rgba(215, 166, 79, .4); color: var(--gold-hi); background: rgba(215, 166, 79, .06); transition: background .2s, border-color .2s; text-align: left; }
.ai-chip:hover { background: rgba(215, 166, 79, .16); border-color: var(--gold); }

.ai-form { display: flex; align-items: flex-end; gap: 8px; margin: 6px 12px 0; padding: 6px 6px 6px 14px; border-radius: 22px; background: #12110f; border: 1px solid var(--line-2); transition: border-color .2s; }
.ai-form:focus-within { border-color: rgba(215, 166, 79, .6); }
.ai-form textarea { flex: 1; resize: none; border: 0; outline: 0; background: none; color: var(--text); font: 15px/1.4 var(--body); padding: 8px 0; max-height: 120px; }
.ai-form textarea::placeholder { color: #77736b; }
.ai-send { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #141006; background: linear-gradient(135deg, #f3d48e, #c48f3a); transition: transform .2s, opacity .2s; }
.ai-send:hover { transform: scale(1.06); }
.ai-send:disabled { opacity: .5; transform: none; }
.ai-foot { margin: 8px 16px 12px; font-size: 11.5px; color: #77736b; text-align: center; }
.ai-foot a { color: var(--gold); }

/* ---------- celular: janela em tela cheia ---------- */
@media (max-width: 639px) {
  .ai-fab { right: 16px; bottom: 16px; width: 60px; height: 60px; }
  .ai-hint { right: 86px; bottom: 30px; }
  .ai-panel { left: 0; right: 0; top: 0; bottom: 0; width: auto; height: auto; height: 100dvh; border-radius: 0; border: 0; transform-origin: 50% 100%; }
  .ai.is-open .ai-fab, .ai.is-open .ai-hint { opacity: 0; pointer-events: none; }
  .ai-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .ai-form textarea { font-size: 16px; }
  .ai-foot { margin-bottom: max(12px, env(safe-area-inset-bottom)); }
}
/* some quando a página do produto ou o carrinho estão abertos */
body.lock .ai-fab, body.lock .ai-hint { opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .ai-fab, .ai-orb__ring, .ai-orb__core svg, .ai-fab__waves i, .ai-fab__orbit, .ai-fab__tag, .ai-fab__dot::after, .ai-head__txt b, .ai-panel::before { animation: none !important; }
}

/* tela baixa (notebook pequeno/janela reduzida): janela ocupa a altura toda */
@media (min-width: 640px) and (max-height: 700px) {
  .ai-panel { top: 12px; bottom: 12px; height: auto; }
  .ai.is-open .ai-fab, .ai.is-open .ai-hint { opacity: 0; pointer-events: none; }
}
