/**
 * Preloader & Loader Styles
 * Page loading animations and spinners
 */

/* ====================================
   PAGE PRELOADER
   ==================================== */

#page-preloader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
    pointer-events: auto;
}

#page-preloader.hidden {
    display: none;
}

/* ====================================
   SPINNER ANIMATION
   ==================================== */

.preloader-spinner {
    width: 60px;
    height: 60px;
    position: relative;
}

.preloader-spinner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 4px solid rgba(255, 122, 0, 0.1);
    border-top: 4px solid #ff7a00;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.preloader-spinner::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 3px solid rgba(255, 122, 0, 0.05);
    border-left: 3px solid #cc6200;
    border-radius: 50%;
    animation: spin 2s linear infinite reverse;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ====================================
   PRELOADER TEXT
   ==================================== */

.preloader-text {
    margin-top: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
    animation: fadeInOut 2s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* ====================================
   PROGRESS BAR
   ==================================== */

.preloader-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff7a00, #cc6200);
    animation: progressBar 2s ease-in-out infinite;
}

@keyframes progressBar {
    0% {
        width: 0%;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
    }
}

/* ====================================
   SKELETON LOADING
   ==================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 2s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 12px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-text.lg {
    height: 24px;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.skeleton-image {
    width: 100%;
    height: 300px;
    border-radius: 8px;
}

/* ====================================
   FADE-IN ANIMATION
   ==================================== */

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ====================================
   SLIDE-UP ANIMATION
   ==================================== */

.slide-up {
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====================================
   PULSE ANIMATION (for buttons, links)
   ==================================== */

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* ====================================
   BOUNCE ANIMATION
   ==================================== */

.bounce {
    animation: bounce 0.6s ease-in-out;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* ====================================
   RESPECTS PREFERS-REDUCED-MOTION
   ==================================== */

@media (prefers-reduced-motion: reduce) {
    .preloader-spinner::before,
    .preloader-spinner::after,
    .preloader-text,
    .preloader-progress,
    .skeleton,
    .fade-in,
    .slide-up,
    .pulse,
    .bounce {
        animation: none;
    }
}

/* ====================================
   DARK MODE SUPPORT
   ==================================== */

@media (prefers-color-scheme: dark) {
    #page-preloader {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    }

    .preloader-text {
        color: #9ca3af;
    }

    .skeleton {
        background: linear-gradient(
            90deg,
            #2d3748 25%,
            #4a5568 50%,
            #2d3748 75%
        );
    }
}
