<?php $__env->startSection('title', $title); ?>
<?php $__env->startSection('ad_page_title', 'Candidates'); ?>
<?php $__env->startSection('ad_page_subtitle', 'Manage candidate profiles'); ?>

<?php $__env->startSection('ad_content'); ?>
<div class="container-fluid py-4">
    <div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center gap-3 mb-4">
        <div>
            <h1 class="h3 mb-1">Candidates</h1>
            <p class="text-muted mb-0">Manage candidate profiles</p>
        </div>

        <a href="<?php echo e(route('admin.candidates.create')); ?>" class="btn btn-primary">
            <i class="fa-solid fa-plus me-2"></i>Create Candidate
        </a>
    </div>

    <?php if(session('success')): ?>
        <div class="alert alert-success shadow-sm border-0">
            <?php echo e(session('success')); ?>

        </div>
    <?php endif; ?>

    <div class="card shadow-sm border-0">
        <div class="card-body p-4">
            <form action="<?php echo e(route('admin.candidates.index')); ?>" method="GET" class="row g-3 mb-4">
                <div class="col-lg-10">
                    <input
                        type="text"
                        name="search"
                        value="<?php echo e(request('search')); ?>"
                        class="form-control"
                        placeholder="Search by code, name or country"
                    >
                </div>
                <div class="col-lg-2 d-grid">
                    <button type="submit" class="btn btn-outline-primary">
                        <i class="fa-solid fa-magnifying-glass me-2"></i>Search
                    </button>
                </div>
            </form>

            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead>
                        <tr>
                            <th style="width: 110px;">Image</th>
                            <th>Candidate</th>
                            <th>Country</th>
                            <th>Source</th>
                            <th>Sponsorship</th>
                            <th>Age</th>
                            <th>Status</th>
                            <th class="text-end" style="width: 220px;">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $candidates; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $candidate): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td>
                                    <?php if($candidate->image): ?>
                                        <img
                                            src="<?php echo e($candidate->image ? (str_starts_with($candidate->image, 'http') ? $candidate->image : asset('storage/' . $candidate->image)) : ''); ?>"
                                            alt="<?php echo e($candidate->name); ?>"
                                            width="90"
                                            height="60"
                                            class="rounded border"
                                            style="object-fit: cover;"
                                        >
                                    <?php else: ?>
                                        <div class="d-flex align-items-center justify-content-center rounded border bg-light text-muted" style="width: 90px; height: 60px;">
                                            <i class="fa-regular fa-image"></i>
                                        </div>
                                    <?php endif; ?>
                                </td>

                                <td>
                                    <div class="fw-semibold"><?php echo e($candidate->name); ?></div>
                                    <div class="small text-muted mt-1"><code><?php echo e($candidate->code); ?></code></div>
                                </td>

                                <td><?php echo e($candidate->country); ?></td>
                                <td><span class="badge text-bg-light border"><?php echo e($candidate->source); ?></span></td>
                                <td><span class="badge text-bg-light border"><?php echo e($candidate->sponsorship); ?></span></td>
                                <td>
                                    <?php if($candidate->age): ?>
                                        <?php echo e($candidate->age); ?> <span class="text-muted">(<?php echo e($candidate->age_band); ?>)</span>
                                    <?php else: ?>
                                        <span class="text-muted">-</span>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <?php if($candidate->is_active): ?>
                                        <span class="badge text-bg-success">Active</span>
                                    <?php else: ?>
                                        <span class="badge text-bg-secondary">Inactive</span>
                                    <?php endif; ?>
                                </td>

                                <td class="text-end">
                                    <div class="d-inline-flex gap-2 flex-wrap justify-content-end">
                                        <a href="<?php echo e(route('admin.candidates.edit', $candidate)); ?>" class="btn btn-sm btn-warning">
                                            <i class="fa-solid fa-pen-to-square me-1"></i>Edit
                                        </a>

                                        <form action="<?php echo e(route('admin.candidates.destroy', $candidate)); ?>" method="POST" onsubmit="return confirm('Delete this candidate?')">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="btn btn-sm btn-danger">
                                                <i class="fa-solid fa-trash me-1"></i>Delete
                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="8" class="text-center py-5 text-muted">
                                    No candidates found.
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>

            <?php if($candidates->hasPages()): ?>
                <div class="mt-4">
                    <?php echo e($candidates->links()); ?>

                </div>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('admin.ad_master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/onesourceerp/public_html/project/resources/views/admin/candidates/index.blade.php ENDPATH**/ ?>