{{-- 개발 진행 중 목록 --}}
<div class="bg-white rounded-lg shadow-sm overflow-hidden flex flex-col min-h-0">
    <div class="bg-purple-500 text-white px-4 py-3 flex items-center gap-2 flex-shrink-0">
        <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
        </svg>
        <span class="font-semibold">개발 진행중</span>
        <span class="ml-auto bg-purple-600 px-2 py-0.5 rounded-full text-xs">{{ $progressItems->total() }}건</span>
    </div>
    <div class="overflow-y-auto flex-1">
        <div class="divide-y divide-gray-200">
            @forelse($progressItems as $item)
            @php
                $tenant = $item->tenant;
                $prospect = $item->tenantProspect;
                $companyName = $tenant?->company_name ?? $prospect?->company_name ?? '알 수 없음';
                $representativeName = $tenant?->representative_name ?? $prospect?->ceo_name ?? '-';
                $businessNumber = $tenant?->business_number ?? $prospect?->business_number ?? '-';
                $currentHqStep = $hqStatusOrder[$item->hq_status ?? 'pending'] ?? 0;

                // 담당자 정보 (영업파트너 또는 가망고객 등록자)
                $salesPersonName = $item->salesPartner?->user?->name ?? $prospect?->registeredBy?->name ?? '-';
                $managerName = $item->manager?->name ?? $salesPersonName; // 매니저 없으면 영업담당자와 동일
            @endphp
            <div class="p-4 hover:bg-purple-50 transition" id="progress-row-{{ $item->id }}">
                <div class="flex justify-between items-start mb-2">
                    <div>
                        <div class="font-medium text-gray-900 text-sm">{{ $companyName }}</div>
                        <div class="text-xs text-gray-500">
                            {{ $representativeName }} | {{ $businessNumber }}
                        </div>
                    </div>
                    <div class="text-xs text-gray-400">{{ $item->updated_at->format('m/d') }}</div>
                </div>

                {{-- 8단계 프로그레스 바 --}}
                <div class="mb-3">
                    <div class="flex items-center gap-0.5">
                        @foreach($hqStatuses as $statusKey => $statusLabel)
                            @php
                                $stepNum = $hqStatusOrder[$statusKey];
                                $isCompleted = $stepNum < $currentHqStep;
                                $isCurrent = $stepNum === $currentHqStep;
                            @endphp
                            <div class="group relative flex-1">
                                <div class="h-2 rounded-full transition-all {{ $isCompleted ? 'bg-purple-500' : ($isCurrent ? 'bg-purple-300' : 'bg-gray-200') }}"></div>
                                <div class="absolute bottom-full left-1/2 -translate-x-1/2 mb-1 px-2 py-1 bg-gray-800 text-white text-xs rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap z-10 pointer-events-none">
                                    {{ $statusLabel }}
                                </div>
                            </div>
                        @endforeach
                    </div>
                    <div class="text-xs text-purple-600 font-medium mt-1 text-center">{{ $item->hq_status_label }}</div>
                </div>

                {{-- 상태 변경 드롭다운 --}}
                <div class="flex items-center gap-2 mb-3">
                    <select id="status-select-{{ $item->id }}"
                            class="flex-1 text-xs border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-1 focus:ring-purple-500">
                        @foreach($hqStatuses as $statusKey => $statusLabel)
                            @if($statusKey !== 'pending')
                            <option value="{{ $statusKey }}" {{ $item->hq_status === $statusKey ? 'selected' : '' }}>
                                {{ $statusLabel }}
                            </option>
                            @endif
                        @endforeach
                    </select>
                    <button type="button"
                            onclick="updateStatus({{ $item->id }}, '{{ addslashes($companyName) }}')"
                            class="px-2 py-1 bg-purple-500 hover:bg-purple-600 text-white text-xs font-medium rounded transition">
                        변경
                    </button>
                </div>

                {{-- 담당자 정보 --}}
                <div class="text-xs text-gray-500 mb-2">
                    <span class="inline-flex items-center gap-1">
                        <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
                        </svg>
                        영업: {{ $salesPersonName }}
                    </span>
                    <span class="mx-2">|</span>
                    <span class="inline-flex items-center gap-1">
                        매니저: {{ $managerName }}
                    </span>
                </div>

                {{-- 버튼 --}}
                <div class="flex items-center justify-end gap-1">
                    <button type="button"
                            onclick="revertToPending({{ $item->id }}, '{{ addslashes($companyName) }}')"
                            class="px-2 py-1 bg-yellow-500 hover:bg-yellow-600 text-white text-xs font-medium rounded transition">
                        승인대기로
                    </button>
                    <button type="button"
                            onclick="openDetailModal({{ $item->id }})"
                            class="px-2 py-1 bg-gray-400 hover:bg-gray-500 text-white text-xs font-medium rounded transition">
                        상세
                    </button>
                </div>
            </div>
            @empty
            <div class="p-8 text-center text-gray-500 text-sm">
                <svg class="w-12 h-12 mx-auto text-gray-300 mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
                </svg>
                개발 진행 중인 항목이 없습니다.
            </div>
            @endforelse
        </div>
    </div>
    @if($progressItems->hasPages())
    <div class="px-4 py-2 border-t border-gray-200 flex-shrink-0 bg-gray-50">
        {{ $progressItems->withQueryString()->links() }}
    </div>
    @endif
</div>
