﻿#custom-app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #FFFBF5 0%, #FFF5E6 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* Animated background particles */
#custom-app-loader::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(41, 124, 130, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: backgroundDrift 30s linear infinite;
}

/* Subtle floating orbs */
#custom-app-loader::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle, rgba(41, 124, 130, 0.04) 0%, rgba(41, 124, 130, 0.02) 50%, transparent 100%),
        radial-gradient(circle, rgba(41, 124, 130, 0.05) 0%, rgba(41, 124, 130, 0.025) 50%, transparent 100%),
        radial-gradient(circle, rgba(41, 124, 130, 0.03) 0%, rgba(41, 124, 130, 0.015) 50%, transparent 100%);
    background-size: 
        180px 180px,
        220px 220px,
        160px 160px;
    background-position: 
        15% 25%,
        80% 70%,
        45% 80%;
    animation: subtleFloat 20s ease-in-out infinite;
    pointer-events: none;
}

#custom-app-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

#custom-app-loader.active {
    opacity: 1;
}

/* Logo centered above main text */
.loader-logo-center {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
    animation: fadeIn 0.6s ease-out;
}

.center-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(41, 124, 130, 0.15));
}

/* Center loading content */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 500px;
    width: 90%;
    position: relative;
    z-index: 1;
}

.loader-main-text {
    font-size: 24px;
    font-weight: 600;
    color: #297C82;
    text-align: center;
    letter-spacing: -0.5px;
    animation: fadeIn 0.8s ease-out;
}

.progress-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(41, 124, 130, 0.1);
    border-radius: 100px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Animated gradient background in progress bar */
.progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(41, 124, 130, 0.05) 50%, 
        transparent 100%);
    animation: progressSweep 2s ease-in-out infinite;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, 
        #297C82 0%, 
        #3BA8B0 50%, 
        #297C82 100%);
    background-size: 200% 100%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 100px;
    width: 0%;
    position: relative;
    animation: gradientSlide 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(41, 124, 130, 0.4);
}

/* Glowing dot at the end of progress bar */
.progress-fill::after {
    content: '';
    position: absolute;
    right: -3px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(41, 124, 130, 0.8);
    opacity: 0;
    animation: dotPulse 1.5s ease-in-out infinite;
}

/* Status text below progress bar */
.loader-status-text {
    font-size: 15px;
    font-weight: 500;
    color: #5A7C7F;
    text-align: center;
    min-height: 24px;
    animation: fadeIn 0.4s ease-out;
}

.slow-loading-message {
    font-size: 14px;
    color: #856404;
    text-align: center;
    margin-top: 16px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffe9a6 100%);
    border-radius: 12px;
    border-left: 4px solid #ffc107;
    line-height: 1.6;
    animation: messageSlideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: none;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.2);
}

.slow-loading-message.show {
    display: block;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

@keyframes dotPulse {
    0%, 100% {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.2);
    }
}

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

@keyframes backgroundDrift {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(50px, 50px);
    }
}

@keyframes subtleFloat {
    0%, 100% {
        background-position: 
            15% 25%,
            80% 70%,
            45% 80%;
    }
    33% {
        background-position: 
            18% 30%,
            78% 65%,
            42% 75%;
    }
    66% {
        background-position: 
            12% 28%,
            82% 72%,
            48% 78%;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .loader-logo-center {
        margin-bottom: 24px;
    }

    .center-logo {
        height: 36px;
    }

    .loader-container {
        gap: 16px;
        width: 85%;
    }

    .loader-main-text {
        font-size: 20px;
    }

    .loader-status-text {
        font-size: 14px;
    }

    .slow-loading-message {
        font-size: 13px;
        padding: 10px 16px;
    }

    .progress-bar {
        height: 10px;
    }

    .progress-fill::after {
        width: 12px;
        height: 12px;
        right: -2px;
    }

    /* Smaller orbs on mobile */
    #custom-app-loader::after {
        background-size: 
            140px 140px,
            170px 170px,
            120px 120px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #custom-app-loader::before,
    #custom-app-loader::after,
    .progress-fill,
    .progress-fill::after {
        animation: none !important;
    }

    #custom-app-loader {
        transition: opacity 0.3s ease;
    }
}
