<?php $__env->startSection('title', 'Tableau de bord BO · LineUp France'); ?>

<?php $__env->startSection('css'); ?>
    <link
        rel="stylesheet"
        href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
        integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
        crossorigin=""
    >
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="bg-body-light bo-page-top">
        <div class="content content-full bo-page-top-content">
            <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center py-2 bo-page-head">
                <div class="flex-grow-1">
                    <h1 class="h3 fw-bold mb-1 bo-page-title">Tableau de bord BO</h1>
                    <h2 class="fs-base lh-base fw-medium text-muted mb-0 bo-page-subtitle">
                        Vue operationnelle missions, moderation et paiements.
                    </h2>
                </div>
                <nav class="flex-shrink-0 mt-3 mt-sm-0 ms-sm-3" aria-label="breadcrumb">
                    <ol class="breadcrumb breadcrumb-alt bo-breadcrumb">
                        <li class="breadcrumb-item">LineUp France</li>
                        <li class="breadcrumb-item" aria-current="page">Tableau de bord</li>
                    </ol>
                </nav>
            </div>
            <div class="bo-hero-actions">
                <a href="<?php echo e(route('bo.users.index')); ?>" class="btn btn-sm btn-alt-secondary">
                    <i class="si si-users me-1"></i> Utilisateurs
                </a>
                <a href="<?php echo e(route('bo.missions.index')); ?>" class="btn btn-sm btn-alt-secondary">
                    <i class="si si-briefcase me-1"></i> Missions
                </a>
                <a href="<?php echo e(route('bo.kyc.index')); ?>" class="btn btn-sm btn-alt-secondary">
                    <i class="si si-shield me-1"></i> KYC
                </a>
                <a href="<?php echo e(route('bo.payouts.index')); ?>" class="btn btn-sm btn-alt-secondary">
                    <i class="si si-wallet me-1"></i> Retraits
                </a>
                <a href="<?php echo e(route('bo.finance')); ?>" class="btn btn-sm btn-alt-primary">
                    <i class="si si-credit-card me-1"></i> Finance
                </a>
            </div>
        </div>
    </div>

    <div class="content bo-page-content">
        <div class="row items-push bo-kpi-grid">
            <div class="col-sm-6 col-xxl-3">
                <div class="block block-rounded d-flex flex-column h-100 mb-0">
                    <div class="block-content block-content-full d-flex justify-content-between align-items-center">
                        <dl class="mb-0">
                            <dt class="fs-sm fw-medium text-muted mb-1">Utilisateurs</dt>
                            <dd class="fs-3 fw-semibold mb-0"><?php echo e($metrics['users']['total']); ?></dd>
                        </dl>
                        <div class="item item-rounded-lg bg-body-light">
                            <i class="si si-users fs-3 text-primary"></i>
                        </div>
                    </div>
                    <div class="block-content py-2 bg-body-light fs-sm">
                        Clients: <?php echo e($metrics['users']['clients']); ?> · Liners: <?php echo e($metrics['users']['liners']); ?> · Admins: <?php echo e($metrics['users']['admins']); ?>

                        <br>
                        Liners dispo: <?php echo e($metrics['users']['liners_available']); ?> ·
                        indispo: <?php echo e($metrics['users']['liners_unavailable']); ?> ·
                        actifs live: <?php echo e($metrics['users']['liners_active']); ?>

                    </div>
                </div>
            </div>
            <div class="col-sm-6 col-xxl-3">
                <div class="block block-rounded d-flex flex-column h-100 mb-0">
                    <div class="block-content block-content-full d-flex justify-content-between align-items-center">
                        <dl class="mb-0">
                            <dt class="fs-sm fw-medium text-muted mb-1">Missions</dt>
                            <dd class="fs-3 fw-semibold mb-0"><?php echo e($metrics['missions']['total']); ?></dd>
                        </dl>
                        <div class="item item-rounded-lg bg-body-light">
                            <i class="si si-briefcase fs-3 text-success"></i>
                        </div>
                    </div>
                    <div class="block-content py-2 bg-body-light fs-sm">
                        Publiees: <?php echo e($metrics['missions']['published']); ?> · En cours: <?php echo e($metrics['missions']['in_progress']); ?> · Terminees: <?php echo e($metrics['missions']['completed']); ?>

                    </div>
                </div>
            </div>
            <div class="col-sm-6 col-xxl-3">
                <div class="block block-rounded d-flex flex-column h-100 mb-0">
                    <div class="block-content block-content-full d-flex justify-content-between align-items-center">
                        <dl class="mb-0">
                            <dt class="fs-sm fw-medium text-muted mb-1">Paiements encaisses</dt>
                            <dd class="fs-3 fw-semibold mb-0"><?php echo e(number_format($metrics['finance']['payments_total'], 2, ',', ' ')); ?> €</dd>
                        </dl>
                        <div class="item item-rounded-lg bg-body-light">
                            <i class="si si-credit-card fs-3 text-info"></i>
                        </div>
                    </div>
                    <div class="block-content py-2 bg-body-light fs-sm">
                        En attente: <?php echo e(number_format($metrics['finance']['payments_pending'], 2, ',', ' ')); ?> €
                    </div>
                </div>
            </div>
            <div class="col-sm-6 col-xxl-3">
                <div class="block block-rounded d-flex flex-column h-100 mb-0">
                    <div class="block-content block-content-full d-flex justify-content-between align-items-center">
                        <dl class="mb-0">
                            <dt class="fs-sm fw-medium text-muted mb-1">Retraits liners</dt>
                            <dd class="fs-3 fw-semibold mb-0"><?php echo e(number_format($metrics['finance']['payouts_total'], 2, ',', ' ')); ?> €</dd>
                        </dl>
                        <div class="item item-rounded-lg bg-body-light">
                            <i class="si si-wallet fs-3 text-warning"></i>
                        </div>
                    </div>
                    <div class="block-content py-2 bg-body-light fs-sm">
                        En attente: <?php echo e(number_format($metrics['finance']['payouts_pending'], 2, ',', ' ')); ?> €
                    </div>
                </div>
            </div>
            <div class="col-sm-6 col-xxl-3">
                <div class="block block-rounded d-flex flex-column h-100 mb-0">
                    <div class="block-content block-content-full d-flex justify-content-between align-items-center">
                        <dl class="mb-0">
                            <dt class="fs-sm fw-medium text-muted mb-1">KYC en attente</dt>
                            <dd class="fs-3 fw-semibold mb-0"><?php echo e($metrics['kyc']['pending']); ?></dd>
                        </dl>
                        <div class="item item-rounded-lg bg-body-light">
                            <i class="si si-shield fs-3 text-danger"></i>
                        </div>
                    </div>
                    <div class="block-content py-2 bg-body-light fs-sm">
                        Approuves: <?php echo e($metrics['kyc']['approved']); ?> · Rejetes: <?php echo e($metrics['kyc']['rejected']); ?>

                    </div>
                </div>
            </div>
            <div class="col-sm-6 col-xxl-3">
                <div class="block block-rounded d-flex flex-column h-100 mb-0">
                    <div class="block-content block-content-full d-flex justify-content-between align-items-center">
                        <dl class="mb-0">
                            <dt class="fs-sm fw-medium text-muted mb-1">Moderation</dt>
                            <dd class="fs-3 fw-semibold mb-0"><?php echo e($metrics['moderation']['proofs_pending']); ?></dd>
                        </dl>
                        <div class="item item-rounded-lg bg-body-light">
                            <i class="si si-check fs-3 text-primary"></i>
                        </div>
                    </div>
                    <div class="block-content py-2 bg-body-light fs-sm">
                        Litiges ouverts: <?php echo e($metrics['moderation']['disputes_open']); ?>

                    </div>
                </div>
            </div>
            <div class="col-sm-6 col-xxl-3">
                <div class="block block-rounded d-flex flex-column h-100 mb-0">
                    <div class="block-content block-content-full d-flex justify-content-between align-items-center">
                        <dl class="mb-0">
                            <dt class="fs-sm fw-medium text-muted mb-1">Notifications</dt>
                            <dd class="fs-3 fw-semibold mb-0"><?php echo e($metrics['notifications']['total']); ?></dd>
                        </dl>
                        <div class="item item-rounded-lg bg-body-light">
                            <i class="si si-bell fs-3 text-success"></i>
                        </div>
                    </div>
                    <div class="block-content py-2 bg-body-light fs-sm">
                        Non lues: <?php echo e($metrics['notifications']['unread']); ?>

                    </div>
                </div>
            </div>
            <div class="col-sm-6 col-xxl-3">
                <div class="block block-rounded d-flex flex-column h-100 mb-0">
                    <div class="block-content block-content-full d-flex justify-content-between align-items-center">
                        <dl class="mb-0">
                            <dt class="fs-sm fw-medium text-muted mb-1">Appareils push</dt>
                            <dd class="fs-3 fw-semibold mb-0"><?php echo e($metrics['push']['devices_active']); ?></dd>
                        </dl>
                        <div class="item item-rounded-lg bg-body-light">
                            <i class="si si-screen-smartphone fs-3 text-info"></i>
                        </div>
                    </div>
                    <div class="block-content py-2 bg-body-light fs-sm">
                        Total: <?php echo e($metrics['push']['devices_total']); ?>

                    </div>
                </div>
            </div>
        </div>

        <div class="row items-push">
            <div class="col-12">
                <div class="block block-rounded mb-0">
                    <div class="block-header block-header-default">
                        <h3 class="block-title"><i class="si si-map me-1"></i>Carte live des liners actifs</h3>
                    </div>
                    <div class="block-content">
                        <?php if(empty($metrics['active_liners'])): ?>
                            <div class="alert alert-info mb-0">
                                Aucun liner actif geolocalise pour le moment.
                            </div>
                        <?php else: ?>
                            <div id="bo-active-liners-map" class="bo-dashboard-map"></div>
                            <div class="table-responsive mt-3">
                                <table class="table table-vcenter table-hover fs-sm mb-0 bo-table">
                                    <thead>
                                    <tr>
                                        <th>Liner</th>
                                        <th>Mission</th>
                                        <th>Statut mission</th>
                                        <th>Maj position</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php $__currentLoopData = $metrics['active_liners']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $activeLiner): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td><?php echo e($activeLiner['liner']['name'] ?? '-'); ?></td>
                                            <td>
                                                <?php if(!empty($activeLiner['mission_id'])): ?>
                                                    #<?php echo e($activeLiner['mission_id']); ?> · <?php echo e($activeLiner['mission_title'] ?? '-'); ?>

                                                <?php else: ?>
                                                    <?php echo e($activeLiner['mission_title'] ?? 'Disponible (sans mission)'); ?>

                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <?php
                                                    $status = $activeLiner['mission_status'] ?? '-';
                                                    $statusLabel = match ($status) {
                                                        'accepted' => 'Acceptee',
                                                        'en_route' => 'En route',
                                                        'arrived' => 'Arrivee',
                                                        'in_queue' => 'Dans la file',
                                                        'client_arrived' => 'Client arrive',
                                                        'spot_transmitted' => 'Place transmise',
                                                        'available' => 'Disponible',
                                                        'completed' => 'Terminee',
                                                        'failed' => 'Echec',
                                                        'cancelled' => 'Annulee',
                                                        default => ucfirst(str_replace('_', ' ', (string) $status)),
                                                    };
                                                ?>
                                                <span class="badge <?php echo e($status === 'available' ? 'bg-success' : 'bg-info'); ?>"><?php echo e($statusLabel); ?></span>
                                            </td>
                                            <td><?php echo e($activeLiner['updated_at'] ?? '-'); ?></td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </tbody>
                                </table>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>

        <div class="row items-push">
            <div class="col-xxl-6">
                <div class="block block-rounded mb-0">
                    <div class="block-header block-header-default">
                        <h3 class="block-title"><i class="si si-briefcase me-1"></i>Dernieres missions</h3>
                        <div class="block-options">
                            <a href="<?php echo e(route('bo.missions.index')); ?>" class="btn btn-sm btn-alt-secondary">Voir tout</a>
                        </div>
                    </div>
                    <div class="block-content p-0">
                        <div class="table-responsive">
                            <table class="table table-striped table-hover table-vcenter fs-sm mb-0 bo-table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Titre</th>
                                    <th>Client</th>
                                    <th>Liner</th>
                                    <th>Statut</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $metrics['recent']['missions']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mission): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td>#<?php echo e($mission->id); ?></td>
                                        <td><?php echo e($mission->title); ?></td>
                                        <td><?php echo e($mission->client?->name ?? '-'); ?></td>
                                        <td><?php echo e($mission->liner?->name ?? '-'); ?></td>
                                        <?php
                                            $missionStatusLabel = match ($mission->status) {
                                                'published' => 'Publiee',
                                                'accepted' => 'Acceptee',
                                                'en_route' => 'En route',
                                                'arrived' => 'Arrivee',
                                                'in_queue' => 'Dans la file',
                                                'client_arrived' => 'Client arrive',
                                                'spot_transmitted' => 'Place transmise',
                                                'completed' => 'Terminee',
                                                'failed' => 'Echec',
                                                'cancelled' => 'Annulee',
                                                default => ucfirst(str_replace('_', ' ', (string) $mission->status)),
                                            };
                                        ?>
                                        <td><span class="badge bg-info"><?php echo e($missionStatusLabel); ?></span></td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="5" class="text-center text-muted">Aucune mission.</td>
                                    </tr>
                                <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xxl-6">
                <div class="block block-rounded mb-0">
                    <div class="block-header block-header-default">
                        <h3 class="block-title"><i class="si si-credit-card me-1"></i>Derniers paiements</h3>
                        <div class="block-options">
                            <a href="<?php echo e(route('bo.finance')); ?>" class="btn btn-sm btn-alt-secondary">Voir finance</a>
                        </div>
                    </div>
                    <div class="block-content p-0">
                        <div class="table-responsive">
                            <table class="table table-striped table-hover table-vcenter fs-sm mb-0 bo-table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Client</th>
                                    <th>Liner</th>
                                    <th>Montant</th>
                                    <th>Statut</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $metrics['recent']['payments']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td>#<?php echo e($payment->id); ?></td>
                                        <td><?php echo e($payment->client?->name ?? '-'); ?></td>
                                        <td><?php echo e($payment->liner?->name ?? '-'); ?></td>
                                        <td><?php echo e(number_format((float) $payment->amount, 2, ',', ' ')); ?> <?php echo e($payment->currency); ?></td>
                                        <td>
                                            <?php
                                                $paymentStatusLabel = match ($payment->status) {
                                                    'paid' => 'Paye',
                                                    'pending' => 'En attente',
                                                    'failed' => 'Echoue',
                                                    default => ucfirst(str_replace('_', ' ', (string) $payment->status)),
                                                };
                                            ?>
                                            <span class="badge <?php echo e($payment->status === 'paid' ? 'bg-success' : 'bg-warning text-dark'); ?>"><?php echo e($paymentStatusLabel); ?></span>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="5" class="text-center text-muted">Aucun paiement.</td>
                                    </tr>
                                <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row items-push">
            <div class="col-xxl-6">
                <div class="block block-rounded mb-0">
                    <div class="block-header block-header-default">
                        <h3 class="block-title"><i class="si si-shield me-1"></i>Moderation KYC en attente</h3>
                        <div class="block-options">
                            <a href="<?php echo e(route('bo.kyc.index')); ?>" class="btn btn-sm btn-alt-secondary">Voir KYC</a>
                        </div>
                    </div>
                    <div class="block-content p-0">
                        <div class="table-responsive">
                            <table class="table table-vcenter table-hover fs-sm mb-0 bo-table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Liner</th>
                                    <th>Type</th>
                                    <th>Numero</th>
                                    <th style="width: 220px;">Actions</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $metrics['recent']['kyc_pending']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $doc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td>#<?php echo e($doc->id); ?></td>
                                        <td><?php echo e($doc->user?->name ?? '-'); ?></td>
                                        <td><?php echo e($doc->document_type); ?></td>
                                        <td><?php echo e($doc->document_number); ?></td>
                                        <td>
                                            <div class="bo-table-actions">
                                                <form method="POST" action="<?php echo e(route('bo.kyc.approve', $doc)); ?>">
                                                    <?php echo csrf_field(); ?>
                                                    <button class="btn btn-sm btn-success" type="submit">
                                                        <i class="fa fa-check me-1"></i>Approuver
                                                    </button>
                                                </form>
                                                <form method="POST" action="<?php echo e(route('bo.kyc.reject', $doc)); ?>" class="d-flex gap-2">
                                                    <?php echo csrf_field(); ?>
                                                    <input class="form-control form-control-sm" type="text" name="reason" placeholder="Motif rejet">
                                                    <button class="btn btn-sm btn-danger" type="submit">
                                                        <i class="fa fa-xmark me-1"></i>Rejeter
                                                    </button>
                                                </form>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="5" class="text-center text-muted">Aucune demande KYC.</td>
                                    </tr>
                                <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xxl-6">
                <div class="block block-rounded mb-0">
                    <div class="block-header block-header-default">
                        <h3 class="block-title"><i class="si si-camera me-1"></i>Preuves mission en attente</h3>
                    </div>
                    <div class="block-content p-0">
                        <div class="table-responsive">
                            <table class="table table-vcenter table-hover fs-sm mb-0 bo-table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Mission</th>
                                    <th>Liner</th>
                                    <th>Type</th>
                                    <th style="width: 220px;">Actions</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $metrics['recent']['proofs_pending']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $proof): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td>#<?php echo e($proof->id); ?></td>
                                        <td><?php echo e($proof->mission?->title ?? '-'); ?></td>
                                        <td><?php echo e($proof->liner?->name ?? '-'); ?></td>
                                        <td><?php echo e($proof->type); ?></td>
                                        <td>
                                            <div class="bo-table-actions">
                                                <form method="POST" action="<?php echo e(route('bo.proofs.approve', $proof)); ?>">
                                                    <?php echo csrf_field(); ?>
                                                    <button class="btn btn-sm btn-success" type="submit">
                                                        <i class="fa fa-check me-1"></i>Valider
                                                    </button>
                                                </form>
                                                <form method="POST" action="<?php echo e(route('bo.proofs.reject', $proof)); ?>" class="d-flex gap-2">
                                                    <?php echo csrf_field(); ?>
                                                    <input class="form-control form-control-sm" type="text" name="review_notes" placeholder="Note moderation">
                                                    <button class="btn btn-sm btn-danger" type="submit">
                                                        <i class="fa fa-xmark me-1"></i>Rejeter
                                                    </button>
                                                </form>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="5" class="text-center text-muted">Aucune preuve.</td>
                                    </tr>
                                <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xxl-8">
                <div class="block block-rounded mb-0">
                    <div class="block-header block-header-default">
                        <h3 class="block-title"><i class="si si-flag me-1"></i>Litiges ouverts</h3>
                    </div>
                    <div class="block-content p-0">
                        <div class="table-responsive">
                            <table class="table table-vcenter table-hover fs-sm mb-0 bo-table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Mission</th>
                                    <th>Reporter</th>
                                    <th>Categorie</th>
                                    <th style="width: 280px;">Actions</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $metrics['recent']['disputes_open']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dispute): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td>#<?php echo e($dispute->id); ?></td>
                                        <td><?php echo e($dispute->mission?->title ?? '-'); ?></td>
                                        <td><?php echo e($dispute->reporter?->name ?? '-'); ?></td>
                                        <td><?php echo e($dispute->category); ?></td>
                                        <td>
                                            <div class="bo-table-actions">
                                                <form method="POST" action="<?php echo e(route('bo.disputes.resolve', $dispute)); ?>" class="d-flex gap-2">
                                                    <?php echo csrf_field(); ?>
                                                    <input class="form-control form-control-sm" type="text" name="resolution_notes" placeholder="Notes de resolution">
                                                    <button class="btn btn-sm btn-success" type="submit">
                                                        <i class="fa fa-check me-1"></i>Resoudre
                                                    </button>
                                                </form>
                                                <form method="POST" action="<?php echo e(route('bo.disputes.reject', $dispute)); ?>" class="d-flex gap-2">
                                                    <?php echo csrf_field(); ?>
                                                    <input class="form-control form-control-sm" type="text" name="resolution_notes" placeholder="Motif rejet">
                                                    <button class="btn btn-sm btn-danger" type="submit">
                                                        <i class="fa fa-xmark me-1"></i>Rejeter
                                                    </button>
                                                </form>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="5" class="text-center text-muted">Aucun litige.</td>
                                    </tr>
                                <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xxl-4">
                <div class="block block-rounded mb-0">
                    <div class="block-header block-header-default">
                        <h3 class="block-title"><i class="si si-bell me-1"></i>Test push</h3>
                    </div>
                    <div class="block-content">
                        <p class="fs-sm text-muted">
                            Envoyer une notification test a un utilisateur.
                        </p>
                        <form method="POST" action="<?php echo e(route('bo.push.test')); ?>">
                            <?php echo csrf_field(); ?>
                            <div class="mb-3">
                                <label class="form-label" for="push-user-id">ID utilisateur</label>
                                <input id="push-user-id" class="form-control form-control-alt" type="number" name="user_id" min="1" required>
                            </div>
                            <div class="mb-3">
                                <label class="form-label" for="push-type">Type</label>
                                <input id="push-type" class="form-control form-control-alt" type="text" name="type" value="admin.push_test">
                            </div>
                            <div class="mb-3">
                                <label class="form-label" for="push-title">Titre</label>
                                <input id="push-title" class="form-control form-control-alt" type="text" name="title" value="Notification test BO" required>
                            </div>
                            <div class="mb-3">
                                <label class="form-label" for="push-body">Message</label>
                                <textarea id="push-body" class="form-control form-control-alt" name="body" rows="4" required>Ceci est un test push depuis le BO LineUp.</textarea>
                            </div>
                            <button class="btn btn-alt-primary" type="submit">
                                <i class="fa fa-paper-plane opacity-50 me-1"></i> Envoyer push test
                            </button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    <script
        src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
        integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
        crossorigin=""
    ></script>
    <script>
        (function () {
            const points = <?php echo json_encode($metrics['active_liners'], 15, 512) ?>;
            if (!Array.isArray(points) || points.length === 0 || typeof L === 'undefined') {
                return;
            }

            const mapEl = document.getElementById('bo-active-liners-map');
            if (!mapEl) {
                return;
            }

            const map = L.map(mapEl, {
                zoomControl: true,
                scrollWheelZoom: false,
            });

            L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
                maxZoom: 19,
                attribution: '&copy; OpenStreetMap',
            }).addTo(map);

            const bounds = [];
            const colorByStatus = {
                accepted: '#f59e0b',
                en_route: '#2563eb',
                arrived: '#16a34a',
                in_queue: '#9333ea',
                client_arrived: '#0f766e',
                spot_transmitted: '#0891b2',
                available: '#16a34a',
                failed: '#dc2626',
            };

            points.forEach((item) => {
                const lat = Number(item.latitude);
                const lng = Number(item.longitude);
                if (!Number.isFinite(lat) || !Number.isFinite(lng)) {
                    return;
                }

                const markerColor = colorByStatus[item.mission_status] || '#0ea5e9';
                const marker = L.circleMarker([lat, lng], {
                    radius: 8,
                    color: markerColor,
                    weight: 2,
                    fillColor: markerColor,
                    fillOpacity: 0.78,
                }).addTo(map);

                const linerName = item?.liner?.name || 'Liner';
                const missionTitle = item?.mission_title || '-';
                const missionStatusRaw = item?.mission_status || '-';
                const missionStatusLabel = ({
                    accepted: 'Acceptee',
                    en_route: 'En route',
                    arrived: 'Arrivee',
                    available: 'Disponible',
                    completed: 'Terminee',
                    cancelled: 'Annulee',
                })[missionStatusRaw] || missionStatusRaw;
                const updatedAt = item?.updated_at || '-';
                const clientName = item?.client_name || '-';

                marker.bindPopup(
                    `<strong>${linerName}</strong><br>` +
                    `${item.mission_id ? `Mission n°${item.mission_id}: ${missionTitle}` : missionTitle}<br>` +
                    `Statut: ${missionStatusLabel}<br>` +
                    `Client: ${clientName}<br>` +
                    `Mise a jour: ${updatedAt}`
                );

                bounds.push([lat, lng]);
            });

            if (bounds.length === 0) {
                map.setView([48.8566, 2.3522], 11);
                return;
            }

            if (bounds.length === 1) {
                map.setView(bounds[0], 14);
            } else {
                map.fitBounds(bounds, {padding: [24, 24]});
            }
        })();
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('bo.layouts.backend', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/lineupfrance/public_html/resources/views/bo/dashboard.blade.php ENDPATH**/ ?>