/* Full Page Loading Screen with Progress */
#app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(1200px circle at 50% 30%, rgba(34, 211, 238, 0.16), rgba(34, 211, 238, 0.0) 55%),
        radial-gradient(900px circle at 65% 55%, rgba(124, 58, 237, 0.14), rgba(124, 58, 237, 0.0) 60%),
        linear-gradient(135deg, #0a0a0b 0%, #14141a 50%, #0a0a0b 100%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Mobile notch + small viewport friendly */
    box-sizing: border-box;
    padding:
        max(18px, env(safe-area-inset-top))
        16px
        max(18px, env(safe-area-inset-bottom));
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

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

.loader-content {
    text-align: center;
    color: #ffffff;
    max-width: 860px;
    width: min(860px, 92vw);
    padding: 24px 20px;
    position: relative;
}

.loader-logo {
    display: block;
    width: clamp(210px, 42vw, 360px);
    height: auto; /* preserve logo aspect ratio */
    max-height: 300px;
    max-width: 100%;
    object-fit: contain;
    margin: 0 auto 30px;
    animation: pulse 2.4s ease-in-out infinite;
    filter:
        drop-shadow(0 18px 45px rgba(0, 0, 0, 0.45))
        drop-shadow(0 0 26px rgba(255, 255, 255, 0.20))
        drop-shadow(0 0 50px rgba(34, 211, 238, 0.18));
}

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

.loader-title {
    font-size: clamp(44px, 5vw, 72px);
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    line-height: 1.05;
}

.loader-subtitle {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.62);
    margin-bottom: 44px;
    font-weight: 400;
    line-height: 1.35;
    max-width: 60ch;
    margin-left: auto;
    margin-right: auto;
}

/* Progress Bar Container */
.progress-container {
    width: min(720px, 92vw);
    margin: 0 auto;
}

.progress-bar-wrapper {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0;
    position: relative;
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.35),
        0 10px 35px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(8px);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #7c3aed 0%, #22d3ee 35%, #60a5fa 70%, #7c3aed 100%);
    background-size: 240% 100%;
    animation: progress-shift 1.6s ease-in-out infinite;
    border-radius: 999px;
    width: 0%;
    transition: width 0.3s ease-out;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.08),
        0 10px 26px rgba(34, 211, 238, 0.15);
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.28),
        transparent
    );
    animation: shimmer 2.2s infinite;
}

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

@keyframes progress-shift {
    0% { background-position: 0% 0; }
    50% { background-position: 100% 0; }
    100% { background-position: 0% 0; }
}

.status-details {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 10px;
    min-height: 18px;
    text-align: center;
    font-family: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Monaco, "Cascadia Mono", "Cascadia Code", Consolas, "Liberation Mono", "DejaVu Sans Mono", "Ubuntu Mono", monospace;
    letter-spacing: 0.02em;
}

.progress-percent {
    font-size: clamp(34px, 4vw, 56px);
    font-weight: 700;
    color: rgba(255, 255, 255, 0.92);
    margin-top: 10px;
    font-family: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Monaco, "Cascadia Mono", "Cascadia Code", Consolas, "Liberation Mono", "DejaVu Sans Mono", "Ubuntu Mono", monospace;
    letter-spacing: 0.02em;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .loader-logo {
        width: clamp(190px, 62vw, 320px);
        height: auto;
        margin-bottom: 26px;
    }
    
    .progress-container {
        width: 92%;
    }
    
    .progress-bar-wrapper {
        height: 10px;
    }
}

/* Extra small screens (avoid monospace letter-spacing overflow) */
@media (max-width: 380px) {
    .loader-content {
        padding: 20px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .loader-logo,
    .progress-bar,
    .progress-bar::after,
    .progress-text::after {
        animation: none !important;
    }
}
