<div>
    @if($dsarData->isEmpty())
        <div class="text-center py-5 text-muted">
            <i class="mdi mdi-file-search-outline fs-1 d-block mb-2 opacity-25"></i>
            <p class="mb-0">No evidence has been extracted yet.</p>
            <small>Evidence is extracted automatically when DSAR response documents are received.</small>
        </div>
    @else
        @foreach($dsarData as $data)
            @php $dsar = $data['dsar']; @endphp
            <div class="card mb-3">
                <div class="card-header d-flex align-items-center justify-content-between">
                    <div class="d-flex align-items-center gap-2">
                        <i class="mdi mdi-shield-lock text-primary"></i>
                        <span class="fw-semibold">{{ $dsar->institution?->display_name ?? 'Unknown institution' }}</span>
                        <span class="badge bg-primary-subtle text-primary small">{{ $dsar->reference }}</span>
                    </div>
                    <div class="d-flex align-items-center gap-2">
                        @if($data['highCount'] > 0)
                            <span class="badge bg-danger-subtle text-danger">
                                {{ $data['highCount'] }} high severity
                            </span>
                        @endif
                        <a href="{{ route('dsars.show', $dsar->slug) }}#evidence"
                           class="btn btn-sm btn-outline-primary">
                            View evidence <i class="mdi mdi-arrow-right ms-1"></i>
                        </a>
                    </div>
                </div>
                <div class="card-body">
                    <div class="row g-3 mb-3">
                        <div class="col-sm-3 col-6">
                            <div class="text-center">
                                <div class="fs-4 fw-bold">{{ $data['totalItems'] }}</div>
                                <div class="small text-muted">Total items</div>
                            </div>
                        </div>
                        <div class="col-sm-3 col-6">
                            <div class="text-center">
                                <div class="fs-4 fw-bold text-success">{{ $data['confirmed'] }}</div>
                                <div class="small text-muted">Confirmed</div>
                            </div>
                        </div>
                        <div class="col-sm-3 col-6">
                            <div class="text-center">
                                <div class="fs-4 fw-bold" style="color:#d97706;">{{ $data['unreviewed'] }}</div>
                                <div class="small text-muted">Unreviewed</div>
                            </div>
                        </div>
                        <div class="col-sm-3 col-6">
                            <div class="text-center">
                                <div class="fs-4 fw-bold text-secondary">{{ $data['dismissed'] }}</div>
                                <div class="small text-muted">Dismissed</div>
                            </div>
                        </div>
                    </div>

                    @if($data['byCategory']->isNotEmpty())
                        <div class="d-flex flex-wrap gap-1">
                            @foreach($data['byCategory'] as $category => $count)
                                @php $colour = \App\Models\Dsar\DsarEvidenceItem::categoryColour($category); @endphp
                                <span class="badge rounded-pill"
                                      style="background:{{ $colour }}20;color:{{ $colour }};border:1px solid {{ $colour }}40;">
                                    {{ \App\Models\Dsar\DsarEvidenceItem::categoryLabel($category) }}
                                    <span class="ms-1 fw-bold">{{ $count }}</span>
                                </span>
                            @endforeach
                        </div>
                    @endif
                </div>
            </div>
        @endforeach
    @endif
</div>
