<?php $__env->startSection('title', 'Dashboard'); ?>

<?php $__env->startSection('content'); ?>

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
    <div class="bg-white rounded-xl border border-gray-100 p-6">
        <div>
            <p class="text-sm text-gray-500">Total Lowongan</p>
            <p class="text-3xl font-bold text-gray-800"><?php echo e($totalJobs); ?></p>
        </div>
        <p class="text-xs text-green-600 mt-2"><?php echo e($activeJobs); ?> aktif</p>
    </div>

    <div class="bg-white rounded-xl border border-gray-100 p-6">
        <div>
            <p class="text-sm text-gray-500">Total Pelamar</p>
            <p class="text-3xl font-bold text-gray-800"><?php echo e($totalApplicants); ?></p>
        </div>
    </div>

    <div class="bg-white rounded-xl border border-gray-100 p-6">
        <div>
            <p class="text-sm text-gray-500">Total Lamaran</p>
            <p class="text-3xl font-bold text-gray-800"><?php echo e($totalApplications); ?></p>
        </div>
    </div>

    <div class="bg-white rounded-xl border border-gray-100 p-6">
        <div>
            <p class="text-sm text-gray-500">Notifikasi Terkirim</p>
            <p class="text-3xl font-bold text-gray-800"><?php echo e($notificationStats['sent']); ?></p>
        </div>
        <?php if($notificationStats['failed'] > 0): ?>
        <p class="text-xs text-red-600 mt-2"><?php echo e($notificationStats['failed']); ?> gagal</p>
        <?php endif; ?>
    </div>
</div>


<div class="bg-white rounded-xl border border-gray-100 p-6 mb-8">
    <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4">
        <div>
            <h3 class="text-lg font-semibold text-gray-800">Lowongan Terbaru</h3>
        </div>
        <a href="<?php echo e(route('admin.jobs.index')); ?>" class="text-sm font-medium text-indigo-600 hover:text-indigo-800">Lihat semua lowongan</a>
    </div>

    <?php if($recentJobs->count() > 0): ?>
    <div class="divide-y divide-gray-100">
        <?php $__currentLoopData = $recentJobs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $job): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="py-3 flex flex-col md:flex-row md:items-center md:justify-between gap-3">
            <div>
                <p class="text-sm font-medium text-gray-800"><?php echo e($job->title); ?></p>
                <p class="text-xs text-gray-500"><?php echo e($job->company); ?> • <?php echo e($job->location); ?></p>
            </div>

            <div class="flex items-center flex-wrap gap-3">
                <span class="text-xs px-2 py-1 rounded-full <?php echo e($job->is_active ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-500'); ?>">
                    <?php echo e($job->is_active ? 'Aktif' : 'Nonaktif'); ?>

                </span>

                <a href="<?php echo e(route('admin.jobs.edit', $job)); ?>" class="text-sm font-medium text-indigo-600 hover:text-indigo-800">Edit</a>
            </div>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
    <?php else: ?>
    <p class="text-sm text-gray-400 text-center py-4">Belum ada lowongan.</p>
    <?php endif; ?>
</div>


<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
    <div class="bg-white rounded-xl border border-gray-100 p-6">
        <h3 class="text-lg font-semibold text-gray-800 mb-4">Status Lamaran</h3>
        <div class="space-y-3">
            <?php
                $statusColors = [
                    'applied' => 'blue',
                    'accepted' => 'green',
                    'rejected' => 'red',
                ];
            ?>
            <?php $__empty_1 = true; $__currentLoopData = $statusCounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status => $count): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <?php
                if (isset($statusColors[$status])) {
                    $color = $statusColors[$status];
                } elseif (str_contains($status, '_passed')) {
                    $color = 'yellow';
                } elseif (str_contains($status, '_form_filled')) {
                    $color = 'indigo';
                } else {
                    $color = 'gray';
                }
                $label = match(true) {
                    $status === 'applied' => 'Lamaran Masuk',
                    $status === 'accepted' => 'Diterima',
                    $status === 'rejected' => 'Ditolak',
                    str_contains($status, '_passed') => 'Lolos ' . ucfirst(str_replace(['stage', '_passed'], ['Tahap '], $status)),
                    str_contains($status, '_form_filled') => 'Form Terisi ' . ucfirst(str_replace(['stage', '_form_filled'], ['Tahap '], $status)),
                    default => ucfirst(str_replace('_', ' ', $status)),
                };
            ?>
            <div class="flex items-center justify-between">
                <span class="text-sm text-gray-600"><?php echo e($label); ?></span>
                <div class="flex items-center">
                    <div class="w-32 bg-gray-100 rounded-full h-2 mr-3">
                        <div class="bg-<?php echo e($color); ?>-500 h-2 rounded-full" style="width: <?php echo e($totalApplications > 0 ? ($count / $totalApplications * 100) : 0); ?>%"></div>
                    </div>
                    <span class="text-sm font-medium text-gray-700 w-8 text-right"><?php echo e($count); ?></span>
                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <p class="text-gray-400 text-sm text-center py-2">Belum ada data</p>
            <?php endif; ?>
        </div>
    </div>

    <div class="bg-white rounded-xl border border-gray-100 p-6">
        <h3 class="text-lg font-semibold text-gray-800 mb-4">Lamaran Terbaru</h3>
        <div class="space-y-3">
            <?php $__empty_1 = true; $__currentLoopData = $recentApplications; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $app): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <a href="<?php echo e(route('admin.applications.show', $app)); ?>" class="flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg">
                <div>
                    <p class="text-sm font-medium text-gray-800"><?php echo e($app->applicant->name ?? 'N/A'); ?></p>
                    <p class="text-xs text-gray-500"><?php echo e($app->jobListing->title ?? 'N/A'); ?></p>
                </div>
                <span class="inline-block px-2 py-1 text-xs font-medium rounded-full <?php echo e($app->status_badge_class); ?>">
                    <?php echo e($app->status_label); ?>

                </span>
            </a>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <p class="text-gray-400 text-sm text-center py-4">Belum ada lamaran</p>
            <?php endif; ?>
        </div>
    </div>
</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/dashboard.blade.php ENDPATH**/ ?>