/**
 * Dynamic Animation Effects CSS
 * Creates active, moving animations for all product showcases
 */

/* ================================
   DYNAMIC TYPING ANIMATIONS
   ================================ */

/* Typing cursor animation */
@keyframes blink-cursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Code typing effect */
@keyframes type-code {
    0% { width: 0; }
    100% { width: 100%; }
}

/* Line appearing animation */
@keyframes line-appear {
    0% { 
        opacity: 0; 
        transform: translateY(10px);
    }
    100% { 
        opacity: 1; 
        transform: translateY(0);
    }
}

/* Suggestion popup animation */
@keyframes suggestion-popup {
    0% { 
        opacity: 0; 
        transform: scale(0.8) translateY(20px);
    }
    100% { 
        opacity: 1; 
        transform: scale(1) translateY(0);
    }
}

/* ================================
   CHAT MESSAGE ANIMATIONS
   ================================ */

/* Chat message appearing */
@keyframes message-appear {
    0% { 
        opacity: 0; 
        transform: translateY(20px);
        max-height: 0;
    }
    100% { 
        opacity: 1; 
        transform: translateY(0);
        max-height: 500px;
    }
}

/* Typing indicator animation */
@keyframes typing-dots {
    0%, 60%, 100% { 
        transform: translateY(0);
        opacity: 0.4;
    }
    30% { 
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chat input pulse */
@keyframes input-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.4); }
    50% { box-shadow: 0 0 0 5px rgba(108, 99, 255, 0.1); }
}

/* ================================
   ROUTER/OPERATOR ANIMATIONS
   ================================ */

/* Data flow animation */
@keyframes data-flow {
    0% { 
        transform: translateX(-100%);
        opacity: 0;
    }
    50% { 
        opacity: 1;
    }
    100% { 
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Progress bar animation */
@keyframes progress-fill {
    0% { width: 0%; }
    100% { width: var(--progress-width, 85%); }
}

/* Status indicator pulse */
@keyframes status-pulse {
    0%, 100% { 
        background-color: #10b981;
        transform: scale(1);
    }
    50% { 
        background-color: #34d399;
        transform: scale(1.1);
    }
}

/* Router switching animation */
@keyframes router-switch {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* ================================
   GENERAL UI ANIMATIONS
   ================================ */

/* Floating animation for elements */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

/* Gentle glow animation */
@keyframes gentle-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(108, 99, 255, 0.3); }
    50% { box-shadow: 0 0 30px rgba(108, 99, 255, 0.5); }
}

/* Scale in animation */
@keyframes scale-in {
    0% { 
        transform: scale(0.9);
        opacity: 0;
    }
    100% { 
        transform: scale(1);
        opacity: 1;
    }
}

/* ================================
   CODER ANIMATION SPECIFIC
   ================================ */

.coder-animation-container .code-line.typing::after {
    content: '|';
    animation: blink-cursor 1s infinite;
    color: #6c63ff;
    font-weight: bold;
}

.coder-animation-container .code-line {
    animation: line-appear 0.8s ease-out;
    animation-fill-mode: both;
}

.coder-animation-container .code-line:nth-child(1) { animation-delay: 0.1s; }
.coder-animation-container .code-line:nth-child(2) { animation-delay: 0.2s; }
.coder-animation-container .code-line:nth-child(3) { animation-delay: 0.3s; }
.coder-animation-container .code-line:nth-child(4) { animation-delay: 0.4s; }
.coder-animation-container .code-line:nth-child(5) { animation-delay: 0.5s; }

.coder-animation-container .code-suggestion {
    animation: suggestion-popup 1s ease-out 2s both;
    transform-origin: bottom right;
}

.coder-animation-container .editor-tab.active {
    animation: gentle-glow 3s ease-in-out infinite;
}

/* ================================
   LLM CHAT ANIMATION SPECIFIC
   ================================ */

.llmchat-animation-container .message {
    animation: message-appear 0.6s ease-out;
    animation-fill-mode: both;
}

.llmchat-animation-container .message:nth-child(2) { animation-delay: 0.5s; }
.llmchat-animation-container .message:nth-child(3) { animation-delay: 1.5s; }
.llmchat-animation-container .message:nth-child(4) { animation-delay: 3s; }
.llmchat-animation-container .message:nth-child(5) { animation-delay: 4.5s; }

.llmchat-animation-container .message.typing::after {
    content: '...';
    animation: typing-dots 1.5s infinite;
    color: #6c63ff;
    font-size: 1.2em;
    display: inline-block;
    width: 20px;
}

.llmchat-animation-container .chat-input {
    animation: input-pulse 3s ease-in-out infinite;
}

.llmchat-animation-container .selected-model {
    animation: float 4s ease-in-out infinite;
}

/* ================================
   OPERATOR/ROUTER ANIMATION SPECIFIC
   ================================ */

.operator-animation-container .router-node::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -20px;
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #6c63ff, transparent);
    animation: data-flow 2s ease-in-out infinite;
}

.operator-animation-container .progress-bar {
    position: relative;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    height: 8px;
    margin: 8px 0;
    overflow: hidden;
}

.operator-animation-container .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6c63ff, #8b7df7, #a29bfa);
    border-radius: 4px;
    animation: progress-fill 3s ease-out infinite;
    position: relative;
    overflow: hidden;
}

.operator-animation-container .progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progress-shine 2s ease-in-out infinite;
}

@keyframes progress-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Throughput bar styling */
.throughput-bar {
    width: 60px;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.throughput-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    border-radius: 2px;
    animation: throughput-flow 1.5s ease-in-out infinite;
}

@keyframes throughput-flow {
    0%, 100% { width: 30%; }
    50% { width: 90%; }
}

/* Enhanced chat input styling */
.chat-input.active-input {
    border: 2px solid #6c63ff;
    background: rgba(108, 99, 255, 0.05);
    animation: input-pulse 3s ease-in-out infinite;
}

.send-button.active-send {
    background: #6c63ff;
    color: white;
    animation: button-ready 2s ease-in-out infinite;
}

@keyframes button-ready {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Feature button active state */
.feature-button.active {
    background: rgba(108, 99, 255, 0.2);
    border: 1px solid #6c63ff;
    color: #6c63ff;
    animation: feature-highlight 3s ease-in-out infinite;
}

@keyframes feature-highlight {
    0%, 100% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1); }
}

/* Enhanced editor status */
.editor-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-text {
    color: #10b981;
    font-weight: 500;
}

.editor-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.progress-text {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    animation: progress-text-pulse 2s ease-in-out infinite;
}

@keyframes progress-text-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Chat status bar */
.chat-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    margin-top: 8px;
    font-size: 0.85em;
}

.response-time {
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

/* Streaming text cursor */
.streaming-cursor {
    animation: blink-cursor 1s infinite;
    color: #6c63ff;
    font-weight: bold;
    margin-left: 2px;
}

/* Dynamic value switching */
.dynamic-value {
    transition: all 0.3s ease;
    position: relative;
}

.dynamic-value::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(108, 99, 255, 0.1);
    border-radius: 3px;
    opacity: 0;
    animation: value-update 4s ease-in-out infinite;
}

@keyframes value-update {
    0%, 90%, 100% { opacity: 0; }
    5%, 85% { opacity: 1; }
}

/* ================================
   RESPONSIVE ANIMATIONS
   ================================ */

@media (max-width: 768px) {
    /* Reduce animation intensity on mobile */
    .coder-animation-container .code-line,
    .llmchat-animation-container .message {
        animation-duration: 0.4s;
    }
    
    .operator-animation-container .progress-fill {
        animation-duration: 2s;
    }
}

/* ================================
   LIGHT MODE ANIMATION ADJUSTMENTS
   ================================ */

[data-theme="light"] .coder-animation-container .code-line.typing::after {
    color: #5a52d5;
}

[data-theme="light"] .llmchat-animation-container .message.typing::after {
    color: #5a52d5;
}

[data-theme="light"] .operator-animation-container .progress-fill {
    background: linear-gradient(90deg, #5a52d5, #7169e8);
}

[data-theme="light"] .operator-animation-container .system-status::before {
    color: #059669;
}

/* ================================
   PERFORMANCE OPTIMIZATIONS
   ================================ */

/* Enable hardware acceleration for smooth animations */
.coder-animation-container,
.llmchat-animation-container,
.operator-animation-container {
    transform: translateZ(0);
    will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================================
   ENHANCED INTERACTIVE ELEMENTS
   ================================ */

/* Typing dots animation for chat */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #6c63ff;
    animation: typing-dots 1.5s infinite;
}

.typing-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Enhanced status indicators */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-indicator.online {
    background-color: #10b981;
    animation: status-pulse 2s ease-in-out infinite;
}

.status-indicator.pulsing {
    animation: status-pulse 1.5s ease-in-out infinite;
}

/* Enhanced progress bars */
.progress-bar {
    position: relative;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    height: 8px;
    margin: 8px 0;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6c63ff, #8b7df7, #a29bfa);
    border-radius: 4px;
    animation: progress-fill 3s ease-out infinite;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progress-shine 2s ease-in-out infinite;
}

@keyframes progress-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Throughput bar styling */
.throughput-bar {
    width: 60px;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.throughput-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    border-radius: 2px;
    animation: throughput-flow 1.5s ease-in-out infinite;
}

@keyframes throughput-flow {
    0%, 100% { width: 30%; }
    50% { width: 90%; }
}

/* Enhanced chat input styling */
.chat-input.active-input {
    border: 2px solid #6c63ff;
    background: rgba(108, 99, 255, 0.05);
    animation: input-pulse 3s ease-in-out infinite;
}

.send-button.active-send {
    background: #6c63ff;
    color: white;
    animation: button-ready 2s ease-in-out infinite;
}

@keyframes button-ready {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Feature button active state */
.feature-button.active {
    background: rgba(108, 99, 255, 0.2);
    border: 1px solid #6c63ff;
    color: #6c63ff;
    animation: feature-highlight 3s ease-in-out infinite;
}

@keyframes feature-highlight {
    0%, 100% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1); }
}

/* Enhanced editor status */
.editor-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-text {
    color: #10b981;
    font-weight: 500;
}

.editor-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.progress-text {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.7);
    animation: progress-text-pulse 2s ease-in-out infinite;
}

@keyframes progress-text-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Chat status bar */
.chat-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    margin-top: 8px;
    font-size: 0.85em;
}

.response-time {
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

/* Streaming text cursor */
.streaming-cursor {
    animation: blink-cursor 1s infinite;
    color: #6c63ff;
    font-weight: bold;
    margin-left: 2px;
}

/* Dynamic value switching */
.dynamic-value {
    transition: all 0.3s ease;
    position: relative;
}

.dynamic-value::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(108, 99, 255, 0.1);
    border-radius: 3px;
    opacity: 0;
    animation: value-update 4s ease-in-out infinite;
}

@keyframes value-update {
    0%, 90%, 100% { opacity: 0; }
    5%, 85% { opacity: 1; }
}

/* ================================
   PERFORMANCE AND ACCESSIBILITY
   ================================ */

/* Reduce animations for accessibility */
@media (prefers-reduced-motion: reduce) {
    .typing-dots .dot,
    .status-indicator,
    .progress-fill,
    .streaming-cursor {
        animation: none !important;
    }
    
    .progress-fill {
        width: var(--progress-width, 75%) !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .status-indicator.online {
        background-color: #00ff00;
    }
    
    .progress-fill {
        background: #0080ff;
    }
}
