/**
 * Real-Time Animation Styles for QuantInvests
 * Smooth transitions for price updates and data changes
 */

/* ============================================================================
   Stream Status Indicator
   ============================================================================ */

.stream-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    transition: all 0.3s ease;
}

.stream-indicator.connected {
    background-color: #06D6A0;
    box-shadow: 0 0 8px rgba(6, 214, 160, 0.6);
    animation: pulse-green 2s infinite;
}

.stream-indicator.disconnected {
    background-color: #FF6B6B;
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.6);
    animation: pulse-red 1s infinite;
}

@keyframes pulse-green {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

@keyframes pulse-red {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}


/* ============================================================================
   Price Update Animations
   ============================================================================ */

.price-updated {
    animation: flashUpdate 0.6s ease;
}

@keyframes flashUpdate {
    0%, 100% {
        background-color: transparent;
        transform: scale(1);
    }
    50% {
        background-color: rgba(6, 214, 160, 0.3);
        transform: scale(1.02);
    }
}

.price-up {
    animation: flashGreen 0.6s ease;
}

@keyframes flashGreen {
    0%, 100% {
        background-color: transparent;
        color: inherit;
    }
    50% {
        background-color: #06D6A0;
        color: white;
        box-shadow: 0 0 10px rgba(6, 214, 160, 0.5);
    }
}

.price-down {
    animation: flashRed 0.6s ease;
}

@keyframes flashRed {
    0%, 100% {
        background-color: transparent;
        color: inherit;
    }
    50% {
        background-color: #FF6B6B;
        color: white;
        box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
    }
}

.price-direction {
    display: inline-block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* ============================================================================
   Value Change Animations
   ============================================================================ */

.value-changed {
    animation: pulseValue 0.4s ease;
}

@keyframes pulseValue {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
        font-weight: 600;
    }
}

.pl-positive-flash {
    animation: flashPositive 0.5s ease;
}

@keyframes flashPositive {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(6, 214, 160, 0.2);
    }
}

.pl-negative-flash {
    animation: flashNegative 0.5s ease;
}

@keyframes flashNegative {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(255, 107, 107, 0.2);
    }
}


/* ============================================================================
   Loading States
   ============================================================================ */

.skeleton-loader {
    background: linear-gradient(90deg, #2b3553 25%, #344367 50%, #2b3553 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s ease-in-out infinite;
    border-radius: 4px;
    height: 1em;
}

@keyframes skeletonLoading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #06D6A0;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* ============================================================================
   Smooth Transitions
   ============================================================================ */

.smooth-number {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.smooth-bg {
    transition: background-color 0.3s ease;
}

.smooth-transform {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.smooth-opacity {
    transition: opacity 0.3s ease;
}


/* ============================================================================
   Hover Effects for Interactive Elements
   ============================================================================ */

.portfolio-row:hover {
    background-color: rgba(255, 255, 255, 0.05);
    transform: translateX(2px);
    transition: all 0.2s ease;
}

.clickable-row {
    cursor: pointer;
    transition: all 0.2s ease;
}

.clickable-row:hover {
    background-color: rgba(6, 214, 160, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.clickable-row:active {
    transform: scale(0.99);
}


/* ============================================================================
   Badge Animations
   ============================================================================ */

.badge-pulse {
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(6, 214, 160, 0.7);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(6, 214, 160, 0);
    }
}


/* ============================================================================
   Chart Update Animations
   ============================================================================ */

.chart-updating {
    position: relative;
}

.chart-updating::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #06D6A0, transparent);
    animation: chartLoading 1.5s ease-in-out infinite;
}

@keyframes chartLoading {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}


/* ============================================================================
   Responsive Adjustments
   ============================================================================ */

@media (max-width: 768px) {
    .price-direction {
        font-size: 0.75em !important;
    }
    
    .stream-indicator {
        width: 8px;
        height: 8px;
    }
}


/* ============================================================================
   Dark Theme Overrides
   ============================================================================ */

.dark-theme .skeleton-loader {
    background: linear-gradient(90deg, #1e2139 25%, #2b3553 50%, #1e2139 75%);
    background-size: 200% 100%;
}

.dark-theme .clickable-row:hover {
    background-color: rgba(255, 255, 255, 0.08);
}
