/**
 * ============================================================================
 * Loading Indicator Styles
 * ============================================================================
 *
 * 로딩 인디케이터 스타일시트
 * - 전체 화면 오버레이 로딩
 * - 버튼 로딩 상태
 * - 인라인 로딩 스피너
 * - 진행률 표시
 * - 다크 모드 지원
 * - 모바일 반응형
 *
 * ============================================================================
 */

/* ========================================
   전체 화면 로딩 오버레이
   ======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none; /* JavaScript로 제어 */
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.loading-spinner-wrapper {
    text-align: center;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 200px;
}

/* ========================================
   로딩 스피너 애니메이션
   ======================================== */
.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #ff6b35;
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

.loading-spinner-small {
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ff6b35;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

.button-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   로딩 텍스트
   ======================================== */
.loading-text {
    margin: 0;
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

.loading-text-inline {
    font-size: 0.9rem;
    color: #666;
    vertical-align: middle;
}

/* ========================================
   버튼 로딩 상태
   ======================================== */
button.loading,
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
    opacity: 0.7;
}

button.loading::after,
.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ========================================
   인라인 로딩
   ======================================== */
.loading-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #666;
}

/* 카드 내부 로딩 */
.card .loading-inline {
    min-height: 200px;
}

/* 테이블 로딩 */
.table-loading {
    position: relative;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   진행률 표시
   ======================================== */
.loading-progress {
    width: 200px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin: 1rem auto 0.5rem;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff6b35, #ff8c42);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.loading-progress-text {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
}

/* ========================================
   스켈레톤 로딩 (선택사항)
   ======================================== */
.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;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    width: 80%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   다크 모드 지원
   ======================================== */
@media (prefers-color-scheme: dark) {
    .loading-overlay {
        background: rgba(0, 0, 0, 0.85);
    }

    .loading-spinner-wrapper {
        background: #2d2d2d;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    }

    .loading-text {
        color: #f0f0f0;
    }

    .loading-text-inline {
        color: #b0b0b0;
    }

    .loading-spinner {
        border-color: #444;
        border-top-color: #ff6b35;
    }

    .loading-spinner-small {
        border-color: #444;
        border-top-color: #ff6b35;
    }

    .loading-progress {
        background: #444;
    }

    .loading-progress-text {
        color: #b0b0b0;
    }

    .skeleton {
        background: linear-gradient(
            90deg,
            #2d2d2d 25%,
            #3d3d3d 50%,
            #2d2d2d 75%
        );
        background-size: 200% 100%;
    }
}

/* ========================================
   모바일 반응형
   ======================================== */
@media (max-width: 768px) {
    .loading-spinner-wrapper {
        padding: 1.5rem;
        min-width: 150px;
    }

    .loading-spinner {
        width: 50px;
        height: 50px;
        border-width: 4px;
    }

    .loading-text {
        font-size: 0.9rem;
    }

    .loading-progress {
        width: 150px;
    }
}

@media (max-width: 480px) {
    .loading-spinner-wrapper {
        padding: 1rem;
        min-width: 120px;
    }

    .loading-spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }

    .loading-text {
        font-size: 0.85rem;
    }

    .loading-progress {
        width: 120px;
        height: 4px;
    }
}

/* ========================================
   페이드 인/아웃 애니메이션
   ======================================== */
.loading-overlay.fade-in {
    animation: fadeIn 0.2s ease-in;
}

.loading-overlay.fade-out {
    animation: fadeOut 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ========================================
   접근성
   ======================================== */
.loading-overlay[aria-hidden="true"] {
    display: none !important;
}

.loading-spinner::before {
    content: '';
    position: absolute;
    clip: rect(1px, 1px, 1px, 1px);
}

/* 스크린 리더용 텍스트 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================
   인쇄 시 숨김
   ======================================== */
@media print {
    .loading-overlay,
    .loading-inline,
    .loading-spinner,
    .skeleton {
        display: none !important;
    }
}
