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

<?php $__env->startSection('content'); ?>
<div class="max-w-6xl 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 justify-between flex-wrap gap-4">
            <div>
                <h1 class="text-2xl font-bold text-gray-800">Halo, <?php echo e($applicant->name); ?>!</h1>
                <p class="text-gray-500 mt-1">Kelola semua lamaran pekerjaan Anda di sini</p>
            </div>
            <a href="<?php echo e(route('home')); ?>" class="bg-indigo-50 text-indigo-600 px-5 py-2.5 rounded-lg font-medium hover:outline hover:outline-2 hover:outline-indigo-300 text-sm">
                + Lamar Lowongan Baru
            </a>
        </div>
    </div>

    
    <?php
        $profileIncomplete = !$applicant->birth_date || !$applicant->gender || !$applicant->province || !$applicant->city;
    ?>
    <?php if($profileIncomplete): ?>
    <div class="bg-blue-50 border border-blue-200 rounded-xl p-5 mb-6 flex items-start space-x-3">
        <svg class="w-6 h-6 text-blue-500 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
        <div>
            <p class="text-blue-800 font-medium">Lengkapi profil Anda untuk meningkatkan peluang diterima kerja oleh perusahaan pilihan Anda</p>
            <a href="<?php echo e(route('profile.edit')); ?>" class="inline-block mt-2 text-sm text-blue-600 font-semibold hover:underline">Lengkapi Profil Sekarang →</a>
        </div>
    </div>
    <?php endif; ?>

    
    <?php if($generatedPassword ?? null): ?>
    <div class="bg-yellow-50 border border-yellow-200 rounded-xl p-6 mb-6">
        <h3 class="font-semibold text-yellow-800 mb-2">Simpan Password Anda!</h3>
        <p class="text-yellow-700 mb-2">Password Anda yang digenerate otomatis:</p>
        <div class="bg-white border border-yellow-300 rounded-lg px-4 py-3 font-mono text-lg text-center select-all">
            <?php echo e($generatedPassword); ?>

        </div>
        <p class="text-yellow-600 text-sm mt-2">Catat password ini! Anda akan membutuhkannya untuk login kembali.</p>
    </div>
    <?php endif; ?>

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

    
    <div class="bg-white rounded-xl border border-gray-100 p-6 mb-6 animate-fade-in-up" style="animation-delay: 0.1s">
        <div class="flex flex-col sm:flex-row sm:items-center justify-between mb-4 gap-3">
            <h2 class="text-lg font-semibold text-gray-800">Data Diri</h2>
            <div class="flex items-center space-x-3 flex-wrap gap-y-2">
                <a href="<?php echo e(route('profile.edit')); ?>" class="inline-flex items-center text-sm text-indigo-600 hover:text-indigo-800 font-medium">
                    <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="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>
                    Edit Profil
                </a>
                <a href="<?php echo e(route('password.change.form')); ?>" class="inline-flex items-center text-sm text-indigo-600 hover:text-indigo-800 font-medium">
                    <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 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"/></svg>
                    Ubah Password
                </a>
            </div>
        </div>
        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
            <div>
                <span class="text-sm text-gray-500">Nama Lengkap</span>
                <p class="font-medium text-gray-800"><?php echo e($applicant->name); ?></p>
            </div>
            <div>
                <span class="text-sm text-gray-500">Email</span>
                <p class="font-medium text-gray-800"><?php echo e($applicant->email); ?></p>
            </div>
            <div>
                <span class="text-sm text-gray-500">WhatsApp</span>
                <p class="font-medium text-gray-800"><?php echo e($applicant->whatsapp); ?></p>
            </div>
            <div>
                <span class="text-sm text-gray-500">Pendidikan Terakhir</span>
                <p class="font-medium text-gray-800"><?php echo e($applicant->education); ?></p>
            </div>
            <div>
                <span class="text-sm text-gray-500">Tanggal Lahir</span>
                <p class="font-medium text-gray-800"><?php echo e($applicant->birth_date ? $applicant->birth_date->format('d M Y') : '-'); ?></p>
            </div>
            <div>
                <span class="text-sm text-gray-500">Jenis Kelamin</span>
                <p class="font-medium text-gray-800"><?php echo e($applicant->gender ?? '-'); ?></p>
            </div>
            <div>
                <span class="text-sm text-gray-500">Provinsi</span>
                <p class="font-medium text-gray-800"><?php echo e($applicant->province ?? '-'); ?></p>
            </div>
            <div>
                <span class="text-sm text-gray-500">Kota / Kabupaten</span>
                <p class="font-medium text-gray-800"><?php echo e($applicant->city ?? '-'); ?></p>
            </div>
        </div>
    </div>

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

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

    <?php if($applications->count() > 0): ?>
    <div class="space-y-4">
        <?php $__currentLoopData = $applications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $app): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php
            $nextFormStage = $app->getNextFormStage();
        ?>
        <div class="bg-white rounded-xl border border-gray-100 p-6 app-card">
            <div class="flex items-start justify-between flex-wrap gap-4">
                <div class="flex-1">
                    <div class="flex items-center space-x-3 mb-2 flex-wrap gap-2">
                        <?php if($app->jobListing->company_logo): ?>
                        <img src="<?php echo e(asset('storage/' . $app->jobListing->company_logo)); ?>" class="w-8 h-8 object-contain rounded">
                        <?php endif; ?>
                        <h3 class="text-lg font-semibold text-gray-800"><?php echo e($app->jobListing->title); ?></h3>
                        <span class="inline-block px-3 py-1 text-xs font-medium rounded-full
                            <?php echo e($app->status === 'pending' ? 'badge-pulse' : ''); ?>

                            <?php echo e($app->status_badge_class); ?>">
                            <?php echo e($app->status_label); ?>

                        </span>
                    </div>
                    <p class="text-indigo-600 font-medium text-sm"><?php echo e($app->jobListing->company); ?></p>
                    <p class="text-gray-400 text-sm mt-1">Dilamar: <?php echo e($app->applied_at->format('d M Y H:i')); ?></p>

                    <?php if(count($app->document_paths) > 0): ?>
                    <div class="flex flex-wrap gap-2 mt-1">
                        <?php $__currentLoopData = $app->document_paths; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $docPath): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <a href="<?php echo e(asset('storage/' . $docPath)); ?>" target="_blank" class="inline-flex items-center text-blue-500 text-xs hover:underline">
                            <svg class="w-3.5 h-3.5 mr-1" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg>
                            Dokumen <?php echo e($i + 1); ?>

                        </a>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                    <?php endif; ?>
                </div>


            </div>

            
            <div class="mt-4 pt-4 border-t border-gray-50">
                <?php if($app->status === 'accepted'): ?>
                    <div class="bg-green-50 border border-green-200 rounded-lg p-4 text-center">
                        <p class="text-green-700 font-semibold text-lg">Selamat! Anda DITERIMA!</p>
                    </div>
                <?php elseif($app->status === 'rejected'): ?>
                    <div class="bg-red-50 border border-red-200 rounded-lg p-4">
                        <p class="text-red-700 font-medium mb-2">Maaf, Anda belum berhasil lolos pada seleksi ini.</p>
                        <a href="<?php echo e(route('home')); ?>" class="text-indigo-600 font-medium hover:underline text-sm">
                            Lihat Lowongan Lainnya →
                        </a>
                    </div>
                <?php else: ?>
                    <?php if($nextFormStage): ?>
                    <div class="bg-yellow-50 border border-yellow-200 rounded-lg p-4">
                        <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
                            <div>
                                <p class="text-yellow-800 font-medium">Selamat! Anda lolos seleksi tahap sebelumnya</p>
                                <p class="text-yellow-700 text-sm mt-1">Silakan isi formulir <strong><?php echo e($nextFormStage->name); ?></strong> untuk melanjutkan proses seleksi.</p>
                            </div>
                            <a href="<?php echo e(route('form.stage', [$app, $nextFormStage])); ?>"
                               class="inline-flex items-center justify-center bg-indigo-600 text-white px-5 py-2.5 rounded-lg font-medium hover:outline hover:outline-2 hover:outline-indigo-800 text-sm whitespace-nowrap pulse-cta">
                                <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg>
                                Isi Formulir <?php echo e($nextFormStage->name); ?>

                            </a>
                        </div>
                    </div>
                    <?php else: ?>
                    <p class="text-sm text-gray-400">Lamaran Anda sedang diproses...</p>
                    <?php endif; ?>
                <?php endif; ?>
            </div>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
    <?php else: ?>
    <div class="bg-white rounded-xl border border-gray-100 p-12 text-center animate-fade-in">
        <h3 class="text-lg font-semibold text-gray-700 mb-2">Belum ada lamaran</h3>
        <p class="text-gray-500 mb-4">Anda belum melamar pekerjaan apapun</p>
        <a href="<?php echo e(route('home')); ?>" class="inline-block bg-indigo-600 text-white px-6 py-2.5 rounded-lg font-medium hover:outline hover:outline-2 hover:outline-indigo-800">
            Lihat Lowongan
        </a>
    </div>
    <?php endif; ?>

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

    
    <?php if($mobileBanner ?? false): ?>
    <div class="ad-container mt-6 ad-mobile">
        <div class="ad-label">Iklan</div>
        <div class="ad-content"><?php echo $mobileBanner->code; ?></div>
    </div>
    <?php endif; ?>
</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/dashboard.blade.php ENDPATH**/ ?>