<?php $__env->startSection('title', 'Edit Visa Success Story'); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-2xl mx-auto">
    <div class="mb-6 flex items-center gap-3">
        <a href="<?php echo e(route('admin.visa-stories.index')); ?>" class="text-sm text-blue-600 hover:underline">← Back</a>
        <h1 class="text-xl font-bold text-gray-800">Edit Visa Success Story</h1>
    </div>

    <?php if($errors->any()): ?>
        <div class="mb-4 rounded-lg bg-red-100 border border-red-300 text-red-700 px-4 py-3 text-sm">
            <ul class="list-disc list-inside space-y-1"><?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $e): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><li><?php echo e($e); ?></li><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></ul>
        </div>
    <?php endif; ?>

    <form action="<?php echo e(route('admin.visa-stories.update', $visaStory)); ?>" method="POST" enctype="multipart/form-data" class="bg-white rounded-xl border border-gray-200 p-6 space-y-4">
        <?php echo csrf_field(); ?>
        <?php echo method_field('PUT'); ?>
        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
            <div class="md:col-span-2">
                <label class="text-sm font-medium text-gray-700">Story Title <span class="text-red-500">*</span></label>
                <input name="title" value="<?php echo e(old('title', $visaStory->title)); ?>" required class="w-full mt-1 rounded-lg border-gray-300 text-sm">
            </div>
            <div>
                <label class="text-sm font-medium text-gray-700">Student Name</label>
                <input name="student_name" value="<?php echo e(old('student_name', $visaStory->student_name)); ?>" class="w-full mt-1 rounded-lg border-gray-300 text-sm">
            </div>
            <div>
                <label class="text-sm font-medium text-gray-700">Program</label>
                <input name="program" value="<?php echo e(old('program', $visaStory->program)); ?>" class="w-full mt-1 rounded-lg border-gray-300 text-sm">
            </div>
            <div>
                <label class="text-sm font-medium text-gray-700">University</label>
                <input name="university" value="<?php echo e(old('university', $visaStory->university)); ?>" class="w-full mt-1 rounded-lg border-gray-300 text-sm">
            </div>
            <div>
                <label class="text-sm font-medium text-gray-700">Country</label>
                <input name="country_name" value="<?php echo e(old('country_name', $visaStory->country_name)); ?>" class="w-full mt-1 rounded-lg border-gray-300 text-sm">
            </div>
            <div class="md:col-span-2">
                <label class="text-sm font-medium text-gray-700">Description</label>
                <textarea name="description" rows="3" class="w-full mt-1 rounded-lg border-gray-300 text-sm"><?php echo e(old('description', $visaStory->description)); ?></textarea>
            </div>
            <div>
                <label class="text-sm font-medium text-gray-700">Replace Image</label>
                <input type="file" name="image" accept="image/*" class="w-full mt-1 text-sm" id="visa-story-image-input">
                <?php if($visaStory->image_url): ?>
                    <div class="mt-2">
                        <img src="<?php echo e($visaStory->image_url); ?>" alt="Current" class="h-20 rounded-lg object-cover border border-gray-200" id="visa-story-image-preview">
                        <p class="text-xs text-gray-400 mt-1">Current image</p>
                    </div>
                <?php else: ?>
                    <img src="" alt="Selected image preview" class="mt-2 h-20 rounded-lg object-cover border border-gray-200 hidden" id="visa-story-image-preview">
                <?php endif; ?>
            </div>
            <div>
                <label class="text-sm font-medium text-gray-700">Sort Order</label>
                <input type="number" name="sort_order" value="<?php echo e(old('sort_order', $visaStory->sort_order)); ?>" min="0" class="w-full mt-1 rounded-lg border-gray-300 text-sm">
            </div>
            <div class="flex items-center gap-2 mt-2">
                <input type="hidden" name="is_active" value="0">
                <input type="checkbox" name="is_active" id="is_active" value="1" <?php echo e(old('is_active', $visaStory->is_active ? '1' : '0') == '1' ? 'checked' : ''); ?> class="rounded border-gray-300">
                <label for="is_active" class="text-sm font-medium text-gray-700">Active (show on website)</label>
            </div>
        </div>
        <div class="flex gap-3 pt-2">
            <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white font-semibold px-6 py-2.5 rounded-lg text-sm">Update Story</button>
            <a href="<?php echo e(route('admin.visa-stories.index')); ?>" class="px-6 py-2.5 rounded-lg text-sm border border-gray-300 text-gray-600 hover:bg-gray-50">Cancel</a>
        </div>
    </form>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
(() => {
    const input = document.getElementById('visa-story-image-input');
    const preview = document.getElementById('visa-story-image-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 $__env->stopPush(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/gpsmigration/public_html/gpsmigration.com/resources/views/admin/visa-stories/edit.blade.php ENDPATH**/ ?>