/* Global Loading Animation Styles */
/* ================================ */

/* Loading Overlay Container */
.global-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* Dark theme support */
.dark .global-loading-overlay {
    background: rgba(17, 24, 39, 0.95);
}

/* Active state */
.global-loading-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Loading Container */
.global-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark .global-loading-container {
    background: rgba(31, 41, 55, 0.9);
    border: 1px solid rgba(75, 85, 99, 0.3);
}

.global-loading-overlay.active .global-loading-container {
    transform: scale(1);
}

/* Loading Icon Container */
.global-loading-icon {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Spinner Animation */
.loading-spinner {
    width: 100%;
    height: 100%;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.dark .loading-spinner {
    border: 3px solid #374151;
    border-top: 3px solid #60a5fa;
}

/* Pulse Animation */
.loading-pulse {
    width: 100%;
    height: 100%;
    background: #3b82f6;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

.dark .loading-pulse {
    background: #60a5fa;
}

/* Dots Animation */
.loading-dots {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
}

.loading-dot {
    width: 0.75rem;
    height: 0.75rem;
    background: #3b82f6;
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite both;
}

.dark .loading-dot {
    background: #60a5fa;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }
.loading-dot:nth-child(3) { animation-delay: 0s; }

/* Bars Animation */
.loading-bars {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    justify-content: center;
}

.loading-bar {
    width: 0.25rem;
    height: 2rem;
    background: #3b82f6;
    border-radius: 0.125rem;
    animation: bars 1.2s ease-in-out infinite;
}

.dark .loading-bar {
    background: #60a5fa;
}

.loading-bar:nth-child(1) { animation-delay: -1.1s; }
.loading-bar:nth-child(2) { animation-delay: -1.0s; }
.loading-bar:nth-child(3) { animation-delay: -0.9s; }
.loading-bar:nth-child(4) { animation-delay: -0.8s; }
.loading-bar:nth-child(5) { animation-delay: -0.7s; }

/* Ring Animation */
.loading-ring {
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid #3b82f6;
    border-right: 3px solid #3b82f6;
    border-radius: 50%;
    animation: ring 1s linear infinite;
}

.dark .loading-ring {
    border-top: 3px solid #60a5fa;
    border-right: 3px solid #60a5fa;
}

/* Custom Icon Animation */
.loading-custom-icon {
    font-size: 2.5rem;
    color: #3b82f6;
    animation: customIcon 2s ease-in-out infinite;
}

.dark .loading-custom-icon {
    color: #60a5fa;
}

/* Loading Text */
.global-loading-text {
    color: #374151;
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    opacity: 0;
    animation: fadeInUp 0.5s ease-out 0.2s forwards;
}

.dark .global-loading-text {
    color: #d1d5db;
}

/* Loading Subtext */
.global-loading-subtext {
    color: #6b7280;
    font-size: 0.875rem;
    opacity: 0;
    animation: fadeInUp 0.5s ease-out 0.4s forwards;
}

.dark .global-loading-subtext {
    color: #9ca3af;
}

/* Progress Bar */
.global-loading-progress {
    width: 100%;
    max-width: 200px;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    margin-top: 1rem;
    overflow: hidden;
    opacity: 0;
    animation: fadeInUp 0.5s ease-out 0.6s forwards;
}

.dark .global-loading-progress {
    background: #374151;
}

.global-loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
    animation: progressIndeterminate 2s ease-in-out infinite;
}

.dark .global-loading-progress-bar {
    background: linear-gradient(90deg, #60a5fa, #3b82f6);
}

/* Keyframe Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.1);
        opacity: 0.7;
    }
}

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

@keyframes bars {
    0%, 40%, 100% {
        transform: scaleY(0.4);
        opacity: 0.5;
    }
    20% {
        transform: scaleY(1);
        opacity: 1;
    }
}

@keyframes ring {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes customIcon {
    0%, 100% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% { 
        transform: scale(1.1) rotate(180deg);
        opacity: 0.8;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes progressIndeterminate {
    0% {
        width: 0%;
        margin-left: 0%;
    }
    50% {
        width: 75%;
        margin-left: 25%;
    }
    100% {
        width: 0%;
        margin-left: 100%;
    }
}

/* Responsive Design */
@media (max-width: 640px) {
    .global-loading-container {
        padding: 1.5rem;
        margin: 1rem;
        border-radius: 0.75rem;
    }
    
    .global-loading-icon {
        width: 3rem;
        height: 3rem;
        margin-bottom: 0.75rem;
    }
    
    .loading-custom-icon {
        font-size: 2rem;
    }
    
    .global-loading-text {
        font-size: 0.875rem;
    }
    
    .global-loading-subtext {
        font-size: 0.75rem;
    }
    
    .global-loading-progress {
        max-width: 150px;
        height: 3px;
    }
}

@media (max-width: 480px) {
    .global-loading-container {
        padding: 1rem;
        margin: 0.5rem;
    }
    
    .global-loading-icon {
        width: 2.5rem;
        height: 2.5rem;
    }
    
    .loading-custom-icon {
        font-size: 1.75rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .global-loading-overlay {
        background: rgba(255, 255, 255, 0.98);
    }
    
    .dark .global-loading-overlay {
        background: rgba(0, 0, 0, 0.98);
    }
    
    .global-loading-container {
        border: 2px solid #000;
    }
    
    .dark .global-loading-container {
        border: 2px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .global-loading-overlay,
    .global-loading-container {
        transition: none;
    }
    
    .loading-spinner,
    .loading-pulse,
    .loading-dot,
    .loading-bar,
    .loading-ring,
    .loading-custom-icon,
    .global-loading-progress-bar {
        animation: none;
    }
    
    .loading-pulse {
        opacity: 0.7;
    }
    
    .loading-dot,
    .loading-bar {
        opacity: 0.8;
    }
}

/* Print styles */
@media print {
    .global-loading-overlay {
        display: none !important;
    }
}

/* Utility Classes */
.loading-small .global-loading-icon {
    width: 2rem;
    height: 2rem;
}

.loading-large .global-loading-icon {
    width: 5rem;
    height: 5rem;
}

.loading-minimal .global-loading-container {
    background: transparent;
    box-shadow: none;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.loading-no-blur .global-loading-overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Success/Error States */
.global-loading-success .loading-custom-icon {
    color: #10b981;
    animation: successPulse 0.6s ease-out;
}

.global-loading-error .loading-custom-icon {
    color: #ef4444;
    animation: errorShake 0.6s ease-out;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}