<?php $__env->startSection('title', $stage->name . ' - ' . $application->jobListing->title); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-3xl mx-auto px-4 py-8">
    
    <div class="bg-white rounded-xl border border-gray-100 p-6 mb-6 animate-fade-in-up">
        <div class="flex items-center space-x-4 mb-4">
            <?php if($application->jobListing->company_logo): ?>
            <img src="<?php echo e(asset('storage/' . $application->jobListing->company_logo)); ?>" class="w-12 h-12 object-contain rounded-lg border">
            <?php endif; ?>
            <div>
                <h1 class="text-xl font-bold text-gray-800"><?php echo e($stage->name); ?></h1>
                <p class="text-sm text-gray-500"><?php echo e($application->jobListing->title); ?> — <?php echo e($application->jobListing->company); ?></p>
            </div>
        </div>
        <?php if($stage->description): ?>
        <div class="bg-indigo-50 border border-indigo-100 rounded-lg p-4 text-sm text-indigo-700">
            <?php echo e($stage->description); ?>

        </div>
        <?php endif; ?>

        
        <?php
            $totalStages = $application->jobListing->stages()->count();
            $progress = $application->progress;
        ?>
        <div class="mt-4">
            <div class="flex items-center justify-between text-xs text-gray-500 mb-1">
                <span>Tahap <?php echo e($stage->stage_number); ?> dari <?php echo e($totalStages); ?></span>
                <span><?php echo e($progress['percentage']); ?>%</span>
            </div>
            <div class="w-full bg-gray-100 rounded-full h-2">
                <div class="bg-indigo-600 h-2 rounded-full progress-animate" style="width: <?php echo e($progress['percentage']); ?>%"></div>
            </div>
        </div>
    </div>

    
    <?php if($countdownAd ?? false): ?>
    <div class="ad-container mb-6">
        <div class="ad-label">IKLAN</div>
        <div class="ad-content">
            <?php echo $countdownAd->code; ?>

        </div>
    </div>
    <?php endif; ?>

    
    <?php if($mobileBanner ?? false): ?>
    <div class="ad-container mb-6 ad-mobile">
        <div class="ad-label">Iklan</div>
        <div class="ad-content"><?php echo $mobileBanner->code; ?></div>
    </div>
    <?php endif; ?>

    
    <?php
        $enableSmartlink = in_array((int) $stage->stage_number, [3, 4, 5], true);
    ?>
    <div class="bg-white rounded-xl border border-gray-100 p-6 animate-fade-in-up" style="animation-delay: 0.1s">
        <form action="<?php echo e(route('form.stage.submit', [$application, $stage])); ?>" method="POST" enctype="multipart/form-data" <?php if($enableSmartlink): ?> data-smartlink-form <?php endif; ?>>
            <?php echo csrf_field(); ?>

            <div class="space-y-5">
                <?php if($stage->form_fields && count($stage->form_fields) > 0): ?>
                    <?php $__currentLoopData = $stage->form_fields; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $field): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php
                        $fieldName = 'field_' . ($field['name'] ?? '');
                        $fieldLabel = $field['label'] ?? $field['name'] ?? '';
                        $fieldType = $field['type'] ?? 'text';
                        $isRequired = !empty($field['required']);
                        $options = $field['options'] ?? [];
                        if (is_string($options)) $options = array_map('trim', explode(',', $options));
                    ?>

                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">
                            <?php echo e($fieldLabel); ?> <?php if($isRequired): ?> <span class="text-red-500">*</span> <?php endif; ?>
                        </label>

                        <?php if($fieldType === 'textarea'): ?>
                            <textarea name="<?php echo e($fieldName); ?>" rows="4" <?php echo e($isRequired ? 'required' : ''); ?>

                                class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none"
                                placeholder="Isi <?php echo e(strtolower($fieldLabel)); ?>..."><?php echo e(old($fieldName)); ?></textarea>

                        <?php elseif($fieldType === 'select'): ?>
                            <select name="<?php echo e($fieldName); ?>" <?php echo e($isRequired ? 'required' : ''); ?>

                                class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none">
                                <option value="">Pilih...</option>
                                <?php $__currentLoopData = $options; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $opt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($opt); ?>" <?php echo e(old($fieldName) === $opt ? 'selected' : ''); ?>><?php echo e($opt); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>

                        <?php elseif($fieldType === 'radio'): ?>
                            <div class="space-y-2 mt-1">
                                <?php $__currentLoopData = $options; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $opt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <label class="flex items-center space-x-3">
                                    <input type="radio" name="<?php echo e($fieldName); ?>" value="<?php echo e($opt); ?>"
                                        <?php echo e(old($fieldName) === $opt ? 'checked' : ''); ?>

                                        class="w-4 h-4 text-indigo-600 focus:ring-indigo-500">
                                    <span class="text-sm text-gray-700"><?php echo e($opt); ?></span>
                                </label>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>

                        <?php elseif($fieldType === 'checkbox'): ?>
                            <div class="space-y-2 mt-1">
                                <?php $__currentLoopData = $options; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $opt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <label class="flex items-center space-x-3">
                                    <input type="checkbox" name="<?php echo e($fieldName); ?>[]" value="<?php echo e($opt); ?>"
                                        class="w-4 h-4 text-indigo-600 rounded focus:ring-indigo-500">
                                    <span class="text-sm text-gray-700"><?php echo e($opt); ?></span>
                                </label>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>

                        <?php elseif($fieldType === 'number'): ?>
                            <input type="number" name="<?php echo e($fieldName); ?>" value="<?php echo e(old($fieldName)); ?>" <?php echo e($isRequired ? 'required' : ''); ?>

                                class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none">

                        <?php elseif($fieldType === 'email'): ?>
                            <input type="email" name="<?php echo e($fieldName); ?>" value="<?php echo e(old($fieldName)); ?>" <?php echo e($isRequired ? 'required' : ''); ?>

                                class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none">

                        <?php elseif($fieldType === 'tel'): ?>
                            <input type="tel" name="<?php echo e($fieldName); ?>" value="<?php echo e(old($fieldName)); ?>" <?php echo e($isRequired ? 'required' : ''); ?>

                                class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none">

                        <?php elseif($fieldType === 'date'): ?>
                            <input type="date" name="<?php echo e($fieldName); ?>" value="<?php echo e(old($fieldName)); ?>" <?php echo e($isRequired ? 'required' : ''); ?>

                                class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none">

                        <?php elseif($fieldType === 'file'): ?>
                            <input type="file" name="<?php echo e($fieldName); ?>" <?php echo e($isRequired ? 'required' : ''); ?>

                                class="w-full border border-gray-200 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-indigo-500 outline-none">

                        <?php else: ?>
                            <input type="text" name="<?php echo e($fieldName); ?>" value="<?php echo e(old($fieldName)); ?>" <?php echo e($isRequired ? 'required' : ''); ?>

                                class="w-full border border-gray-200 rounded-lg px-4 py-3 focus:ring-2 focus:ring-indigo-500 outline-none"
                                placeholder="Isi <?php echo e(strtolower($fieldLabel)); ?>...">
                        <?php endif; ?>

                        <?php $__errorArgs = [$fieldName];
$__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>

                    
                    <?php if($loop->iteration % 2 === 0 && !$loop->last && ($formBanner ?? false)): ?>
                    <div class="ad-container">
                        <div class="ad-label">Iklan</div>
                        <div class="ad-content"><?php echo $formBanner->code; ?></div>
                    </div>
                    <?php endif; ?>

                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php else: ?>
                    <div class="text-center py-6 bg-gray-50 rounded-lg">
                        <p class="text-gray-500">Tahap ini tidak memiliki formulir tambahan.</p>
                        <p class="text-sm text-gray-400 mt-1">Klik tombol di bawah untuk melanjutkan.</p>
                    </div>
                <?php endif; ?>


            </div>

            
            <?php if($nativeAd ?? false): ?>
            <div class="ad-container mt-6">
                <div class="ad-label">Iklan</div>
                <div class="ad-content"><?php echo $nativeAd->code; ?></div>
            </div>
            <?php endif; ?>

            <div class="flex items-center space-x-3 mt-8">
                <button type="submit" <?php if($enableSmartlink): ?> data-smartlink <?php endif; ?> class="bg-indigo-600 text-white px-8 py-3 rounded-lg font-medium hover:outline hover:outline-2 hover:outline-indigo-800">
                    Kirim Formulir
                </button>
                <a href="<?php echo e(route('dashboard')); ?>" class="text-gray-500 hover:text-gray-700 font-medium">Kembali ke Dashboard</a>
            </div>
        </form>
    </div>
</div>
<?php $__env->stopSection(); ?>

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