@extends('admin.layouts.app')

@section('title', 'Kategori')
@section('page_title', 'Kategori Wisata')
@section('page_subtitle', 'Kelola jenis destinasi pariwisata Lumajang')

@section('content')
<div class="card soft-card">
    <div class="card-body">
        <div class="d-flex flex-column flex-md-row justify-content-between gap-3 mb-3">
            <form class="d-flex gap-2" method="GET">
                <input class="form-control" name="search" value="{{ request('search') }}" placeholder="Cari kategori">
                <button class="btn btn-outline-ocean" type="submit"><i class="bi bi-search"></i></button>
            </form>
            <a class="btn btn-nature" href="{{ route('admin.kategori.create') }}"><i class="bi bi-plus-lg me-1"></i>Tambah Kategori</a>
        </div>
        <div class="table-responsive">
            <table class="table table-hover align-middle">
                <thead><tr><th>Nama</th><th>Slug</th><th>Jumlah Wisata</th><th class="text-end">Aksi</th></tr></thead>
                <tbody>
                @forelse($kategoris as $kategori)
                    <tr>
                        <td class="fw-semibold">{{ $kategori->nama }}</td>
                        <td><span class="badge text-bg-light">{{ $kategori->slug }}</span></td>
                        <td>{{ $kategori->wisatas_count }}</td>
                        <td class="text-end">
                            <a class="btn btn-sm btn-outline-ocean" href="{{ route('admin.kategori.edit', $kategori) }}"><i class="bi bi-pencil"></i></a>
                            <form class="d-inline" method="POST" action="{{ route('admin.kategori.destroy', $kategori) }}" data-confirm="Hapus kategori ini?">
                                @csrf @method('DELETE')
                                <button class="btn btn-sm btn-outline-danger" type="submit"><i class="bi bi-trash"></i></button>
                            </form>
                        </td>
                    </tr>
                @empty
                    <tr><td colspan="4" class="text-center text-muted py-4">Belum ada kategori.</td></tr>
                @endforelse
                </tbody>
            </table>
        </div>
        {{ $kategoris->links() }}
    </div>
</div>
@endsection
