/* ==========================================================================
   LoadingUI — 高级加载动画系统 v1.0
   自适应各系统主色: var(--primary-color, #0052d9)
   ========================================================================== */

/* ===== 1. 基础旋转动画 ===== */
@keyframes lu-spin {
    to { transform: rotate(360deg); }
}
@keyframes lu-spin-reverse {
    to { transform: rotate(-360deg); }
}

/* ===== 2. 主旋转器 (Spinner) ===== */
.lu-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 2.5px solid rgba(0, 0, 0, 0.06);
    border-top-color: var(--primary-color, #0052d9);
    border-radius: 50%;
    animation: lu-spin 0.7s linear infinite;
    vertical-align: middle;
    flex-shrink: 0;
}
.lu-spinner-sm { width: 18px; height: 18px; border-width: 2px; }
.lu-spinner-lg { width: 40px; height: 40px; border-width: 3px; }
.lu-spinner-xl { width: 52px; height: 52px; border-width: 3.5px; }

/* ===== 3. 双环旋转器 (Dual Ring) ===== */
.lu-spinner-dual {
    display: inline-block;
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}
.lu-spinner-dual::before,
.lu-spinner-dual::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
}
.lu-spinner-dual::before {
    border-top-color: var(--primary-color, #0052d9);
    border-right-color: var(--primary-color, #0052d9);
    animation: lu-spin 0.9s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}
.lu-spinner-dual::after {
    border-bottom-color: var(--primary-color, #0052d9);
    border-left-color: var(--primary-color, #0052d9);
    opacity: 0.35;
    animation: lu-spin-reverse 1.2s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}

/* ===== 4. 弹跳点 (Dots) ===== */
.lu-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    vertical-align: middle;
}
.lu-dots span {
    display: block;
    width: 7px;
    height: 7px;
    background: var(--primary-color, #0052d9);
    border-radius: 50%;
    animation: lu-dot-bounce 1.2s ease-in-out infinite;
}
.lu-dots span:nth-child(2) { animation-delay: 0.15s; }
.lu-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes lu-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== 5. 脉冲点 (Pulse Dot) ===== */
.lu-pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary-color, #0052d9);
    border-radius: 50%;
    animation: lu-pulse-dot 1.4s ease-in-out infinite;
}
@keyframes lu-pulse-dot {
    0%, 100% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* ===== 6. 骨架屏闪烁 (Skeleton Shimmer) ===== */
.lu-skeleton {
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.04) 25%,
        rgba(0, 0, 0, 0.08) 37%,
        rgba(0, 0, 0, 0.04) 63%
    );
    background-size: 400% 100%;
    animation: lu-shimmer 1.4s ease infinite;
    border-radius: 6px;
}
.lu-skeleton-text {
    height: 14px;
    margin-bottom: 6px;
    border-radius: 4px;
}
.lu-skeleton-text:last-child { width: 60%; }
.lu-skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.lu-skeleton-card {
    border-radius: 12px;
    padding: 16px;
}
@keyframes lu-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===== 7. 脉冲呼吸 (Pulse) ===== */
.lu-pulse {
    animation: lu-pulse 1.8s ease-in-out infinite;
}
@keyframes lu-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ===== 8. 页面初始加载器 (Page Loader) ===== */
#lu-page-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--lu-bg, #f5f5f7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
#lu-page-loader.lu-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
#lu-page-loader .lu-pl-spinner {
    width: 36px;
    height: 36px;
    border: 2.5px solid rgba(0, 0, 0, 0.06);
    border-top-color: var(--primary-color, #0052d9);
    border-radius: 50%;
    animation: lu-spin 0.7s linear infinite;
}
#lu-page-loader .lu-pl-text {
    color: #94a3b8;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    letter-spacing: 0.5px;
    animation: lu-pulse 1.8s ease-in-out infinite;
}

/* ===== 9. 全屏遮罩 (Overlay) ===== */
.lu-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 99998;
}
.lu-overlay.lu-show {
    opacity: 1;
}
.lu-overlay-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 28px 36px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.10);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    min-width: 140px;
}
.lu-overlay-card .lu-ov-text {
    color: #4e5969;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-weight: 500;
}

/* ===== 10. 按钮加载态 (Button Loading) ===== */
.lu-btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.85;
}
.lu-btn-loading > * {
    visibility: hidden;
}
.lu-btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: lu-spin 0.6s linear infinite;
}
.lu-btn-loading.lu-btn-dark::after {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary-color, #0052d9);
}

/* ===== 11. 顶部进度条 (Progress Bar) ===== */
.lu-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2.5px;
    z-index: 99999;
    background: transparent;
    pointer-events: none;
    overflow: hidden;
}
.lu-progress-bar {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--primary-color, #0052d9), rgba(0, 82, 217, 0.3));
    border-radius: 0 4px 4px 0;
    animation: lu-progress-move 1.2s ease-in-out infinite;
    box-shadow: 0 0 8px var(--primary-color, #0052d9);
}
@keyframes lu-progress-move {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(150%); }
    100% { transform: translateX(350%); }
}

/* ===== 12. 内联加载容器 (Inline Loader) ===== */
.lu-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px 16px;
    color: #94a3b8;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* ===== 13. 卡片加载遮罩 (Card Loader) ===== */
.lu-card-loading {
    position: relative;
    pointer-events: none;
    overflow: hidden;
}
.lu-card-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== 14. 淡入动画 (Fade In) ===== */
.lu-fade-in {
    animation: lu-fade-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.lu-fade-in-up {
    animation: lu-fade-in-up 0.45s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.lu-fade-in-up-stagger > * {
    animation: lu-fade-in-up 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.lu-fade-in-up-stagger > *:nth-child(1) { animation-delay: 0.02s; }
.lu-fade-in-up-stagger > *:nth-child(2) { animation-delay: 0.06s; }
.lu-fade-in-up-stagger > *:nth-child(3) { animation-delay: 0.10s; }
.lu-fade-in-up-stagger > *:nth-child(4) { animation-delay: 0.14s; }
.lu-fade-in-up-stagger > *:nth-child(5) { animation-delay: 0.18s; }
.lu-fade-in-up-stagger > *:nth-child(6) { animation-delay: 0.22s; }
.lu-fade-in-up-stagger > *:nth-child(7) { animation-delay: 0.26s; }
.lu-fade-in-up-stagger > *:nth-child(8) { animation-delay: 0.30s; }
.lu-fade-in-up-stagger > *:nth-child(9) { animation-delay: 0.34s; }
.lu-fade-in-up-stagger > *:nth-child(10) { animation-delay: 0.38s; }
@keyframes lu-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes lu-fade-in-up {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 15. 滚动条加载条 (Mini Bar) ===== */
.lu-bar-pulse {
    display: inline-block;
    width: 48px;
    height: 3px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    vertical-align: middle;
}
.lu-bar-pulse::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary-color, #0052d9);
    border-radius: 2px;
    animation: lu-bar-slide 1.1s ease-in-out infinite;
}
@keyframes lu-bar-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

/* ===== 16. 圆环进度 (Ring Progress) ===== */
.lu-ring {
    display: inline-block;
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}
.lu-ring svg {
    transform: rotate(-90deg);
}
.lu-ring circle {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
}
.lu-ring .lu-ring-track {
    stroke: rgba(0, 0, 0, 0.06);
}
.lu-ring .lu-ring-active {
    stroke: var(--primary-color, #0052d9);
    stroke-dasharray: 100;
    stroke-dashoffset: 60;
    animation: lu-ring-rotate 1.2s linear infinite;
    transform-origin: center;
}
@keyframes lu-ring-rotate {
    0% { stroke-dashoffset: 100; transform: rotate(0deg); }
    50% { stroke-dashoffset: 30; transform: rotate(180deg); }
    100% { stroke-dashoffset: 100; transform: rotate(360deg); }
}

/* ===== 17. 淡出工具类 ===== */
.lu-transition {
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.lu-hidden-fade {
    opacity: 0;
    pointer-events: none;
}

/* ===== 18. 尊重 prefers-reduced-motion ===== */
@media (prefers-reduced-motion: reduce) {
    .lu-spinner,
    .lu-spinner-dual::before,
    .lu-spinner-dual::after,
    .lu-dots span,
    .lu-pulse-dot,
    .lu-skeleton,
    .lu-pulse,
    .lu-progress-bar,
    .lu-bar-pulse::after,
    .lu-ring .lu-ring-active,
    #lu-page-loader .lu-pl-spinner,
    #lu-page-loader .lu-pl-text {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
    }
}
