/**
 * AI Loading 图片处理特效样式
 * 用于所有 AI 工具页面的加载动画
 */

/* ========== 特效容器 ========== */
.processing-effect {
    position: relative;
    width: 300px;
    height: 300px;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 24px;
    background: var(--bg-tertiary, #1a1a1a);
}

/* 卡片内类型尺寸调整 */
.processing-effect-inline {
    width: 200px;
    height: 200px;
    margin: 0 auto 16px;
}

/* 背景图片 */
.processing-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    filter: blur(2px);
    display: none;
}

.processing-bg[src]:not([src=""]) {
    display: block;
}

/* 无背景图时的默认渐变背景 */
.processing-effect::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
        rgba(168, 199, 250, 0.1) 0%,
        rgba(196, 167, 231, 0.1) 50%,
        rgba(242, 167, 195, 0.1) 100%
    );
    z-index: 1;
}

/* ========== 扫描线效果 ========== */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(168, 199, 250, 0.3) 20%,
        rgba(168, 199, 250, 0.9) 50%,
        rgba(168, 199, 250, 0.3) 80%,
        transparent 100%
    );
    box-shadow:
        0 0 20px rgba(168, 199, 250, 0.8),
        0 0 40px rgba(196, 167, 231, 0.6),
        0 0 60px rgba(242, 167, 195, 0.4);
    animation: scanLine 2s ease-in-out infinite;
    z-index: 10;
}

/* 扫描线扫过时的光带效果 */
.scan-line::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(
        to bottom,
        rgba(168, 199, 250, 0.15) 0%,
        transparent 100%
    );
}

@keyframes scanLine {
    0% {
        top: 0;
        opacity: 1;
    }
    100% {
        top: calc(100% - 4px);
        opacity: 1;
    }
}

/* ========== 粒子闪烁效果 ========== */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: particleFlicker var(--particle-duration, 1.5s) ease-in-out infinite;
    animation-delay: var(--particle-delay, 0s);
}

.particle.color-1 {
    background: #a8c7fa;
    box-shadow: 0 0 8px #a8c7fa, 0 0 16px #a8c7fa;
}

.particle.color-2 {
    background: #c4a7e7;
    box-shadow: 0 0 8px #c4a7e7, 0 0 16px #c4a7e7;
}

.particle.color-3 {
    background: #f2a7c3;
    box-shadow: 0 0 8px #f2a7c3, 0 0 16px #f2a7c3;
}

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

/* ========== 边缘光晕效果 ========== */
.edge-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px;
    pointer-events: none;
    z-index: 15;
    animation: edgeGlowPulse 3s ease-in-out infinite;
}

@keyframes edgeGlowPulse {
    0%, 100% {
        box-shadow:
            inset 0 0 30px rgba(168, 199, 250, 0.4),
            inset 0 0 60px rgba(196, 167, 231, 0.2),
            0 0 20px rgba(168, 199, 250, 0.5),
            0 0 40px rgba(196, 167, 231, 0.3);
    }
    33% {
        box-shadow:
            inset 0 0 30px rgba(196, 167, 231, 0.4),
            inset 0 0 60px rgba(242, 167, 195, 0.2),
            0 0 20px rgba(196, 167, 231, 0.5),
            0 0 40px rgba(242, 167, 195, 0.3);
    }
    66% {
        box-shadow:
            inset 0 0 30px rgba(242, 167, 195, 0.4),
            inset 0 0 60px rgba(168, 199, 250, 0.2),
            0 0 20px rgba(242, 167, 195, 0.5),
            0 0 40px rgba(168, 199, 250, 0.3);
    }
}

/* ========== 隐藏原有 spinner ========== */
.loading-overlay.has-effect .loading-spinner {
    display: none;
}

.spinner-container.has-effect .spinner {
    display: none;
}

/* ========== 响应式调整 ========== */
@media (max-width: 768px) {
    .processing-effect {
        width: 240px;
        height: 240px;
    }

    .processing-effect-inline {
        width: 160px;
        height: 160px;
    }
}

/* ========== prefers-reduced-motion ========== */
@media (prefers-reduced-motion: reduce) {
    .scan-line,
    .particle,
    .edge-glow {
        animation: none;
    }

    .scan-line {
        top: 50%;
        opacity: 0.5;
    }

    .particle {
        opacity: 0.7;
    }

    .edge-glow {
        box-shadow:
            inset 0 0 30px rgba(168, 199, 250, 0.3),
            0 0 20px rgba(168, 199, 250, 0.4);
    }
}
