/* 增强的 Loading 动画系统 */

/* ==================== 1. 旋转 Loading ==================== */

/* 渐变色旋转 Loading */
.loading-spinner-gradient {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        #667eea 0deg,
        #764ba2 90deg,
        transparent 90deg
    );
    mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 0);
    animation: spin-gradient 1s linear infinite;
}

@keyframes spin-gradient {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 双环旋转 Loading */
.loading-spinner-dual {
    width: 48px;
    height: 48px;
    position: relative;
}

.loading-spinner-dual::before,
.loading-spinner-dual::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 3px solid transparent;
    animation: spin-dual 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.loading-spinner-dual::before {
    width: 48px;
    height: 48px;
    border-top-color: #667eea;
    border-right-color: #667eea;
}

.loading-spinner-dual::after {
    width: 36px;
    height: 36px;
    top: 6px;
    left: 6px;
    border-bottom-color: #764ba2;
    border-left-color: #764ba2;
    animation-duration: 1s;
    animation-direction: reverse;
}

@keyframes spin-dual {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 脉冲点 Loading */
.loading-dots {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.loading-dots .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    animation: pulse-dot 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.loading-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse-dot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== 2. 骨架屏 Loading ==================== */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-card {
    padding: 20px;
    background: white;
    border-radius: 12px;
}

/* ==================== 3. 进度条 Loading ==================== */

.loading-progress {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    animation: progress-indeterminate 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes progress-indeterminate {
    0% {
        transform: translateX(-100%) scaleX(0.3);
    }
    50% {
        transform: translateX(0) scaleX(0.6);
    }
    100% {
        transform: translateX(100%) scaleX(0.3);
    }
}

/* ==================== 4. 全屏 Loading 遮罩 ==================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-overlay-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-overlay-text {
    font-size: 16px;
    color: #666;
    font-weight: 500;
}

.loading-overlay-subtext {
    font-size: 14px;
    color: #999;
}

/* ==================== 5. 内联 Loading 状态 ==================== */

.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 14px;
}

.loading-inline-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==================== 6. 按钮 Loading 状态 ==================== */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-loading .btn-text {
    visibility: hidden;
}

/* ==================== 7. 波纹 Loading ==================== */

.loading-ripple {
    width: 64px;
    height: 64px;
    position: relative;
}

.loading-ripple::before,
.loading-ripple::after {
    content: '';
    position: absolute;
    border: 4px solid #667eea;
    border-radius: 50%;
    opacity: 1;
    animation: ripple 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.loading-ripple::after {
    animation-delay: 0.5s;
}

@keyframes ripple {
    0% {
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        opacity: 1;
        margin: 0;
    }
    100% {
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        margin: 0;
    }
}

/* ==================== 8. 百分比 Loading ==================== */

.loading-percentage {
    position: relative;
    width: 64px;
    height: 64px;
}

.loading-percentage-circle {
    transform: rotate(-90deg);
}

.loading-percentage-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 6;
}

.loading-percentage-bar {
    fill: none;
    stroke: url(#loading-gradient);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: loading-circle 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes loading-circle {
    0% { stroke-dashoffset: 200; }
    50% { stroke-dashoffset: 50; }
    100% { stroke-dashoffset: 200; }
}

.loading-percentage-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
}

/* ==================== 9. 组合 Loading 卡片 ==================== */

.loading-card {
    background: white;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    text-align: center;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-card-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.loading-card-message {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

/* ==================== 10. 响应式适配 ==================== */

@media (max-width: 768px) {
    .loading-overlay-text {
        font-size: 14px;
    }

    .loading-card {
        max-width: 280px;
        padding: 24px;
    }
}
