<?php
    $auditLogs = $auditLogs ?? null;
?>

<div class="overflow-hidden rounded-2xl border border-slate-200/80 bg-white shadow-sm">
    <div class="flex flex-wrap items-start justify-between gap-4 border-b border-slate-100 bg-gradient-to-r from-slate-50 via-white to-amber-50/30 px-5 py-5">
        <div class="flex items-start gap-3">
            <span class="flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-amber-100 text-amber-700">
                <i class="bi bi-clock-history text-lg"></i>
            </span>
            <div>
                <p class="text-xs font-semibold uppercase tracking-[0.18em] text-primary">History</p>
                <h2 class="mt-0.5 text-lg font-semibold text-slate-900">Audit History</h2>
                <p class="mt-1 text-sm text-slate-500">Payroll run and cycle actions.</p>
            </div>
        </div>
        <form method="GET" class="flex gap-2">
            <input type="hidden" name="tab" value="audit">
            <div class="relative">
                <span class="pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"><i class="bi bi-search"></i></span>
                <input type="search" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search action/actor…"
                       class="w-56 rounded-full border border-slate-200 bg-slate-50/80 py-2 pl-9 pr-3 text-sm focus:border-primary focus:bg-white focus:outline-none focus:ring-0">
            </div>
            <button type="submit" class="inline-flex items-center gap-1.5 rounded-full border border-slate-200 bg-white px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-50">
                Search
            </button>
        </form>
    </div>

    <div class="overflow-x-auto">
        <table class="min-w-full divide-y divide-slate-100">
            <thead class="bg-slate-50/80">
                <tr>
                    <th class="px-5 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-500">Schedule On</th>
                    <th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-500">Request type</th>
                    <th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-500">Outcome</th>
                    <th class="px-5 py-3 text-left text-xs font-semibold uppercase tracking-wide text-slate-500">Actioned By</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-slate-100 bg-white">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = ($auditLogs?->items() ?? []); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <?php
                        $outcomeStr = isset($log->payload['processed'])
                            ? 'Pass: ' . ($log->payload['processed'] ?? 0) . ' Fail: ' . ($log->payload['skipped'] ?? 0)
                            : '—';
                    ?>
                    <tr class="transition hover:bg-teal-50/30">
                        <td class="whitespace-nowrap px-5 py-3.5 text-sm text-slate-600"><?php echo e($log->created_at?->format('M j, Y, g:i a')); ?></td>
                        <td class="whitespace-nowrap px-4 py-3.5 text-sm font-medium text-slate-900"><?php echo e(str_replace('_', ' ', ucfirst($log->action))); ?></td>
                        <td class="whitespace-nowrap px-4 py-3.5 text-sm text-slate-600"><?php echo e($outcomeStr); ?></td>
                        <td class="whitespace-nowrap px-5 py-3.5 text-sm text-slate-600"><?php echo e($log->actor?->name ?? '—'); ?></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="4" class="px-5 py-12 text-center text-sm text-slate-500">No audit entries yet.</td>
                    </tr>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </tbody>
        </table>
    </div>
    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($auditLogs && $auditLogs->hasPages()): ?>
        <div class="border-t border-slate-100 bg-slate-50/60 px-5 py-3"><?php echo e($auditLogs->links()); ?></div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
</div>
<?php /**PATH /var/www/html/kiyohr/v2_version/resources/views/payroll/tabs/audit.blade.php ENDPATH**/ ?>