<!-- 수리이력 탭 -->
<div class="bg-white rounded-lg shadow-sm p-6">
    <div class="flex justify-between items-center mb-4 pb-2 border-b">
        <h2 class="text-lg font-semibold text-gray-800">수리이력</h2>
    </div>

    @if($equipment->repairs->isNotEmpty())
        <div class="overflow-x-auto">
            <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-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">
                    @foreach($equipment->repairs->sortByDesc('repair_date') as $repair)
                        <tr>
                            <td class="px-3 py-2 text-sm text-center">{{ $repair->repair_date->format('Y-m-d') }}</td>
                            <td class="px-3 py-2 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-2 text-sm text-center">{{ $repair->repair_hours ? $repair->repair_hours . 'h' : '-' }}</td>
                            <td class="px-3 py-2 text-sm">{{ Str::limit($repair->description, 50) ?? '-' }}</td>
                            <td class="px-3 py-2 text-sm text-right font-mono">{{ $repair->formatted_cost }}</td>
                            <td class="px-3 py-2 text-sm text-center">{{ $repair->vendor ?? '-' }}</td>
                            <td class="px-3 py-2 text-sm text-center">
                                <button onclick="deleteRepair({{ $repair->id }})" class="text-red-600 hover:text-red-900">삭제</button>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    @else
        <p class="text-gray-500 text-center py-8">수리이력이 없습니다.</p>
    @endif
</div>
