@extends('backend.layouts.app')

@section('title', '{{modelName}}')

@section('content')
<div class="mb-6 flex flex-wrap items-center justify-between gap-3">
    <h2 class="text-xl font-semibold text-gray-800 dark:text-white/90">{{modelName}}</h2>
    <a href="{{ route('{{routePrefix}}.create') }}" class="rounded-lg bg-brand-600 px-4 py-2 text-sm text-white">Create New</a>
</div>

<div class="rounded-2xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-white/[0.03]">
    <div class="p-5">
        <form method="GET" class="mb-4 flex justify-end">
            <input type="text" name="search" value="{{ $search ?? '' }}" placeholder="Search..." class="h-10 w-full max-w-xs rounded-lg border border-gray-300 px-4 text-sm">
        </form>

        <div class="max-w-full overflow-x-auto">
            <table class="w-full">
                <thead>
                    <tr class="border-b border-gray-100 dark:border-gray-800">
                        <th class="px-5 py-3 text-left text-xs font-medium uppercase text-gray-500">#</th>
                        {{headers}}
                        <th class="px-5 py-3 text-right text-xs font-medium uppercase text-gray-500">Actions</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-100 dark:divide-gray-800">
                    @forelse($data as $item)
                    <tr>
                        <td class="px-5 py-4 text-sm">{{ ($data->currentPage() - 1) * $data->perPage() + $loop->iteration }}</td>
                        {{rows}}
                        <td class="px-5 py-4 text-right">
                            <a href="{{ route('{{routePrefix}}.edit', $item) }}" class="text-brand-600 hover:underline">Edit</a>
                            <form action="{{ route('{{routePrefix}}.destroy', $item) }}" method="POST" class="inline">
                                @csrf @method('DELETE')
                                <button type="submit" class="ml-2 text-error-500 hover:underline" onclick="return confirm('Delete?')">Delete</button>
                            </form>
                        </td>
                    </tr>
                    @empty
                    <tr>
                        <td colspan="{{colspan}}" class="px-5 py-12 text-center text-gray-500">No records found.</td>
                    </tr>
                    @endforelse
                </tbody>
            </table>
        </div>

        <div class="mt-6">
            {{ $data->appends(request()->query())->links('vendor.pagination.custom') }}
        </div>
    </div>
</div>
@endsection
