/* IA en la tienda: asesora, búsqueda inteligente y test */
:root {
  --ai-1: #33cc33;
  --ai-2: #14b8a6;
  --ai-3: #7c5cff;
  --ai-grad: linear-gradient(120deg, var(--ai-1), var(--ai-2) 45%, var(--ai-3));
  /* Versión que se repite sin cortes, para los degradados que se mueven */
  --ai-grad-loop: linear-gradient(90deg, var(--ai-1), var(--ai-2), var(--ai-3), var(--ai-2), var(--ai-1));
  --ai-spark-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 2.5l1.9 5.6 5.6 1.9-5.6 1.9L10 17.5l-1.9-5.6L2.5 10l5.6-1.9z'/%3E%3Cpath d='M18.5 13l.9 2.6 2.6.9-2.6.9-.9 2.6-.9-2.6-2.6-.9 2.6-.9z'/%3E%3C/svg%3E");
}

/* Destello de IA (ícono con degradado) */
.ai-spark {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  background: var(--ai-grad-loop);
  background-size: 200% 100%;
  -webkit-mask: var(--ai-spark-svg) center / contain no-repeat;
  mask: var(--ai-spark-svg) center / contain no-repeat;
  animation: ai-twinkle 2.4s ease-in-out infinite, ai-flow 4s linear infinite;
}
@keyframes ai-twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.15) rotate(12deg); }
}
@keyframes ai-flow {
  to { background-position: 200% 0; }
}

/* Esfera animada: tres manchas de color que giran y se funden */
.ai-orb {
  position: relative;
  display: inline-block;
  flex: none;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #ffffff 0, #e9fff0 30%, #c9f2e8 60%, #b9b0ff 100%);
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.8), 0 4px 14px rgba(20, 184, 166, 0.35);
  isolation: isolate;
}
.ai-orb i {
  position: absolute;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  filter: blur(5px);
  mix-blend-mode: multiply;
  opacity: 0.9;
  animation: ai-orbit 6s linear infinite;
}
.ai-orb i:nth-child(1) {
  left: 0;
  top: 0;
  background: var(--ai-1);
}
.ai-orb i:nth-child(2) {
  right: -5%;
  top: 10%;
  background: var(--ai-2);
  animation-duration: 7.5s;
  animation-direction: reverse;
}
.ai-orb i:nth-child(3) {
  left: 15%;
  bottom: -10%;
  background: var(--ai-3);
  animation-duration: 9s;
}
.ai-orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.85), transparent 38%);
}
@keyframes ai-orbit {
  0% { transform: rotate(0deg) translateX(14%) rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) translateX(14%) rotate(-180deg) scale(1.15); }
  100% { transform: rotate(360deg) translateX(14%) rotate(-360deg) scale(1); }
}

/* Texto con brillo que recorre */
.ai-shimmer-text {
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 35%, var(--ai-2) 50%, var(--muted) 65%, var(--muted) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 600;
  animation: ai-shimmer 1.8s linear infinite;
}
@keyframes ai-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -150% 0; }
}

/* Botones con degradado de IA */
.btn-ai,
.ai-btn {
  position: relative;
  border: 0;
  background: var(--ai-grad-loop);
  background-size: 200% 100%;
  color: #fff;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.28);
  animation: ai-flow 6s linear infinite;
}
.btn-ai:hover,
.ai-btn:hover {
  box-shadow: 0 10px 30px rgba(124, 92, 255, 0.4);
  filter: saturate(1.1);
}
.btn-ai .ai-spark,
.ai-btn .ai-spark {
  background: #fff;
}
.nav-ai {
  background: linear-gradient(120deg, var(--ai-2), var(--ai-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
  font-weight: 700;
}

/* ------------------------------ Botón flotante ------------------------------ */
.ai-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 31;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 20px 0 10px;
  border: 0;
  border-radius: 999px;
  background: #1f2421;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 34px rgba(20, 30, 25, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: ai-launch-in 0.6s 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
body.has-wa .ai-launcher {
  bottom: 92px;
}
.ai-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(124, 92, 255, 0.4);
}
.ai-launcher .ai-orb {
  width: 42px;
  height: 42px;
}
/* Anillo de luz que gira alrededor del botón */
.ai-launcher-ring {
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(from var(--ai-angle, 0deg), var(--ai-1), var(--ai-2), var(--ai-3), transparent 70%, var(--ai-1));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: ai-spin 3s linear infinite;
}
.ai-launcher-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 22px rgba(20, 184, 166, 0.55);
  animation: ai-glow 2.6s ease-in-out infinite;
}
@property --ai-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}
@keyframes ai-spin {
  to { --ai-angle: 360deg; }
}
@keyframes ai-glow {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}
@keyframes ai-launch-in {
  from { opacity: 0; transform: translateY(20px) scale(0.8); }
}
body.ai-open .ai-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* Invitación */
.ai-teaser {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 31;
  display: grid;
  gap: 2px;
  max-width: 250px;
  padding: 14px 38px 14px 16px;
  border-radius: 18px 18px 6px 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  cursor: pointer;
  animation: ai-pop-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
body.has-wa .ai-teaser {
  bottom: 164px;
}
.ai-teaser span {
  color: var(--muted);
}
.ai-teaser-x {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}
.ai-teaser-x svg {
  width: 14px;
  height: 14px;
}
@keyframes ai-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.92); }
}

/* --------------------------------- Ventana de chat --------------------------------- */
.ai-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 40px));
  height: min(660px, calc(100dvh - 40px));
  overflow: hidden;
  border-radius: 26px;
  background: var(--bg);
  box-shadow: 0 30px 80px rgba(20, 30, 25, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  transform-origin: bottom right;
  animation: ai-chat-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes ai-chat-in {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
}
.ai-chat-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 12px 16px 16px;
  overflow: hidden;
  background: #1c211e;
  color: #fff;
  isolation: isolate;
}
/* Aurora: luces de color que se mueven detrás del encabezado */
.ai-aurora {
  position: absolute;
  inset: -60%;
  z-index: -1;
  background:
    radial-gradient(closest-side, rgba(51, 204, 51, 0.55), transparent) 10% 30% / 50% 60% no-repeat,
    radial-gradient(closest-side, rgba(20, 184, 166, 0.5), transparent) 60% 60% / 55% 70% no-repeat,
    radial-gradient(closest-side, rgba(124, 92, 255, 0.55), transparent) 90% 20% / 50% 60% no-repeat;
  filter: blur(18px);
  animation: ai-aurora 12s ease-in-out infinite alternate;
}
@keyframes ai-aurora {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(6%, -4%) rotate(8deg); }
  100% { transform: translate(-6%, 4%) rotate(-6deg); }
}
.ai-chat-head .ai-orb {
  width: 42px;
  height: 42px;
}
.ai-chat-title {
  display: grid;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.ai-chat-title strong {
  font-size: 16px;
}
.ai-chat-title small {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}
.ai-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ai-1);
  box-shadow: 0 0 0 0 rgba(51, 204, 51, 0.7);
  animation: ai-live 1.8s infinite;
}
@keyframes ai-live {
  70% { box-shadow: 0 0 0 7px rgba(51, 204, 51, 0); }
  100% { box-shadow: 0 0 0 0 rgba(51, 204, 51, 0); }
}
.ai-icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}
.ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}
.ai-icon-btn svg {
  width: 18px;
  height: 18px;
}

.ai-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ai-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: ai-pop-in 0.3s ease;
}
.ai-msg .ai-orb {
  width: 28px;
  height: 28px;
}
.ai-msg-user {
  justify-content: flex-end;
}
.ai-bubble {
  min-width: 0;
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 18px 18px 18px 6px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  font-size: 14.5px;
  line-height: 1.5;
}
.ai-msg-user .ai-bubble {
  border-radius: 18px 18px 6px 18px;
  background: var(--charcoal);
  color: #fff;
}
.ai-bubble p {
  margin: 0;
}
.ai-bubble p + p,
.ai-bubble ul + p,
.ai-bubble p + ul {
  margin-top: 8px;
}
.ai-bubble ul {
  margin: 0;
  padding-left: 18px;
}
.ai-bubble.ai-pop {
  animation: ai-settle 0.4s ease;
}
@keyframes ai-settle {
  from { box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.35); }
}
.ai-caret {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 2px;
  border-radius: 2px;
  background: var(--ai-grad);
  vertical-align: -2px;
  animation: ai-blink 0.9s steps(2) infinite;
}
@keyframes ai-blink {
  50% { opacity: 0; }
}
.ai-thinking span {
  animation: ai-blink 1.2s infinite;
}
.ai-thinking span:nth-child(2) { animation-delay: 0.2s; }
.ai-thinking span:nth-child(3) { animation-delay: 0.4s; }
.ai-thinking {
  color: var(--muted);
  font-weight: 600;
}
/* Mientras piensa, la esfera gira más rápido y respira */
.ai-msg.thinking .ai-orb {
  animation: ai-breathe 1.1s ease-in-out infinite;
}
.ai-msg.thinking .ai-orb i {
  animation-duration: 1.6s;
}
@keyframes ai-breathe {
  50% { transform: scale(1.12); box-shadow: inset 0 0 8px #fff, 0 0 18px rgba(124, 92, 255, 0.55); }
}

.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 36px;
}
.ai-suggestions button {
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--ai-grad) border-box;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s;
  animation: ai-pop-in 0.4s ease both;
}
.ai-suggestions button:nth-child(2) { animation-delay: 0.06s; }
.ai-suggestions button:nth-child(3) { animation-delay: 0.12s; }
.ai-suggestions button:nth-child(4) { animation-delay: 0.18s; }
.ai-suggestions button:nth-child(5) { animation-delay: 0.24s; }
.ai-suggestions button:hover {
  transform: translateY(-1px);
}

.ai-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 12px;
  padding: 6px 6px 6px 16px;
  border: 1.5px solid transparent;
  border-radius: 22px;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(120deg, var(--line), var(--line)) border-box;
  transition: background 0.2s;
}
.ai-chat-form:focus-within {
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--ai-grad) border-box;
}
.ai-chat-form textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 9px 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  resize: none;
}
.ai-send {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ai-grad-loop);
  background-size: 200% 100%;
  color: #fff;
  cursor: pointer;
  animation: ai-flow 5s linear infinite;
}
.ai-send:disabled {
  opacity: 0.5;
  cursor: default;
}
.ai-send svg {
  width: 18px;
  height: 18px;
}
.ai-disclaimer {
  margin: 8px 16px 12px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

/* Tarjetas de producto dentro de la IA */
.ai-products {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.ai-product {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  animation: ai-pop-in 0.35s ease both;
}
.ai-product:nth-child(2) { animation-delay: 0.08s; }
.ai-product:nth-child(3) { animation-delay: 0.16s; }
.ai-product-img {
  width: 54px;
  height: 54px;
  padding: 3px;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: var(--tint, var(--surface-2));
  cursor: pointer;
}
.ai-product-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}
.ai-product-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.ai-product-name {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}
.ai-product-info p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.ai-product .price {
  font-size: 15px;
}
.ai-product .price.ask {
  font-size: 12px;
}
.ai-wa {
  margin-top: 10px;
}

/* ------------------------------ Búsqueda con IA ------------------------------ */
.sug-ai button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  background: linear-gradient(#f6fbf7, #f6fbf7) padding-box, var(--ai-grad) border-box;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sug-ai.active button,
.sug-ai button:hover {
  background: linear-gradient(#eef8f1, #eef8f1) padding-box, var(--ai-grad) border-box;
}
.sug-ai span:last-child {
  display: grid;
}
.sug-ai strong {
  font-size: 14px;
}
.sug-ai small {
  color: var(--muted);
  font-size: 12px;
}
.ai-search-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
}
.ai-search-loading .ai-orb {
  animation: ai-breathe 1.1s ease-in-out infinite;
}
.ai-search-head {
  display: flex;
  gap: 10px;
  padding: 10px 10px 6px;
  font-size: 14px;
}
.ai-search-head p {
  margin: 0;
}
.ai-search-item .ai-product {
  border: 0;
  border-radius: 12px;
}
.ai-search-item .ai-product:hover {
  background: var(--surface-2);
}

/* --------------------------------- Test con IA --------------------------------- */
.ai-quiz-section {
  position: relative;
  overflow: hidden;
}
.ai-quiz {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 56px;
  align-items: center;
}
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: linear-gradient(var(--bg), var(--bg)) padding-box, var(--ai-grad) border-box;
  font-size: 13px;
  font-weight: 700;
}
.ai-quiz-copy h2 {
  margin: 16px 0 12px;
}
.ai-quiz-copy > p {
  color: var(--muted);
  font-size: 17px;
}
.ai-quiz-copy .checks {
  margin: 18px 0 24px;
}
.ai-quiz-card {
  position: relative;
  isolation: isolate;
}
/* Resplandor de colores que gira detrás de la tarjeta */
.ai-quiz-glow {
  position: absolute;
  inset: -18px;
  z-index: -1;
  border-radius: 40px;
  background: conic-gradient(from var(--ai-angle, 0deg), var(--ai-1), var(--ai-2), var(--ai-3), var(--ai-1));
  filter: blur(36px);
  opacity: 0.45;
  animation: ai-spin 8s linear infinite;
}
.ai-quiz-box {
  min-height: 380px;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
}
.ai-quiz-box.quiz-in > * {
  animation: ai-pop-in 0.4s ease both;
}
.ai-quiz-box.quiz-in > :nth-child(2) { animation-delay: 0.04s; }
.ai-quiz-box.quiz-in > :nth-child(3) { animation-delay: 0.08s; }
.ai-quiz-box.quiz-in > :nth-child(4) { animation-delay: 0.12s; }
.ai-quiz-box h3 {
  margin: 4px 0 18px;
  font-size: 24px;
}
.quiz-progress {
  display: flex;
  gap: 6px;
}
.quiz-progress i {
  flex: 1;
  height: 5px;
  border-radius: 5px;
  background: var(--line);
}
.quiz-progress i.on {
  background: var(--ai-grad);
}
.quiz-step {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.quiz-options button {
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.quiz-options button:hover {
  transform: translateY(-2px);
  border-color: var(--ai-2);
}
.quiz-options button[aria-pressed="true"] {
  border-color: transparent;
  background: var(--ai-grad);
  color: #fff;
}
.quiz-back {
  margin-top: 18px;
}
.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.quiz-loading {
  display: grid;
  min-height: 316px;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
}
.quiz-loading .ai-orb {
  width: 84px;
  height: 84px;
  animation: ai-breathe 1.2s ease-in-out infinite;
}
.quiz-loading .ai-orb i {
  animation-duration: 2s;
  filter: blur(10px);
}
.quiz-loading p {
  margin: 8px 0 0;
  font-size: 18px;
}
.quiz-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ai-3);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.quiz-result h3 {
  margin: 8px 0;
}
.quiz-result > p {
  margin: 0;
  color: var(--muted);
}
.quiz-tip {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--green-soft);
  color: #1d4d24;
  font-size: 14px;
}
.quiz-result .ai-disclaimer {
  margin: 14px 0 0;
  text-align: left;
}

@media (max-width: 980px) {
  .ai-quiz {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

@media (max-width: 600px) {
  .ai-launcher {
    right: 16px;
    bottom: 16px;
    height: 56px;
    padding: 0 7px;
  }
  body.has-wa .ai-launcher {
    bottom: 86px;
  }
  .ai-launcher-label {
    display: none;
  }
  .ai-teaser {
    right: 16px;
    bottom: 84px;
  }
  body.has-wa .ai-teaser {
    bottom: 154px;
  }
  .ai-chat {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }
  .ai-chat-form {
    margin-bottom: 0;
  }
  .ai-quiz-box {
    min-height: 0;
    padding: 22px 18px;
    border-radius: 22px;
  }
  .ai-quiz-box h3 {
    font-size: 21px;
  }
  .quiz-options button {
    flex: 1 1 calc(50% - 10px);
    padding: 11px 12px;
    font-size: 14px;
  }
}
