<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Add Service') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6 text-gray-900">
                    <form action="{{ route('services.store') }}" method="POST" enctype="multipart/form-data">
                        @csrf
                        <div class="mb-4">
                            <label class="block text-gray-700 font-bold mb-2">Title <span class="text-red-500">*</span></label>
                            <input type="text" name="title" class="border rounded w-full py-2 px-3 text-gray-700" value="{{ old('title') }}" required>
                            @error('title') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
                        </div>

                        <div class="mb-4">
                            <label class="block text-gray-700 font-bold mb-2">Service ID (Optional, for URL links)</label>
                            <input type="text" name="service_id" class="border rounded w-full py-2 px-3 text-gray-700" value="{{ old('service_id') }}" placeholder="e.g. recycling">
                        </div>

                        <div class="mb-4">
                            <label class="block text-gray-700 font-bold mb-2">Description <span class="text-red-500">*</span></label>
                            <textarea name="description" rows="3" class="border rounded w-full py-2 px-3 text-gray-700" required>{{ old('description') }}</textarea>
                            @error('description') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
                        </div>

                        <div class="mb-4">
                            <label class="block text-gray-700 font-bold mb-2">Image <span class="text-red-500">*</span></label>
                            <input type="file" name="image" class="border rounded w-full py-2 px-3 text-gray-700" required accept="image/*">
                            @error('image') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
                        </div>

                        <div class="mb-4">
                            <label class="block text-gray-700 font-bold mb-2">Link (Optional)</label>
                            <input type="text" name="link" class="border rounded w-full py-2 px-3 text-gray-700" value="{{ old('link') }}">
                        </div>

                        <div class="mb-4">
                            <label class="block text-gray-700 font-bold mb-2">Bento Class (Optional Tailwind classes)</label>
                            <input type="text" name="bento_class" class="border rounded w-full py-2 px-3 text-gray-700" value="{{ old('bento_class') }}" placeholder="e.g. lg:col-span-2">
                        </div>

                        <div class="mb-4 flex items-center gap-6">
                            <label class="flex items-center">
                                <input type="checkbox" name="is_cover" class="form-checkbox" value="1" {{ old('is_cover') ? 'checked' : '' }}>
                                <span class="ml-2 text-gray-700 font-bold">Is Cover Image? (Full height image)</span>
                            </label>

                            <label class="flex items-center">
                                <input type="checkbox" name="is_active" class="form-checkbox" value="1" checked>
                                <span class="ml-2 text-gray-700 font-bold">Active</span>
                            </label>
                        </div>

                        <div class="flex items-center gap-4">
                            <button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700">Save</button>
                            <a href="{{ route('services.index') }}" class="text-gray-600 hover:underline">Cancel</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</x-app-layout>
