<form method="POST" action="<?php echo e($action); ?>" enctype="multipart/form-data" class="space-y-6" data-ai-form="true" data-ai-context="Events CMS">
    <?php echo csrf_field(); ?>
    <?php if($method === 'PUT'): ?>
        <?php echo method_field('PUT'); ?>
    <?php endif; ?>

    <div class="grid grid-cols-1 xl:grid-cols-3 gap-6">
        <div class="xl:col-span-2 space-y-6">
            <div class="bg-white rounded-xl border border-gray-100 p-6">
                <h3 class="text-base font-semibold text-gray-700 mb-4">Event Information</h3>
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Title</label>
                        <input name="title" value="<?php echo e(old('title', $event->title ?? '')); ?>" required class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Slug (optional)</label>
                        <input name="slug" value="<?php echo e(old('slug', $event->slug ?? '')); ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Excerpt</label>
                        <textarea name="excerpt" rows="2" class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm"><?php echo e(old('excerpt', $event->excerpt ?? '')); ?></textarea>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Details / Content</label>
                        <textarea name="content" rows="8" class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm"><?php echo e(old('content', $event->content ?? '')); ?></textarea>
                    </div>
                </div>
            </div>
        </div>

        <div class="space-y-6">
            <div class="bg-white rounded-xl border border-gray-100 p-6">
                <h3 class="text-base font-semibold text-gray-700 mb-4">Publish</h3>
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Start Date & Time</label>
                        <input type="datetime-local" name="starts_at" value="<?php echo e(old('starts_at', isset($event->starts_at) && $event->starts_at ? $event->starts_at->format('Y-m-d\TH:i') : '')); ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Venue</label>
                        <input name="venue" value="<?php echo e(old('venue', $event->venue ?? '')); ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Location</label>
                        <input name="location" value="<?php echo e(old('location', $event->location ?? '')); ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Sort Order</label>
                        <input type="number" min="0" name="sort_order" value="<?php echo e(old('sort_order', $event->sort_order ?? 0)); ?>" class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm">
                    </div>
                    <div class="flex items-center justify-between">
                        <label class="text-sm font-medium text-gray-700">Active</label>
                        <input type="checkbox" name="is_active" value="1" <?php echo e(old('is_active', $event->is_active ?? true) ? 'checked' : ''); ?>>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Cover Image</label>
                        <input type="file" name="cover_image" accept="image/*" class="w-full text-sm" id="event-cover-input">
                        <?php if(isset($event->cover_image) && $event->cover_image): ?>
                            <img src="<?php echo e($event->cover_url); ?>" class="w-full h-32 object-cover rounded mt-2 border border-gray-200" alt="Event cover" id="event-cover-preview">
                        <?php else: ?>
                            <img src="" class="w-full h-32 object-cover rounded mt-2 border border-gray-200 hidden" alt="Event cover preview" id="event-cover-preview">
                        <?php endif; ?>
                    </div>
                </div>
            </div>

            <div class="bg-white rounded-xl border border-gray-100 p-6">
                <h3 class="text-base font-semibold text-gray-700 mb-4">SEO</h3>
                <div class="space-y-3">
                    <input name="seo_title" value="<?php echo e(old('seo_title', $event->seo_title ?? '')); ?>" placeholder="SEO title" class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm">
                    <textarea name="seo_description" rows="3" placeholder="SEO description" class="w-full px-4 py-2.5 border border-gray-300 rounded-lg text-sm"><?php echo e(old('seo_description', $event->seo_description ?? '')); ?></textarea>
                </div>
            </div>
        </div>
    </div>

    <div class="flex gap-3">
        <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white font-semibold text-sm px-6 py-2.5 rounded-lg">
            <?php echo e($method === 'PUT' ? 'Update Event' : 'Create Event'); ?>

        </button>
        <a href="<?php echo e(route('admin.events.index')); ?>" class="bg-gray-100 hover:bg-gray-200 text-gray-700 font-semibold text-sm px-6 py-2.5 rounded-lg">Cancel</a>
    </div>
</form>

<script>
(() => {
    const input = document.getElementById('event-cover-input');
    const preview = document.getElementById('event-cover-preview');
    if (!input || !preview) return;

    input.addEventListener('change', () => {
        const file = input.files && input.files[0];
        if (!file) return;
        preview.src = URL.createObjectURL(file);
        preview.classList.remove('hidden');
    });
})();
</script>
<?php /**PATH /home/gpsmigration/public_html/gpsmigration.com/resources/views/admin/events/_form.blade.php ENDPATH**/ ?>