<?php $__env->startSection('title', 'Update Profil - ' . ($siteName ?? 'Bursa Kerja')); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-3xl mx-auto px-4 py-8">
    
    <a href="<?php echo e(route('dashboard')); ?>" class="inline-flex items-center text-sm text-gray-500 hover:text-indigo-600 mb-6">
        <svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7"/></svg>
        Kembali ke Dashboard
    </a>

    <div class="bg-white rounded-xl border border-gray-100 p-6 md:p-8 animate-fade-in-up">
        <h1 class="text-2xl font-bold text-gray-800 mb-1">Update Profil</h1>
        <p class="text-gray-500 text-sm mb-6">Lengkapi data diri Anda untuk mempermudah proses lamaran</p>

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

        <form action="<?php echo e(route('profile.update')); ?>" method="POST">
            <?php echo csrf_field(); ?>

            
            <div class="mb-5">
                <label for="name" class="block text-sm font-medium text-gray-700 mb-1">Nama Lengkap <span class="text-red-500">*</span></label>
                <input type="text" name="name" id="name" value="<?php echo e(old('name', $applicant->name)); ?>" required
                    class="w-full border border-gray-300 rounded-lg px-4 py-2.5 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none">
            </div>

            
            <div class="mb-5">
                <label for="email" class="block text-sm font-medium text-gray-700 mb-1">Email</label>
                <input type="email" id="email" value="<?php echo e($applicant->email); ?>" disabled
                    class="w-full border border-gray-200 rounded-lg px-4 py-2.5 bg-gray-50 text-gray-500 cursor-not-allowed">
                <p class="text-xs text-gray-400 mt-1">Email tidak dapat diubah</p>
            </div>

            
            <div class="mb-5">
                <label for="whatsapp" class="block text-sm font-medium text-gray-700 mb-1">No. WhatsApp <span class="text-red-500">*</span></label>
                <input type="text" name="whatsapp" id="whatsapp" value="<?php echo e(old('whatsapp', $applicant->whatsapp)); ?>" required
                    class="w-full border border-gray-300 rounded-lg px-4 py-2.5 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none"
                    placeholder="08xxxxxxxxxx">
            </div>

            
            <div class="mb-5">
                <label for="education" class="block text-sm font-medium text-gray-700 mb-1">Pendidikan Terakhir <span class="text-red-500">*</span></label>
                <select name="education" id="education" required
                    class="w-full border border-gray-300 rounded-lg px-4 py-2.5 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none">
                    <option value="">Pilih Pendidikan</option>
                    <?php $__currentLoopData = ['SD', 'SMP', 'SMA/SMK', 'D1', 'D2', 'D3', 'D4/S1', 'S2', 'S3']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $edu): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($edu); ?>" <?php echo e(old('education', $applicant->education) == $edu ? 'selected' : ''); ?>><?php echo e($edu); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <hr class="my-6 border-gray-100">

            <h2 class="text-lg font-semibold text-gray-800 mb-4">Data Tambahan</h2>

            
            <div class="mb-5">
                <label for="birth_date" class="block text-sm font-medium text-gray-700 mb-1">Tanggal Lahir</label>
                <input type="date" name="birth_date" id="birth_date"
                    value="<?php echo e(old('birth_date', $applicant->birth_date?->format('Y-m-d'))); ?>"
                    max="<?php echo e(now()->subYears(15)->format('Y-m-d')); ?>"
                    class="w-full border border-gray-300 rounded-lg px-4 py-2.5 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none">
            </div>

            
            <div class="mb-5">
                <label class="block text-sm font-medium text-gray-700 mb-2">Jenis Kelamin</label>
                <div class="flex items-center space-x-6">
                    <label class="flex items-center cursor-pointer">
                        <input type="radio" name="gender" value="Laki-laki"
                            <?php echo e(old('gender', $applicant->gender) == 'Laki-laki' ? 'checked' : ''); ?>

                            class="w-4 h-4 text-indigo-600 border-gray-300 focus:ring-indigo-500">
                        <span class="ml-2 text-gray-700">Laki-laki</span>
                    </label>
                    <label class="flex items-center cursor-pointer">
                        <input type="radio" name="gender" value="Perempuan"
                            <?php echo e(old('gender', $applicant->gender) == 'Perempuan' ? 'checked' : ''); ?>

                            class="w-4 h-4 text-indigo-600 border-gray-300 focus:ring-indigo-500">
                        <span class="ml-2 text-gray-700">Perempuan</span>
                    </label>
                </div>
            </div>

            
            <div class="mb-5">
                <label for="province" class="block text-sm font-medium text-gray-700 mb-1">Provinsi</label>
                <select name="province" id="province"
                    class="w-full border border-gray-300 rounded-lg px-4 py-2.5 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none">
                    <option value="">Pilih Provinsi</option>
                    <?php $__currentLoopData = $provinces; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prov): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($prov); ?>" <?php echo e(old('province', $applicant->province) == $prov ? 'selected' : ''); ?>><?php echo e($prov); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            
            <div class="mb-5">
                <label for="city" class="block text-sm font-medium text-gray-700 mb-1">Kota / Kabupaten</label>
                <select name="city" id="city"
                    class="w-full border border-gray-300 rounded-lg px-4 py-2.5 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none">
                    <option value="">Pilih Kota/Kabupaten</option>
                </select>
            </div>

            
            <div class="flex items-center justify-between mt-8">
                <a href="<?php echo e(route('dashboard')); ?>" class="text-gray-500 hover:text-gray-700 text-sm font-medium">Batal</a>
                <button type="submit"
                    class="bg-indigo-600 text-white px-8 py-2.5 rounded-lg font-medium hover:outline hover:outline-2 hover:outline-indigo-800 text-sm pulse-cta">
                    Simpan Perubahan
                </button>
            </div>
        </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('styles'); ?>
<style>
    select { appearance: auto; }
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
document.addEventListener('DOMContentLoaded', function () {
    const provinceSelect = document.getElementById('province');
    const citySelect = document.getElementById('city');
    const savedCity = <?php echo json_encode(old('city', $applicant->city), 512) ?>;

    function loadCities(province, selectedCity) {
        citySelect.innerHTML = '<option value="">Memuat...</option>';
        if (!province) {
            citySelect.innerHTML = '<option value="">Pilih Kota/Kabupaten</option>';
            return;
        }

        fetch('/api/cities/' + encodeURIComponent(province))
            .then(res => res.json())
            .then(cities => {
                citySelect.innerHTML = '<option value="">Pilih Kota/Kabupaten</option>';
                cities.forEach(city => {
                    const opt = document.createElement('option');
                    opt.value = city;
                    opt.textContent = city;
                    if (selectedCity && city === selectedCity) {
                        opt.selected = true;
                    }
                    citySelect.appendChild(opt);
                });
            })
            .catch(() => {
                citySelect.innerHTML = '<option value="">Pilih Kota/Kabupaten</option>';
            });
    }

    // Load cities on province change
    provinceSelect.addEventListener('change', function () {
        loadCities(this.value, null);
    });

    // Load cities on page load if province is already selected
    if (provinceSelect.value) {
        loadCities(provinceSelect.value, savedCity);
    }
});
</script>
<?php $__env->stopPush(); ?>

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