/* Premium Streaming Animations & Styles */

/* Reasoning Container Animations */
@keyframes reasoningEnter {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
    max-height: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    max-height: 500px;
  }
}

@keyframes reasoningPulse {
  0%, 100% {
    border-left-color: #9CA3AF;
  }
  50% {
    border-left-color: #6B7280;
  }
}

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

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

@keyframes typingIndicator {
  0%, 100% {
    opacity: 0.4;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Reasoning Styles */
.reasoning-streaming-container {
  position: relative;
  margin-bottom: 12px;
  animation: reasoningEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.reasoning-streaming-container.reasoning-active {
  animation: reasoningPulse 2s ease-in-out infinite;
}

.reasoning-streaming-container.reasoning-complete {
  animation: none;
  opacity: 0.9;
}

.reasoning-toggle-btn {
  background: rgba(107, 114, 128, 0.08);
  color: #6B7280;
  border: 1px solid rgba(107, 114, 128, 0.15);
  transition: all 0.2s ease;
}

.reasoning-toggle-btn:hover {
  background: rgba(107, 114, 128, 0.15);
  color: #4B5563;
  transform: translateY(-1px);
}

.reasoning-icon {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reasoning-icon.open {
  transform: rotate(90deg);
}

.reasoning-content-wrapper {
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.reasoning-content-wrapper.collapsed {
  max-height: 0;
}

.reasoning-text {
  font-size: 0.875rem;
  line-height: 1.5;
  font-style: italic;
  color: #6B7280;
  background: rgba(107, 114, 128, 0.04);
  border-left: 2px solid #9CA3AF;
  border-radius: 0 4px 4px 0;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  transition: all 0.3s ease;
}

.reasoning-text.updating {
  background: rgba(107, 114, 128, 0.08);
}

.reasoning-status {
  font-size: 0.8125rem;
  color: #9CA3AF;
  transition: all 0.3s ease;
}

.reasoning-status.complete {
  color: #10B981;
}

/* Message Animations */
.streaming-message {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.streaming-message.message-visible {
  opacity: 1;
  transform: translateY(0);
}

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

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: typingIndicator 1.4s ease-in-out infinite;
}

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

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

/* Smooth Scroll Behavior */
.messages-container {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.messages-container.auto-scrolling {
  scroll-behavior: auto;
}

/* Content Streaming */
.message-content {
  transition: all 0.15s ease-out;
}

.message-content.streaming {
  position: relative;
}

.message-content.streaming::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 2px;
  height: 1.2em;
  background: var(--accent);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Virtual Scrolling Optimizations */
.message-wrapper {
  contain: layout style paint;
  content-visibility: auto;
  contain-intrinsic-size: auto 100px;
}

.message-wrapper.opacity-50 {
  opacity: 0.5;
  filter: grayscale(0.3);
}

/* Provider Badge */
.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.provider-badge.deepseek {
  background: rgba(59, 130, 246, 0.1);
  color: #3B82F6;
}

.provider-badge.deepseek_plus {
  background: rgba(14, 165, 233, 0.1);
  color: #0EA5E9;
}

/* Scroll Indicator */
.scroll-indicator {
  position: absolute;
  bottom: 80px;
  right: 20px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.scroll-indicator.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-indicator:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: translateY(0) scale(1.05);
}

/* Connection Status */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  transition: all 0.3s ease;
}

.connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.connection-dot.connected {
  background: #10B981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.connection-dot.disconnected {
  background: #EF4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.connection-dot.connecting {
  background: #F59E0B;
  animation: blink 1.5s ease-in-out infinite;
}

/* Performance Mode */
@media (prefers-reduced-motion: reduce) {
  .reasoning-streaming-container,
  .streaming-message,
  .reasoning-content-wrapper {
    animation: none !important;
    transition: none !important;
  }
  
  .typing-indicator span {
    animation: none !important;
  }
}
