﻿/* ===== 智能載入指示器樣式 ===== */

/* 智能載入遮罩 */
.smart-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease-in-out;
}

/* 載入容器 */
.smart-loading-container {
    text-align: center;
    background: white;
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    min-width: 150px;
    animation: slideInScale 0.3s ease-out;
}

/* 載入動畫 */
@keyframes slideInScale {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 載入旋轉器容器 */
.smart-loading-spinner {
    margin-bottom: 1rem;
}

    .smart-loading-spinner .spinner-border {
        width: 2.5rem;
        height: 2.5rem;
        border-width: 0.25rem;
    }

/* 載入文字 */
.smart-loading-text {
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0;
}

/* 頁面載入狀態時的樣式 */
body.loading-active {
    overflow: hidden;
    pointer-events: none;
}

    body.loading-active * {
        cursor: wait !important;
    }

/* 允許載入指示器本身可互動 */
.smart-loading-overlay,
.smart-loading-overlay * {
    cursor: default !important;
    pointer-events: auto !important;
}

/* ===== 元素特定載入樣式 ===== */

/* 元素載入狀態 */
.element-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: #6c757d;
    font-size: 0.9rem;
    background-color: rgba(248, 249, 250, 0.8);
    border-radius: 0.375rem;
    min-height: 60px;
}

/* 元素載入時的容器樣式 */
.loading {
    position: relative;
    overflow: hidden;
}

    .loading::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.7);
        z-index: 1;
        pointer-events: none;
    }

/* ===== 按鈕載入樣式 ===== */

/* 按鈕載入狀態 */
.btn-loading {
    position: relative;
    pointer-events: none;
}

    .btn-loading .spinner-border-sm {
        width: 1rem;
        height: 1rem;
        border-width: 0.15rem;
    }

/* 不同大小的按鈕載入樣式 */
.btn-sm.btn-loading .spinner-border-sm {
    width: 0.8rem;
    height: 0.8rem;
    border-width: 0.1rem;
}

.btn-lg.btn-loading .spinner-border-sm {
    width: 1.2rem;
    height: 1.2rem;
    border-width: 0.2rem;
}

/* ===== 表格載入樣式 ===== */

/* 表格載入遮罩 */
.table-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
}

.table-container {
    position: relative;
}

    .table-container.loading {
        pointer-events: none;
    }

/* ===== 卡片載入樣式 ===== */

/* 卡片載入狀態 */
.card.loading {
    position: relative;
    overflow: hidden;
}

    .card.loading::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.8);
        z-index: 5;
        pointer-events: none;
    }

.card-loading-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    text-align: center;
}

/* ===== Modal 載入樣式 ===== */

/* Modal 載入遮罩 */
.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.loading .modal-dialog {
    pointer-events: none;
}

/* ===== 骨架載入動畫 ===== */

/* 骨架載入效果 */
.skeleton-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
    border-radius: 0.25rem;
}

@keyframes skeletonLoading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* 骨架載入的不同元素 */
.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

    .skeleton-text.short {
        width: 60%;
    }

    .skeleton-text.medium {
        width: 80%;
    }

    .skeleton-text.long {
        width: 100%;
    }

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

/* ===== 響應式載入樣式 ===== */

/* 小螢幕優化 */
@media (max-width: 768px) {
    .smart-loading-container {
        padding: 1.5rem;
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    .smart-loading-spinner .spinner-border {
        width: 2rem;
        height: 2rem;
    }

    .smart-loading-text {
        font-size: 0.8rem;
    }
}

/* ===== 暗黑模式支援 ===== */

/* 暗黑模式載入樣式 */
@media (prefers-color-scheme: dark) {
    .smart-loading-overlay {
        background: rgba(33, 37, 41, 0.85);
    }

    .smart-loading-container {
        background: #495057;
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .smart-loading-text {
        color: #adb5bd;
    }

    .element-loading {
        background-color: rgba(73, 80, 87, 0.8);
        color: #adb5bd;
    }

    .skeleton-loading {
        background: linear-gradient(90deg, #495057 25%, #6c757d 50%, #495057 75%);
        background-size: 200% 100%;
    }
}

/* ===== 可及性改善 ===== */

/* 減少動畫偏好的使用者 */
@media (prefers-reduced-motion: reduce) {
    .smart-loading-container {
        animation: none;
    }

    .skeleton-loading {
        animation: none;
        background: #e0e0e0;
    }

    .spinner-border {
        animation-duration: 2s;
    }
}

/* 高對比模式 */
@media (prefers-contrast: high) {
    .smart-loading-overlay {
        background: rgba(255, 255, 255, 0.95);
    }

    .smart-loading-container {
        border: 2px solid #000;
    }

    .smart-loading-text {
        color: #000;
    }
}
