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

    <div class="card">
        <div class="table-responsive">
            <table class="table table-hover mb-0">
                <thead>
                    <tr>
                        <th>Nama</th>
                        <th>Kabupaten</th>
                        <th>Slug</th>
                        <th>Jumlah Desa</th>
                        <th class="text-end">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse ($kecamatan as $item)
                        <tr>
                            <td>{{ $item->nama }}</td>
                            <td>{{ $item->kabupaten->nama }}</td>
                            <td><code>{{ $item->slug }}</code></td>
                            <td>{{ $item->desa_count }}</td>
                            <td class="text-end">
                                <a href="{{ route('super-admin.kecamatan.edit', $item) }}" class="btn btn-sm btn-outline-secondary">Edit</a>
                                <form action="{{ route('super-admin.kecamatan.destroy', $item) }}" method="POST" class="d-inline" onsubmit="return confirm('Hapus kecamatan ini?')">
                                    @csrf @method('DELETE')
                                    <button class="btn btn-sm btn-outline-danger">Hapus</button>
                                </form>
                            </td>
                        </tr>
                    @empty
                        <tr><td colspan="5" class="text-center text-muted py-4">Belum ada data Kecamatan.</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
    </div>

    <div class="mt-3">{{ $kecamatan->links() }}</div>
</x-app-layout>
