<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-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-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($equipments as $eq)
                    <tr class="hover:bg-gray-50 cursor-pointer" onclick="window.location='{{ route('equipment.show', $eq->id) }}'">
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center font-mono text-blue-600">
                            {{ $eq->equipment_code }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm font-medium text-gray-900">
                            {{ $eq->name }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center text-gray-600">
                            {{ $eq->equipment_type ?? '-' }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center text-gray-600">
                            {{ $eq->location ?? '-' }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center text-gray-600">
                            {{ $eq->production_line ?? '-' }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center">
                            <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium {{ $eq->status_color }}">
                                {{ $eq->status_label }}
                            </span>
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center text-gray-600">
                            {{ $eq->manager?->name ?? '-' }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center text-gray-600">
                            {{ $eq->purchase_date?->format('Y-m-d') ?? '-' }}
                        </td>
                        <td class="px-3 py-3 whitespace-nowrap text-sm text-center" onclick="event.stopPropagation()">
                            <a href="{{ route('equipment.edit', $eq->id) }}" class="text-blue-600 hover:text-blue-900 mr-2">수정</a>
                            <button onclick="confirmDelete({{ $eq->id }}, '{{ $eq->name }}')"
                                    class="text-red-600 hover:text-red-900">삭제</button>
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="9" class="px-6 py-12 text-center text-gray-500">
                            등록된 설비가 없습니다.
                        </td>
                    </tr>
                @endforelse
            </tbody>
        </table>
    </x-table-swipe>
</div>

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