body {
  font-family: sans-serif;
  margin: 0;
  padding: 0;
}

/* Botón flotante */
.chat-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, #4ECDC4, #A8E6CF);
  color: #fff;
  padding: 16px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
  z-index: 10000;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  animation: pulse 2s infinite;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.7);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(78, 205, 196, 0);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(78, 205, 196, 0);
    transform: scale(1);
  }
}

.chat-toggle:hover {
  transform: scale(1.15) rotate(5deg);
  background: linear-gradient(135deg, #3DB9B1, #4ECDC4);
  box-shadow: 0 8px 25px rgba(78, 205, 196, 0.6);
}

.chat-toggle:active {
  transform: scale(0.95);
}

/* Contenedor de chat - REMOVIDO: ahora se define en la sección de visibilidad */

@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Header */
.chat-header {
  background: #4ECDC4;
  padding: 20px 15px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  min-height: 20px;
}

.chat-header span#close-btn {
  cursor: pointer;
  font-size: 18px;
  padding: 5px;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.1);
}

.chat-header span#close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

/* Mensajes */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: #1e1e1e;
  scroll-behavior: smooth;
}

/* Estilo de scrollbar personalizado */
#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-track {
  background: #2a2a2a;
  border-radius: 3px;
}

#messages::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #4ECDC4, #A8E6CF);
  border-radius: 3px;
  transition: background 0.3s ease;
}

#messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #3DB9B1, #4ECDC4);
}

.user-msg, .bot-msg {
  margin: 4px 0;
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 85%;
  animation: messageSlideIn 0.6s ease-out;
  position: relative;
  overflow: hidden;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Styling for lists in bot messages */
.bot-msg ul, .bot-msg ol {
  margin: 4px 0;
  padding-left: 20px;
  color: #ffffff;
}

.bot-msg li {
  margin: 2px 0;
  line-height: 1.3;
  color: #ffffff;
}

.bot-msg p {
  margin: 4px 0;
  color: #ffffff;
}

.bot-msg strong {
  font-weight: 600;
  color: #ffffff;
}

.bot-msg em {
  font-style: italic;
  color: #ffffff;
}

.user-msg {
  background: linear-gradient(135deg, #4ECDC4, #A8E6CF);
  color: #fff;
  align-self: flex-end;
  margin-left: auto;
  border-radius: 18px 18px 5px 18px;
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
  animation: messageSlideInRight 0.6s ease-out;
}

.bot-msg {
  background: linear-gradient(135deg, #2a2a2a, #3a3a3a);
  color: #ffffff !important;
  align-self: flex-start;
  border-radius: 18px 18px 18px 5px;
  box-shadow: 0 4px 12px rgba(42, 42, 42, 0.5);
  animation: messageSlideInLeft 0.6s ease-out;
  border-left: 3px solid #4ECDC4;
}

/* Forzar color blanco en TODO el contenido del bot */
.bot-msg,
.bot-msg *,
.bot-msg span,
.bot-msg div,
.bot-msg p,
.bot-msg li,
.bot-msg ul,
.bot-msg ol {
  color: #ffffff !important;
}

/* Estilos para Markdown en mensajes del bot */
.bot-msg h1, .bot-msg h2, .bot-msg h3, .bot-msg h4, .bot-msg h5, .bot-msg h6 {
  color: #4ECDC4 !important;
  margin: 8px 0 4px 0;
  font-weight: 600;
}

.bot-msg h1 { font-size: 1.3em; }
.bot-msg h2 { font-size: 1.2em; }
.bot-msg h3 { font-size: 1.1em; }

.bot-msg a {
  color: #4ECDC4;
  text-decoration: underline;
}

.bot-msg code {
  background: #1a1a1a;
  color: #4ECDC4;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.bot-msg pre {
  background: #1a1a1a;
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
}

.bot-msg pre code {
  background: none;
  padding: 0;
}

.bot-msg blockquote {
  border-left: 3px solid #4ECDC4;
  margin: 8px 0;
  padding-left: 12px;
  color: #cccccc;
}

.bot-msg hr {
  border: none;
  border-top: 1px solid #4ECDC4;
  margin: 8px 0;
}

@keyframes messageSlideInLeft {
  from {
    transform: translateX(-100%) scale(0.8);
    opacity: 0;
  }
  60% {
    transform: translateX(5px) scale(1.02);
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes messageSlideInRight {
  from {
    transform: translateX(100%) scale(0.8);
    opacity: 0;
  }
  60% {
    transform: translateX(-5px) scale(1.02);
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes messageSlideIn {
  from {
    transform: translateY(20px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Mensajes del sistema */
.sistema-msg {
  background: #333;
  color: #eee;
  align-self: center;
  margin: 0.8rem auto;
  text-align: center;
  font-weight: 500;
  font-style: normal;
  border: none;
  max-width: 85%;
  border-radius: 20px;
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
}

.sistema-msg::before {
  content: '💬';
  position: absolute;
  top: -5px;
  right: 10px;
  font-size: 1.2rem;
  opacity: 0.6;
}

.sistema-msg.desconexion {
  background: #333;
  color: #eee;
  box-shadow: 0 4px 15px rgba(51, 51, 51, 0.3);
}

.sistema-msg.satisfaccion {
  background: #333;
  color: #eee;
  box-shadow: 0 4px 15px rgba(51, 51, 51, 0.3);
}

/* Área de input */
.input-area {
  display: flex;
  border-top: 1px solid #333;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.input-area input[type="text"] {
  flex: 1;
  padding: 12px 15px;
  border: none;
  background: #1e1e1e;
  color: #fff;
  font-size: 14px;
  transition: all 0.3s ease;
  border-radius: 0;
}

.input-area input[type="text"]:focus {
  outline: none;
  background: #2a2a2a;
  box-shadow: inset 0 0 0 2px rgba(44, 62, 80, 0.3);
}

.input-area input[type="text"]::placeholder {
  color: #888;
  transition: color 0.3s ease;
}

.input-area input[type="text"]:focus::placeholder {
  color: #aaa;
}

.input-area button {
  padding: 12px 18px;
  background: linear-gradient(135deg, #4ECDC4, #A8E6CF);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.input-area button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.input-area button:hover::before {
  width: 100px;
  height: 100px;
}

.input-area button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #3DB9B1, #4ECDC4);
  box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.input-area button:active {
  transform: translateY(0);
}

/* Escribiendo */
/* Indicador de escritura avanzado con 3 puntos animados */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #2a2a2a, #3a3a3a);
  border-radius: 18px 18px 18px 5px;
  margin: 8px 12px;
  max-width: fit-content;
  border-left: 3px solid #4ECDC4;
  animation: fadeInSlide 0.3s ease-out;
}

.typing-indicator-text {
  color: #888;
  font-size: 13px;
  font-style: italic;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4ECDC4, #A8E6CF);
  animation: typingWave 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingWave {
  0%, 60%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px) scale(1.1);
    opacity: 1;
  }
}

@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Header con animación */
.chat-header {
  background: linear-gradient(135deg, #4ECDC4, #A8E6CF);
  padding: 12px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.chat-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: rotate(45deg);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) rotate(45deg);
  }
}

/* Botones con animaciones */
button {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

button:active {
  transform: translateY(0);
}

/* Animación fade mejorada */
@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(15px) scale(0.95);
  }
  to { 
    opacity: 1; 
    transform: translateY(0) scale(1);
  }
}

/* Wrapper especifico para boton de descarga PDF - Más delgado y compacto */
.pdf-download-wrapper {
  margin: 4px 0 !important;
  text-align: center;
  padding: 2px 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  animation: none !important;
  align-self: center !important;
  max-width: none !important;
  width: auto !important;
  display: inline-block !important;
}

.pdf-download-button {
  display: inline-block;
  padding: 8px 16px;
  background: #2C3E50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  min-width: 120px;
  line-height: 1.3;
}

.pdf-download-button:hover {
  background: #1B2631;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.pdf-download-button:active {
  transform: translateY(0);
}

.pdf-download-text {
  font-size: 10px;
  color: #888;
  margin-bottom: 3px;
  line-height: 1.1;
}

/* Nueva clase para wrapper de botón de soporte técnico */
.support-button-wrapper {
  margin: 8px 0 !important;
  text-align: center;
  padding: 8px !important;
  background: rgba(40, 167, 69, 0.1) !important;
  border-radius: 8px !important;
  border: 1px solid rgba(40, 167, 69, 0.2) !important;
  box-shadow: none !important;
  animation: none !important;
  align-self: center !important;
  max-width: 300px !important;
  width: auto !important;
}

/* Nueva clase para el botón de soporte técnico */
.support-button {
  display: inline-block;
  padding: 8px 16px;
  background: linear-gradient(135deg, #28a745, #20963d);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
  min-width: 140px;
  line-height: 1.3;
}

.support-button:hover {
  background: linear-gradient(135deg, #218838, #1d7e33);
  box-shadow: 0 3px 6px rgba(40, 167, 69, 0.4);
  transform: translateY(-1px);
}

.support-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

/* Texto descriptivo para el botón de soporte */
.support-description {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
  line-height: 1.4;
}

/* Nueva clase para wrapper de botón de soporte técnico */
.support-button-wrapper {
  margin: 8px 0 !important;
  text-align: center;
  padding: 8px !important;
  background: rgba(40, 167, 69, 0.1) !important;
  border-radius: 8px !important;
  border: 1px solid rgba(40, 167, 69, 0.2) !important;
  box-shadow: none !important;
  animation: none !important;
  align-self: center !important;
  max-width: 300px !important;
  width: auto !important;
}

/* Nueva clase para el botón de soporte técnico */
.support-button {
  display: inline-block;
  padding: 8px 16px;
  background: linear-gradient(135deg, #28a745, #20963d);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
  min-width: 140px;
  line-height: 1.3;
}

.support-button:hover {
  background: linear-gradient(135deg, #218838, #1d7e33);
  box-shadow: 0 3px 6px rgba(40, 167, 69, 0.4);
  transform: translateY(-1px);
}

.support-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

/* Texto descriptivo para el botón de soporte */
.support-description {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
  line-height: 1.4;
}

/* Estados de visibilidad con animaciones suaves */
.chat-container {
  position: fixed;
  bottom: 95px;
  right: 20px;
  width: 380px;
  background: #121212;
  color: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  max-height: 600px;
  z-index: 9999;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: bottom right;
}

.chat-container.hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  visibility: hidden;
}

.chat-container.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

.chat-container.closing {
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  pointer-events: none;
}

/* === MEJORAS DE CHATBOT AVANZADO === */

/* Timestamps en mensajes */
.message-timestamp {
  font-size: 10px;
  color: #666;
  margin-top: 4px;
  text-align: right;
  opacity: 0.7;
}

.user-msg .message-timestamp {
  color: rgba(255,255,255,0.7);
}

/* Estado de mensaje (enviado, entregado, leído) */
.message-status {
  font-size: 10px;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
}

.message-status.sent::after { content: '✓'; color: #888; }
.message-status.delivered::after { content: '✓✓'; color: #888; }
.message-status.read::after { content: '✓✓'; color: #4ECDC4; }

/* Avatar del bot */
.bot-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4ECDC4, #A8E6CF);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-right: 8px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3);
}

.message-with-avatar {
  display: flex;
  align-items: flex-start;
  margin: 8px 0;
}

.message-with-avatar .bot-msg {
  margin: 0;
}

/* Quick replies / Respuestas rápidas */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  animation: fadeInUp 0.3s ease-out;
}

.quick-reply-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid #4ECDC4;
  color: #4ECDC4;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.3s ease;
}

.quick-reply-btn:hover {
  background: #4ECDC4;
  color: #1e1e1e;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Indicador de conexión */
.connection-status {
  position: absolute;
  top: 50%;
  right: 50px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #28a745;
  animation: pulse-dot 2s infinite;
}

.connection-dot.offline {
  background: #dc3545;
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* Emoji picker button */
.emoji-btn {
  padding: 8px 12px;
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.2s ease;
  opacity: 0.7;
}

.emoji-btn:hover {
  transform: scale(1.2);
  opacity: 1;
}

/* Mejoras de accesibilidad */
.chat-container:focus-within {
  outline: 2px solid #4ECDC4;
  outline-offset: 2px;
}

.input-area input[type="text"]:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px #4ECDC4;
}

/* Animación de mensaje nuevo */
@keyframes newMessage {
  0% {
    background-color: rgba(78, 205, 196, 0.2);
  }
  100% {
    background-color: transparent;
  }
}

.new-message {
  animation: newMessage 2s ease-out;
}

/* Scroll to bottom button */
.scroll-to-bottom {
  position: absolute;
  bottom: 70px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4ECDC4, #A8E6CF);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.3s ease;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

.scroll-to-bottom.visible {
  opacity: 1;
  transform: scale(1);
}

.scroll-to-bottom:hover {
  transform: scale(1.1);
}

/* Contenedor de archivo adjunto */
.attachment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #2a2a2a;
  border-radius: 8px;
  margin: 4px 12px;
  border-left: 3px solid #4ECDC4;
}

.attachment-preview .file-icon {
  font-size: 20px;
}

.attachment-preview .file-name {
  flex: 1;
  font-size: 12px;
  color: #ccc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview .remove-btn {
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  transition: color 0.2s ease;
}

.attachment-preview .remove-btn:hover {
  color: #dc3545;
}

/* Badge de notificación en el botón flotante */
.chat-toggle .notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
  background: #dc3545;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  color: white;
  animation: bounce 0.5s ease;
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Skeleton loader para mensajes */
.skeleton-message {
  background: linear-gradient(135deg, #2a2a2a, #3a3a3a);
  border-radius: 18px;
  padding: 12px 16px;
  margin: 8px 12px;
  max-width: 70%;
}

.skeleton-line {
  height: 12px;
  background: linear-gradient(90deg, #3a3a3a 25%, #4a4a4a 50%, #3a3a3a 75%);
  background-size: 200% 100%;
  animation: shimmerSkeleton 1.5s infinite;
  border-radius: 4px;
  margin: 4px 0;
}

.skeleton-line:nth-child(2) { width: 80%; }
.skeleton-line:nth-child(3) { width: 60%; }

@keyframes shimmerSkeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
