:root {
  --chatbot-primary-color: #5b6c8f;
  --chatbot-secondary-color: #4a5a7a;
  --chatbot-text-color: #ffffff;
}

#chatbotFloatingButton {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: var(--chatbot-primary-color);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(91, 108, 143, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  z-index: 9999;
  border: none;
}

#chatbotFloatingButton:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(91, 108, 143, 0.6);
}

#chatbotFloatingButton .chatbot-icon {
  width: 28px;
  height: 28px;
  color: white;
  stroke-width: 2;
}

.chatbot-floating-status-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: chatbot-pulse 2s ease-in-out infinite;
}

/* Contenedor chatbot */
#chatbotContainer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100vw;
  height: calc(var(--chatbot-vh, 1vh) * 100);
  background: white;
  display: none;
  flex-direction: column;
  z-index: 10000;
  overflow: hidden;
  touch-action: none;
  -webkit-overflow-scrolling: touch;
}

/* */
.chatbot-header {
  background: var(--chatbot-primary-color);
  color: var(--chatbot-text-color);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chatbot-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-header-icon {
  width: 24px;
  height: 24px;
  color: var(--chatbot-text-color);
  stroke-width: 2;
  flex-shrink: 0;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chatbot-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.chatbot-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.15);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  color: #10b981;
}

.chatbot-status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  animation: chatbot-pulse 2s ease-in-out infinite;
}

@keyframes chatbot-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.95);
  }
}

.chatbot-subheader {
  background: var(--chatbot-primary-color);
  color: var(--chatbot-text-color);
  padding: 0 20px 16px 20px;
  flex-shrink: 0;
}

.chatbot-subheader p {
  margin: 0;
  font-size: 14px;
  opacity: 0.95;
  line-height: 1.4;
}

#chatbotCloseButton {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

#chatbotCloseButton:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chatbot-close-icon {
  width: 20px;
  height: 20px;
  color: var(--chatbot-text-color);
  stroke-width: 2.5;
}


#chatbotMessages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
}


@supports (padding-bottom: constant(safe-area-inset-bottom)) {
  #chatbotMessages {
    padding-bottom: calc(20px + constant(safe-area-inset-bottom));
  }
}


#chatbotMessages::-webkit-scrollbar {
  width: 6px;
}

#chatbotMessages::-webkit-scrollbar-track {
  background: transparent;
}

#chatbotMessages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

#chatbotMessages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* messages */
.chatbot-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message-user {
  align-items: flex-end;
}

.chatbot-message-agent {
  align-items: flex-start;
}

/* Burbuja del mensaje */
.chatbot-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chatbot-bubble-user {
  background: var(--chatbot-primary-color);
  color: var(--chatbot-text-color);
  border-bottom-right-radius: 4px;
}

.chatbot-bubble-agent {
  background: white;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Enlaces dentro de las burbujas del agente */
.chatbot-link {
  color: var(--chatbot-primary-color);
  text-decoration: underline;
  word-break: break-all;
  transition: opacity 0.2s ease;
}

.chatbot-link:hover {
  opacity: 0.8;
}

/*  */
.chatbot-typing-container {
  display: inline-flex;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 12px 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  max-width: fit-content;
}

.chatbot-typing {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chatbot-typing span {
  width: 6px;
  height: 6px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.chatbot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Footer */
.chatbot-footer {
  background: white;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
 
  padding-bottom: env(safe-area-inset-bottom);
}


@supports (padding-bottom: constant(safe-area-inset-bottom)) {
  .chatbot-footer {
    padding-bottom: constant(safe-area-inset-bottom);
  }
}

.chatbot-footer-info {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: #fafafa;
  font-size: 11px;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
}

.chatbot-info-icon {
  width: 13px;
  height: 13px;
  color: #9ca3af;
  stroke-width: 2;
  flex-shrink: 0;
}

.chatbot-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  background: white;
}

#chatbotInput {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #f5f5f5;
}

#chatbotInput:focus {
  outline: none;
  border-color: var(--chatbot-primary-color);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(91, 108, 143, 0.1);
}

#chatbotInput::placeholder {
  color: #999;
}

#chatbotSendButton {
  width: 40px;
  height: 40px;
  background: var(--chatbot-primary-color);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

#chatbotSendButton:hover:not(:disabled) {
  transform: scale(1.05);
  background: var(--chatbot-secondary-color);
  box-shadow: 0 3px 10px rgba(91, 108, 143, 0.3);
}

#chatbotSendButton:active:not(:disabled) {
  transform: scale(0.98);
}

#chatbotSendButton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-send-icon {
  width: 18px;
  height: 18px;
  color: white;
  stroke-width: 2.5;
}

/* Responsive */
@media (max-width: 640px) {
  #chatbotFloatingButton {
    bottom: 80px;
    right: 16px;
  }

  .chatbot-bubble {
    max-width: 90%;
  }
  
  .chatbot-header {
    padding: 14px 16px;
  }
  
  .chatbot-subheader {
    padding: 0 16px 14px 16px;
  }
  
  .chatbot-input-wrapper {
    padding: 10px 12px;
  }
  
  .chatbot-footer-info {
    padding: 8px 12px;
  }
  
  
  #chatbotInput {
    font-size: 16px !important;
  }
}


@media screen and (max-height: 600px) {
  #chatbotMessages {
    padding: 10px 16px;
  }
  
  .chatbot-header {
    padding: 10px 16px;
  }
  
  .chatbot-subheader {
    padding: 0 16px 10px 16px;
  }
  
  .chatbot-input-wrapper {
    padding: 8px 12px;
  }
  
  .chatbot-footer-info {
    padding: 6px 12px;
    font-size: 10px;
  }
}




