<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>
                    <th class="px-3 py-2 text-center text-sm font-semibold text-gray-700">QR</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->subManager?->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()">
                            <button type="button" onclick="showQr({{ $eq->id }}, '{{ addslashes($eq->equipment_code) }}', '{{ addslashes($eq->name) }}')"
                                    class="text-gray-500 hover:text-blue-600 transition" title="QR 코드">
                                <svg class="w-5 h-5 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 3h7v7H3V3zm11 0h7v7h-7V3zM3 14h7v7H3v-7zm14 3h.01M17 14h3v3h-3v-3zm0 4h3v3h-3v-3zm-4 0h3v3h-3v-3z"/>
                                </svg>
                            </button>
                        </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="11" 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
