/* --- Variables de color (pueden ser globales o dentro de .chat-whatsapp-style si quieres que apliquen solo ahí) --- */
:root {
  --whatsapp-green: #075e54;
  --whatsapp-light-green: #128c7e;
  --whatsapp-bg-light: #ece5dd;
  --whatsapp-bubble-received: #ffffff;
  --whatsapp-bubble-sent: #dcf8c6;
  --text-dark: #333;
  --text-light: #555;
  --border-color: #ddd;
}

/* --- ESTILOS BASE (TU ESTILO ORIGINAL) --- */
.chat-wrapper {
  position: fixed;
  bottom: 2px;
  right: 2px;
  z-index: 10000;
}

.chat-button {
  border-radius: 50%;
  width: 50px;
  height: 50px;
}
.chat-button:hover{
  transform:scale(1.2);
  margin-right:5px;
  margin-bottom:5px
}

.chat-container {
  max-width: 100%;
  width:700px; /* Tu ancho original */
  border: 1px solid #ccc;
  border-radius: 5px;
  display:table-cell; /* Tu display original */
  background-color: #f9f9f9;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  padding: 5px 10px;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

.chatbox {
  height: 200px; /* Tu altura original */
  overflow: auto;
  padding: 10px;
  border-bottom: 1px solid #ccc;
  font-size: 0.9rem;
  line-height: 1rem;
  background-color: #fff; /* Asegura un fondo base para el estilo original */
}

.message-wrapper {
    /* Si tenías estilos base para message-wrapper, ponlos aquí */
    margin-bottom: 0; /* Por tu ejemplo de HTML */
}

.user-message {
  color: #333;
}

.bot-message {
  color: #007bff;
}

/* Para el p.m-0 que usas */
.message-content p.m-0 {
  margin-bottom: 0 !important;
}

/* Estilos para los botones dentro de los mensajes */
.message-content .mt-1.mb-2 {
    margin-top: 5px; /* Ajuste si quieres un poco más de espacio */
    margin-bottom: 5px;
    display: block; /* O flex si ya lo usabas así */
}
.rxcal-btn {
    /* Tu estilo original para estos botones */
    background-color: #007bff; /* Color de ejemplo */
    color: white;
    border: none;
    padding: 5px 8px;
    border-radius: 3px;
    margin-right: 5px;
    margin-bottom: 5px;
    cursor: pointer;
}

.chat-footer {
  /* Tu estilo original para el footer */
}

.chat-footer .input-group {
  /* Tu estilo original para el input group */
}
.chat-footer .form-control {
  /* Tu estilo original para el input */
}
.chat-footer .btn {
  /* Tu estilo original para los botones del footer */
}


/* --- ESTILOS TIPO WHATSAPP (APLICADOS SOLO CON .chat-whatsapp-style) --- */
.chat-container.chat-whatsapp-style {
  max-width: 400px; /* Ancho típico de un chat móvil/widget */
  width: 100%;
  background-color: var(--whatsapp-bg-light); /* Fondo del chat */
  border-radius: 8px; /* Bordes más suaves */
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); /* Sombra más moderna */
  display: flex; /* Usar flexbox para layout interno */
  flex-direction: column;
  overflow: hidden; /* Asegura que los bordes redondeados se apliquen bien */
  margin-top: 10px;
}

/* Sobrescribir estilos del botón si es necesario para el estilo WhatsApp */
.chat-whatsapp-style + .chat-button { /* Si el botón está adyacente al contenedor y quieres que cambie */
    width: 55px;
    height: 55px;
    background-color: var(--whatsapp-light-green);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    font-size: 1.8rem;
}

.chat-whatsapp-style + .chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}


.chat-container.chat-whatsapp-style .chat-header {
  background-color: var(--whatsapp-green); /* Verde oscuro WhatsApp */
  padding: 10px 15px; /* Más padding */
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 1.1rem;
  font-weight: 500;
  border-top-left-radius: 8px; /* Ajustar radios para el nuevo estilo */
  border-top-right-radius: 8px;
}

.chat-container.chat-whatsapp-style .chat-header .header-actions .btn {
  background-color: transparent;
  border: none;
  color: white;
  font-size: 1.1rem;
  padding: 5px;
  margin-left: 8px;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.chat-container.chat-whatsapp-style .chat-header .header-actions .btn:hover {
  opacity: 1;
}

.chat-container.chat-whatsapp-style .chatbox {
  flex-grow: 1;
  height: 450px; /* Altura fija para el área de chat */
  overflow-y: auto;
  padding: 15px;
  background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png'); /* Fondo de WhatsApp */
  background-size: cover;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Estilos de la barra de scroll (opcional, para navegadores basados en WebKit) */
.chat-container.chat-whatsapp-style .chatbox::-webkit-scrollbar {
  width: 8px;
}

.chat-container.chat-whatsapp-style .chatbox::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container.chat-whatsapp-style .chatbox::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.chat-container.chat-whatsapp-style .message-wrapper {
  display: flex;
  margin-bottom: 5px;
}

.chat-container.chat-whatsapp-style .message-content {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 10px;
  position: relative;
  font-size: 0.95rem;
  line-height: 1.3;
  word-wrap: break-word;
}

.chat-container.chat-whatsapp-style .user-message {
  justify-content: flex-end;
}

.chat-container.chat-whatsapp-style .user-message .message-content {
  background-color: var(--whatsapp-bubble-sent);
  color: var(--text-dark);
  border-bottom-right-radius: 2px;
  margin-right: 5px;
}

.chat-container.chat-whatsapp-style .user-message .message-content::after {
  content: '';
  position: absolute;
  right: 0px;
  bottom: 0;
  width: 0;
  height: 0;
  border-bottom: 8px solid var(--whatsapp-bubble-sent);
  border-left: 8px solid transparent;
}

.chat-container.chat-whatsapp-style .bot-message {
  justify-content: flex-start;
}

.chat-container.chat-whatsapp-style .bot-message .message-content {
  background-color: var(--whatsapp-bubble-received);
  color: var(--text-dark);
  border-bottom-left-radius: 2px;
  margin-left: 5px;
}

.chat-container.chat-whatsapp-style .bot-message .message-content::after {
  content: '';
  position: absolute;
  left: 0px;
  bottom: 0;
  width: 0;
  height: 0;
  border-bottom: 8px solid var(--whatsapp-bubble-received);
  border-right: 8px solid transparent;
}

.chat-container.chat-whatsapp-style .message-content b {
  font-weight: 600;
}

.chat-container.chat-whatsapp-style .message-content i {
  font-style: italic;
}

.chat-container.chat-whatsapp-style .message-time {
  font-size: 0.7rem;
  color: var(--text-light);
  text-align: right;
  margin-top: 3px;
  display: block;
}

.chat-container.chat-whatsapp-style .message-content .mt-1.mb-2 {
  margin-top: 8px !important;
  margin-bottom: 0 !important;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chat-container.chat-whatsapp-style .rxcal-btn {
  background-color: var(--whatsapp-light-green);
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 0.85rem;
  white-space: normal;
  max-width: 100%;
}

.chat-container.chat-whatsapp-style .rxcal-btn:hover {
  background-color: var(--whatsapp-green);
}

.chat-container.chat-whatsapp-style .chat-footer {
  padding: 10px 15px;
  background-color: #f0f0f0;
  border-top: 1px solid var(--border-color);
}

.chat-container.chat-whatsapp-style .chat-footer .input-group {
  display: flex;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-container.chat-whatsapp-style .chat-footer .form-control {
  flex-grow: 1;
  border: none;
  padding: 8px 15px;
  font-size: 0.95rem;
  outline: none;
}

.chat-container.chat-whatsapp-style .chat-footer .btn {
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-container.chat-whatsapp-style .chat-footer .btn-light {
  background-color: white;
  color: var(--text-light);
  border-top-left-radius: 20px;
  border-bottom-left-radius: 20px;
  padding-left: 15px;
}

.chat-container.chat-whatsapp-style .chat-footer .btn-themecolor {
  background-color: var(--whatsapp-light-green);
  color: white;
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
  padding-right: 15px;
}

/* Responsive (opcional, para pantallas más pequeñas) */
@media (max-width: 600px) {
  .chat-wrapper.chat-whatsapp-style { /* Aplica esto también al wrapper si quieres que se adapte */
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    align-items: stretch;
    justify-content: flex-end;
  }

  .chat-container.chat-whatsapp-style {
    max-width: 100%;
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  .chat-container.chat-whatsapp-style .chatbox {
    height: calc(100vh - 120px);
  }
}

/* LOADING OVERLAY */
#loadingOverlay {
  position: fixed;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1010;
}

#spinner {
  border: 5px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top: 5px solid #007bff; /* Color original */
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

/* Si quieres que el spinner también cambie de color con el estilo WhatsApp */
.chat-whatsapp-style #spinner { /* Esto no es ideal, el spinner suele ser global */
    border-top: 5px solid var(--whatsapp-green);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}