/**
 * InstaSave Premium Circular Progress Indicator
 * Mobile-first, Instagram-inspired design
 */

/* ========================================
   LOADING CONTAINER (REPLACES OLD LOADING)
   ======================================== */
.instasave-loading {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,248,250,0.98) 100%);
    border-radius: 24px;
    padding: 50px 40px 45px;
    text-align: center;
    box-shadow: 
        0 20px 60px rgba(131, 58, 180, 0.15),
        0 8px 25px rgba(0, 0, 0, 0.08);
    max-width: 320px;
    margin: 0 auto;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

/* Ambient glow behind loader */
.instasave-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(131, 58, 180, 0.15) 0%, transparent 70%);
    transform: translate(-50%, -60%);
    pointer-events: none;
}

/* ========================================
   CIRCULAR PROGRESS INDICATOR
   ======================================== */
.circular-progress {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 30px;
}

/* SVG Container */
.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

/* Background track */
.progress-ring__bg {
    fill: none;
    stroke: rgba(200, 200, 210, 0.3);
    stroke-width: 8;
}

/* Main progress arc */
.progress-ring__progress {
    fill: none;
    stroke: url(#instasave-gradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 377;
    stroke-dashoffset: 377;
    transition: stroke-dashoffset 0.5s ease;
    filter: drop-shadow(0 0 8px rgba(131, 58, 180, 0.5));
}

/* Animated indeterminate mode */
.progress-ring__progress.indeterminate {
    animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
    0% {
        stroke-dashoffset: 377;
        transform: rotate(0deg);
    }
    50% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 377;
        transform: rotate(360deg);
    }
}

/* Outer decorative ring */
.progress-ring__outer {
    fill: none;
    stroke: url(#instasave-gradient);
    stroke-width: 2;
    stroke-dasharray: 8 12;
    opacity: 0.4;
    animation: rotateOuter 20s linear infinite;
    transform-origin: center;
}

@keyframes rotateOuter {
    100% { transform: rotate(360deg); }
}

/* Center icon container */
.progress-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 8px 25px rgba(131, 58, 180, 0.4),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
    animation: centerPulse 2s ease-in-out infinite;
}

@keyframes centerPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}

.progress-center .material-icons {
    font-size: 32px;
    color: #fff;
    animation: iconBounce 1s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Orbiting particles */
.progress-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: linear-gradient(135deg, #833ab4, #fd1d1d);
    border-radius: 50%;
    opacity: 0;
    animation: particleOrbit 3s linear infinite;
}

.particle:nth-child(1) { animation-delay: 0s; }
.particle:nth-child(2) { animation-delay: 0.6s; }
.particle:nth-child(3) { animation-delay: 1.2s; }
.particle:nth-child(4) { animation-delay: 1.8s; }
.particle:nth-child(5) { animation-delay: 2.4s; }

@keyframes particleOrbit {
    0% {
        opacity: 0;
        transform: translate(70px, 0) scale(0);
    }
    10% {
        opacity: 1;
        transform: translate(70px, 0) scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(70px, 0) rotate(360deg) scale(0);
    }
}

/* Glow ring on active */
.circular-progress::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(131, 58, 180, 0.2) 0%, transparent 70%);
    animation: glowPulse 2s ease-in-out infinite;
    pointer-events: none;
}

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

/* ========================================
   LOADING TEXT
   ======================================== */
.instasave-loading .loading-text {
    color: #333;
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 8px;
    letter-spacing: 0.3px;
}

.instasave-loading .loading-subtext {
    color: #888;
    font-size: 13px;
    font-weight: 400;
    margin: 0;
}

/* ========================================
   RESPONSIVE - MOBILE FIRST
   ======================================== */
@media (max-width: 480px) {
    .instasave-loading {
        padding: 40px 30px 35px;
        border-radius: 20px;
        max-width: 280px;
    }

    .circular-progress {
        width: 120px;
        height: 120px;
        margin-bottom: 25px;
    }

    .progress-center {
        width: 58px;
        height: 58px;
    }

    .progress-center .material-icons {
        font-size: 26px;
    }

    .instasave-loading .loading-text {
        font-size: 15px;
    }

    .instasave-loading .loading-subtext {
        font-size: 12px;
    }

    .particle {
        width: 4px;
        height: 4px;
    }
}

@media (max-width: 320px) {
    .instasave-loading {
        padding: 35px 20px 30px;
        max-width: 260px;
    }

    .circular-progress {
        width: 100px;
        height: 100px;
    }

    .progress-center {
        width: 48px;
        height: 48px;
    }

    .progress-center .material-icons {
        font-size: 22px;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .progress-ring__progress.indeterminate,
    .progress-ring__outer,
    .progress-center,
    .progress-center .material-icons,
    .particle,
    .circular-progress::after {
        animation: none;
    }
    
    .progress-ring__progress.indeterminate {
        stroke-dashoffset: 188;
    }
}

/* ========================================
   SUCCESS STATE
   ======================================== */
.instasave-loading.success .progress-center {
    background: linear-gradient(135deg, #00c853 0%, #69f0ae 100%);
    animation: successPop 0.5s ease;
}

@keyframes successPop {
    0% { transform: translate(-50%, -50%) scale(0.8); }
    50% { transform: translate(-50%, -50%) scale(1.15); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

.instasave-loading.success .progress-ring__progress {
    stroke: #00c853;
    stroke-dashoffset: 0;
}

/* Success particles burst */
.instasave-loading.success .particle {
    animation: particleBurst 0.8s ease-out forwards;
}

@keyframes particleBurst {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--x, 50px), var(--y, -50px)) scale(0);
    }
}

.instasave-loading.success .particle:nth-child(1) { --x: 60px; --y: -40px; }
.instasave-loading.success .particle:nth-child(2) { --x: -50px; --y: -50px; }
.instasave-loading.success .particle:nth-child(3) { --x: 40px; --y: 50px; }
.instasave-loading.success .particle:nth-child(4) { --x: -60px; --y: 40px; }
.instasave-loading.success .particle:nth-child(5) { --x: 0px; --y: -70px; }
