/* ==========================================================================
   Chatbot IA — Widget flotante (Infinia Innovation)
   ========================================================================== */

/* --- Burbuja flotante --- */
.chatbot-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, #2ec4b6 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(67, 97, 238, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chatbot-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(67, 97, 238, 0.55);
}

/* --- Ventana del chat --- */
.chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: "Poppins", sans-serif;
}
.chatbot-window.open {
  display: flex;
}

/* --- Cabecera --- */
.chatbot-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chatbot-header h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.chatbot-header small {
  opacity: 0.8;
  font-weight: 400;
  font-size: 0.75rem;
}
.chatbot-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  opacity: 0.8;
  padding: 0 0 0 8px;
  line-height: 1;
}
.chatbot-close:hover { opacity: 1; }

/* --- Cuerpo (mensajes) --- */
.chatbot-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chatbot-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}
.chatbot-msg.assistant {
  background: #fff;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.chatbot-msg.user {
  background: var(--primary-color);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chatbot-msg.error {
  background: #fdecea;
  color: #a32020;
  align-self: center;
  font-size: 0.8rem;
}

/* --- Indicador de escritura --- */
.chatbot-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: #fff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.chatbot-typing.active { display: block; }
.chatbot-typing span {
  display: inline-block;
  width: 7px; height: 7px;
  background: #adb5bd;
  border-radius: 50%;
  margin: 0 2px;
  animation: chatbot-bounce 1.4s infinite ease-in-out both;
}
.chatbot-typing span:nth-child(1) { animation-delay: 0s; }
.chatbot-typing span:nth-child(2) { animation-delay: 0.16s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes chatbot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* --- Sugerencias --- */
.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
  flex-shrink: 0;
}
.chatbot-suggestion {
  background: #e8ecff;
  color: var(--primary-color);
  border: 1px solid rgba(67,97,238,0.15);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}
.chatbot-suggestion:hover { background: #d4dbff; }

/* --- Input --- */
.chatbot-input-row {
  display: flex;
  padding: 10px 14px;
  gap: 8px;
  border-top: 1px solid #e9ecef;
  flex-shrink: 0;
}
.chatbot-input {
  flex: 1;
  border: 1px solid #dee2e6;
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.chatbot-input:focus { border-color: var(--primary-color); }
.chatbot-send {
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chatbot-send:hover { background: var(--primary-dark); }

/* --- Responsive (móvil: pantalla completa) --- */
@media (max-width: 480px) {
  .chatbot-window {
    bottom: 0; right: 0;
    width: 100%; max-width: 100%;
    height: 100%; max-height: 100%;
    border-radius: 0;
  }
  .chatbot-bubble {
    bottom: 16px; right: 16px;
  }
}
