/**
 * AI Loading States & Animations
 * ===============================
 * Branded loading UI components for AI operations
 * Matches Web3 Hub's glassmorphism and purple/magenta theme
 */

/* AI Spinner Loader */
.ai-loader {
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: ai-spin 1s linear infinite;
    display: inline-block;
}

.ai-loader-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

@keyframes ai-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Pulse Animation for AI Thinking */
@keyframes ai-pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

.ai-pulse {
    animation: ai-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Soft Pulse for Chat Messages */
@keyframes ai-pulse-soft {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.ai-loading-pulse {
    animation: ai-pulse-soft 1.5s ease-in-out infinite;
}

/* Skeleton Loader for Content */
.skeleton-loader {
    padding: 1rem;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg,
            rgba(139, 92, 246, 0.1) 0%,
            rgba(217, 70, 239, 0.2) 50%,
            rgba(139, 92, 246, 0.1) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.skeleton-line.short {
    width: 60%;
}

@keyframes skeleton-shimmer {
    0% {
        backgroundposition: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: absolute !important;
    inset: 0;
    background: rgba(11, 5, 20, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-center;
    z-index: 50;
    border-radius: inherit;
}

/* AI Toast Notifications */
.ai-toast {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
}

.ai-toast-info {
    border-left: 3px solid var(--accent-color);
}

.ai-toast-success {
    border-left: 3px solid #10b981;
}

.ai-toast-error {
    border-left: 3px solid #ef4444;
}

.ai-toast-warning {
    border-left: 3px solid #f59e0b;
}

.ai-toast-loading {
    border-left: 3px solid var(--accent-secondary);
}

/* Progress Bar for Batch Operations */
.ai-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.ai-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--accent-glow);
}

.ai-progress-indeterminate {
    position: absolute;
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary));
    animation: progress-indeterminate 1.5s ease-in-out infinite;
    box-shadow: 0 0 10px var(--accent-glow);
}

@keyframes progress-indeterminate {
    0% {
        left: -40%;
    }

    100% {
        left: 100%;
    }
}

/* Button Loading States */
button.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
}

/* Card Loading Shimmer Effect */
.card-loading {
    position: relative;
    overflow: hidden;
}

.card-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(139, 92, 246, 0.1),
            transparent);
    animation: card-shimmer 2s infinite;
}

@keyframes card-shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* AI Chat Message Animations */
@keyframes ai-message-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-message {
    animation: ai-message-in 0.3s ease-out;
}

/* Typing Indicator (3 dots) */
.ai-typing {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: ai-typing-bounce 1.4s ease-in-out infinite;
}

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

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

@keyframes ai-typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Fade In Animation for Content */
@keyframes ai-fade-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-fade-in {
    animation: ai-fade-in 0.4s ease-out;
}

/* Status Badge */
.ai-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-status-pending {
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}

.ai-status-processing {
    background: rgba(217, 70, 239, 0.2);
    color: var(--accent-secondary);
    border: 1px solid var(--accent-secondary);
    animation: ai-pulse 2s ease-in-out infinite;
}

.ai-status-complete {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid #10b981;
}

.ai-status-error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid #ef4444;
}

/* Glow Effect for Active AI Elements */
.ai-glow {
    box-shadow: 0 0 20px var(--accent-glow);
    animation: ai-glow-pulse 2s ease-in-out infinite;
}

@keyframes ai-glow-pulse {

    0%,
    100% {
        box-shadow: 0 0 15px var(--accent-glow);
    }

    50% {
        box-shadow: 0 0 25px var(--accent-glow-secondary);
    }
}

/* Responsive Loading States */
@media (max-width: 768px) {
    .ai-toast {
        min-width: 280px;
        max-width: calc(100vw - 2rem);
    }

    .ai-loader-lg {
        width: 24px;
        height: 24px;
        border-width: 2px;
    }
}

/* Circuit Breaker Warning Banner */
.circuit-breaker-warning {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.2), rgba(251, 146, 60, 0.2));
    border: 1px solid #ef4444;
    border-radius: 8px;
    padding: 1rem;
    color: #fecaca;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: ai-pulse 2s ease-in-out infinite;
}

.circuit-breaker-warning i {
    font-size: 1.5rem;
    color: #ef4444;
}