<?php $__env->startSection('title', 'Tableau de bord Admin'); ?>
<?php $__env->startSection('content'); ?>
<h3 class="mb-4">Tableau de bord</h3>

<div class="row g-3 mb-4">
    <div class="col-md-2 col-6">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold"><?php echo e($stats['total_partners']); ?></div>
            <div class="small text-muted">Partenaires</div>
        </div>
    </div>
    <div class="col-md-2 col-6">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold"><?php echo e($stats['total_couriers']); ?></div>
            <div class="small text-muted">Coursiers</div>
        </div>
    </div>
    <div class="col-md-2 col-6">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold text-secondary"><?php echo e($stats['en_attente']); ?></div>
            <div class="small text-muted">En attente</div>
        </div>
    </div>
    <div class="col-md-2 col-6">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold text-success"><?php echo e($stats['collecte']); ?></div>
            <div class="small text-muted">Collectees / livrees</div>
        </div>
    </div>
    <div class="col-md-2 col-6">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold text-warning"><?php echo e($stats['non_disponible']); ?></div>
            <div class="small text-muted">Non disponibles</div>
        </div>
    </div>
    <div class="col-md-2 col-6">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold text-danger"><?php echo e($stats['ecarts']); ?></div>
            <div class="small text-muted">Ecarts detectes</div>
        </div>
    </div>
</div>

<?php if($stats['ecarts'] > 0): ?>
<div class="alert alert-danger">
    <strong>Attention :</strong> <?php echo e($stats['ecarts']); ?> demande(s) presentent un ecart entre la quantite demandee et la quantite reellement collectee.
    <a href="<?php echo e(route('admin.requests.index', ['status' => 'ecart'])); ?>" class="alert-link">Voir les ecarts</a>
</div>
<?php endif; ?>

<div class="card p-3">
    <h5 class="mb-3">Dernieres demandes</h5>
    <div class="table-responsive">
        <table class="table table-sm align-middle">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Partenaire</th>
                    <th>Type</th>
                    <th>Statut</th>
                    <th>Coursier</th>
                    <th>Cree le</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $recentRequests; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td><?php echo e($r->id); ?></td>
                    <td><?php echo e($r->partner->name); ?></td>
                    <td><?php echo e(\App\Models\ServiceRequest::types()[$r->type]); ?></td>
                    <td>
                        <span class="badge <?php echo e($r->status === 'ecart' ? 'badge-ecart' : ($r->urgency === 'urgent' ? 'badge-urgent' : 'bg-secondary')); ?>">
                            <?php echo e(\App\Models\ServiceRequest::statuses()[$r->status]); ?>

                        </span>
                    </td>
                    <td><?php echo e($r->courier->name ?? '-'); ?></td>
                    <td><?php echo e($r->created_at->format('d/m/Y H:i')); ?></td>
                    <td><a href="<?php echo e(route('admin.requests.show', $r)); ?>" class="btn btn-sm btn-outline-primary">Voir</a></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="7" class="text-center text-muted">Aucune demande pour le moment.</td></tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/smartch/capara/resources/views/admin/dashboard.blade.php ENDPATH**/ ?>