@forelse($items as $item)
    <div class="item-row px-3 py-2 border-b border-gray-100 cursor-pointer hover:bg-gray-50 transition-colors"
         data-item-id="{{ $item->id }}"
         onclick="selectItem({{ $item->id }})">
        <div class="flex items-center gap-2">
            {{-- 유형 뱃지 --}}
            @php
                $badgeColors = [
                    'FG' => 'bg-blue-100 text-blue-800',
                    'PT' => 'bg-green-100 text-green-800',
                    'SM' => 'bg-yellow-100 text-yellow-800',
                    'RM' => 'bg-orange-100 text-orange-800',
                    'CS' => 'bg-gray-100 text-gray-800',
                ];
                $color = $badgeColors[$item->item_type] ?? 'bg-gray-100 text-gray-800';
            @endphp
            <span class="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium {{ $color }}">
                {{ $item->item_type }}
            </span>
            <div class="flex-1 min-w-0">
                <p class="text-sm font-medium text-gray-900 truncate">{{ $item->name }}</p>
                <p class="text-xs text-gray-500 font-mono">{{ $item->code }}</p>
            </div>
        </div>
    </div>
@empty
    <div class="p-8 text-center text-gray-400 text-sm">
        검색 결과가 없습니다.
    </div>
@endforelse

{{-- 페이지네이션 정보 --}}
@if($items->hasPages())
    <div class="px-3 py-2 border-t border-gray-200 text-xs text-gray-500 text-center">
        {{ $items->total() }}건 중 {{ $items->firstItem() }}-{{ $items->lastItem() }}
        @if($items->hasMorePages())
            <button class="text-blue-600 hover:underline ml-2"
                    hx-get="{{ $items->nextPageUrl() }}"
                    hx-target="#item-list"
                    hx-swap="innerHTML"
                    hx-headers='{"X-CSRF-TOKEN": "{{ csrf_token() }}"}'>
                더보기
            </button>
        @endif
    </div>
@endif
