@extends('layouts.verifier')

@section('title', 'Dashboard Vérificateur')
@section('page-title', 'Mon Dashboard Vérificateur')

@section('content')
<div class="container-fluid py-4">
    <!-- KYC Stats Cards -->
    <div class="row g-4 mb-4">
        <!-- Pending Approvals -->
        <div class="col-lg-3 col-md-6 col-sm-12">
            <div class="stat-card shadow-sm border-0 rounded-3" style="background: #f1f5f9;">
                <div class="d-flex justify-content-between align-items-start mb-3">
                    <div class="flex-grow-1">
                        <p class="text-muted small fw-500 mb-1">⏳ En attente</p>
                        <h3 class="mb-1 text-warning fw-700">{{ $pendingCount ?? 0 }}</h3>
                    </div>
                    <div class="stat-icon bg-warning-light rounded-circle p-3">
                        <i class="bi bi-hourglass-split text-warning fs-5"></i>
                    </div>
                </div>
                <p class="small text-muted mb-2">Vérifications à traiter</p>
                <a href="{{ route('verifier.kyc.index', ['status' => 'pending']) }}" class="btn btn-sm btn-outline-warning w-100 rounded-2">
                    <i class="bi bi-arrow-right me-1"></i> Voir
                </a>
            </div>
        </div>

        <!-- Approved -->
        <div class="col-lg-3 col-md-6 col-sm-12">
            <div class="stat-card shadow-sm border-0 rounded-3" style="background: #f1f5f9;">
                <div class="d-flex justify-content-between align-items-start mb-3">
                    <div class="flex-grow-1">
                        <p class="text-muted small fw-500 mb-1">✅ Approuvé</p>
                        <h3 class="mb-1 text-success fw-700">{{ $approvedCount ?? 0 }}</h3>
                    </div>
                    <div class="stat-icon bg-success-light rounded-circle p-3">
                        <i class="bi bi-check-circle-fill text-success fs-5"></i>
                    </div>
                </div>
                <p class="small text-muted mb-2">Cette semaine</p>
                <a href="{{ route('verifier.kyc.index', ['status' => 'approved']) }}" class="btn btn-sm btn-outline-success w-100 rounded-2">
                    <i class="bi bi-arrow-right me-1"></i> Voir
                </a>
            </div>
        </div>

        <!-- Rejected -->
        <div class="col-lg-3 col-md-6 col-sm-12">
            <div class="stat-card shadow-sm border-0 rounded-3" style="background: #f1f5f9;">
                <div class="d-flex justify-content-between align-items-start mb-3">
                    <div class="flex-grow-1">
                        <p class="text-muted small fw-500 mb-1">❌ Rejeté</p>
                        <h3 class="mb-1 text-danger fw-700">{{ $rejectedCount ?? 0 }}</h3>
                    </div>
                    <div class="stat-icon bg-danger-light rounded-circle p-3">
                        <i class="bi bi-x-circle-fill text-danger fs-5"></i>
                    </div>
                </div>
                <p class="small text-muted mb-2">À réviser</p>
                <a href="{{ route('verifier.kyc.index', ['status' => 'rejected']) }}" class="btn btn-sm btn-outline-danger w-100 rounded-2">
                    <i class="bi bi-arrow-right me-1"></i> Voir
                </a>
            </div>
        </div>

        <!-- Deliveries -->
        <div class="col-lg-3 col-md-6 col-sm-12">
            <div class="stat-card shadow-sm border-0 rounded-3" style="background: #f1f5f9;">
                <div class="d-flex justify-content-between align-items-start mb-3">
                    <div class="flex-grow-1">
                        <p class="text-muted small fw-500 mb-1">🚚 Livraisons</p>
                        <h3 class="mb-1 text-primary fw-700">{{ $pendingDeliveries ?? 0 }}</h3>
                    </div>
                    <div class="stat-icon bg-primary-light rounded-circle p-3">
                        <i class="bi bi-truck text-primary fs-5"></i>
                    </div>
                </div>
                <p class="small text-muted mb-2">En attente de vérification</p>
                <a href="{{ route('verifier.delivery.index') }}" class="btn btn-sm btn-outline-primary w-100 rounded-2">
                    <i class="bi bi-arrow-right me-1"></i> Voir
                </a>
            </div>
        </div>
    </div>

    <!-- Pending KYC Verifications -->
    <div class="row g-4 mb-4">
        <div class="col-lg-8">
            <div class="card shadow-sm border-0 rounded-3">
                <div class="card-header bg-white border-0 p-4">
                    <h5 class="mb-0">Vérifications en attente</h5>
                </div>
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <table class="table mb-0">
                            <thead class="bg-light">
                                <tr>
                                    <th>Utilisateur</th>
                                    <th>Type de KYC</th>
                                    <th>Date</th>
                                    <th>Statut</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse($pendingKyc ?? [] as $kyc)
                                <tr>
                                    <td>
                                        <small>{{ $kyc->user->name ?? 'N/A' }}</small>
                                    </td>
                                    <td>
                                        <small>{{ $kyc->type ?? 'Basique' }}</small>
                                    </td>
                                    <td>
                                        <small>{{ $kyc->created_at?->format('d/m/Y') }}</small>
                                    </td>
                                    <td>
                                        <span class="badge bg-warning">En attente</span>
                                    </td>
                                    <td>
                                        <a href="{{ route('verifier.kyc.show', $kyc->id) }}" class="btn btn-sm btn-outline-primary rounded-2">
                                            <i class="bi bi-eye me-1"></i> Examiner
                                        </a>
                                    </td>
                                </tr>
                                @empty
                                <tr>
                                    <td colspan="5" class="text-center py-4 text-muted">
                                        <p class="mb-0">Aucune vérification en attente</p>
                                    </td>
                                </tr>
                                @endforelse
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <!-- Recent Activity -->
        <div class="col-lg-4">
            <div class="card shadow-sm border-0 rounded-3">
                <div class="card-header bg-white border-0 p-4">
                    <h6 class="mb-0">Activité récente</h6>
                </div>
                <div class="card-body">
                    <div class="activity-feed">
                        @forelse($recentActivity ?? [] as $activity)
                        <div class="mb-3 pb-3 border-bottom">
                            <small class="d-block fw-600">{{ $activity->action ?? 'Action' }}</small>
                            <small class="text-muted d-block">{{ $activity->user?->name ?? 'Utilisateur' }}</small>
                            <small class="text-muted d-block">{{ $activity->created_at?->diffForHumans() }}</small>
                        </div>
                        @empty
                        <p class="text-muted text-center py-4">Aucune activité récente</p>
                        @endforelse
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@endsection
