/* ==========================================================================
   Chatbot IA - Tecnologías Perú
   Estilos modernos con Glassmorphism y Paleta Dark Tech
   ========================================================================== */

/* Contenedor flotante de botones inferiores */
.floating-actions-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 95;
}

/* Reajuste del botón de WhatsApp si está dentro del contenedor */
.floating-actions-container .wa-fab {
  position: static;
  margin: 0;
}

/* Botón flotante del Chatbot */
.chatbot-fab {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10263f 0%, #00b4d8 50%, #55e6c1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  border: 1px solid rgba(85, 230, 193, 0.4);
  box-shadow: 0 6px 22px rgba(0, 180, 216, 0.35), 0 0 16px rgba(85, 230, 193, 0.25);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  outline: none;
  padding: 0;
}

.chatbot-fab:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 180, 216, 0.5), 0 0 25px rgba(85, 230, 193, 0.4);
}

.chatbot-fab:active {
  transform: scale(0.95);
}

.chatbot-fab-icon {
  width: 28px;
  height: 28px;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-fab.active .chatbot-fab-icon {
  transform: rotate(90deg);
}

/* Tooltip / Badge del botón */
.chatbot-fab-tooltip {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(14, 27, 43, 0.95);
  color: #edf5ff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid rgba(85, 230, 193, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(-50%) translateX(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-fab-tooltip .sparkle {
  color: #55e6c1;
  font-size: 13px;
  animation: pulse-sparkle 1.8s infinite;
}

.chatbot-fab:hover .chatbot-fab-tooltip,
.chatbot-fab.show-teaser .chatbot-fab-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

@keyframes pulse-sparkle {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.8; }
}

/* Pulso animado del botón */
.chatbot-fab::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(85, 230, 193, 0.6);
  opacity: 0;
  animation: fab-ripple 2.5s infinite cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: none;
}

@keyframes fab-ripple {
  0% { transform: scale(0.9); opacity: 0.8; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ==========================================================================
   Ventana Principal del Chatbot
   ========================================================================== */
.chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: rgba(11, 22, 36, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(85, 230, 193, 0.25);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 5, 15, 0.6), 0 0 30px rgba(85, 230, 193, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), 
              visibility 0.3s;
}

.chatbot-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Cabecera del Chat */
.chatbot-header {
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(14, 27, 43, 0.95) 0%, rgba(19, 36, 56, 0.95) 100%);
  border-bottom: 1px solid rgba(157, 185, 215, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #00b4d8 0%, #55e6c1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #07101c;
  box-shadow: 0 4px 12px rgba(85, 230, 193, 0.3);
  flex-shrink: 0;
}

.chatbot-avatar svg {
  width: 22px;
  height: 22px;
}

.chatbot-status-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #55e6c1;
  border: 2px solid #0b1624;
  border-radius: 50%;
  box-shadow: 0 0 6px #55e6c1;
}

.chatbot-titles {
  display: flex;
  flex-direction: column;
}

.chatbot-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #edf5ff;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-title .badge {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(85, 230, 193, 0.15);
  color: #55e6c1;
  border: 1px solid rgba(85, 230, 193, 0.3);
  border-radius: 10px;
  font-weight: 600;
}

.chatbot-subtitle {
  font-size: 11px;
  color: #93a6bb;
}

.chatbot-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-ctrl-btn {
  background: transparent;
  border: none;
  color: #93a6bb;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chatbot-ctrl-btn:hover {
  background: rgba(157, 185, 215, 0.12);
  color: #edf5ff;
}

/* Área de Mensajes */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* Scrollbar personalizada */
.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(157, 185, 215, 0.2);
  border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(85, 230, 193, 0.4);
}

/* Burbujas de mensajes */
.chat-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: message-appear 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes message-appear {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-msg.bot {
  align-self: flex-start;
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(85, 230, 193, 0.15);
  border: 1px solid rgba(85, 230, 193, 0.3);
  color: #55e6c1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 4px;
}

.chat-msg.user .chat-msg-avatar {
  background: rgba(114, 167, 255, 0.2);
  border-color: rgba(114, 167, 255, 0.4);
  color: #72a7ff;
}

.chat-msg-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.chat-msg.bot .chat-msg-bubble {
  background: #112135;
  color: #edf5ff;
  border: 1px solid rgba(157, 185, 215, 0.15);
  border-top-left-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-msg.user .chat-msg-bubble {
  background: linear-gradient(135deg, #1b4965 0%, #1e3d59 100%);
  color: #ffffff;
  border: 1px solid rgba(114, 167, 255, 0.3);
  border-top-right-radius: 4px;
}

.chat-msg-bubble p {
  margin: 0 0 8px 0;
}

.chat-msg-bubble p:last-child {
  margin-bottom: 0;
}

.chat-msg-bubble strong {
  color: #55e6c1;
  font-weight: 600;
}

.chat-msg-bubble ul {
  margin: 6px 0;
  padding-left: 18px;
}

.chat-msg-bubble li {
  margin-bottom: 4px;
}

.chat-msg-bubble a {
  color: #55e6c1;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-msg-bubble a:hover {
  color: #72a7ff;
}

.chat-msg-time {
  font-size: 10px;
  color: #6d8299;
  margin-top: 4px;
  text-align: right;
}

/* Tarjetas de acción dentro de mensajes del bot */
.bot-action-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.bot-card-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(14, 27, 43, 0.8);
  border: 1px solid rgba(85, 230, 193, 0.25);
  border-radius: 8px;
  color: #edf5ff;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.bot-card-btn:hover {
  background: rgba(85, 230, 193, 0.15);
  border-color: #55e6c1;
  color: #55e6c1;
  transform: translateX(2px);
}

.bot-card-btn.wa-btn {
  border-color: rgba(37, 211, 102, 0.4);
  color: #25d366;
}

.bot-card-btn.wa-btn:hover {
  background: rgba(37, 211, 102, 0.15);
  border-color: #25d366;
  color: #25d366;
}

/* Indicador de "Escribiendo..." */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #112135;
  border: 1px solid rgba(157, 185, 215, 0.15);
  border-radius: 14px;
  border-top-left-radius: 4px;
  width: fit-content;
  margin-left: 38px;
  animation: message-appear 0.2s ease;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #55e6c1;
  border-radius: 50%;
  opacity: 0.6;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Chips / Sugerencias rápidas */
.chatbot-suggestions {
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(11, 22, 36, 0.8);
  border-top: 1px solid rgba(157, 185, 215, 0.08);
}

.suggestion-chip {
  padding: 6px 11px;
  background: rgba(19, 36, 56, 0.8);
  border: 1px solid rgba(157, 185, 215, 0.2);
  border-radius: 16px;
  color: #dce9f7;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: rgba(85, 230, 193, 0.15);
  border-color: #55e6c1;
  color: #55e6c1;
  transform: translateY(-1px);
}

/* Footer / Formulario de Envío */
.chatbot-footer {
  padding: 10px 14px 14px 14px;
  background: rgba(14, 27, 43, 0.95);
  border-top: 1px solid rgba(157, 185, 215, 0.15);
}

.chatbot-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0b1624;
  border: 1px solid rgba(157, 185, 215, 0.25);
  border-radius: 12px;
  padding: 4px 6px 4px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-input-form:focus-within {
  border-color: #55e6c1;
  box-shadow: 0 0 10px rgba(85, 230, 193, 0.2);
}

.chatbot-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #edf5ff;
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 0;
  outline: none;
}

.chatbot-input::placeholder {
  color: #687f96;
}

.chatbot-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #55e6c1;
  color: #07101c;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
  background: #72a7ff;
  color: #ffffff;
  transform: scale(1.05);
}

.chatbot-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chatbot-footer-brand {
  font-size: 10.5px;
  color: #63778e;
  text-align: center;
  margin-top: 6px;
}

.chatbot-footer-brand span {
  color: #55e6c1;
}

/* ==========================================================================
   Responsividad Móvil
   ========================================================================== */
@media (max-width: 600px) {
  .floating-actions-container {
    bottom: 20px;
    right: 20px;
    gap: 10px;
  }

  .chatbot-fab {
    width: 48px;
    height: 48px;
  }

  .chatbot-fab-icon {
    width: 24px;
    height: 24px;
  }

  .chatbot-fab-tooltip {
    display: none; /* Ocultar tooltip en móviles para no tapar pantalla */
  }

  .chatbot-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    z-index: 1000;
  }

  .chatbot-header {
    padding: 16px 16px;
    border-radius: 0;
  }
}
