/* Estilos base existentes - mantener todos los que ya tienes */
#chat-wrapper {
  position: fixed;
  bottom: 80px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
}

#chat-container {
  width: 400px;
  height: 80vh;
  max-height: 100vh;
  background-color: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 10px rgba(75, 150, 232, 0.1);
  overflow: hidden;
  padding: 10px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: bottom right;
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

#chat-container.expanded {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

#chat-box {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: #f8fbff;
  margin-bottom: 15px;
  box-shadow: inset 0 4px 6px rgba(75, 150, 232, 0.05);
}

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

/* ESTILOS MEJORADOS PARA MENSAJES CON FORMATO */
.user-message,
.chatbot-message {
  display: flex;
  align-items: flex-start; /* Cambiado de center a flex-start para mejor alineación */
  max-width: 85%; /* Aumentado para dar más espacio al contenido */
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5; /* Mejor espaciado entre líneas */
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 2px 4px rgba(75, 150, 232, 0.1);
  animation: fadeIn 0.3s ease-out;
}

/* Contenedor del texto del mensaje para manejar el formato */
.message-content {
  flex: 1;
  white-space: pre-wrap; /* Preserva saltos de línea y espacios */
}

/* Estilos para texto formateado en mensajes del chatbot */
.chatbot-message .message-content {
  /* Estilos para negritas simuladas con ** */
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Estilos para listas numeradas y con viñetas */
.chatbot-message .message-content {
  /* Mejorar el espaciado para listas */
  line-height: 1.6;
}

/* Estilos específicos para simular formato markdown */
.formatted-message {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
}

.formatted-message strong,
.formatted-message b {
  font-weight: 600;
  color: #2c3e50;
}

/* Estilos para listas en mensajes */
.formatted-message ul,
.formatted-message ol {
  margin: 8px 0;
  padding-left: 20px;
}

.formatted-message li {
  margin: 4px 0;
  line-height: 1.5;
}

.formatted-message ol li {
  margin: 8px 0;
}

/* Espaciado entre párrafos */
.formatted-message p {
  margin: 8px 0;
}

.formatted-message p:first-child {
  margin-top: 0;
}

.formatted-message p:last-child {
  margin-bottom: 0;
}

/* Estilos mejorados para precios */
.price-highlight {
  font-weight: 600;
  color: #e74c3c;
  background-color: rgba(231, 76, 60, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.error-message {
  border-radius: 20px;
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 10px;
}

.chatbot-icon {
  width: 30px;
  height: 30px;
  margin-right: 10px;
  flex-shrink: 0; /* Evita que el icono se deforme */
  align-self: flex-start; /* Alinea el icono al inicio */
  margin-top: 2px; /* Pequeño ajuste para alineación */
}

.user-message {
  align-self: flex-end;
  background: linear-gradient(145deg, #4B96E8, #00C4CE);
  color: white;
  border-bottom-right-radius: 0;
}

.chatbot-message {
  align-self: flex-start;
  background-color: #f0f7ff;
  color: #333; /* Color más oscuro para mejor contraste */
  border-bottom-left-radius: 0;
}

/* Resto de estilos existentes... */
#input-container {
  display: flex;
  gap: 10px;
}

#user-input {
  width: calc(100% - 90px);
  padding: 12px;
  border: 1px solid #e0e0e0;
  background-color: #fff;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  box-shadow: inset 0 2px 4px rgba(75, 150, 232, 0.05);
}

#user-input:focus {
  border-color: #4B96E8;
}

#send-button {
  width: 80px;
  border: none;
  background: linear-gradient(145deg, #4B96E8, #00C4CE);
  color: white;
  padding: 12px;
  cursor: pointer;
  border-radius: 20px;
  font-size: 14px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(75, 150, 232, 0.2);
}

#send-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(75, 150, 232, 0.3);
}

#chat-toggle {
  background-color: #ffffff;
  color: white;
  border: none;
  border-radius: 50%;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  position: fixed;
  bottom: 70px;
  right: 12px;
  z-index: 1001;
  pointer-events: auto;
}

#chat-toggle:hover {
  background-color: #c9c9c9;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
}

.icon-small {
  width: 50px;
  height: 50px;
}

#chat-toggle.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: linear-gradient(145deg, #4B96E8, #00C4CE);
  color: white;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 4px 6px rgba(75, 150, 232, 0.2);
}

.header .title {
  font-size: 16px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  text-align: center;
  width: 100%;
  padding: 10px 15px;
}

.header button {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.header button:hover {
  color: #f1f1f1;
}

.header-banner {
  width: 100%;
  display: flex;
  align-items: center;
  background-color: #25D366;
  padding: 10px 15px;
  border-radius: 8px;
}

.header-banner a {
  color: white;
  text-decoration: none;
  font-size: 14px;
  display: flex;
  align-items: center;
}

.header-banner .fa-whatsapp {
  margin-right: 8px;
  font-size: 24px;
}

/* Media queries existentes */
@media (max-height: 600px) {
  #chat-container {
    height: 70vh;
    max-height: 70vh;
  }
  #chat-toggle {
    bottom: 10px;
  }
}

@media (max-width: 768px) {
  #chat-wrapper {
    bottom: 80px;
    right: 10px;
  }

  #chat-container {
    width: 100%;
    height: 80%;
    max-height: 80vh;
    right: 0;
    bottom: 0;
    border-radius: 15px 15px 0 0;
    transform-origin: bottom center;
    transform: translateY(100%);
  }

  #chat-box {
    padding: 10px;
    margin-bottom: 10px;
    overflow-y: auto;
  }

  .user-message,
  .chatbot-message {
    font-size: 12px;
    max-width: 90%; /* Aumentado para móviles */
    padding: 8px 12px;
  }

  #input-container {
    gap: 5px;
  }

  #user-input {
    width: calc(100% - 70px);
    padding: 10px;
  }

  #send-button {
    width: 60px;
    padding: 10px;
  }

  #chat-toggle {
    width: 50px;
    height: 50px;
    right: 12px;
  }

  .icon-small {
    width: 50px;
    height: 50px;
  }

  #chat-container.expanded {
    transform: translateY(0);
  }
}

/* Estilos para el modal existente */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  right: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
  padding-top: 60px;
}

.modal-content {
  background-color: #fff;
  margin: 5% 0 5% auto;
  padding: 20px;
  border: 1px solid #ccc;
  width: 80%;
  max-width: 500px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close:hover,
.close:focus {
  color: black;
  text-decoration: none;
  cursor: pointer;
}

.chat-history-body {
  max-height: 60vh;
  overflow-y: auto;
}

.chat-message {
  margin-bottom: 15px;
}

.chat-message-right {
  text-align: right;
}

.chat-message-wrapper {
  display: flex;
  flex-direction: column;
}

.chat-message-text {
  background-color: #e4e6eb;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 5px;
}

.chat-message-right .chat-message-text {
  background: linear-gradient(145deg, #4B96E8, #00C4CE);
  color: white;
}