<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>Laporan e-Sijil</title>
<style>body{font-family:DejaVu Sans,sans-serif;font-size:12px}table{width:100%;border-collapse:collapse}th,td{border:1px solid #ccc;padding:6px}th{background:#003366;color:white}.header{text-align:center;margin-bottom:20px}</style>
</head>
<body>
<div class="header">
    <h2>{{ $settings['event_name'] ?? 'e-Sijil Acara Larian 2026' }}</h2>
    <h3>Laporan: {{ ucfirst(str_replace('_', ' ', $type)) }}</h3>
    <p>Dijana: {{ $generatedAt->format('d/m/Y H:i') }} | Admin: {{ auth()->user()->name }}</p>
</div>
<table>
    <thead><tr>@foreach($headings as $h)<th>{{ $h }}</th>@endforeach</tr></thead>
    <tbody>
        @foreach($data as $row)
        <tr>
            @if($type === 'downloaded')
            <td>{{ $row->full_name }}</td><td>{{ $row->participant_number }}</td><td>{{ $row->category }}</td>
            <td>{{ $row->first_downloaded_at?->format('d/m/Y H:i') }}</td><td>{{ $row->last_downloaded_at?->format('d/m/Y H:i') }}</td><td>{{ $row->download_count }}</td>
            @elseif(is_array($row))
            @foreach($row as $v)<td>{{ $v }}</td>@endforeach
            @else
            @foreach((array)$row as $v)<td>{{ is_object($v) ? '' : $v }}</td>@endforeach
            @endif
        </tr>
        @endforeach
    </tbody>
</table>
</body>
</html>
