@if(isset($error))
    <div class="p-8 text-center">
        <div class="text-yellow-600 mb-2">
            <svg class="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
            </svg>
        </div>
        <p class="text-gray-600">{{ $error }}</p>
    </div>
@elseif(empty($statuses))
    <div class="p-8 text-center text-gray-500">
        시딩 상태 정보가 없습니다.
    </div>
@else
    <table class="w-full">
        <thead class="bg-gray-50 border-b border-gray-200">
            <tr>
                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">소스 테이블</th>
                <th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">시스템 필드 수</th>
                <th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">현재 등록 수</th>
                <th class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">상태</th>
                <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">액션</th>
            </tr>
        </thead>
        <tbody class="divide-y divide-gray-200">
            @foreach($statuses as $sourceTable => $status)
            <tr class="hover:bg-gray-50 cursor-pointer transition-colors"
                onclick="goToFieldManagement('{{ $sourceTable }}')"
                title="클릭하여 {{ $status['label'] }} 필드 목록 보기">
                <td class="px-6 py-4">
                    <div class="flex items-center gap-2">
                        <div>
                            <div class="font-medium text-gray-900">{{ $status['label'] }}</div>
                            <code class="text-xs text-gray-500 font-mono">{{ $sourceTable }}</code>
                        </div>
                        <svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
                        </svg>
                    </div>
                </td>
                <td class="px-6 py-4 text-center text-sm text-gray-500">
                    {{ $status['total_count'] }}개
                </td>
                <td class="px-6 py-4 text-center text-sm text-gray-500">
                    {{ $status['current_count'] }}개
                </td>
                <td class="px-6 py-4 text-center">
                    @if($status['status'] === 'complete')
                        <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                            완료
                        </span>
                    @elseif($status['status'] === 'partial')
                        <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800">
                            일부
                        </span>
                    @else
                        <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
                            미시딩
                        </span>
                    @endif
                </td>
                <td class="px-6 py-4 text-right" onclick="event.stopPropagation()">
                    <div class="flex justify-end gap-2">
                        @if($status['status'] !== 'complete')
                            <button onclick="seedTable('{{ $sourceTable }}')"
                                    class="text-green-600 hover:text-green-800 text-sm font-medium">
                                시딩
                            </button>
                        @endif
                        @if($status['current_count'] > 0)
                            <button onclick="resetTable('{{ $sourceTable }}')"
                                    class="text-red-600 hover:text-red-800 text-sm font-medium">
                                초기화
                            </button>
                        @endif
                    </div>
                </td>
            </tr>
            @endforeach
        </tbody>
    </table>

    <!-- 요약 정보 -->
    <div class="px-6 py-4 bg-gray-50 border-t border-gray-200">
        <div class="flex justify-between items-center text-sm text-gray-600">
            <span>
                총 {{ count($statuses) }}개 테이블 /
                {{ collect($statuses)->where('status', 'complete')->count() }}개 완료
            </span>
            <span class="text-xs text-gray-400">
                * 행 클릭: 필드 목록 보기 / 시딩: 시스템 필드 등록 / 초기화: 삭제 후 재시딩
            </span>
        </div>
    </div>
@endif