/* ===========================
   Apptiva - Estilo oficial Apptivate 💙
   =========================== */

#chatbot-widget {
  position: fixed;
  top: 20px;
  left: 20px;
  font-family: "Poppins", sans-serif;
  z-index: 9999;
  cursor: grab;
}

#chatbot-widget:active {
  cursor: grabbing;
}

/* Botón para abrir el chat */
#openChatbot {
  background: linear-gradient(90deg, #004cff, #00aaff);
  color: white;
  border: none;
  border-radius: 30px;
  padding: 12px 20px;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  transition: transform 0.2s ease;
}

#openChatbot:hover {
  transform: scale(1.05);
}

/* Ventana del chat — altura fija real */
#chatbot-modal {
  display: none;
  flex-direction: column;
  width: 360px;

  /* Alturas rígidas */
  min-height: 520px;
  max-height: 520px;

  background: #111;
  color: white;
  border-radius: 15px;
  box-shadow: 0 0 20px rgba(0,0,0,0.6);
  overflow: hidden;
  backdrop-filter: blur(6px);
}

/* Encabezado */
#chatbot-header {
  background: linear-gradient(90deg, #00aaff, #004cff);
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  border-bottom: 2px solid #0088dd;
}

#chatbot-header button {
  background: transparent;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

/* Área de mensajes — altura rígida + scroll interno */
#chatbot-messages {
  flex: none;

  height: 360px;
  max-height: 360px;

  padding: 10px;
  overflow-y: auto;
  text-align: left;
  font-size: 14px;
  scroll-behavior: smooth;
}

/* Mensajes */
.user-msg, .bot-msg {
  padding: 8px 10px;
  border-radius: 10px;
  margin: 6px 0;
  max-width: 85%;
  word-wrap: break-word;
  white-space: normal;
}

.user-msg {
  background: #0055ff;
  color: white;
  margin-left: auto;
  animation: fadeIn 0.3s ease;
}

.bot-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  animation: fadeIn 0.4s ease;
}

/* Avatar */
.bot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #00aaff;
  animation: breathe 3s ease-in-out infinite, blink 12s infinite;
  box-shadow: 0 0 8px rgba(0,170,255,0.3);
}

/* Mensaje IA */
.bot-msg {
  background: #1b1b1b;
  color: #f0f0f0;
  padding: 8px 10px;
  border-radius: 10px;
  margin-right: auto;
  line-height: 1.4;
}

/* ===========================
   INPUT Y BOTONES ESTILO SARAI
   =========================== */
#chatbot-input {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: #000;
  border-top: 1px solid #222;

  /* Evita que el input se comprima */
  flex-shrink: 0;
}

#chatbot-input input {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: none;
  outline: none;
  font-size: 14px;
  background: #1a1a1a;
  color: white;
}

/* Botones estilo SarAI */
.chatbot-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

#sendMessage,
#resetChat {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 10px 0;
  color: white;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.3s ease, box-shadow 0.3s ease;
}

#sendMessage {
  background: #00aaff;
  box-shadow: 0 0 10px rgba(0,170,255,0.3);
}

#sendMessage:hover {
  background: #0099dd;
  box-shadow: 0 0 15px rgba(0,170,255,0.6);
  transform: scale(1.03);
}

#resetChat {
  background: #ff3333;
}

#resetChat:hover {
  background: #ff0000;
  transform: scale(1.03);
}

/* Animaciones */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes breathe {
  50% { transform: scale(1.05); opacity: 0.95; }
}

@keyframes blink {
  98% { filter: brightness(0.7); }
}

/* Vista móvil */
@media (max-width: 768px) {
  #chatbot-modal {
    width: 95%;
    min-height: 80vh;
    max-height: 80vh;
    left: 2.5%;
    top: 5%;
    position: fixed;
  }

  #chatbot-messages {
    height: calc(80vh - 160px);
    max-height: calc(80vh - 160px);
  }

  #chatbot-header {
    font-size: 16px;
  }

  .bot-avatar {
    width: 42px;
    height: 42px;
  }
}

/* Legibilidad */
#chatbot-messages,
.user-msg,
.bot-msg,
#chatbot-input input {
  font-size: 16px !important;
  line-height: 1.5;
}

#chatbot-header {
  font-size: 17px !important;
  font-weight: 600;
}

/* Tooltip arrastre */
#chatbot-header {
  position: relative;
}

#chatbot-header:hover::after {
  content: "📍 Arrástrame y colócame donde te resulte más cómodo";
  position: absolute;
  bottom: -35px;
  left: 10px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 1;
  pointer-events: none;
  z-index: 99999;
  transition: opacity 0.3s ease;
}

#chatbot-header::after {
  opacity: 0;
}

/* Tooltip botón */
#openChatbot {
  position: relative;
}

#openChatbot:hover::after {
  content: "📍 Puedes mover el chat por la pantalla";
  position: absolute;
  top: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 1;
  pointer-events: none;
  z-index: 99999;
  transition: opacity 0.3s ease;
}

#openChatbot::after {
  opacity: 0;
}

