/**
 * Loading Overlay Component
 * SourceCode Website - File Selling System
 * Reusable loading animation with progress and success state
 */

/* Loading Overlay Styles */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    backdrop-filter: blur(5px);
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

/* Spinner */
.loading-spinner {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    position: relative;
}

.loading-spinner::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #10b981;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 4px solid rgba(255, 255, 255, 0.05);
    border-bottom-color: #6366f1;
    border-radius: 50%;
    animation: spin 1.2s linear infinite reverse;
}

/* Progress Bar */
.loading-progress {
    width: 250px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #10b981);
    width: 0;
    transition: width 0.2s ease-out;
    border-radius: 4px;
    position: relative;
}

.loading-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.3),
            transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.loading-text {
    color: white;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.loading-percentage {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    font-family: monospace;
}

/* Success State */
.loading-success {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-success.show {
    display: flex;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    animation: successPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 40px rgba(16, 185, 129, 0.4);
}

.success-icon i {
    animation: checkmark 0.3s ease-out 0.2s forwards;
    opacity: 0;
    transform: scale(0);
}

/* Error State */
.error-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    animation: successPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 40px rgba(239, 68, 68, 0.4);
}

.success-text {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.success-subtext {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

/* Animations */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes successPop {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }

    50% {
        transform: scale(1.2) rotate(0deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes checkmark {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Dots Animation for waiting */
.loading-dots {
    display: inline-flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Light Theme Override */
body .loading-overlay {
    background: rgba(255, 255, 255, 0.95);
}

body .loading-text {
    color: var(--primary, #6366f1);
    background: linear-gradient(135deg, #6366f1, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

body .loading-percentage {
    color: var(--gray-600, #4b5563);
}

body .success-text {
    color: var(--success, #10b981);
    background: linear-gradient(135deg, #10b981, #059669);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body .success-subtext {
    color: var(--gray-600, #4b5563);
}

body .loading-spinner::before {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: #10b981;
}

body .loading-spinner::after {
    border-color: rgba(0, 0, 0, 0.05);
    border-bottom-color: #6366f1;
}

body .loading-dots span {
    background: var(--primary, #6366f1);
}

body .loading-progress {
    background: rgba(0, 0, 0, 0.1);
}