/* ══════════════════════════════════════════════════════════════════════════════
   MARIANA IA CHATBOT - DESIGN SYSTEM
   Soft Luxury / Beige - Transparent Glassmorphism
   ══════════════════════════════════════════════════════════════════════════════ */

:root {
  --chat-gold: var(--gold-muted, #b39b6d);
  --chat-gold-light: var(--gold-soft, #a18a5e);
  --chat-gold-deep: var(--gold-deep, #8a7553);
  --chat-dark: var(--ink-soft, #2a2a2a);
  --chat-text: var(--text-primary, #4a4a4a);
  --chat-bg-glass: rgba(249, 248, 246, 0.85);
  --chat-border: rgba(204, 201, 195, 0.5);
  --chat-shadow: var(--shadow-4, 0 12px 32px rgba(0, 0, 0, 0.08)), var(--shadow-gold, 0 8px 24px rgba(179, 155, 109, 0.15));
}

/* --- Floating Button --- */
#mariana-chat-trigger {
  position: fixed;
  bottom: 50px;
  /* despeja el botón de "volver arriba" de la página de producto */
  right: 24px;
  /* ← DERECHA, alineado con el panel de chat */
  left: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-gold), var(--chat-gold-deep));
  color: white;
  border: none;
  box-shadow: 0 8px 24px rgba(179, 155, 109, 0.3);
  cursor: pointer;
  z-index: 1800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#mariana-chat-trigger:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 12px 30px rgba(179, 155, 109, 0.45);
}

#mariana-chat-trigger .chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background-color: var(--chat-gold-light);
  border: 2px solid white;
  border-radius: 50%;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.15);
    opacity: 1;
  }

  100% {
    transform: scale(0.95);
    opacity: 0.8;
  }
}

/* --- Mariana Teaser / Callout Bubble --- */
#mariana-chat-teaser {
  position: fixed;
  bottom: 118px;
  right: 24px;
  width: 280px;
  max-width: calc(100vw - 48px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(179, 155, 109, 0.38);
  border-radius: 18px 18px 6px 18px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.1), 0 4px 14px rgba(179, 155, 109, 0.2);
  padding: 13px 15px 12px 15px;
  z-index: 1799;
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.165, 0.84, 0.44, 1), transform 0.35s cubic-bezier(0.165, 0.84, 0.44, 1);
  font-family: var(--font-sans, 'Lato', -apple-system, BlinkMacSystemFont, sans-serif);
}

#mariana-chat-teaser::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid rgba(179, 155, 109, 0.38);
  border-bottom: 1px solid rgba(179, 155, 109, 0.38);
  transform: rotate(45deg);
  border-radius: 2px;
}

#mariana-chat-teaser.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: marianaTeaserFloat 4s ease-in-out infinite alternate;
}

@keyframes marianaTeaserFloat {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-4px);
  }
}

.mariana-teaser-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  padding-right: 18px;
}

.mariana-teaser-sparkle {
  font-size: 0.95rem;
  line-height: 1;
}

.mariana-teaser-header strong {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--chat-gold-deep, #8a7553);
  letter-spacing: 0.2px;
}

.mariana-teaser-close {
  position: absolute;
  top: 7px;
  right: 8px;
  background: transparent;
  border: none;
  color: #999;
  font-size: 1.15rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s ease;
  z-index: 2;
}

.mariana-teaser-close:hover {
  background: rgba(0, 0, 0, 0.07);
  color: #222;
}

.mariana-teaser-text {
  font-size: 0.84rem;
  color: #444;
  line-height: 1.4;
  margin: 0 0 7px 0;
}

.mariana-teaser-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--chat-gold, #b39b6d);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: gap 0.2s ease, color 0.2s ease;
}

#mariana-chat-teaser:hover .mariana-teaser-cta {
  gap: 7px;
  color: var(--chat-gold-deep, #8a7553);
}

/* Bloquear scroll de la página de fondo cuando el chat está abierto en móvil */
body.mariana-chat-open,
html.mariana-chat-open {
  overflow: hidden !important;
  height: 100% !important;
  touch-action: none !important;
  -webkit-overflow-scrolling: auto !important;
}

/* --- Chat Container --- */
#mariana-chat-container {
  position: fixed;
  top: 24px;
  bottom: 24px;
  right: 24px;
  left: auto;
  width: 360px;
  height: auto;
  border-radius: 20px;
  background: var(--chat-bg-glass);
  backdrop-filter: blur(25px) saturate(1.2);
  -webkit-backdrop-filter: blur(25px) saturate(1.2);
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow);
  z-index: 1800;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  /* Tipografía elegante oficial de la tienda */
  font-family: var(--font-sans, 'Lato', sans-serif) !important;
}

#mariana-chat-container.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* --- Header --- */
.mariana-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(249, 248, 246, 0.9), rgba(235, 233, 230, 0.9));
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.mariana-avatar-container {
  position: relative;
}

.mariana-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--chat-gold);
  object-fit: cover;
}

.mariana-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #27ae60;
  border: 1.5px solid white;
}

.mariana-header-info {
  flex: 1;
}

.mariana-header-info h4 {
  margin: 0;
  font-family: var(--font-display, 'Cinzel', serif) !important;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--chat-dark);
}

.mariana-header-info span {
  font-size: 0.75rem;
  color: #777;
  display: block;
}

.mariana-close-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: #888;
  cursor: pointer;
  transition: color 0.3s;
}

.mariana-close-btn:hover {
  color: var(--chat-dark);
}

/* --- Messages Body --- */
.mariana-body {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--chat-gold) transparent;
}

.mariana-body::-webkit-scrollbar {
  width: 4px;
}

.mariana-body::-webkit-scrollbar-track {
  background: transparent;
}

.mariana-body::-webkit-scrollbar-thumb {
  background: var(--chat-gold);
  border-radius: 4px;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-wrap: break-word;
  color: var(--chat-text) !important;
  /* Texto marrón cálido de marca, en vez de negro genérico */
  font-family: var(--font-sans, 'Lato', sans-serif) !important;
}

.chat-bubble.bot {
  background-color: white;
  color: var(--chat-text) !important;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.03);
  max-width: 95%;
  /* Ensanchar para que quepan mejor las tarjetas de producto */
}

.chat-bubble.user {
  background: linear-gradient(135deg, var(--chat-gold), var(--chat-gold-deep));
  color: white !important;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(179, 155, 109, 0.15);
}

/* Enlaces estilo Oro en la conversación bot */
.chat-bubble.bot a {
  color: var(--chat-gold-deep) !important;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(138, 117, 83, 0.4);
  transition: all 0.2s;
}

.chat-bubble.bot a:hover {
  color: var(--chat-gold) !important;
  text-decoration-color: var(--chat-gold) !important;
}

/* Markdown rendered elements inside bot bubbles */
.chat-bubble.bot strong {
  font-weight: 700;
  color: var(--chat-dark);
}

.chat-bubble.bot em {
  font-style: italic;
  color: #555;
}

.chat-bubble.bot .chat-list {
  margin: 6px 0 6px 4px;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-bubble.bot .chat-list li {
  line-height: 1.5;
  color: var(--chat-dark);
}

.chat-bubble.bot br+br {
  display: none;
  /* evitar doble espacio */
}

/* Typind indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background-color: white;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background-color: var(--chat-gold);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing-bounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

/* --- Input Area --- */
.mariana-input-area {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 12px 20px;
  background-color: white;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.mariana-input-area input {
  flex: 1;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.3s;
}

.mariana-input-area input:focus {
  border-color: var(--chat-gold);
}

.mariana-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--chat-gold);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s;
}

.mariana-send-btn:hover {
  background-color: var(--chat-gold-deep);
}

/* --- Product Cards with images inside chat --- */
.chat-bubble.bot .chat-list {
  list-style: none;
  padding-left: 0;
  margin: 8px 0;
}

.chat-bubble.bot .product-card-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid rgba(179, 155, 109, 0.2);
  /* Borde dorado premium suave */
  border-radius: 12px;
  padding: 10px;
  margin-top: 8px;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.chat-bubble.bot .product-card-item:hover {
  box-shadow: 0 4px 12px rgba(179, 155, 109, 0.15);
  border-color: var(--chat-gold);
}

.product-card-thumb {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card-thumb:hover {
  transform: scale(1.06);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.chat-add-to-cart-btn {
  flex-basis: 100%;
  background: linear-gradient(135deg, var(--chat-gold, #b39b6d), var(--chat-gold-deep, #8a7553));
  color: white;
  border: none;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-sans, 'Lato', sans-serif);
  cursor: pointer;
  transition: opacity 0.2s;
}

.chat-add-to-cart-btn:hover {
  opacity: 0.88;
}

.chat-inline-image {
  max-width: 100%;
  width: 100%;
  border-radius: 12px;
  margin: 6px 0;
  display: block;
  object-fit: cover;
}

/* Instrucciones de compra debajo de la tarjeta de producto */
.product-card-note {
  font-size: 0.78rem;
  color: #6b5c4a;
  margin: 4px 0 6px 0;
  padding: 8px 10px;
  background: rgba(179, 155, 109, 0.08);
  border-left: 3px solid var(--chat-gold, #b39b6d);
  border-radius: 0 8px 8px 0;
  line-height: 1.5;
  font-family: var(--font-sans, 'Lato', sans-serif);
}

/* --- Mobile Adaptations: mismo estilo y formas que escritorio, a pantalla completa --- */
@media (max-width: 480px) {

  #mariana-chat-trigger {
    width: 48px !important;
    height: 48px !important;
    font-size: 1.3rem !important;
    bottom: calc(85px + env(safe-area-inset-bottom, 0px)) !important;
    right: 18px !important;
  }

  #mariana-chat-teaser {
    bottom: calc(142px + env(safe-area-inset-bottom, 0px)) !important;
    right: 18px !important;
    width: 255px !important;
    max-width: calc(100vw - 36px) !important;
    padding: 11px 13px 10px 13px !important;
  }

  #mariana-chat-teaser .mariana-teaser-text {
    font-size: 0.8rem !important;
  }

  /* En móvil el chat ocupa la pantalla visual libre (manejada dinámicamente con Visual Viewport) */
  #mariana-chat-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 999999 !important;
    transition: transform 0.25s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.25s ease !important;
    transform: translateY(100%) !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
  }

  #mariana-chat-container.active {
    transform: translateY(0) !important;
    opacity: 1 !important;
  }

  /* Botón volver (solo existe en móvil, usa el mismo color que el botón cerrar de escritorio) */
  .mariana-back-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    color: #888 !important;
    padding: 6px !important;
    margin-right: 2px !important;
    cursor: pointer !important;
    transition: color 0.3s !important;
  }

  .mariana-back-btn:hover {
    color: var(--chat-dark) !important;
  }

  #mariana-chat-container .mariana-header {
    flex-shrink: 0 !important;
    padding: 12px 16px !important;
  }

  #mariana-chat-container .mariana-body {
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding: 14px !important;
  }

  /* Zona segura del teclado/notch, sin cambiar el estilo del área de input */
  #mariana-chat-container .mariana-input-area {
    padding: 10px 14px !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
    flex-shrink: 0 !important;
  }

  /* 16px evita que iOS haga zoom automático al enfocar el campo */
  .mariana-input-area input {
    font-size: 16px !important;
  }
}

/* --- Fancybox Carousel: Close button always visible on the image --- */
.fancybox__toolbar {
  --fancybox-color: #fff;
  background: transparent !important;
  padding: 0 !important;
}

/* Make the close button a solid, clearly visible circle on the image */
.fancybox__button--close {
  position: fixed !important;
  top: 12px !important;
  right: 12px !important;
  z-index: 999999 !important;
  width: 42px !important;
  height: 42px !important;
  border-radius: 50% !important;
  background: rgba(0, 0, 0, 0.65) !important;
  color: #fff !important;
  border: 2px solid rgba(255, 255, 255, 0.7) !important;
  backdrop-filter: blur(8px) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
  opacity: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: background 0.2s, transform 0.2s !important;
}

.fancybox__button--close:hover {
  background: rgba(0, 0, 0, 0.85) !important;
  transform: scale(1.1) !important;
  border-color: #fff !important;
}

.fancybox__button--close svg {
  width: 20px !important;
  height: 20px !important;
  stroke-width: 2.5px !important;
  color: #fff !important;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)) !important;
}

/* Ensure Fancybox container has highest z-index when opened from chat */
.fancybox__container {
  z-index: 999990 !important;
}

/* En Desktop ocultar el botón volver */
@media (min-width: 481px) {
  .mariana-back-btn {
    display: none !important;
  }
}