<form action="<?php echo e($service ? route('admin.services.update', $service) : route('admin.services.store')); ?>" method="POST" enctype="multipart/form-data">
    <?php echo csrf_field(); ?>
    <?php if($service): ?> <?php echo method_field('PUT'); ?> <?php endif; ?>

    <div class="row g-3">
        <div class="col-md-6">
            <label class="form-label">Title <span class="text-danger">*</span></label>
            <input type="text" name="title" class="form-control" value="<?php echo e(old('title', $service->title ?? '')); ?>" required>
        </div>
        <div class="col-md-6">
            <label class="form-label">Slug</label>
            <input type="text" name="slug" class="form-control" value="<?php echo e(old('slug', $service->slug ?? '')); ?>" placeholder="Leave blank to auto-generate">
        </div>
        <div class="col-md-4">
            <label class="form-label">Bootstrap Icon</label>
            <input type="text" name="icon" class="form-control" value="<?php echo e(old('icon', $service->icon ?? '')); ?>" placeholder="e.g. bi-building">
        </div>
        <div class="col-md-4">
            <label class="form-label">Image</label>
            <input type="file" name="image" class="form-control">
            <?php if($service && $service->image): ?>
                <img src="<?php echo e(\App\Services\FileUploadService::url($service->image)); ?>" class="img-fluid mt-2" style="max-height:100px">
            <?php endif; ?>
        </div>
        <div class="col-md-2">
            <label class="form-label">Sort Order</label>
            <input type="number" name="sort_order" class="form-control" value="<?php echo e(old('sort_order', $service->sort_order ?? 0)); ?>" min="0">
        </div>
        <div class="col-md-2 d-flex align-items-end">
            <div class="form-check mb-2">
                <input type="checkbox" class="form-check-input" id="status" name="status" value="1" <?php echo e(old('status', $service->status ?? true) ? 'checked' : ''); ?>>
                <label class="form-check-label" for="status">Active</label>
            </div>
        </div>

        <div class="col-12">
            <label class="form-label">Short Description</label>
            <textarea name="short_description" class="form-control" rows="2"><?php echo e(old('short_description', $service->short_description ?? '')); ?></textarea>
        </div>
        <div class="col-12">
            <label class="form-label">Full Description</label>
            <textarea name="description" class="form-control" rows="5"><?php echo e(old('description', $service->description ?? '')); ?></textarea>
        </div>
    </div>

    <hr>
    <h6 class="fw-bold mb-3">Service Features <small class="text-muted">(add/remove feature points)</small></h6>
    <div id="features-wrap">
        <?php
            $existingFeatures = $service ? $service->features->pluck('title')->toArray() : [];
            $existingFeatures[] = '';
        ?>
        <?php $__currentLoopData = $existingFeatures; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $feature): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="input-group mb-2 feature-row">
                <input type="text" name="features[]" class="form-control" value="<?php echo e(old('features.'.($loop->index), $feature)); ?>" placeholder="Feature e.g. Earthworks">
                <button type="button" class="btn btn-outline-danger remove-feature"><i class="bi bi-x-lg"></i></button>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
    <button type="button" id="add-feature" class="btn btn-outline-primary btn-sm"><i class="bi bi-plus-lg"></i> Add Feature</button>

    <hr>
    <h6 class="fw-bold mb-3">SEO</h6>
    <div class="row g-3">
        <div class="col-12">
            <label class="form-label">Meta Title</label>
            <input type="text" name="meta_title" class="form-control" value="<?php echo e(old('meta_title', $service->meta_title ?? '')); ?>">
        </div>
        <div class="col-12">
            <label class="form-label">Meta Description</label>
            <textarea name="meta_description" class="form-control" rows="2"><?php echo e(old('meta_description', $service->meta_description ?? '')); ?></textarea>
        </div>
    </div>

    <div class="mt-4">
        <button type="submit" class="btn btn-primary"><?php echo e($service ? 'Update' : 'Create'); ?> Service</button>
        <a href="<?php echo e(route('admin.services.index')); ?>" class="btn btn-outline-secondary">Cancel</a>
    </div>
</form>

<?php $__env->startPush('scripts'); ?>
<script>
$(function () {
    $('#add-feature').on('click', function () {
        $('#features-wrap').append(
            '<div class="input-group mb-2 feature-row">' +
            '<input type="text" name="features[]" class="form-control" placeholder="Feature e.g. Earthworks">' +
            '<button type="button" class="btn btn-outline-danger remove-feature"><i class="bi bi-x-lg"></i></button>' +
            '</div>'
        );
    });
    $(document).on('click', '.remove-feature', function () {
        $(this).closest('.feature-row').remove();
    });
});
</script>
<?php $__env->stopPush(); ?>
<?php /**PATH C:\xampp\htdocs\skyline\resources\views/admin/services/_form.blade.php ENDPATH**/ ?>