/* ==========================================================================
   NEBULA GAMES - CHATBOT WEB STYLING (chatbot.css)
   ========================================================================== */

/* Contenedor Flotante General */
.chatbot-wrapper {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1100;
  font-family: var(--font-body);
}

/* Botón Lanzador / Launcher */
.chatbot-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-neon-purple), 0 5px 15px rgba(0, 0, 0, 0.4);
  color: white;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
}

.chatbot-launcher:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: var(--shadow-neon-cyan), 0 8px 25px rgba(0, 0, 0, 0.5);
  background: var(--gradient-cyan);
}

/* Tooltip sobre el Botón Lanzador */
.chatbot-tooltip {
  position: absolute;
  right: 75px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(18, 10, 23, 0.9);
  border: 1px solid var(--accent-cyan);
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-neon-cyan);
  opacity: 0;
  animation: tooltipPulse 4s infinite alternate;
}

.chatbot-launcher:hover .chatbot-tooltip {
  opacity: 1;
}

@keyframes tooltipPulse {
  0% { transform: translateY(-50%) scale(0.95); opacity: 0.8; }
  100% { transform: translateY(-50%) scale(1.02); opacity: 1; }
}

/* Ventana de Chat */
.chatbot-window {
  width: 380px;
  height: 520px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-filter);
  -webkit-backdrop-filter: var(--glass-filter);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), var(--shadow-neon-purple);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: absolute;
  bottom: 75px;
  right: 0;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.chatbot-window.active {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), var(--shadow-neon-cyan);
}

/* Cabecera del Chat */
.chatbot-header {
  padding: 15px 20px;
  background: var(--gradient-cyan);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
}

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

.chatbot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  position: relative;
  font-size: 1.1rem;
}

.chatbot-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #25D366;
  border-radius: 50%;
  border: 1.5px solid white;
  animation: pulseGreen 1.5s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 5px rgba(37, 211, 102, 0); }
  100% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

.chatbot-info h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: white;
}

.chatbot-status {
  font-size: 0.7rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chatbot-status i {
  font-size: 0.5rem;
  color: #25D366;
}

.chatbot-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.8;
  transition: var(--transition-smooth);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.chatbot-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.15);
}

/* Cuerpo de Mensajes */
.chatbot-body {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(10, 6, 20, 0.4);
}

/* Estilos de Scrollbar Interno */
.chatbot-body::-webkit-scrollbar {
  width: 6px;
}
.chatbot-body::-webkit-scrollbar-track {
  background: transparent;
}
.chatbot-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}
.chatbot-body::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

/* Mensajes Individuales */
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msgEnter 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes msgEnter {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  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;
  max-width: 80%;
}

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.chat-msg-content {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #f1f1f1;
  word-break: break-word;
}

.chat-msg.bot .chat-msg-content {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top-left-radius: 2px;
}

.chat-msg.user .chat-msg-content {
  background: var(--gradient-primary);
  color: white;
  border-top-right-radius: 2px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.chat-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.chat-msg.user .chat-msg-time {
  text-align: right;
}

/* Indicador de Escritura del Bot */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  align-items: center;
  justify-content: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-cyan);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Menú de Botones Rápidos (Chips) */
.chatbot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 15px;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.chat-chip {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.chat-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-cyan);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}

/* Área de Entrada de Mensaje */
.chatbot-input-area {
  padding: 12px 15px;
  display: flex;
  gap: 10px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.chatbot-input-area input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  color: white;
  font-size: 0.85rem;
  transition: var(--transition-smooth);
}

.chatbot-input-area input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-neon-cyan);
}

.chatbot-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--gradient-primary);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-neon-purple);
}

.chatbot-send-btn:hover {
  background: var(--gradient-cyan);
  box-shadow: var(--shadow-neon-cyan);
  transform: scale(1.05);
}

/* Tarjetas de Juegos dentro del Chat (Recomendaciones) */
.chat-game-cards-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
}

.chat-game-card {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  overflow: hidden;
  gap: 10px;
  padding: 8px;
  transition: var(--transition-smooth);
}

.chat-game-card:hover {
  border-color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.05);
}

.chat-game-card-img {
  width: 60px;
  height: 75px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.chat-game-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.chat-game-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  margin: 0;
  color: white;
  line-height: 1.2;
}

.chat-game-card-rating {
  font-size: 0.7rem;
  color: #ffb700;
  display: flex;
  align-items: center;
  gap: 3px;
}

.chat-game-card-pricing {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.chat-game-card-price {
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--accent-gold);
}

.chat-game-card-price-old {
  font-size: 0.7rem;
  text-decoration: line-through;
  color: var(--text-muted);
}

.chat-game-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.btn-chat-buy {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: bold;
}

/* ==========================================================================
   RESPONSIVIDAD DEL CHATBOT
   ========================================================================== */
@media (max-width: 768px) {
  .chatbot-wrapper {
    bottom: 85px; /* Sube para quedar sobre la barra de navegacion inferior */
    right: 15px;
  }
  
  .chatbot-launcher {
    width: 50px;
    height: 50px;
  }
  
  .chatbot-tooltip {
    display: none !important; /* Ocultar tooltip en móviles */
  }

  .chatbot-window {
    width: calc(100vw - 30px);
    height: calc(100vh - 170px);
    bottom: 65px;
    right: 0;
    max-height: none;
    border-radius: 12px;
  }
}
