<?php $__env->startSection('title', isset($job) ? 'Edit Lowongan' : 'Tambah Lowongan'); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-4xl">
    <div class="bg-white rounded-xl border border-gray-100 p-8">
        <form action="<?php echo e(isset($job) ? route('admin.jobs.update', $job) : route('admin.jobs.store')); ?>" method="POST" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
            <?php if(isset($job)): ?> <?php echo method_field('PUT'); ?> <?php endif; ?>

            <div class="space-y-5">
                <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Posisi / Judul *</label>
                        <input type="text" name="title" value="<?php echo e(old('title', $job->title ?? '')); ?>" required
                            class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none">
                        <?php $__errorArgs = ['title'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <p class="text-red-500 text-xs mt-1"><?php echo e($message); ?></p> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Perusahaan *</label>
                        <input type="text" name="company" value="<?php echo e(old('company', $job->company ?? '')); ?>" required
                            class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none">
                    </div>
                </div>

                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Logo Perusahaan</label>
                        <?php if(isset($job) && $job->company_logo): ?>
                        <div class="mb-2 flex items-center space-x-3">
                            <img src="<?php echo e(asset('storage/' . $job->company_logo)); ?>" class="w-16 h-16 object-contain rounded-lg border">
                            <label class="flex items-center space-x-2 text-sm text-red-500">
                                <input type="checkbox" name="remove_logo" value="1"> <span>Hapus logo</span>
                            </label>
                        </div>
                        <?php endif; ?>
                        <input type="file" name="company_logo" accept="image/*"
                            class="w-full border border-gray-200 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-indigo-500 outline-none">
                        <p class="text-xs text-gray-400 mt-1">JPG, PNG, WebP. Maks 2MB</p>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Gambar Lowongan</label>
                        <?php if(isset($job) && $job->image): ?>
                        <div class="mb-2 flex items-center space-x-3">
                            <img src="<?php echo e(asset('storage/' . $job->image)); ?>" class="w-16 h-16 object-cover rounded-lg border">
                            <label class="flex items-center space-x-2 text-sm text-red-500">
                                <input type="checkbox" name="remove_image" value="1"> <span>Hapus gambar</span>
                            </label>
                        </div>
                        <?php endif; ?>
                        <input type="file" name="image" accept="image/*"
                            class="w-full border border-gray-200 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-indigo-500 outline-none">
                        <p class="text-xs text-gray-400 mt-1">JPG, PNG, WebP. Maks 2MB</p>
                    </div>
                </div>

                <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Lokasi *</label>
                        <input type="text" name="location" value="<?php echo e(old('location', $job->location ?? '')); ?>" required
                            class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Tipe *</label>
                        <select name="type" required
                            class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none">
                            <?php $__currentLoopData = ['Full-time', 'Part-time', 'Freelance', 'Internship', 'Contract']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($type); ?>" <?php echo e(old('type', $job->type ?? '') === $type ? 'selected' : ''); ?>><?php echo e($type); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </div>

                <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Gaji Minimum (Rp)</label>
                        <input type="number" name="salary_min" value="<?php echo e(old('salary_min', $job->salary_min ?? '')); ?>"
                            class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none" placeholder="3000000">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Gaji Maksimum (Rp)</label>
                        <input type="number" name="salary_max" value="<?php echo e(old('salary_max', $job->salary_max ?? '')); ?>"
                            class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none" placeholder="8000000">
                    </div>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Deskripsi Pekerjaan *</label>
                    <textarea name="description" rows="5" required
                        class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none"><?php echo e(old('description', $job->description ?? '')); ?></textarea>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Persyaratan *</label>
                    <textarea name="requirements" rows="5" required
                        class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none"><?php echo e(old('requirements', $job->requirements ?? '')); ?></textarea>
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Benefit</label>
                    <textarea name="benefits" rows="3"
                        class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none"><?php echo e(old('benefits', $job->benefits ?? '')); ?></textarea>
                </div>

                <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
                    <div class="flex items-end">
                        <label class="flex items-center space-x-3 py-3">
                            <input type="checkbox" name="is_active" value="1"
                                <?php echo e(old('is_active', $job->is_active ?? true) ? 'checked' : ''); ?>

                                class="w-4 h-4 text-indigo-600 rounded focus:ring-indigo-500">
                            <span class="text-sm font-medium text-gray-700">Aktif (Tampilkan di website)</span>
                        </label>
                    </div>
                </div>
            </div>

            <div class="flex items-center space-x-3 mt-8">
                <button type="submit" class="bg-indigo-600 text-white px-6 py-2.5 rounded-lg font-medium hover:outline hover:outline-2 hover:outline-indigo-800">
                    <?php echo e(isset($job) ? 'Simpan Perubahan' : 'Tambah Lowongan'); ?>

                </button>
                <a href="<?php echo e(route('admin.jobs.index')); ?>" class="text-gray-500 hover:text-gray-700 font-medium">Batal</a>
            </div>
        </form>
    </div>

    
    <?php if(isset($job)): ?>
    <div class="bg-white rounded-xl border border-gray-100 p-8 mt-6">
        <div class="flex items-center justify-between mb-6">
            <div>
                <h3 class="text-lg font-semibold text-gray-800">Tahapan Seleksi</h3>
                <p class="text-sm text-gray-500 mt-1">5 tahapan seleksi tetap — klik Edit untuk mengatur formulir</p>
            </div>
        </div>

        <?php if($job->stages->count() > 0): ?>
        <div class="space-y-3">
            <?php $__currentLoopData = $job->stages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $stage): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="flex flex-col sm:flex-row sm:items-center justify-between p-4 bg-gray-50 rounded-lg border <?php echo e($stage->is_active ? 'border-gray-200' : 'border-red-200 bg-red-50 opacity-60'); ?>">
                <div class="flex items-center space-x-4 mb-3 sm:mb-0">
                    <div class="w-10 h-10 rounded-full bg-indigo-100 text-indigo-700 flex items-center justify-center font-bold text-sm">
                        <?php echo e($stage->stage_number); ?>

                    </div>
                    <div>
                        <h4 class="font-medium text-gray-800"><?php echo e($stage->name); ?></h4>
                        <p class="text-xs text-gray-500">
                            <?php echo e($stage->form_fields ? count($stage->form_fields) . ' field form' : 'Tanpa form (hanya seleksi admin)'); ?>

                            <?php if(!$stage->is_active): ?> <span class="text-red-500 font-medium">— Nonaktif</span> <?php endif; ?>
                        </p>
                    </div>
                </div>
                <div class="flex items-center space-x-2">
                    <a href="<?php echo e(route('admin.jobs.stages.edit', [$job, $stage])); ?>"
                        class="text-indigo-600 hover:text-indigo-800 text-sm font-medium px-3 py-1.5 rounded-lg hover:outline hover:outline-2 hover:outline-indigo-300">
                        Edit
                    </a>
                    <form action="<?php echo e(route('admin.jobs.stages.toggle', [$job, $stage])); ?>" method="POST" class="inline">
                        <?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
                        <button type="submit" class="text-sm font-medium px-3 py-1.5 rounded-lg <?php echo e($stage->is_active ? 'text-yellow-600 hover:outline hover:outline-2 hover:outline-yellow-200' : 'text-green-600 hover:outline hover:outline-2 hover:outline-green-200'); ?>">
                            <?php echo e($stage->is_active ? 'Nonaktifkan' : 'Aktifkan'); ?>

                        </button>
                    </form>
                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
        <?php else: ?>
        <div class="text-center py-8 bg-gray-50 rounded-lg">
            <p class="text-gray-400 mb-2">Belum ada tahapan seleksi</p>
            <p class="text-sm text-gray-500">Tahapan akan otomatis dibuat saat lowongan disimpan.</p>
        </div>
        <?php endif; ?>
    </div>
    <?php endif; ?>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/bursakerja/resources/views/admin/jobs/form.blade.php ENDPATH**/ ?>