.xai-chat {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 360px;
  max-width: 90vw;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 5px 25px rgba(0,0,0,0.15);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
}

.xai-chat.minimized {
   display: flex !important; /* Mantenlo como flex pero contrólalo con la visibilidad */
   opacity: 0;
   visibility: hidden;
   transform: translateY(20px);
}

.xai-chat.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ESTE ES EL CÓDIGO CORREGIDO */
.xai-chat-minimized {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #007bff;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;  /* <--- ¡ESTA ES LA CORRECCIÓN! */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 99999;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
}
.xai-chat-minimized:hover {
    transform: scale(1.1);
}

.xai-chat-minimized.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.minimized-profile-pic {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* --- INICIO DE SECCIÓN CORREGIDA --- */
.chat-header {
  background: #007bff;
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between; /* Organiza los elementos en los extremos */
  align-items: center;
  font-weight: 600;
  font-size: 1em;
  position: relative;
}

.chat-header-title {
    flex-grow: 1; /* Permite que el título ocupe el espacio central */
    text-align: center; /* Centra el texto */
    margin: 0 10px; /* Añade un pequeño margen para que no toque los íconos */
}

.chat-toggle {
  cursor: pointer;
  font-size: 24px;
  font-weight: bold;
  padding: 0 5px;
  line-height: 1;
}
/* --- FIN DE SECCIÓN CORREGIDA --- */

.chat-body {
  flex-grow: 1;
  max-height: 400px;
  min-height: 200px;
  overflow-y: auto;
  padding: 16px;
  background: #f4f7f9;
  border-top: 1px solid #e9ecef;
  border-bottom: 1px solid #e9ecef;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}
.chat-body::-webkit-scrollbar-track {
  background: #f4f7f9;
}
.chat-body::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}
.chat-body::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.chat-footer {
  display: flex;
  padding: 12px 16px;
  background: #ffffff;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 10px 15px;
  border: 1px solid #ced4da;
  border-radius: 20px;
  background: #ffffff;
  font-size: 0.95em;
  margin-right: 8px;
}

.chat-input:focus {
  outline: none;
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.chat-send, .chat-clear {
  padding: 8px 15px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 600;
  transition: background-color 0.2s ease;
}

.chat-send {
  background: #007bff;
  color: white;
  border: none;
  width: 38px; /* Ancho fijo */
  height: 38px; /* Altura fija para hacerlo cuadrado */
  border-radius: 50%; /* Lo hace completamente circular */
  padding: 0; /* Eliminamos el padding que ya no es necesario */
  cursor: pointer;
  display: flex; /* Usamos flexbox para centrar el ícono */
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
  margin-left: 8px; /* Ajustamos el margen */
}

/* Regla adicional para ajustar el tamaño del ícono */
.chat-send .dashicons-arrow-right-alt2 {
    font-size: 22px;
    line-height: 1;
}

.chat-send:hover {
  background: #0056b3;
}

/* ESTILOS NUEVOS */
.chat-clear {
  background: #6c757d;
  color: white;
  margin-left: 8px;
  border: none;
  width: 38px; /* Ancho fijo */
  height: 38px; /* Altura fija para hacerlo cuadrado */
  border-radius: 50%; /* Lo hace completamente circular */
  padding: 0; /* Eliminamos el padding que ya no es necesario */
  cursor: pointer;
  display: flex; /* Usamos flexbox para centrar el ícono */
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.chat-clear:hover {
  background: #545b62;
}

/* Ajustamos el tamaño del ícono dentro del botón */
.chat-clear .dashicons-trash {
  font-size: 20px;
  line-height: 1;
}

.user-message, .bot-message {
  display: flex;
  align-items: flex-end;
  margin-bottom: 12px;
  max-width: 85%;
}

.user-message {
  margin-left: auto;
  flex-direction: row-reverse;
}

.bot-message {
  margin-right: auto;
  flex-direction: row;
}

.message-content {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.95em;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.user-message .message-content {
  background: #007bff;
  color: white;
  border-bottom-right-radius: 5px;
}

.bot-message .message-content {
  background: #e9ecef;
  color: #212529;
  border-bottom-left-radius: 5px;
}

.profile-pic {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin: 0 8px;
  object-fit: cover;
  background-color: #adb5bd;
  border: 1px solid #fff;
  box-shadow: 0 0 2px rgba(0,0,0,0.1);
}

.bot-message .highlight {
  font-weight: bold;
  color: #0056b3;
}

.bot-message a {
  color: #0056b3;
  text-decoration: underline;
  font-weight: 500;
}
.bot-message a:hover {
  color: #003d80;
}

.product-welcome .product-item {
  display: flex;
  align-items: center;
  margin: 8px 0;
  padding: 5px;
  border-radius: 6px;
}

.product-thumbnail {
  width: 40px;
  height: 40px;
  object-fit: cover;
  margin-right: 10px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
}

.typing-dots span {
  display: inline-block; /* <-- LÍNEA AÑADIDA */
  width: 8px;
  height: 8px;
  background: blue; /* <-- Color corregido con alto contraste */
  border-radius: 50%;
  margin: 0 3px;
  animation: typingPulse 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typingPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1.0); opacity: 1; }
}

.bot-message.bot-context-message .message-content {
  background-color: #eef2f7;
  border-left: 3px solid #6c757d;
  font-style: italic;
  font-size: 0.9em;
  color: #495057;
}

.xai-action-buttons {
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid #dee2e6;
  text-align: center;
}

.xai-action-btn {
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  margin: 5px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}
.xai-action-btn:hover {
  background-color: #0056b3;
  transform: translateY(-1px);
}
.xai-action-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0,123,255,.35);
}

a.xai-action-btn-link {
  display: inline-block;
  background-color: #28a745;
  color: white;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.9em;
  font-weight: 600;
  text-decoration: none;
  margin: 5px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}
a.xai-action-btn-link:hover {
  background-color: #1e7e34;
  color: white;
  transform: translateY(-1px);
}

/* --- ESTILOS PARA EL CARRITO --- */

.chat-header .chat-cart-link {
    color: white;
    text-decoration: none;
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
}
.chat-header .chat-cart-link:hover {
    opacity: 0.8;
}

.chat-header .chat-cart-link svg {
    width: 20px;
    height: 20px;
    fill: currentColor; /* Esto hace que el ícono sea blanco, heredando el color del enlace */
}

/* Es buena idea añadir esto para alinear el ícono perfectamente */
.chat-header .chat-cart-link .dashicons-cart:before {
    vertical-align: middle;
}

.chat-header .chat-cart-count {
    position: absolute;
    top: -4px;
    right: -8px;
    background-color: #28a745;
    color: white;
    border-radius: 50%;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: bold;
    line-height: 1.2;
    border: 2px solid #007bff;
    min-width: 20px;
    text-align: center;
}

.xai-cart-summary {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    background-color: #f8f9fa;
    margin-bottom: 15px;
}

.xai-cart-summary h4 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1em;
    color: #343a40;
    text-align: center;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
}

.xai-cart-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.9em;
}

.xai-cart-item:last-of-type {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.xai-cart-item-thumbnail img {
    width: 45px;
    height: 45px;
    border-radius: 4px;
    margin-right: 10px;
    object-fit: cover;
}

.xai-cart-item-details {
    flex-grow: 1;
    line-height: 1.3;
}

.xai-cart-item-name {
    font-weight: 600;
    color: #0056b3;
    display: block;
}
.xai-cart-item-name a {
    color: inherit;
    text-decoration: none;
}
.xai-cart-item-price {
    font-size: 0.9em;
    color: #6c757d;
}

.xai-cart-item-remove {
    margin-left: 10px;
}

.xai-remove-item-btn {
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 0 5px;
    color: #dc3545;
    transition: color 0.2s;
}
.xai-remove-item-btn:hover {
    color: #a71d2a;
}
.xai-remove-item-btn:focus {
    outline: none;
}

.xai-cart-totals {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px solid #dee2e6;
    text-align: right;
    font-size: 1em;
    font-weight: bold;
}

/* --- ESTILOS PARA AVATAR DE USUARIO --- */

.user-avatar {
  background-color: #e9ecef; /* Un fondo gris claro para el círculo */
  display: flex; /* Permite centrar el ícono fácilmente */
  align-items: center;
  justify-content: center;
}

.user-avatar .dashicons-admin-users {
  font-size: 22px; /* Tamaño del ícono */
  color: #6c757d; /* Color gris oscuro para el ícono */
}

/* --- ESTILOS PARA TEXTO RESALTADO --- */
.bot-message .message-content strong {
  /* Estilo por defecto para negritas */
  font-weight: 600;
  color: #212529; /* Color de texto un poco más oscuro */
}

.bot-message .message-content .highlight-price {
  /* Estilo específico para precios, como en la imagen */
  font-weight: 700; /* Más grueso */
  color: #0056b3; /* Azul oscuro del tema */
}

/* --- Animación MEJORADA para llamar la atención sobre el input --- */
@keyframes input-attention-glow {
  0% {
    border-color: #ced4da;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0);
  }
  50% {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.35); /* Resplandor azul */
  }
  100% {
    border-color: #ced4da;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0);
  }
}

.chat-input.input-attention {
  animation: input-attention-glow 1.5s ease-in-out;
}

/* --- ESTILOS PARA SUGERENCIAS DE PRODUCTOS --- */

/* Contenedor principal para las sugerencias */
.xai-product-suggestions {
  display: flex;
  flex-direction: column;
  gap: 12px; /* Espacio entre cada tarjeta de producto */
  margin-top: 10px;
}

/* Tarjeta individual de producto */
.xai-product-suggestion-item {
  display: flex;
  align-items: center;
  background-color: #ffffff;
  border: 1px solid #e9ecef;
  border-radius: 8px; /* Bordes redondeados */
  padding: 10px;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Sombra sutil */
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.xai-product-suggestion-item:hover {
  transform: translateY(-2px); /* Efecto de levantar al pasar el mouse */
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* Miniatura de la imagen del producto */
.xai-product-thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover; /* Asegura que la imagen cubra el espacio sin deformarse */
  border-radius: 6px;
  flex-shrink: 0; /* Evita que la imagen se encoja */
}

/* Contenedor para la información (título y precio) */
.xai-product-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

/* Título del producto */
.xai-product-title {
  font-weight: 600;
  color: #0056b3;
  text-decoration: none; /* Quitamos el subrayado por defecto */
  font-size: 0.95em;
}

.xai-product-title:hover {
  text-decoration: underline; /* Subrayado solo al pasar el mouse */
  color: #003d80;
}

/* Precio del producto */
.xai-product-price {
  font-size: 0.9em;
  color: #495057;
  font-weight: 500;
}

/* Para que el precio en oferta (si existe) se vea bien */
.xai-product-price del {
  opacity: 0.7;
  margin-right: 5px;
}

.xai-product-price ins {
  text-decoration: none;
  font-weight: 700;
}

/* --- ESTILOS PARA BOTÓN SECUNDARIO --- */
.xai-action-btn.secondary {
  background-color: #ffffff;
  color: #007bff;
  border: 1px solid #007bff;
}

.xai-action-btn.secondary:hover {
  background-color: #f8f9fa;
  color: #0056b3;
  border-color: #0056b3;
}

/* En: assets/css/chatbot.css
   Añade este nuevo estilo al final para el texto creativo. */

.xai-product-creative-text {
  font-size: 0.85em; /* Un poco más pequeño */
  color: #555; /* Un color gris oscuro, no negro */
  margin: 8px 0 0 0; /* Espacio superior, sin margen inferior */
  font-style: italic; /* Le da un toque especial */
  line-height: 1.4;
}

/* Hacemos la tarjeta un enlace sin el subrayado azul feo */
a.xai-product-suggestion-item,
a.xai-product-suggestion-item:hover {
    text-decoration: none;
    color: inherit;
}

/* --- Estilos para la Burbuja de Notificación --- */
.xai-notification-bubble {
  position: fixed;
  bottom: 90px; /* Posición justo encima del botón minimizado */
  right: 20px;
  background: rgba(33, 37, 41, 0.9); /* Fondo oscuro semitransparente */
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  z-index: 99998; /* Justo debajo del chat por si acaso */
  font-size: 0.95em;
  max-width: 250px;
  
  /* Estado inicial (oculto) */
  opacity: 0;
  visibility: hidden;
  transform: translateY(15px);
  transition: opacity 0.5s ease, transform 0.5s ease, visibility 0.5s;
}

/* Estado visible */
.xai-notification-bubble.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* "Colita" del globo de diálogo */
.xai-notification-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px; /* Lo saca del globo */
  right: 22px; /* Lo alinea con el botón minimizado */
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(33, 37, 41, 0.9); /* Mismo color que el fondo */
}

/* --- ESTILOS PARA BOTONES DE SOLO MÓVIL --- */

/* Por defecto, el botón está oculto en pantallas grandes */
.xai-mobile-only-btn {
    display: none !important;
}


/* Pega este nuevo estilo al final del archivo */
.xai-action-btn:disabled,
.xai-action-btn.disabled {
    background-color: #e9ecef !important;
    border-color: #dee2e6 !important;
    color: #6c757d !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Cuando la pantalla es de 768px o menos (tablets y móviles), el botón se muestra */
@media (max-width: 768px) {
    .xai-mobile-only-btn {
        display: inline-block !important;
    }
}

/* --- AJUSTES RESPONSIVE --- */
@media (max-width: 400px) {
  .xai-chat {
    width: 100%;
    bottom: 0;
    right: 0;
    border-radius: 0;
    max-height: 80vh;
  }
  .chat-header { border-radius: 0; }
  .chat-body { max-height: calc(80vh - 120px); }
  .xai-chat-minimized {
    bottom: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
  }
}