@if(empty($errorLogs))
    <div class="p-8 text-center text-gray-500">
        <div class="mb-2">
            <svg class="w-12 h-12 mx-auto text-green-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
            </svg>
        </div>
        <p class="text-lg font-medium text-green-600">오류 없음</p>
        <p class="text-sm mt-1">최근 시딩 작업에서 오류가 발생하지 않았습니다.</p>
    </div>
@else
    <div class="divide-y divide-gray-200">
        @foreach($errorLogs as $index => $log)
        <div class="p-4 {{ $index === 0 ? 'bg-red-50' : 'bg-white' }}">
            <div class="flex justify-between items-start mb-3">
                <div>
                    <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium {{ $index === 0 ? 'bg-red-100 text-red-800' : 'bg-gray-100 text-gray-800' }}">
                        {{ $index === 0 ? '최신' : '#' . ($index + 1) }}
                    </span>
                    <span class="ml-2 text-sm text-gray-600">{{ $log['timestamp'] }}</span>
                </div>
                <div class="text-sm text-gray-500">
                    테넌트: {{ $log['tenant_id'] }} / {{ $log['source_table'] }}
                </div>
            </div>

            @if(!empty($log['errors']))
            <div class="space-y-2">
                @foreach($log['errors'] as $error)
                <div class="bg-white border border-red-200 rounded-lg p-3 text-sm">
                    <div class="flex items-center gap-2 mb-1">
                        <span class="font-medium text-gray-900">{{ $error['field_name'] }}</span>
                        <code class="text-xs bg-gray-100 px-1 py-0.5 rounded">{{ $error['field_key'] }}</code>
                    </div>
                    <div class="text-red-600 text-xs font-mono overflow-x-auto">
                        {{ Str::limit($error['error_message'], 200) }}
                    </div>
                    @if($error['error_code'])
                    <div class="mt-1 text-xs text-gray-500">
                        오류 코드: {{ $error['error_code'] }}
                    </div>
                    @endif
                </div>
                @endforeach
            </div>
            @endif
        </div>
        @endforeach
    </div>

    <!-- 하단 정보 -->
    <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($errorLogs) }}개의 오류 로그 (최대 10개 저장)</span>
            <button onclick="clearErrorLogs()"
                    class="text-red-600 hover:text-red-800 text-sm font-medium">
                로그 초기화
            </button>
        </div>
    </div>
@endif
