<div class="bg-white rounded-lg shadow-sm overflow-hidden">
    <x-table-swipe>
        <table class="min-w-full divide-y divide-gray-200">
            <thead class="bg-gray-50">
                <tr>
                    <th class="px-3 py-2 text-center text-sm font-semibold text-gray-700">수리일</th>
                    <th class="px-3 py-2 text-left text-sm font-semibold text-gray-700">설비</th>
                    <th class="px-3 py-2 text-center text-sm font-semibold text-gray-700">보전구분</th>
                    <th class="px-3 py-2 text-center text-sm font-semibold text-gray-700">수리시간</th>
                    <th class="px-3 py-2 text-left text-sm font-semibold text-gray-700">수리내용</th>
                    <th class="px-3 py-2 text-right text-sm font-semibold text-gray-700">비용</th>
                    <th class="px-3 py-2 text-center text-sm font-semibold text-gray-700">외주업체</th>
                    <th class="px-3 py-2 text-center text-sm font-semibold text-gray-700">액션</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-gray-200">
                @forelse($repairs as $repair)
                    <tr class="hover:bg-gray-50">
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center">
                            {{ $repair->repair_date->format('Y-m-d') }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm">
                            <span class="font-mono text-blue-600 text-xs">{{ $repair->equipment?->equipment_code }}</span>
                            <span class="ml-1">{{ $repair->equipment?->name }}</span>
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center">
                            <span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium
                                {{ $repair->repair_type === 'internal' ? 'bg-blue-100 text-blue-800' : 'bg-orange-100 text-orange-800' }}">
                                {{ $repair->repair_type_label }}
                            </span>
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center">
                            {{ $repair->repair_hours ? $repair->repair_hours . 'h' : '-' }}
                        </td>
                        <td class="px-3 py-3 text-sm">
                            {{ Str::limit($repair->description, 40) ?? '-' }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-right font-mono">
                            {{ $repair->formatted_cost }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center">
                            {{ $repair->vendor ?? '-' }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center">
                            <button onclick="confirmDeleteRepair({{ $repair->id }})"
                                    class="text-red-600 hover:text-red-900">삭제</button>
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="8" class="px-6 py-12 text-center text-gray-500">
                            수리이력이 없습니다.
                        </td>
                    </tr>
                @endforelse
            </tbody>
        </table>
    </x-table-swipe>
</div>

@if($repairs->hasPages())
    @include('partials.pagination', ['paginator' => $repairs, 'target' => '#repair-table'])
@endif
