/* ============================================
   CHAT WIDGET - ESTILOS PROFESIONALES
   Diseño minimalista y elegante
   ============================================ */

:root {
  /* Colores principales */
  --mc-primary: #05679B;
  --mc-primary-dark: #044a75;
  --mc-primary-light: #0678b8;
  --mc-on-primary: #ffffff;
  --mc-bg: #ffffff;
  --mc-surface: #f9fafb;
  --mc-border: #e5e7eb;
  --mc-border-light: #f3f4f6;
  --mc-text: #1f2937;
  --mc-text-light: #374151;
  --mc-muted: #6b7280;
  --mc-success: #10b981;
  --mc-error: #ef4444;

  /* Sombras profesionales (múltiples capas) */
  --mc-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --mc-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --mc-shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --mc-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --mc-shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --mc-shadow-launcher: 0 8px 16px rgba(5, 103, 155, 0.3), 0 4px 8px rgba(5, 103, 155, 0.2);

  /* Efectos */
  --mc-blur: blur(8px);
  --mc-radius: 16px;
  --mc-radius-sm: 12px;
  --mc-radius-lg: 20px;
  --mc-radius-full: 9999px;
}

/* ============================================
   LAUNCHER (Botón Flotante)
   ============================================ */

#mc-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483646;
  width: 64px;
  height: 64px;
  border-radius: var(--mc-radius-full);
  border: none;
  background: linear-gradient(135deg, var(--mc-primary) 0%, var(--mc-primary-light) 100%);
  color: var(--mc-on-primary);
  box-shadow: var(--mc-shadow-launcher);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              scale 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#mc-chat-launcher:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 24px rgba(5, 103, 155, 0.4), 0 6px 12px rgba(5, 103, 155, 0.3);
}

#mc-chat-launcher:active {
  transform: translateY(-2px) scale(0.98);
}

#mc-chat-launcher svg {
  width: 28px;
  height: 28px;
  display: block;
}

/* ============================================
   BOCADILLO DEL LAUNCHER
   ============================================ */

#mc-launcher-bubble {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 2147483645;
  max-width: 240px;
  background: var(--mc-bg);
  color: var(--mc-text);
  border-radius: var(--mc-radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--mc-shadow-md);
  border: 1px solid var(--mc-border);
  display: none;
  line-height: 1.4;
  animation: mcBubbleSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transition: opacity 0.2s ease;
}

#mc-launcher-bubble.visible {
  display: block;
  animation: mcBubbleSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1), mcBubblePulse 3s ease-in-out infinite;
  opacity: 1;
}

#mc-launcher-bubble.changing {
  opacity: 0;
  transition: opacity 0.2s ease;
}

#mc-launcher-bubble::after {
  content: '';
  position: absolute;
  right: 18px;
  bottom: -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid var(--mc-bg);
  border-bottom: none;
}

@keyframes mcBubbleSlideIn {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes mcBubblePulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.75;
  }
}

/* ============================================
   WIDGET DE CHAT
   ============================================ */

#mc-chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2147483647;
  width: 420px;
  max-width: calc(100vw - 48px);
  height: 680px;
  max-height: calc(100vh - 48px);
  background: var(--mc-bg);
  border-radius: var(--mc-radius-lg);
  display: none;
  box-shadow: var(--mc-shadow-xl);
  border: 1px solid var(--mc-border-light);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: mcWidgetOpen 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mc-chat-widget.chat-fullscreen {
  width: 90% !important;
  height: 92% !important;
  right: 5% !important;
  bottom: 4% !important;
  border-radius: var(--mc-radius);
}

@keyframes mcWidgetOpen {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ============================================
   HEADER DEL WIDGET
   ============================================ */

#mc-chat-header {
  background: linear-gradient(135deg, var(--mc-primary) 0%, var(--mc-primary-dark) 100%);
  color: var(--mc-on-primary);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

#mc-chat-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.mc-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mc-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--mc-radius-full);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mc-avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mc-avatar svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.mc-title {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.mc-title strong {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.mc-title span {
  font-size: 12px;
  opacity: 0.9;
  font-weight: 400;
}

.mc-actions {
  display: flex;
  gap: 8px;
}

.mc-iconbtn {
  all: unset;
  cursor: pointer;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--mc-on-primary);
  transition: background 0.15s ease, transform 0.15s ease;
}

.mc-iconbtn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.1);
}

.mc-iconbtn:active {
  transform: scale(0.95);
}

.mc-iconbtn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* ============================================
   ÁREA DE MENSAJES
   ============================================ */

#mc-chat-messages {
  flex: 1;
  background: var(--mc-surface);
  padding: 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Scrollbar personalizada */
#mc-chat-messages::-webkit-scrollbar {
  width: 6px;
}

#mc-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#mc-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

#mc-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ============================================
   BURBUJAS DE MENSAJE
   ============================================ */

.mc-row {
  display: flex;
  gap: 8px;
  animation: mcMessageSlideIn 0.25s ease-out;
}

.mc-row.user {
  justify-content: flex-end;
}

.mc-row.bot {
  justify-content: flex-start;
}

@keyframes mcMessageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mc-bubble {
  position: relative;
  max-width: 75%;
  padding: 14px 16px;
  border-radius: var(--mc-radius);
  font-size: 14px;
  line-height: 1.5;
  box-shadow: var(--mc-shadow-sm);
  word-wrap: break-word;
}

.mc-bubble.bot {
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  color: var(--mc-text);
  border-radius: var(--mc-radius) var(--mc-radius) var(--mc-radius) 4px;
}

.mc-bubble.bot::after {
  content: '';
  position: absolute;
  left: -6px;
  top: 14px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid var(--mc-bg);
}

.mc-bubble.user {
  background: var(--mc-primary);
  color: var(--mc-on-primary);
  border: none;
  border-radius: var(--mc-radius) var(--mc-radius) 4px var(--mc-radius);
}

.mc-bubble.user::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 14px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid var(--mc-primary);
}

.mc-meta {
  margin-top: 6px;
  font-size: 10px;
  color: var(--mc-muted);
  opacity: 0.7;
}

/* ============================================
   INDICADOR DE ESCRITURA (TYPING)
   ============================================ */

.mc-typing {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mc-typing span {
  width: 8px;
  height: 8px;
  background: var(--mc-muted);
  border-radius: var(--mc-radius-full);
  animation: mcType 1.4s infinite ease-in-out;
}

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

.mc-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes mcType {
  0%, 100% {
    transform: scale(1);
    opacity: 0.4;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* ============================================
   INTENCIONES (QUICK ACTIONS)
   ============================================ */

#mc-intents {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--mc-bg);
  border-top: 1px solid var(--mc-border-light);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

#mc-intents::-webkit-scrollbar {
  display: none;
}

.mc-intent {
  appearance: none;
  border-radius: var(--mc-radius-full);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--mc-primary);
  color: var(--mc-primary);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.04s ease;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.mc-intent:hover {
  background: var(--mc-primary);
  color: var(--mc-on-primary);
  transform: scale(1.05);
}

.mc-intent:active {
  transform: scale(0.98);
}

.mc-intent.is-primary {
  background: var(--mc-primary);
  color: var(--mc-on-primary);
}

/* ============================================
   INPUT DE MENSAJE
   ============================================ */

#mc-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--mc-bg);
  border-top: 1px solid var(--mc-border-light);
  flex-shrink: 0;
}

#mc-input {
  flex: 1;
  height: 44px;
  border-radius: var(--mc-radius-sm);
  border: 1.5px solid var(--mc-border);
  padding: 12px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: var(--mc-bg);
  color: var(--mc-text);
}

#mc-input::placeholder {
  color: var(--mc-muted);
}

#mc-input:focus {
  border-color: var(--mc-primary);
  box-shadow: 0 0 0 3px rgba(5, 103, 155, 0.1);
}

/* ============================================
   BOTÓN ENVIAR
   ============================================ */

#mc-send {
  height: 44px;
  padding: 0 20px;
  border-radius: var(--mc-radius-sm);
  border: none;
  cursor: pointer;
  background: var(--mc-primary);
  color: var(--mc-on-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease, transform 0.15s ease;
}

#mc-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

#mc-send:hover {
  background: var(--mc-primary-dark);
  transform: scale(1.02);
}

#mc-send:active {
  transform: scale(0.98) translateY(1px);
}

#mc-send[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================
   PREVISUALIZACIÓN DE PRODUCTOS
   ============================================ */

.mc-product-preview {
  margin-top: 10px;
  background: var(--mc-bg);
  border: 1.5px solid var(--mc-border);
  border-radius: var(--mc-radius);
  overflow: hidden;
  display: flex;
  gap: 14px;
  padding: 14px;
  box-shadow: var(--mc-shadow-md);
  animation: mcMessageSlideIn 0.3s ease-out;
  max-width: 100%;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  position: relative;
}

.mc-product-preview:hover {
  box-shadow: var(--mc-shadow-lg);
  transform: translateY(-2px);
}

.mc-product-image {
  flex-shrink: 0;
  width: 140px;
  height: 140px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--mc-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--mc-shadow-sm);
  position: relative;
}

.mc-product-image::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
  pointer-events: none;
}

.mc-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.mc-product-preview:hover .mc-product-image img {
  transform: scale(1.05);
}

.mc-product-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--mc-primary-light) 0%, var(--mc-primary) 100%);
  color: var(--mc-on-primary);
  position: relative;
  overflow: hidden;
}

.mc-product-image-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.mc-product-image-placeholder svg {
  opacity: 0.7;
  width: 56px;
  height: 56px;
  z-index: 1;
  position: relative;
}

.mc-product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  justify-content: space-between;
}

.mc-product-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--mc-text);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.01em;
}

.mc-product-description {
  font-size: 13px;
  color: var(--mc-muted);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.mc-product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--mc-border-light);
}

.mc-product-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--mc-primary);
  letter-spacing: -0.02em;
}

.mc-product-price-placeholder {
  font-size: 14px;
  font-weight: 500;
  color: var(--mc-muted);
  font-style: italic;
}

.mc-product-link {
  font-size: 13px;
  color: var(--mc-primary);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(5, 103, 155, 0.08);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mc-product-link:hover {
  background: var(--mc-primary);
  color: var(--mc-on-primary);
  transform: translateY(-1px);
  box-shadow: var(--mc-shadow-sm);
  text-decoration: none;
}

.mc-product-link::after {
  content: '→';
  font-size: 14px;
  transition: transform 0.2s ease;
}

.mc-product-link:hover::after {
  transform: translateX(2px);
}

/* ============================================
   PREVISUALIZACIÓN COMPACTA (cuando falta información)
   ============================================ */

.mc-product-preview-compact {
  padding: 14px 18px;
  gap: 0;
  flex-direction: row;
  align-items: center;
  border-left: 3px solid var(--mc-primary);
  background: linear-gradient(to right, rgba(5, 103, 155, 0.03) 0%, transparent 100%);
}

.mc-product-info-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.mc-product-title-compact {
  font-size: 15px;
  font-weight: 600;
  color: var(--mc-text);
  margin: 0;
  line-height: 1.4;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.01em;
}

.mc-product-link-compact {
  font-size: 13px;
  color: var(--mc-on-primary);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--mc-primary);
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(5, 103, 155, 0.2);
}

.mc-product-link-compact:hover {
  background: var(--mc-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(5, 103, 155, 0.3);
  text-decoration: none;
}

.mc-product-link-compact::after {
  content: '→';
  font-size: 14px;
  transition: transform 0.2s ease;
  margin-left: 2px;
}

.mc-product-link-compact:hover::after {
  transform: translateX(3px);
}

/* Enlaces de productos detectados en texto */
.mc-product-link-detected {
  color: var(--mc-primary);
  text-decoration: underline;
  font-weight: 500;
  transition: opacity 0.15s ease;
}

.mc-product-link-detected:hover {
  opacity: 0.8;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 480px) {
  #mc-chat-widget {
    width: 96%;
    right: 2%;
    height: 85vh;
  }

  #mc-launcher-bubble {
    right: 20px;
    bottom: 96px;
  }

  #mc-launcher-bubble::after {
    right: 22px;
    bottom: -7px;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid var(--mc-bg);
    border-bottom: none;
  }

  .mc-product-preview {
    flex-direction: column;
  }

  .mc-product-image {
    width: 100%;
    height: 200px;
  }
}

/* ============================================
   UTILIDADES
   ============================================ */

.mc-hidden {
  display: none !important;
}

