/**
 * AI-Themed Loading Animations
 * Neural network and brain-inspired loading indicators
 */

/* Custom AI Loading Overlay */
.ai-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
}

/* AI Brain Icon Container */
.ai-brain-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
}

/* Pulsing Brain Icon */
.ai-brain-icon {
    font-size: 80px;
    animation: brainPulse 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(40, 167, 69, 0.3));
}

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

/* Neural Network Nodes */
.neural-nodes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.neural-node {
    position: absolute;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #28a745, #20c997);
    border-radius: 50%;
    animation: nodeFloat 2s ease-in-out infinite;
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.5);
}

.neural-node:nth-child(1) { top: 10%; left: 20%; animation-delay: 0s; }
.neural-node:nth-child(2) { top: 30%; right: 15%; animation-delay: 0.3s; }
.neural-node:nth-child(3) { bottom: 25%; left: 10%; animation-delay: 0.6s; }
.neural-node:nth-child(4) { bottom: 15%; right: 20%; animation-delay: 0.9s; }
.neural-node:nth-child(5) { top: 50%; left: 5%; animation-delay: 1.2s; }
.neural-node:nth-child(6) { top: 50%; right: 5%; animation-delay: 1.5s; }

@keyframes nodeFloat {
    0%, 100% {
        transform: translateY(0px) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
}

/* Connection Lines */
.neural-connection {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(40, 167, 69, 0.3), transparent);
    animation: connectionPulse 2s ease-in-out infinite;
    transform-origin: left center;
}

@keyframes connectionPulse {
    0%, 100% {
        opacity: 0.2;
    }
    50% {
        opacity: 0.6;
    }
}

/* AI Thinking Text */
.ai-thinking-text {
    font-size: 24px;
    font-weight: 600;
    color: #28a745;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Animated Dots */
.thinking-dots {
    display: inline-flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Subtitle Text */
.ai-subtitle {
    font-size: 16px;
    color: #6c757d;
    font-weight: 400;
}

/* Dash Loading Component Customization */
._dash-loading-callback {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(8px);
}

/* AI-themed graph loading */
.ai-loading-graph {
    position: relative;
}

.ai-loading-graph ._dash-loading {
    position: relative;
}

.ai-loading-graph ._dash-loading::before {
    content: '🧠';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 70px;
    animation: brainPulse 1.5s ease-in-out infinite;
    z-index: 10;
    filter: drop-shadow(0 0 25px rgba(40, 167, 69, 0.4));
    pointer-events: none;  /* Don't block hover events on graph */
}

.ai-loading-graph ._dash-loading::after {
    content: 'AI is analyzing...';
    position: absolute;
    top: calc(50% + 60px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    font-weight: 600;
    color: #28a745;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;  /* Don't block hover events on graph */
}

/* AI-themed table loading */
.ai-loading-table {
    position: relative;
}

.ai-loading-table ._dash-loading::before {
    content: '🧠';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 50px;
    animation: brainPulse 1.5s ease-in-out infinite;
    z-index: 10;
    filter: drop-shadow(0 0 20px rgba(40, 167, 69, 0.3));
    margin-top: -50px;
    pointer-events: none;  /* Don't block table interactions */
}

.ai-loading-table ._dash-loading::after {
    content: 'Finding best laptops...';
    position: absolute;
    top: calc(50% + 10px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 500;
    color: #28a745;
    white-space: nowrap;
    z-index: 10;
    margin-top: -50px;
    pointer-events: none;  /* Don't block table interactions */
}

/* Add rotating neural network ring around brain */
.ai-loading-graph ._dash-loading,
.ai-loading-table ._dash-loading {
    position: relative;
}

/* Rotating neural ring */
.ai-loading-graph ._dash-loading::after,
.ai-loading-table ._dash-loading::after {
    animation: neuralRingRotate 3s linear infinite;
}

/* Additional neural nodes floating around */
@keyframes neuralRingRotate {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
    100% {
        opacity: 1;
    }
}

/* Pulsing glow effect around loading area */
.ai-loading-graph._dash-loading-callback,
.ai-loading-table._dash-loading-callback {
    position: relative;
}

.ai-loading-graph._dash-loading-callback::before,
.ai-loading-table._dash-loading-callback::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 3px solid rgba(40, 167, 69, 0.2);
    border-radius: 50%;
    animation: glowPulse 2s ease-in-out infinite;
    pointer-events: none;  /* Don't block interactions */
}

@keyframes glowPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.3;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.6;
    }
}

/* Gradient Border Effect */
.ai-loading-border {
    width: 150px;
    height: 150px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 3px solid transparent;
    border-radius: 50%;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(135deg, #28a745, #20c997, #17a2b8) border-box;
    animation: borderGlow 2s ease-in-out infinite;
}

@keyframes borderGlow {
    0%, 100% {
        opacity: 0.4;
        box-shadow: 0 0 20px rgba(40, 167, 69, 0.2);
    }
    50% {
        opacity: 1;
        box-shadow: 0 0 40px rgba(40, 167, 69, 0.6);
    }
}

/* Particle Effect */
.ai-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #28a745;
    border-radius: 50%;
    animation: particleFloat 3s ease-in-out infinite;
    opacity: 0;
}

@keyframes particleFloat {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(1);
        opacity: 0;
    }
}
