/**
 * 統一されたローディング状態のスタイル
 */

/* ボタンのローディング状態 */
.btn.loading-active,
button.loading-active {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading-active svg.animate-spin,
button.loading-active svg.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* フォームローディングオーバーレイ */
.form-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: inherit;
}

.form-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.form-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.form-loading-message {
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
}

/* グローバルローディングオーバーレイ */
.global-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.global-loading-content {
    background-color: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
}

.global-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.global-loading-message {
    color: #374151;
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
    text-align: center;
}

/* スケルトンローディング */
.skeleton-loading {
    position: relative;
    overflow: hidden;
    background-color: #f3f4f6;
}

.skeleton-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.6),
            transparent);
    animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.skeleton-text {
    height: 1rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    margin-bottom: 0;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 0.5rem;
    background-color: #e5e7eb;
}

.skeleton-card {
    padding: 1.5rem;
    border-radius: 0.5rem;
    background-color: white;
    border: 1px solid #e5e7eb;
}

.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skeleton-list-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background-color: white;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

.skeleton-list-item .skeleton-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 0.5rem;
}

.skeleton-list-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* プログレスバー */
.progress-bar-container {
    width: 100%;
    padding: 0.5rem 0;
}

.progress-bar-track {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.progress-bar-fill.animated {
    background: linear-gradient(90deg,
            #3b82f6,
            #2563eb,
            #3b82f6);
    background-size: 200% 100%;
    animation: progress-shimmer 1.5s infinite;
}

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

    100% {
        background-position: -200% 0;
    }
}

.progress-bar-text {
    margin-top: 0.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* インラインスピナー */
.inline-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.5rem;
}

.inline-spinner.small {
    width: 0.75rem;
    height: 0.75rem;
    border-width: 1.5px;
    margin-right: 0.25rem;
}

.inline-spinner.large {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 3px;
    margin-right: 0.75rem;
}

/* ページ読み込み時のローディング */
.page-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.page-loading-spinner {
    width: 64px;
    height: 64px;
    border: 6px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.page-loading-message {
    margin-top: 1.5rem;
    color: #6b7280;
    font-size: 1rem;
    font-weight: 500;
}

/* ボタン内のスピナーサイズ調整 */
.btn .inline-spinner,
button .inline-spinner {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

.btn-lg .inline-spinner,
button.btn-lg .inline-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border-width: 2.5px;
}

.btn-sm .inline-spinner,
button.btn-sm .inline-spinner {
    width: 0.875rem;
    height: 0.875rem;
    border-width: 1.5px;
}

/* レスポンシブ対応 */
@media (max-width: 640px) {
    .form-loading-spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }

    .form-loading-message {
        font-size: 0.75rem;
    }

    .global-loading-content {
        padding: 1.5rem;
        min-width: 160px;
    }

    .global-loading-spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }

    .global-loading-message {
        font-size: 0.875rem;
    }
}

/* アクセシビリティ */
.loading-active[aria-busy="true"],
.form-loading-overlay[aria-busy="true"],
.global-loading-overlay[aria-busy="true"] {
    /* スクリーンリーダー用 */
}

/* プリファー・リデュース・モーション対応 */
@media (prefers-reduced-motion: reduce) {

    .form-loading-spinner,
    .global-loading-spinner,
    .page-loading-spinner,
    .inline-spinner,
    .btn.loading-active svg.animate-spin,
    button.loading-active svg.animate-spin {
        animation: none;
    }

    .skeleton-loading::after {
        animation: none;
    }

    .progress-bar-fill.animated {
        animation: none;
    }
}

/* Dark Mode for Loading Components */