<x-admin-layout :title="$item->exists ? 'Edit Gallery Image' : 'Create Gallery Image'">
    <x-admin.form-panel :back-route="route('admin.gallery-images.index')">
        <form method="POST" action="{{ $item->exists ? route('admin.gallery-images.update', $item) : route('admin.gallery-images.store') }}" class="space-y-4">
            @csrf
            @if ($item->exists) @method('PUT') @endif

            <div>
                <label class="block text-sm font-medium">Gallery Section</label>
                <select name="gallery_section_id" class="admin-input">
                    <option value="">None</option>
                    @foreach ($sections as $section)
                        <option value="{{ $section->id }}" @selected(old('gallery_section_id', $item->gallery_section_id) == $section->id)>{{ $section->name }}</option>
                    @endforeach
                </select>
            </div>
            <div class="grid grid-cols-2 gap-4">
                <div>
                    <label class="block text-sm font-medium">Image Path</label>
                    <input name="image_path" value="{{ old('image_path', $item->image_path) }}" class="admin-input" required>
                </div>
                <div>
                    <label class="block text-sm font-medium">Caption</label>
                    <input name="caption" value="{{ old('caption', $item->caption) }}" class="admin-input">
                </div>
            </div>
            <div class="grid grid-cols-2 gap-4">
                <div>
                    <label class="block text-sm font-medium">Height Class</label>
                    <input name="height_class" value="{{ old('height_class', $item->height_class ?? 'h-md') }}" class="admin-input" required>
                </div>
                <div>
                    <label class="block text-sm font-medium">Grid Class</label>
                    <input name="grid_class" value="{{ old('grid_class', $item->grid_class) }}" class="admin-input">
                </div>
            </div>
            <div class="grid grid-cols-2 gap-4">
                <div>
                    <label class="block text-sm font-medium">Sort Order</label>
                    <input type="number" name="sort_order" value="{{ old('sort_order', $item->sort_order ?? 0) }}" class="admin-input" required>
                </div>
                <div class="flex items-center gap-2 pt-6">
                    <input type="checkbox" name="is_featured" value="1" @checked(old('is_featured', $item->is_featured ?? false))>
                    <label class="text-sm font-medium">Featured</label>
                </div>
            </div>
            <button type="submit" class="admin-btn-primary">Save</button>
        </form>
    </x-admin.form-panel>
</x-admin-layout>
