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

<div class="row g-3 mb-4">
    <div class="col-md-4">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold">{{ $stats['en_attente'] }}</div>
            <div class="small text-muted">En attente</div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold text-primary">{{ $stats['en_cours'] }}</div>
            <div class="small text-muted">En cours</div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card p-3 text-center">
            <div class="fs-4 fw-bold text-success">{{ $stats['terminees'] }}</div>
            <div class="small text-muted">Terminees</div>
        </div>
    </div>
</div>

<div class="row g-3 mb-4">
    <div class="col-md-3 col-6">
        <a href="{{ route('partner.requests.create', 'prelevement') }}" class="card p-3 text-decoration-none text-dark h-100">
            <div class="fw-bold">Demande de prelevement</div>
            <div class="small text-muted">Planifier une collecte</div>
        </a>
    </div>
    <div class="col-md-3 col-6">
        <a href="{{ route('partner.requests.create', 'consommable') }}" class="card p-3 text-decoration-none text-dark h-100">
            <div class="fw-bold">Demande de consommable</div>
            <div class="small text-muted">Reapprovisionnement</div>
        </a>
    </div>
    <div class="col-md-3 col-6">
        <a href="{{ route('partner.requests.create', 'reclamation') }}" class="card p-3 text-decoration-none text-dark h-100">
            <div class="fw-bold">Reclamation</div>
            <div class="small text-muted">Signaler un probleme</div>
        </a>
    </div>
    <div class="col-md-3 col-6">
        <a href="{{ route('partner.requests.create', 'resultat') }}" class="card p-3 text-decoration-none text-dark h-100">
            <div class="fw-bold">Demande de resultats</div>
            <div class="small text-muted">Suivi patient</div>
        </a>
    </div>
</div>

<div class="card p-3">
    <h5 class="mb-3">Vos dernieres demandes</h5>
    <div class="table-responsive">
        <table class="table table-sm">
            <thead><tr><th>#</th><th>Type</th><th>Statut</th><th>Cree le</th></tr></thead>
            <tbody>
                @forelse($recentRequests as $r)
                <tr>
                    <td>{{ $r->id }}</td>
                    <td>{{ \App\Models\ServiceRequest::types()[$r->type] }}</td>
                    <td><span class="badge bg-secondary">{{ \App\Models\ServiceRequest::statuses()[$r->status] }}</span></td>
                    <td>{{ $r->created_at->format('d/m/Y H:i') }}</td>
                </tr>
                @empty
                <tr><td colspan="4" class="text-center text-muted">Aucune demande pour le moment.</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>
@endsection
