<?php
    $today = now()->startOfDay();
?>

<section class="space-y-4">
    <?php if (isset($component)) { $__componentOriginal53747ceb358d30c0105769f8471417f6 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal53747ceb358d30c0105769f8471417f6 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.card','data' => ['class' => '!p-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('card'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['class' => '!p-4']); ?>
        <div class="mb-1">
            <a href="<?php echo e(route('leaves.create')); ?>"
               class="inline-flex w-full items-center justify-center gap-1.5 rounded bg-primary px-4 py-2.5 text-sm font-semibold text-white shadow-sm hover:opacity-95">
                Request Leave
            </a>
        </div>
        <div class="mt-3 space-y-1.5 text-sm">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(auth()->user()->hasPermission('leave_types_create')): ?>
                <a href="<?php echo e(route('leave-types.manage')); ?>" class="block text-primary hover:underline">Leave Policy / Rules</a>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <a href="<?php echo e(route('leaves.index')); ?>" class="block text-primary hover:underline">Leave History</a>
        </div>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal53747ceb358d30c0105769f8471417f6)): ?>
<?php $attributes = $__attributesOriginal53747ceb358d30c0105769f8471417f6; ?>
<?php unset($__attributesOriginal53747ceb358d30c0105769f8471417f6); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal53747ceb358d30c0105769f8471417f6)): ?>
<?php $component = $__componentOriginal53747ceb358d30c0105769f8471417f6; ?>
<?php unset($__componentOriginal53747ceb358d30c0105769f8471417f6); ?>
<?php endif; ?>

    <?php if (isset($component)) { $__componentOriginal53747ceb358d30c0105769f8471417f6 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal53747ceb358d30c0105769f8471417f6 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.card','data' => ['class' => '!p-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('card'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['class' => '!p-4']); ?>
        <div class="mb-3 flex items-center justify-between">
            <h2 class="text-base font-semibold text-slate-900">Pending leave requests</h2>
            <a href="<?php echo e(route('leaves.index', ['status' => 'pending'])); ?>" class="inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline">
                View all <i class="bi bi-chevron-right text-[10px]"></i>
            </a>
        </div>

        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($pendingLeaves->isEmpty()): ?>
            <p class="text-sm text-slate-500">No pending leave requests.</p>
        <?php else: ?>
            <div class="space-y-3">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $pendingLeaves; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $leave): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php
                        $end = $leave->end_date ? $leave->end_date->copy()->startOfDay() : null;
                        $timing = ($end && $end->lt($today)) ? 'PAST LEAVE' : 'UPCOMING LEAVE';
                        $daysLabel = rtrim(rtrim(number_format((float) $leave->total_days, 2, '.', ''), '0'), '.');
                    ?>
                    <div class="rounded border border-slate-200 p-3">
                        <div class="flex gap-3">
                            <div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-sky-50 text-sky-600">
                                <i class="bi bi-airplane"></i>
                            </div>
                            <div class="min-w-0 flex-1 space-y-2">
                                <div class="grid gap-2 sm:grid-cols-2">
                                    <div>
                                        <p class="text-[10px] font-semibold uppercase tracking-wide text-slate-400"><?php echo e($timing); ?></p>
                                        <p class="text-sm font-medium text-slate-900">
                                            <?php echo e($leave->start_date?->format('d M')); ?>

                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($leave->end_date && ! $leave->start_date?->isSameDay($leave->end_date)): ?>
                                                – <?php echo e($leave->end_date->format('d M Y')); ?>

                                            <?php else: ?>
                                                <?php echo e($leave->start_date?->format('Y')); ?>

                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                            <span class="font-normal text-slate-500">(<?php echo e($daysLabel); ?> <?php echo e(abs((float)$leave->total_days) == 1 ? 'day' : 'days'); ?>)</span>
                                        </p>
                                        <p class="text-xs text-slate-500"><?php echo e($leave->user?->name); ?></p>
                                    </div>
                                    <div class="grid grid-cols-2 gap-2 text-xs">
                                        <div>
                                            <p class="text-[10px] font-semibold uppercase tracking-wide text-slate-400">Leave type</p>
                                            <p class="font-medium text-slate-800"><?php echo e($leave->leaveType?->name ?? '—'); ?></p>
                                        </div>
                                        <div>
                                            <p class="text-[10px] font-semibold uppercase tracking-wide text-slate-400">Requested on</p>
                                            <p class="font-medium text-slate-800"><?php echo e($leave->created_at?->format('d M Y') ?? '—'); ?></p>
                                        </div>
                                        <div class="col-span-2">
                                            <p class="text-[10px] font-semibold uppercase tracking-wide text-slate-400">Status</p>
                                            <p class="font-semibold text-amber-700">Pending</p>
                                        </div>
                                    </div>
                                </div>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($leave->reason): ?>
                                    <p class="truncate text-xs text-slate-500">
                                        <span class="font-medium text-slate-600">Leave Note:</span> <?php echo e($leave->reason); ?>

                                    </p>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                <div class="flex items-center gap-1">
                                    <a href="<?php echo e(route('leave.popup')); ?>?leave_id=<?php echo e($leave->id); ?>" class="btn-icon-action btn-icon-action--view" title="View" aria-label="View"><i class="bi bi-eye"></i></a>
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if((int) $leave->user_id === (int) auth()->id() && $leave->status === 'pending'): ?>
                                        <a href="<?php echo e(route('leaves.edit', $leave)); ?>" class="btn-icon-action btn-icon-action--edit" title="Edit" aria-label="Edit"><i class="bi bi-pencil-square"></i></a>
                                        <form method="POST" action="<?php echo e(route('leaves.destroy', $leave)); ?>" class="inline" onsubmit="return confirm('Cancel this leave request?')">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="btn-icon-action btn-icon-action--delete" title="Delete" aria-label="Delete"><i class="bi bi-trash3"></i></button>
                                        </form>
                                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal53747ceb358d30c0105769f8471417f6)): ?>
<?php $attributes = $__attributesOriginal53747ceb358d30c0105769f8471417f6; ?>
<?php unset($__attributesOriginal53747ceb358d30c0105769f8471417f6); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal53747ceb358d30c0105769f8471417f6)): ?>
<?php $component = $__componentOriginal53747ceb358d30c0105769f8471417f6; ?>
<?php unset($__componentOriginal53747ceb358d30c0105769f8471417f6); ?>
<?php endif; ?>

    <?php if (isset($component)) { $__componentOriginal53747ceb358d30c0105769f8471417f6 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal53747ceb358d30c0105769f8471417f6 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.card','data' => ['class' => '!p-4']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('card'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['class' => '!p-4']); ?>
        <div class="mb-3 flex items-center justify-between">
            <h2 class="text-base font-semibold text-slate-900">My recent requests</h2>
            <a href="<?php echo e(route('leaves.index')); ?>" class="text-xs font-medium text-primary hover:underline">History</a>
        </div>
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($recentLeaves->isEmpty()): ?>
            <p class="text-sm text-slate-500">No leave requests yet.</p>
        <?php else: ?>
            <ul class="divide-y divide-slate-100 text-sm">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $recentLeaves; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $leave): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php
                        $statusClass = match ($leave->status) {
                            'approved' => 'text-emerald-700',
                            'rejected' => 'text-red-600',
                            default => 'text-amber-700',
                        };
                    ?>
                    <li class="flex items-start justify-between gap-2 py-2">
                        <div class="min-w-0">
                            <p class="truncate font-medium text-slate-900"><?php echo e($leave->leaveType?->name); ?></p>
                            <p class="text-xs text-slate-500">
                                <?php echo e($leave->start_date?->format('d M Y')); ?>

                                · <?php echo e(rtrim(rtrim(number_format((float) $leave->total_days, 2, '.', ''), '0'), '.')); ?> day(s)
                            </p>
                        </div>
                        <div class="flex shrink-0 items-center gap-1">
                            <a href="<?php echo e(route('leave.popup')); ?>?leave_id=<?php echo e($leave->id); ?>" class="btn-icon-action btn-icon-action--view" title="View" aria-label="View"><i class="bi bi-eye"></i></a>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if((int) $leave->user_id === (int) auth()->id() && $leave->status === 'pending'): ?>
                                <a href="<?php echo e(route('leaves.edit', $leave)); ?>" class="btn-icon-action btn-icon-action--edit" title="Edit" aria-label="Edit"><i class="bi bi-pencil-square"></i></a>
                                <form method="POST" action="<?php echo e(route('leaves.destroy', $leave)); ?>" class="inline" onsubmit="return confirm('Cancel this leave request?')">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn-icon-action btn-icon-action--delete" title="Delete" aria-label="Delete"><i class="bi bi-trash3"></i></button>
                                </form>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            <span class="text-xs font-semibold capitalize <?php echo e($statusClass); ?>"><?php echo e($leave->status); ?></span>
                        </div>
                    </li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </ul>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal53747ceb358d30c0105769f8471417f6)): ?>
<?php $attributes = $__attributesOriginal53747ceb358d30c0105769f8471417f6; ?>
<?php unset($__attributesOriginal53747ceb358d30c0105769f8471417f6); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal53747ceb358d30c0105769f8471417f6)): ?>
<?php $component = $__componentOriginal53747ceb358d30c0105769f8471417f6; ?>
<?php unset($__componentOriginal53747ceb358d30c0105769f8471417f6); ?>
<?php endif; ?>
</section>
<?php /**PATH /var/www/html/kiyohr/v2_version/resources/views/leaves/partials/pending-cards.blade.php ENDPATH**/ ?>