<div>
    <!-- Table -->
    <div class="relative pt-5 text-gray-900 dark:text-white xl:max-w-[95%] 2xl:max-w-[90%]">
        <div class="flex items-center justify-center">
            <div class="relative overflow-x-auto rounded-lg w-3/6">
                <table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-white">
                    <thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-pink-700 dark:text-neutral-200">
                        <tr>
                            <th class="px-6 py-3">Image</th>
                            <th class="px-6 py-3">Data
                                <select wire:model.live="filter" class="ml-2 p-[2px] w-20 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-rose-800 focus:border-rose-900 dark:bg-neutral-900 dark:border-neutral-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-rose-800 dark:focus:border-rose-900">
                                    <option value="all">All</option>
                                    <option value="active">Active</option>
                                    <option value="inactive">Inactive</option>
                                </select>
                            </th>
                            <th class="px-6 py-3">Action</th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($images as $image)
                    <tr wire:key="{{ $image->id }}" class="bg-white border-t dark:bg-neutral-800 dark:border-pink-700">
                        <td class="px-6 py-4 h-[100px]">
                            <img src="/images/background/{{ $image->id }}-640p.webp" class="rounded-lg" style="width: 200px;" />
                        </td>
                        <td class="px-6 py-4">
                            <form method="POST" action="{{ route('admin.background.update') }}">
                                @csrf
                                @method('put')
                                <input type="hidden" value="{{ $image->id }}" name="id">
                                <div class="flex">
                                    <div class="p-4">
                                        <label class="leading-tight text-gray-800 dark:text-gray-200 w-full" for="date_start">Start Date:</label>
                                        <input 
                                            class="block text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-rose-800 focus:border-rose-900 dark:bg-neutral-900 dark:border-neutral-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-rose-800 dark:focus:border-rose-900" 
                                            type="date" 
                                            name="date_start" 
                                            id="date_start" 
                                            value="{{ \Carbon\Carbon::parse($image->date_start)->format('Y-m-d') }}" 
                                            required
                                        >
                                    </div>

                                    <div class="p-4">
                                        <label class="leading-tight text-gray-800 dark:text-gray-200 w-full" for="date_end">End Date:</label>
                                        <input 
                                            class="block text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-rose-800 focus:border-rose-900 dark:bg-neutral-900 dark:border-neutral-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-rose-800 dark:focus:border-rose-900" 
                                            type="date" 
                                            name="date_end" 
                                            id="date_end" 
                                            value="{{ \Carbon\Carbon::parse($image->date_end)->format('Y-m-d') }}" 
                                            required
                                        >
                                    </div>

                                    <div class="p-4 pt-11">
                                        <label class="leading-tight text-gray-800 dark:text-gray-200 w-full" for="default">Default:</label>
                                        <input 
                                            type="checkbox"  
                                            name="default" 
                                            id="default"
                                            value="1"
                                            @if ($image->default) checked @endif
                                            class="w-5 h-5 text-rose-600 bg-gray-100 border-gray-300 rounded focus:ring-rose-500 dark:focus:ring-rose-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"
                                        >
                                    </div>

                                    <div class="h-5 pt-10">
                                        <button type="submit" class="ml-1 inline-block rounded bg-sky-800 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white transition duration-150 ease-in-out hover:bg-sky-700 focus:bg-sky-600">
                                            Update
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </td>
                        <td class="px-6 py-4 pt-[69px] flex">
                            <form method="POST" action="{{ route('admin.background.delete') }}">
                                @csrf
                                @method('delete')
                                <input type="hidden" value="{{ $image->id }}" name="id">
                                <button type="submit" class="ml-1 inline-block rounded bg-rose-600 px-6 pb-2 pt-2.5 text-xs font-medium uppercase leading-normal text-white transition duration-150 ease-in-out hover:bg-rose-700 focus:bg-rose-600">
                                    Delete
                                </button>
                            </form>
                        </td>
                    </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
            
        </div>
        {{ $images->links('pagination::tailwind') }}
    </div>
</div>
