<x-app-layout>
    <x-slot name="header">
        <div class="d-flex justify-content-between align-items-center">
            <h2 class="h4 mb-0">Daftar Calon</h2>
            <a href="{{ route('admin-desa.candidate.create') }}" class="btn btn-primary btn-sm">+ Tambah Calon</a>
        </div>
    </x-slot>

    <div class="row g-3">
        @forelse ($candidates as $candidate)
            <div class="col-md-4">
                <div class="card h-100">
                    @if ($candidate->foto)
                        <img src="{{ Storage::url($candidate->foto) }}" class="card-img-top" alt="{{ $candidate->nama_lengkap }}">
                    @endif
                    <div class="card-body">
                        <h5 class="card-title">No. {{ $candidate->nomor_urut }} - {{ $candidate->nama_lengkap }}</h5>
                        <span class="badge {{ $candidate->status === 'aktif' ? 'bg-success' : 'bg-secondary' }}">{{ ucfirst($candidate->status) }}</span>
                    </div>
                    <div class="card-footer d-flex justify-content-between">
                        <a href="{{ route('admin-desa.candidate.edit', $candidate) }}" class="btn btn-sm btn-outline-secondary">Kelola</a>
                        <form action="{{ route('admin-desa.candidate.destroy', $candidate) }}" method="POST" onsubmit="return confirm('Hapus calon ini?')">
                            @csrf @method('DELETE')
                            <button class="btn btn-sm btn-outline-danger">Hapus</button>
                        </form>
                    </div>
                </div>
            </div>
        @empty
            <p class="text-muted">Belum ada data calon.</p>
        @endforelse
    </div>
</x-app-layout>
