/* ==========================================================================
   Chatbot MLG - Estilos
   Botón flotante + panel de conversación responsive
   ========================================================================== */

.chatbot {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
  font-family: 'Inter', Arial, sans-serif;
}

/* Botón flotante */
.chatbot-fab {
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #0066ff 0%, #0052cc 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 102, 255, 0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.chatbot-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 22px rgba(0, 102, 255, 0.5);
}

.chatbot-fab i {
  font-size: 1.6rem;
}

.chatbot-fab.is-open {
  background: #003366;
}

/* Panel de conversación */
.chatbot-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 102, 255, 0.12);
  transform-origin: bottom right;
  animation: chatbot-panel-in 0.25s ease;
}

.chatbot-panel[hidden] {
  display: none !important;
}

@keyframes chatbot-panel-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Cabecera */
.chatbot-header {
  background: linear-gradient(135deg, #0066ff 0%, #0052cc 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatbot-avatar i {
  font-size: 1.2rem;
}

.chatbot-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

.chatbot-header p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  opacity: 0.9;
}

.chatbot-close {
  background: transparent;
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Área de mensajes */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f7faff;
}

.chatbot-message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.55;
  word-wrap: break-word;
}

.chatbot-message--bot {
  align-self: flex-start;
  background: #fff;
  color: #222;
  border: 1px solid #eaf1ff;
  border-bottom-left-radius: 4px;
}

.chatbot-message--user {
  align-self: flex-end;
  background: #0066ff;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chatbot-message--system {
  align-self: center;
  background: #fff3cd;
  color: #856404;
  font-size: 0.85rem;
  max-width: 100%;
  text-align: center;
}

/* Sugerencias rápidas */
.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  background: #f7faff;
}

.chatbot-suggestion {
  border: 1px solid #0066ff;
  background: #fff;
  color: #0066ff;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.chatbot-suggestion:hover {
  background: #0066ff;
  color: #fff;
}

/* Formulario de lead */
.chatbot-lead {
  padding: 12px 16px 0;
  background: #f7faff;
  border-top: 1px solid #eaf1ff;
  overflow-y: auto;
  max-height: 55%;
}

.chatbot-lead[hidden] {
  display: none !important;
}

.chatbot-lead-title {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #003366;
}

.chatbot-lead-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatbot-lead-form label {
  font-size: 0.78rem;
  font-weight: 500;
  color: #555;
}

.chatbot-lead-form input,
.chatbot-lead-form textarea {
  width: 100%;
  border: 1px solid #dbe7ff;
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.88rem;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-lead-form input:focus,
.chatbot-lead-form textarea:focus {
  outline: none;
  border-color: #0066ff;
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.15);
}

.chatbot-lead-form textarea {
  min-height: 72px;
  resize: vertical;
}

.chatbot-lead-submit {
  margin-top: 4px;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  background: #0066ff;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.chatbot-lead-submit:hover:not(:disabled) {
  background: #0052cc;
}

.chatbot-lead-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Área de entrada */
.chatbot-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #eaf1ff;
  flex-shrink: 0;
}

.chatbot-input-area input {
  flex: 1;
  border: 1px solid #dbe7ff;
  border-radius: 24px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.9rem;
}

.chatbot-input-area input:focus {
  outline: none;
  border-color: #0066ff;
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}

.chatbot-send {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: #0066ff;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.chatbot-send:hover:not(:disabled) {
  background: #0052cc;
}

.chatbot-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Evitar solapamiento con botones flotantes de la esquina inferior derecha */
body.page-with-chatbot .floating-whatsapp {
  bottom: 96px;
}

/* Mover "volver arriba" a la izquierda para no tapar el chatbot */
body.page-with-chatbot .back-to-top {
  right: auto;
  left: 24px;
  bottom: 24px;
  z-index: 1050;
}

/* Responsive */
@media (max-width: 768px) {
  body.page-with-chatbot .back-to-top {
    left: 16px;
    bottom: 16px;
  }
}

@media (max-width: 480px) {
  .chatbot {
    bottom: 16px;
    right: 16px;
  }

  .chatbot-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    max-height: none;
    bottom: 72px;
  }
}
