/**
 * 用户体验增强样式
 * 包含：加载动画、骨架屏、Toast提示等
 */

/* ==================== 全屏加载动画 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
}

.loading-spinner {
    text-align: center;
    color: white;
}

.loading-text {
    font-size: 16px;
    font-weight: 500;
}

/* ==================== 骨架屏动画 ==================== */
.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-title {
    height: 24px;
    width: 60%;
}

.skeleton-text {
    height: 16px;
    width: 100%;
}

.skeleton-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* 骨架屏卡片 */
.skeleton-card {
    border: 1px solid #e0e0e0;
}

/* 骨架屏列表项 */
.skeleton-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.skeleton-content {
    flex: 1;
}

/* ==================== Toast 提示样式 ==================== */
.toast-container {
    z-index: 9999 !important;
}

.toast {
    min-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-body {
    display: flex;
    align-items: center;
    font-size: 14px;
}

/* Toast 动画 */
.toast.showing {
    animation: slideInRight 0.3s ease-out;
}

.toast.hide {
    animation: slideOutRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ==================== 按钮加载状态 ==================== */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner-border 0.75s linear infinite;
}

/* ==================== 无限滚动加载指示器 ==================== */
#infinite-scroll-loading {
    padding: 2rem 0;
    text-align: center;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state-icon {
    font-size: 64px;
    color: #dee2e6;
    margin-bottom: 20px;
}

.empty-state-title {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 10px;
    color: #495057;
}

.empty-state-description {
    font-size: 14px;
    color: #6c757d;
}

/* ==================== 加载更多按钮 ==================== */
.load-more-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 30px auto;
    padding: 12px 24px;
    border: 2px dashed #dee2e6;
    background: transparent;
    color: #6c757d;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.load-more-btn:hover {
    border-color: #0d6efd;
    color: #0d6efd;
    background: rgba(13, 110, 253, 0.05);
}

/* ==================== 平滑滚动 ==================== */
html {
    scroll-behavior: smooth;
}

/* ==================== 卡片悬停效果 ==================== */
.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* ==================== 淡入动画 ==================== */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== 脉冲动画 ==================== */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ==================== 响应式优化 ==================== */
@media (max-width: 768px) {
    .toast {
        min-width: 250px;
    }
    
    .loading-text {
        font-size: 14px;
    }
    
    .empty-state {
        padding: 40px 15px;
    }
    
    .empty-state-icon {
        font-size: 48px;
    }
}

/* ==================== 深色模式支持 ==================== */
@media (prefers-color-scheme: dark) {
    .skeleton {
        background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
        background-size: 200% 100%;
    }
    
    .skeleton-card,
    .skeleton-item {
        background: #1a1a1a;
        border-color: #3d3d3d;
    }
    
    .empty-state-icon {
        color: #3d3d3d;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .loading-overlay,
    .toast-container,
    #infinite-scroll-loading,
    .load-more-btn {
        display: none !important;
    }
}
