@extends('layouts.verifier')

@section('title', 'Tableau de bord')
@section('page-title', 'Tableau de bord Verificateur')

@section('content')
<div class="row mb-4">
    <div class="col-md-4">
        <div class="card stat-card bg-warning text-dark">
            <div class="card-body">
                <div class="d-flex justify-content-between">
                    <div>
                        <h6 class="text-uppercase fw-bold opacity-75">KYC en attente</h6>
                        <h2 class="mb-0">{{ $pendingKyc }}</h2>
                    </div>
                    <i class="bi bi-person-badge fs-1 opacity-50"></i>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card stat-card bg-info text-white">
            <div class="card-body">
                <div class="d-flex justify-content-between">
                    <div>
                        <h6 class="text-uppercase fw-bold opacity-75">Preuves a verifier</h6>
                        <h2 class="mb-0">{{ $pendingDeliveryProofs }}</h2>
                    </div>
                    <i class="bi bi-truck fs-1 opacity-50"></i>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card stat-card bg-danger text-white">
            <div class="card-body">
                <div class="d-flex justify-content-between">
                    <div>
                        <h6 class="text-uppercase fw-bold opacity-75">Litiges ouverts</h6>
                        <h2 class="mb-0">{{ $openDisputes }}</h2>
                    </div>
                    <i class="bi bi-exclamation-triangle fs-1 opacity-50"></i>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-6 mb-4">
        <div class="card">
            <div class="card-header bg-white d-flex justify-content-between align-items-center">
                <h5 class="mb-0">Dernieres demandes KYC</h5>
                <a href="{{ route('verifier.kyc.index') }}" class="btn btn-sm btn-outline-primary">Voir tout</a>
            </div>
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover mb-0">
                        <thead class="table-light">
                            <tr>
                                <th>Vendeur</th>
                                <th>Date</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse($recentKycSubmissions as $seller)
                            <tr>
                                <td>
                                    <strong>{{ $seller->shop_name }}</strong><br>
                                    <small class="text-muted">{{ $seller->user->email ?? 'N/A' }}</small>
                                </td>
                                <td>{{ $seller->updated_at->format('d/m/Y') }}</td>
                                <td>
                                    <a href="{{ route('verifier.kyc.show', $seller) }}" class="btn btn-sm btn-primary">
                                        <i class="bi bi-eye"></i> Examiner
                                    </a>
                                </td>
                            </tr>
                            @empty
                            <tr>
                                <td colspan="3" class="text-center text-muted py-4">Aucune demande en attente</td>
                            </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    
    <div class="col-lg-6 mb-4">
        <div class="card">
            <div class="card-header bg-white d-flex justify-content-between align-items-center">
                <h5 class="mb-0">Preuves de livraison recentes</h5>
                <a href="{{ route('verifier.delivery.index') }}" class="btn btn-sm btn-outline-primary">Voir tout</a>
            </div>
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover mb-0">
                        <thead class="table-light">
                            <tr>
                                <th>Commande</th>
                                <th>Vendeur</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse($recentDeliveryProofs as $order)
                            <tr>
                                <td>
                                    <strong>#{{ $order->id }}</strong><br>
                                    <small class="text-muted">{{ $order->updated_at->format('d/m/Y') }}</small>
                                </td>
                                <td>{{ $order->seller->shop_name ?? 'N/A' }}</td>
                                <td>
                                    <a href="{{ route('verifier.delivery.show', $order) }}" class="btn btn-sm btn-info">
                                        <i class="bi bi-eye"></i> Verifier
                                    </a>
                                </td>
                            </tr>
                            @empty
                            <tr>
                                <td colspan="3" class="text-center text-muted py-4">Aucune preuve a verifier</td>
                            </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
