/* ============================================
   PREMIUM PAGE LOADER - ADVANCED DESIGN
   ============================================ */

.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a4d54 0%, #1a7580 50%, #2395a0 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Animated Background Pattern */
.page-loader::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
    animation: backgroundFloat 20s ease-in-out infinite;
}

@keyframes backgroundFloat {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(-5%, -5%) rotate(120deg);
    }

    66% {
        transform: translate(5%, 5%) rotate(240deg);
    }
}

/* Floating Particles */
.page-loader::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 60% 70%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 80% 10%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 90% 60%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 33% 80%, rgba(255, 255, 255, 0.3), transparent);
    background-size: 200% 200%;
    animation: particlesMove 15s linear infinite;
}

@keyframes particlesMove {
    0% {
        background-position: 0% 0%;
    }

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

/* Hidden State */
.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

/* Loader Content Container */
.loader-content {
    position: relative;
    z-index: 2;
    text-align: center;
    animation: contentFadeIn 0.8s ease-out forwards;
}

@keyframes contentFadeIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

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

/* Spinner Container */
.spinner-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

/* Animated Rings - Triple Ring System */
.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    animation: ringPulse 2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring:nth-child(1) {
    border: 4px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.9);
    border-right-color: rgba(255, 255, 255, 0.6);
    animation: ringRotate 1.5s linear infinite;
}

.spinner-ring:nth-child(2) {
    border: 4px solid transparent;
    border-bottom-color: rgba(255, 255, 255, 0.7);
    border-left-color: rgba(255, 255, 255, 0.4);
    animation: ringRotateReverse 2s linear infinite;
    transform: scale(0.85);
}

.spinner-ring:nth-child(3) {
    border: 3px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.5);
    border-right-color: rgba(255, 255, 255, 0.3);
    animation: ringRotate 2.5s linear infinite;
    transform: scale(0.7);
}

@keyframes ringRotate {
    0% {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(180deg) scale(1.05);
    }

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

@keyframes ringRotateReverse {
    0% {
        transform: rotate(360deg) scale(0.85);
    }

    50% {
        transform: rotate(180deg) scale(0.9);
    }

    100% {
        transform: rotate(0deg) scale(0.85);
    }
}

@keyframes ringPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.1);
    }

    50% {
        box-shadow: 0 0 30px 10px rgba(255, 255, 255, 0.2);
    }
}

/* Logo Wrapper with Advanced Effects */
.loader-logo-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow:
        0 0 30px rgba(255, 255, 255, 0.3),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    animation: logoFloat 3s ease-in-out infinite;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

@keyframes logoFloat {

    0%,
    100% {
        transform: translate(-50%, -50%) translateY(0px);
        box-shadow:
            0 0 30px rgba(255, 255, 255, 0.3),
            inset 0 0 20px rgba(255, 255, 255, 0.1);
    }

    50% {
        transform: translate(-50%, -50%) translateY(-10px);
        box-shadow:
            0 10px 40px rgba(255, 255, 255, 0.4),
            inset 0 0 25px rgba(255, 255, 255, 0.15);
    }
}

/* Logo Image */
.loader-logo-img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    animation: logoPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.2));
}

@keyframes logoPulse {

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

    50% {
        transform: scale(1.1);
        opacity: 0.9;
    }
}

/* Loading Progress Bar */
.loader-progress {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.loader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.8) 0%,
            rgba(255, 255, 255, 1) 50%,
            rgba(255, 255, 255, 0.8) 100%);
    border-radius: 10px;
    animation: progressMove 1.5s ease-in-out infinite;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

@keyframes progressMove {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(400%);
    }
}

/* Loading Text */
.loader-text {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffffff;
    font-family: 'Cairo', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 2px;
    animation: textPulse 1.5s ease-in-out infinite;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

@keyframes textPulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* Decorative Circles */
.decorative-circle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
}

.decorative-circle:nth-child(1) {
    width: 400px;
    height: 400px;
    top: -200px;
    right: -200px;
    animation: circleFloat1 15s linear infinite;
}

.decorative-circle:nth-child(2) {
    width: 300px;
    height: 300px;
    bottom: -150px;
    left: -150px;
    animation: circleFloat2 20s linear infinite;
}

@keyframes circleFloat1 {

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

    50% {
        transform: translate(-50px, 50px) scale(1.1);
    }
}

@keyframes circleFloat2 {

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

    50% {
        transform: translate(50px, -50px) scale(1.15);
    }
}

/* Page Transition Effect */
body.page-transitioning {
    overflow: hidden;
}

body.page-transitioning::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a4d54 0%, #1a7580 50%, #2395a0 100%);
    z-index: 999998;
    animation: pageTransition 0.4s ease-out forwards;
}

@keyframes pageTransition {
    0% {
        clip-path: circle(0% at 50% 50%);
    }

    100% {
        clip-path: circle(150% at 50% 50%);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .spinner-container {
        width: 150px;
        height: 150px;
    }

    .loader-logo-wrapper {
        width: 80px;
        height: 80px;
    }

    .loader-logo-img {
        width: 55px;
        height: 55px;
    }

    .loader-progress {
        width: 250px;
        bottom: 60px;
    }

    .loader-text {
        font-size: 0.95rem;
        bottom: 30px;
    }
}

@media (max-width: 480px) {
    .spinner-container {
        width: 120px;
        height: 120px;
    }

    .loader-logo-wrapper {
        width: 65px;
        height: 65px;
    }

    .loader-logo-img {
        width: 45px;
        height: 45px;
    }

    .loader-progress {
        width: 200px;
        bottom: 50px;
    }

    .loader-text {
        font-size: 0.85rem;
        bottom: 25px;
    }
}

/* Performance Optimization */
.page-loader,
.spinner-ring,
.loader-logo-wrapper,
.loader-logo-img {
    will-change: transform, opacity;
}

/* Prefers Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    .page-loader *,
    .page-loader::before,
    .page-loader::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}