/* =================================
   ASISTENTE IA - WIDGET FLOTANTE
   ================================= */

.ai-assistant-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.ai-widget-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
}

.ai-widget-header strong {
  font-size: 1.1rem;
}

.ai-widget-body {
  max-height: 500px;
  transition: max-height 0.3s ease;
  overflow: hidden;
}

.ai-widget-body.collapsed {
  max-height: 0;
}

.ai-chat-container {
  padding: 20px;
  height: 350px;
  overflow-y: auto;
  background: #f8f9fa;
}

.ai-chat-container::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-container::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.ai-chat-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.ai-chat-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Welcome Message */
.ai-welcome-message {
  text-align: center;
  padding: 30px 20px;
  background: white;
  border-radius: 12px;
  border: 2px dashed #e0e0e0;
}

.ai-welcome-message ul {
  text-align: left;
  padding-left: 20px;
}

/* Chat Messages */
.ai-message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}

.ai-message-user .ai-message-avatar {
  background: #667eea;
  color: white;
}

.ai-message-assistant .ai-message-avatar {
  background: #764ba2;
  color: white;
}

.ai-message-assistant .ai-message-avatar.bg-warning {
  background: #ffc107 !important;
  color: #000;
}

.ai-message-content {
  flex: 1;
  min-width: 0;
}

.ai-message-text {
  background: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  word-wrap: break-word;
}

.ai-message-user .ai-message-text {
  background: #667eea;
  color: white;
}

.ai-message-text p {
  margin-bottom: 8px;
}

.ai-message-text p:last-child {
  margin-bottom: 0;
}

.ai-message-text ul {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-message-text code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.ai-message-user .ai-message-text code {
  background: rgba(255, 255, 255, 0.2);
}

.ai-message-actions {
  margin-top: 6px;
  display: flex;
  gap: 8px;
}

.ai-message-actions .btn {
  padding: 4px 8px;
  font-size: 0.75rem;
  color: #666;
}

.ai-message-actions .btn:hover {
  color: #667eea;
}

/* Loading Animation */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #667eea;
  animation: typingDot 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Input Container */
.ai-input-container {
  padding: 16px 20px 20px;
  background: white;
  border-top: 1px solid #e0e0e0;
}

.ai-suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ai-suggestion-btn {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
  transition: all 0.2s;
}

.ai-suggestion-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

.ai-input-container .input-group {
  margin-bottom: 8px;
}

.ai-input-container .form-control {
  border-radius: 20px 0 0 20px;
  border: 1px solid #e0e0e0;
  padding: 10px 16px;
}

.ai-input-container .form-control:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.ai-input-container .btn-primary {
  border-radius: 0 20px 20px 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  padding: 10px 20px;
}

.ai-input-container .btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-input-container .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
  .ai-assistant-widget {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 10px;
  }

  .ai-chat-container {
    height: 300px;
  }

  .ai-widget-body {
    max-height: 400px;
  }
}

/* Animación de aparición */
@keyframes widgetSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ai-assistant-widget {
  animation: widgetSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
