@extends('layouts.app')
@section('title', 'Tableau de bord coursier')
@section('content')
<h3 class="mb-4">Bonjour, {{ auth()->user()->name }}</h3>

<div class="row g-3 mb-4">
    <div class="col-md-6">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold">{{ $stats['a_traiter'] }}</div>
            <div class="small text-muted">A traiter</div>
        </div>
    </div>
    <div class="col-md-6">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold text-success">{{ $stats['collectees_aujourdhui'] }}</div>
            <div class="small text-muted">Collectees aujourd'hui</div>
        </div>
    </div>
</div>

<div class="card p-3">
    <h5 class="mb-3">Votre tournee du jour</h5>
    <div class="table-responsive">
        <table class="table align-middle">
            <thead><tr><th>#</th><th>Partenaire</th><th>Type</th><th>Urgence</th><th></th></tr></thead>
            <tbody>
                @forelse($todayRequests as $r)
                <tr>
                    <td>{{ $r->id }}</td>
                    <td>{{ $r->partner->name }}<br><span class="small text-muted">{{ $r->partner->address }}</span></td>
                    <td>{{ \App\Models\ServiceRequest::types()[$r->type] }}</td>
                    <td>{{ $r->urgency === 'urgent' ? '🔴 Urgent' : 'Normal' }}</td>
                    <td><a href="{{ route('courier.requests.show', $r) }}" class="btn btn-sm btn-primary">Traiter</a></td>
                </tr>
                @empty
                <tr><td colspan="5" class="text-center text-muted">Aucune demande assignee pour le moment.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>
@endsection
