<div class="card border border-agi-100 min-w-full">
    <div class="card-header light:bg-agi-50">
        <h3 class="card-title">
            Activity
        </h3>
    </div>
    <div class="card-body">
        <div class="flex flex-col">
            @foreach($permohonan->histories as $activity)
                <div class="flex items-start relative">
                    @if($loop->first)
                        <div
                            class="w-9 left-0 top-9 absolute bottom-0 translate-x-1/2 border-l border-l-primary">
                        </div>
                    @endif
                    @if(!$loop->last && !$loop->first)
                        <div
                            class="w-9 left-0 top-9 absolute bottom-0 translate-x-1/2 border-l border-l-gray-300">
                        </div>
                    @endif
                    <div
                        class="flex items-center justify-center shrink-0 rounded-full
                                {{ $loop->first ? 'btn-outline btn-primary' : 'bg-gray-100 border-gray-300 text-gray-600' }}
                                size-9">
                        @switch(strtolower($activity->status))
                            @case('preregister')
                                <i class="ki-filled ki-note-2 text-base"></i>
                                @break
                            @case('order')
                                <i class="ki-filled ki-handcart text-base"></i>
                                @break
                            @case('revisi')
                                <i class="ki-filled ki-notepad-edit text-base"></i>
                                @break

                            @case('register')
                                <i class="ki-filled ki-note-2 text-base"></i>
                                @break

                            @case('assign')
                                <i class="ki-filled ki-file-added"></i>
                                @break

                            @case('survey')
                                <i class="ki-filled ki-map text-base"></i>
                                @break
                            @case('proses laporan')
                                <i class="ki-filled ki-paper-plane text-base"></i>
                                @break
                            @case('approved')
                                <i class="ki-filled ki-check text-base"></i>
                                @break
                            @case('delivered')
                                <i class="ki-filled ki-delivery-3 text-base"></i>
                                @break
                            @default
                                <i class="ki-filled ki-information text-base"></i>
                        @endswitch
                    </div>
                    <div class="ml-3 mb-5">
                        <span class="text-sm text-gray-700 capitalize font-medium">{{ str_replace('-',' ',$activity->status) }}</span>
                        <p class="text-xs text-gray-500 mt-1">{{ $activity->keterangan ? 'Catatan : '.$activity->keterangan : '' }}</p>
                        <div class="flex items-center mt-2">
                            <span class="text-xs text-gray-400">{{ $activity->created_by ? $activity->creator->name : 'System' }}</span>
                            <span class="text-xs text-gray-400 ml-2">{{ $activity->created_at->format('d M Y H:i') }}</span>
                        </div>
                        @if($activity->file_path)
                            <a href="{{ route('activity.download', $activity->permohonan_id) }}" class="text-xs text-blue-600 hover:underline mt-2 inline-block">
                                <i class="ki-outline ki-attachment"></i> Attachment
                            </a>
                        @endif
                    </div>
                </div>
            @endforeach
        </div>
    </div>
</div>
