/**
 * 页面加载动画和骨架屏样式
 * 提供流畅的加载体验和视觉反馈
 */

/* 页面加载遮罩层 */
.page-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

/* 加载容器 */
.loading-container {
    text-align: center;
    color: white;
    max-width: 300px;
    padding: 2rem;
}

/* 加载动画 */
.loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 2rem;
}

.spinner-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 60px;
    height: 60px;
    top: 10px;
    left: 10px;
    border-top-color: rgba(255, 255, 255, 0.6);
    animation-duration: 1.5s;
    animation-direction: reverse;
}

.spinner-ring:nth-child(3) {
    width: 40px;
    height: 40px;
    top: 20px;
    left: 20px;
    border-top-color: rgba(255, 255, 255, 0.4);
    animation-duration: 1.8s;
}

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

/* 加载文本 */
.loading-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    opacity: 0.9;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 0.6; }
}

/* 进度条 */
.loading-progress {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #fff, rgba(255, 255, 255, 0.8));
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
    animation: progress-glow 2s ease-in-out infinite;
}

@keyframes progress-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.5); }
    50% { box-shadow: 0 0 15px rgba(255, 255, 255, 0.8); }
}

/* 页面加载完成状态 */
body.page-loaded {
    overflow: visible;
}

/* 骨架屏基础样式 */
.skeleton-wrapper {
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.skeleton-loading {
    pointer-events: none;
    user-select: none;
}

.skeleton-loaded {
    animation: skeleton-fade-in 0.5s ease;
}

@keyframes skeleton-loading {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes skeleton-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 骨架屏元素 */
.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

.skeleton-line-title {
    height: 20px;
    width: 60%;
    margin-bottom: 16px;
}

.skeleton-line-text {
    height: 14px;
    width: 100%;
}

.skeleton-line-text.short {
    width: 70%;
}

.skeleton-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 8px;
    margin-bottom: 16px;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 50%;
    margin-right: 16px;
    flex-shrink: 0;
}

.skeleton-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 8px;
    margin: 0 auto 16px;
}

@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* 骨架屏布局 */
.skeleton-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 24px;
    padding: 16px;
    border-radius: 8px;
    background: #fafafa;
}

.skeleton-content {
    flex: 1;
}

.skeleton-feature {
    text-align: center;
    padding: 24px;
    border-radius: 8px;
    background: #fafafa;
    margin-bottom: 16px;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .loading-container {
        padding: 1rem;
        max-width: 250px;
    }
    
    .loading-spinner {
        width: 60px;
        height: 60px;
    }
    
    .spinner-ring:nth-child(2) {
        width: 45px;
        height: 45px;
        top: 7.5px;
        left: 7.5px;
    }
    
    .spinner-ring:nth-child(3) {
        width: 30px;
        height: 30px;
        top: 15px;
        left: 15px;
    }
    
    .loading-progress {
        width: 150px;
    }
    
    .skeleton-image {
        height: 150px;
    }
    
    .skeleton-avatar {
        width: 40px;
        height: 40px;
    }
    
    .skeleton-icon {
        width: 48px;
        height: 48px;
    }
}

/* 暗色主题适配 */
@media (prefers-color-scheme: dark) {
    .page-loading-overlay {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .skeleton-line,
    .skeleton-image,
    .skeleton-avatar,
    .skeleton-icon {
        background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
        background-size: 200% 100%;
    }
    
    .skeleton-item,
    .skeleton-feature {
        background: #1a1a1a;
    }
}

/* 减少动画效果（用户偏好设置） */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner,
    .spinner-ring,
    .loading-text,
    .progress-bar,
    .skeleton-wrapper,
    .skeleton-line,
    .skeleton-image,
    .skeleton-avatar,
    .skeleton-icon {
        animation: none;
    }
    
    .page-loading-overlay {
        transition: none;
    }
}

/* 高对比度模式优化 */
@media (prefers-contrast: high) {
    .page-loading-overlay {
        background: #000;
        color: #fff;
    }
    
    .spinner-ring {
        border-top-color: #fff;
    }
    
    .progress-bar {
        background: #fff;
    }
}