﻿/* ============================================================
   PIMS — Loading Screen (Glass + Animations)
   Include in App.razor:
       <link rel="stylesheet" href="css/pims-loader.css" />
   ============================================================ */

/* ============ BACKDROP ============ */
.pims-loader-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    min-height: 100vh;
    background: radial-gradient(circle at 14% 18%, rgba(33,150,243,.14), transparent 34%), radial-gradient(circle at 86% 82%, rgba(59,130,246,.12), transparent 34%), linear-gradient(135deg, #eef6ff 0%, #e0edff 45%, #f2f8ff 100%);
    backdrop-filter: blur(8px);
}

/* ============ ANIMATED BACKGROUND ============ */
.pims-loader-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

/* ---- Floating Orbs ---- */
.pims-orb {
    position: absolute;
    border-radius: 50%;
    opacity: 0.5;
    animation: pimsFloatOrb 12s ease-in-out infinite;
}

    .pims-orb.orb-1 {
        width: 12px;
        height: 12px;
        top: 10%;
        left: 8%;
        background: radial-gradient(circle, #60a5fa, #1e40af);
        box-shadow: 0 0 20px rgba(37,99,235,.3);
    }

    .pims-orb.orb-2 {
        width: 18px;
        height: 18px;
        top: 20%;
        right: 12%;
        background: radial-gradient(circle, #93c5fd, #2563eb);
        animation-delay: -2s;
        box-shadow: 0 0 30px rgba(37,99,235,.25);
    }

    .pims-orb.orb-3 {
        width: 10px;
        height: 10px;
        bottom: 30%;
        left: 5%;
        background: radial-gradient(circle, #3b82f6, #1e3a8a);
        animation-delay: -4s;
        box-shadow: 0 0 20px rgba(37,99,235,.3);
    }

    .pims-orb.orb-4 {
        width: 16px;
        height: 16px;
        bottom: 15%;
        right: 8%;
        background: radial-gradient(circle, #93c5fd, #3b82f6);
        animation-delay: -6s;
        box-shadow: 0 0 25px rgba(37,99,235,.25);
    }

    .pims-orb.orb-5 {
        width: 8px;
        height: 8px;
        top: 45%;
        left: 20%;
        background: radial-gradient(circle, #60a5fa, #1e40af);
        animation-delay: -1s;
        animation-duration: 15s;
    }

    .pims-orb.orb-6 {
        width: 14px;
        height: 14px;
        top: 55%;
        right: 25%;
        background: radial-gradient(circle, #93c5fd, #2563eb);
        animation-delay: -3s;
        animation-duration: 10s;
    }

    .pims-orb.orb-7 {
        width: 20px;
        height: 20px;
        bottom: 45%;
        left: 45%;
        background: radial-gradient(circle, #60a5fa, #1e40af);
        animation-delay: -5s;
        animation-duration: 14s;
        box-shadow: 0 0 35px rgba(37,99,235,.2);
    }

    .pims-orb.orb-8 {
        width: 9px;
        height: 9px;
        top: 5%;
        left: 50%;
        background: radial-gradient(circle, #93c5fd, #2563eb);
        animation-delay: -7s;
        animation-duration: 11s;
    }

@keyframes pimsFloatOrb {
    0%, 100% {
        transform: translate(0,0) scale(1);
        opacity: .4;
    }

    25% {
        transform: translate(30px,-40px) scale(1.2);
        opacity: .8;
    }

    50% {
        transform: translate(-20px,20px) scale(.8);
        opacity: .3;
    }

    75% {
        transform: translate(40px,30px) scale(1.1);
        opacity: .7;
    }
}

/* ---- Floating Stars ---- */
.pims-star {
    position: absolute;
    color: rgba(37,99,235,.18);
    font-size: 24px;
    animation: pimsFloatStar 14s ease-in-out infinite;
    opacity: 0;
}

    .pims-star.star-1 {
        top: 8%;
        left: 25%;
        animation-delay: 0s;
        font-size: 28px;
    }

    .pims-star.star-2 {
        top: 30%;
        right: 18%;
        animation-delay: -3s;
        font-size: 20px;
    }

    .pims-star.star-3 {
        bottom: 25%;
        left: 30%;
        animation-delay: -6s;
        font-size: 32px;
    }

    .pims-star.star-4 {
        bottom: 10%;
        right: 30%;
        animation-delay: -9s;
        font-size: 18px;
    }

    .pims-star.star-5 {
        top: 50%;
        left: 5%;
        animation-delay: -2s;
        font-size: 22px;
    }

    .pims-star.star-6 {
        top: 15%;
        right: 40%;
        animation-delay: -5s;
        font-size: 26px;
    }

@keyframes pimsFloatStar {
    0%, 100% {
        transform: translate(0,0) rotate(0) scale(.5);
        opacity: 0;
    }

    20% {
        opacity: .6;
    }

    50% {
        transform: translate(50px,-30px) rotate(180deg) scale(1);
        opacity: .8;
    }

    80% {
        opacity: .6;
    }

    100% {
        transform: translate(-20px,40px) rotate(360deg) scale(.5);
        opacity: 0;
    }
}

/* ---- Floating Hexagons ---- */
.pims-hex {
    position: absolute;
    border: 2px solid rgba(37,99,235,.10);
    width: 40px;
    height: 40px;
    animation: pimsFloatHex 18s linear infinite;
    opacity: 0;
    transform: rotate(30deg);
}

    .pims-hex::before {
        content: '';
        position: absolute;
        inset: 6px;
        border: 1.5px solid rgba(37,99,235,.06);
    }

    .pims-hex.hex-1 {
        top: 12%;
        left: 35%;
        animation-delay: 0s;
        width: 45px;
        height: 45px;
    }

    .pims-hex.hex-2 {
        top: 60%;
        right: 10%;
        animation-delay: -4s;
        width: 35px;
        height: 35px;
    }

    .pims-hex.hex-3 {
        bottom: 20%;
        left: 15%;
        animation-delay: -8s;
        width: 50px;
        height: 50px;
    }

    .pims-hex.hex-4 {
        top: 35%;
        right: 35%;
        animation-delay: -12s;
        width: 30px;
        height: 30px;
    }

    .pims-hex.hex-5 {
        bottom: 40%;
        left: 50%;
        animation-delay: -16s;
        width: 38px;
        height: 38px;
    }

@keyframes pimsFloatHex {
    0% {
        transform: translate(0,0) rotate(30deg) scale(.3);
        opacity: 0;
    }

    10% {
        opacity: .6;
    }

    50% {
        transform: translate(60px,-50px) rotate(210deg) scale(1);
        opacity: .8;
    }

    90% {
        opacity: .6;
    }

    100% {
        transform: translate(-30px,60px) rotate(390deg) scale(.3);
        opacity: 0;
    }
}

/* ---- Glow Orbs ---- */
.pims-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: pimsGlowFloat 8s ease-in-out infinite;
}

    .pims-glow.glow-1 {
        width: 350px;
        height: 350px;
        top: -120px;
        right: -100px;
        background: rgba(37,99,235,.10);
    }

    .pims-glow.glow-2 {
        width: 300px;
        height: 300px;
        bottom: -100px;
        left: -100px;
        background: rgba(96,165,250,.10);
        animation-delay: -3s;
        animation-duration: 10s;
    }

    .pims-glow.glow-3 {
        width: 250px;
        height: 250px;
        top: 40%;
        left: 40%;
        background: rgba(37,99,235,.06);
        animation-delay: -6s;
        animation-duration: 12s;
    }

@keyframes pimsGlowFloat {
    0%, 100% {
        transform: translate(0,0) scale(1);
    }

    33% {
        transform: translate(30px,-30px) scale(1.1);
    }

    66% {
        transform: translate(-30px,30px) scale(.9);
    }
}

/* ---- Grid Pattern ---- */
.pims-grid-pattern {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(37,99,235,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(37,99,235,.03) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: pimsGridPulse 6s ease-in-out infinite;
}

@keyframes pimsGridPulse {
    0%, 100% {
        opacity: .3;
    }

    50% {
        opacity: .7;
    }
}

/* ============ GLASS CARD ============ */
.pims-loader-card {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 3rem;
    max-width: 470px;
    width: 100%;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 2rem;
    border: 1px solid rgba(37, 99, 235, 0.15);
    box-shadow: 0 25px 60px rgba(30, 58, 138, 0.14), 0 8px 24px rgba(37, 99, 235, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    text-align: center;
    animation: pimsCardIn 0.5s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes pimsCardIn {
    from {
        opacity: 0;
        transform: translateY(14px) scale(.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---- Badge ---- */
.pims-loader-badge {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .9rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.10);
    border: 1px solid rgba(37, 99, 235, 0.20);
    color: #1e3a8a;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    backdrop-filter: blur(6px);
}

    .pims-loader-badge .pims-badge-dot {
        position: relative;
        display: inline-flex;
        width: 7px;
        height: 7px;
        border-radius: 999px;
        background: #2563eb;
    }

        .pims-loader-badge .pims-badge-dot::after {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: inherit;
            background: #60a5fa;
            animation: pimsBadgePing 1.2s ease-out infinite;
        }

@keyframes pimsBadgePing {
    0% {
        transform: scale(1);
        opacity: .7;
    }

    80% {
        transform: scale(2.5);
        opacity: 0;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* ---- Logo Ring ---- */
.pims-loader-ring {
    position: relative;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100px;
}

    .pims-loader-ring::before {
        content: '';
        position: absolute;
        inset: -4px;
        border-radius: 50%;
        padding: 4px;
        background: conic-gradient(from 0deg, transparent, #2563eb, #60a5fa, #2563eb, transparent);
        -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        -webkit-mask-composite: xor;
        mask-composite: exclude;
        animation: pimsRingSpin 2s linear infinite;
    }

    .pims-loader-ring::after {
        content: '';
        position: absolute;
        inset: -14px;
        border-radius: 50%;
        background: radial-gradient(circle at 30% 30%, rgba(37,99,235,.10), transparent 70%);
        animation: pimsRingPulse 2s ease-in-out infinite;
    }

@keyframes pimsRingSpin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pimsRingPulse {
    0%, 100% {
        transform: scale(1);
        opacity: .4;
    }

    50% {
        transform: scale(1.1);
        opacity: .8;
    }
}

.pims-loader-icon {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 8px 30px rgba(37, 99, 235, 0.15);
    overflow: hidden;
}

    .pims-loader-icon img {
        width: 62px;
        height: 62px;
        object-fit: contain;
        animation: pimsLogoPulse 2s ease-in-out infinite;
    }

@keyframes pimsLogoPulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* ---- App Name ---- */
.pims-loader-brand {
    margin-top: 1rem;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 4px;
    color: #001f3f;
    text-transform: uppercase;
    text-shadow: 0 1px 0 rgba(255,255,255,.6);
}

/* ---- Title + Subtitle ---- */
.pims-loader-title {
    margin: .5rem 0 0 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: #1e3a8a;
    line-height: 1.2;
}

.pims-loader-subtitle {
    margin: .4rem auto 0;
    max-width: 320px;
    font-size: .8125rem;
    font-weight: 600;
    color: #64748b;
    line-height: 1.5;
    min-height: 1.4em;
}

/* ---- Steps ---- */
.pims-loader-steps {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: 100%;
    margin-top: 1.5rem;
    padding: 0 .5rem;
}

.pims-loader-step {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
    border-radius: .75rem;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

    .pims-loader-step.is-loading {
        border-color: rgba(37,99,235,.15);
        background: rgba(37,99,235,.05);
    }

    .pims-loader-step.is-complete {
        border-color: rgba(37,99,235,.15);
        background: rgba(37,99,235,.06);
    }

    .pims-loader-step .step-state {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        color: #ffffff;
        font-size: 9px;
        background: #cbd5e1;
        transition: all 0.3s ease;
        flex-shrink: 0;
    }

    .pims-loader-step.is-loading .step-state {
        background: #2563eb;
        animation: pimsStepPulse 1.2s ease-in-out infinite;
    }

    .pims-loader-step.is-complete .step-state {
        background: #2563eb;
    }

@keyframes pimsStepPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(37,99,235,.25);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(37,99,235,.06);
    }
}

.pims-loader-step span:not(.step-state) {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    text-align: left;
}

.pims-loader-step small {
    font-size: 9px;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.pims-loader-step.is-loading small {
    color: #2563eb;
}

.pims-loader-step.is-complete small {
    color: #16a34a;
}

/* ---- Progress Bar ---- */
.pims-loader-progress {
    width: 100%;
    height: 3px;
    margin-top: 1rem;
    border-radius: 999px;
    background: rgba(37,99,235,.10);
    overflow: hidden;
    position: relative;
}

    .pims-loader-progress::after {
        content: '';
        position: absolute;
        inset: 0;
        width: 40%;
        border-radius: 999px;
        background: linear-gradient(90deg, #1e40af, #3b82f6, #60a5fa, #3b82f6, #1e40af);
        background-size: 200% 100%;
        animation: pimsProgressSlide 1.8s ease-in-out infinite;
    }

@keyframes pimsProgressSlide {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(350%);
    }
}

/* ---- Status ---- */
.pims-loader-status {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: 1rem;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
}

    .pims-loader-status i {
        color: #2563eb;
        font-size: 14px;
        animation: pimsShieldPulse 2s ease-in-out infinite;
    }

@keyframes pimsShieldPulse {
    0%, 100% {
        transform: scale(1);
        opacity: .7;
    }

    50% {
        transform: scale(1.15);
        opacity: 1;
    }
}

/* ---- Dots ---- */
.pims-loader-dots {
    display: flex;
    gap: 6px;
    margin-top: .75rem;
}

    .pims-loader-dots span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #2563eb;
        animation: pimsDotBounce 1.4s ease-in-out infinite;
    }

        .pims-loader-dots span:nth-child(2) {
            animation-delay: .2s;
        }

        .pims-loader-dots span:nth-child(3) {
            animation-delay: .4s;
        }

@keyframes pimsDotBounce {
    0%, 80%, 100% {
        transform: scale(.4);
        opacity: .3;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    .pims-loader-card {
        padding: 1.75rem 1.5rem;
        max-width: 94%;
        border-radius: 1.5rem;
    }

    .pims-loader-ring {
        width: 80px;
        height: 80px;
    }

    .pims-loader-icon {
        width: 58px;
        height: 58px;
    }

        .pims-loader-icon img {
            width: 46px;
            height: 46px;
        }

    .pims-loader-brand {
        font-size: 18px;
        letter-spacing: 3px;
    }

    .pims-loader-title {
        font-size: 1rem;
    }

    .pims-loader-step span:not(.step-state) {
        font-size: 11px;
    }

    .pims-orb, .pims-star, .pims-hex, .pims-glow {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pims-loader-card,
    .pims-loader-ring::before,
    .pims-loader-ring::after,
    .pims-loader-progress::after,
    .pims-loader-dots span,
    .pims-orb, .pims-star, .pims-hex, .pims-glow {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
