/**
 * Global Page Loading Styles for CliveMart
 */

/* Page Loading Overlay */
.page-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: auto;
    pointer-events: none;
}

.page-loading-overlay.page-loading-show {
    opacity: 1;
    pointer-events: auto;
}

/* Loading Content */
.page-loading-content {
    text-align: center;
    max-width: 300px;
    padding: 40px 20px;
}

/* Loading Spinner */
.page-loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
}

.spinner-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 60px;
    height: 60px;
    top: 10px;
    left: 10px;
    border-top-color: #28a745;
    animation-duration: 1s;
    animation-direction: reverse;
}

.spinner-ring:nth-child(3) {
    width: 40px;
    height: 40px;
    top: 20px;
    left: 20px;
    border-top-color: #ffc107;
    animation-duration: 0.8s;
}

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

/* Loading Text */
.page-loading-text {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Loading Progress Bar */
.page-loading-progress {
    width: 200px;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.page-loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #28a745, #ffc107, #007bff);
    background-size: 200% 100%;
    border-radius: 2px;
    animation: progressMove 2s ease-in-out infinite;
}

@keyframes progressMove {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Button Loading States */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: middle;
}

.btn-spinner-ring {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.btn-loading-text {
    vertical-align: middle;
}

/* Page Loading Active State */
.page-loading-active {
    /* Allow scrolling but prevent interactions */
    user-select: none;
}

.page-loading-active * {
    cursor: wait !important;
}

/* Allow scrolling elements to still scroll */
.page-loading-active body,
.page-loading-active html,
.page-loading-active .scroll-container,
.page-loading-active .overflow-auto,
.page-loading-active .overflow-scroll {
    overflow: auto !important;
    pointer-events: auto !important;
}

/* Prevent clicks on interactive elements only */
.page-loading-active button,
.page-loading-active .btn,
.page-loading-active a,
.page-loading-active input[type="submit"],
.page-loading-active input[type="button"],
.page-loading-active [onclick],
.page-loading-active [role="button"] {
    pointer-events: none !important;
}

/* Loading States for Different Elements */
.loading-link {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading-link::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 8px;
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translateY(-50%);
}

/* Form Loading State */
.form-loading {
    opacity: 0.7;
    pointer-events: none;
}

.form-loading input,
.form-loading button,
.form-loading select,
.form-loading textarea {
    cursor: wait;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .page-loading-overlay {
        background: rgba(26, 26, 26, 0.95);
    }
    
    .page-loading-text {
        color: #e0e0e0;
    }
    
    .page-loading-progress {
        background: #333;
    }
    
    .spinner-ring {
        border-top-color: #4dabf7;
    }
    
    .spinner-ring:nth-child(2) {
        border-top-color: #51cf66;
    }
    
    .spinner-ring:nth-child(3) {
        border-top-color: #ffd43b;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .spinner-ring,
    .btn-spinner-ring {
        animation: none;
    }
    
    .page-loading-progress-bar {
        animation: none;
        background: #007bff;
    }
    
    .loading-link::after {
        animation: none;
        content: '⏳';
        border: none;
        font-size: 12px;
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .page-loading-content {
        padding: 30px 15px;
    }
    
    .page-loading-spinner {
        width: 60px;
        height: 60px;
    }
    
    .spinner-ring:nth-child(2) {
        width: 45px;
        height: 45px;
        top: 7.5px;
        left: 7.5px;
    }
    
    .spinner-ring:nth-child(3) {
        width: 30px;
        height: 30px;
        top: 15px;
        left: 15px;
    }
    
    .page-loading-text {
        font-size: 16px;
    }
    
    .page-loading-progress {
        width: 150px;
    }
}

/* High Performance Mode */
@media (prefers-reduced-data: reduce) {
    .page-loading-overlay {
        backdrop-filter: none;
        background: rgba(255, 255, 255, 0.9);
    }
}

/* Loading Pulse Effect for Elements */
.loading-pulse {
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Skeleton Loading for Content */
.skeleton-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
}

@keyframes skeletonLoading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Loading States for Specific Components */
.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(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
}

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

/* Loading Dots Animation */
.loading-dots::after {
    content: '';
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}
