<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-responsive-md align-middle">
                <thead>
                    <tr>
                        <th>Müşteri</th>
                        <th>Tip</th>
                        <th>Tarih Aralığı</th>
                        <th>Kanallar</th>
                        <th>Durum</th>
                        <th>Dosyalar</th>
                        <th>Oluşturma</th>
                        <th class="text-end">İşlem</th>
                    </tr>
                </thead>
                <tbody>
                @forelse($reports as $report)
                    <tr>
                        <td>
                            <strong>{{ $report->client?->company_name ?? '-' }}</strong>
                            @if($report->error_message)
                                <span class="d-block text-danger small">{{ \Illuminate\Support\Str::limit($report->error_message, 70) }}</span>
                            @endif
                        </td>
                        <td>{{ ['daily' => 'Günlük', 'weekly' => 'Haftalık', 'monthly' => 'Aylık', 'custom' => 'Özel'][$report->report_type] ?? ucfirst($report->report_type) }}</td>
                        <td>{{ $report->date_from?->format('d.m.Y') }} - {{ $report->date_to?->format('d.m.Y') }}</td>
                        <td>
                            @foreach(($report->channels ?: []) as $channel)
                                <span class="badge badge-light me-1">{{ str_replace('_', ' ', strtoupper($channel)) }}</span>
                            @endforeach
                        </td>
                        <td>@include('admin.partials.status-badge', ['status' => $report->status])</td>
                        <td>
                            <div class="d-flex flex-wrap gap-1">
                                @if($report->html_path)<a href="{{ route('admin.reports.download', [$report, 'html']) }}" class="badge badge-info">HTML</a>@endif
                                @if($report->pdf_path)<a href="{{ route('admin.reports.download', [$report, 'pdf']) }}" class="badge badge-danger">PDF</a>@endif
                                @if($report->excel_path)<a href="{{ route('admin.reports.download', [$report, 'excel']) }}" class="badge badge-success">XLS</a>@endif
                                @if($report->csv_path)<a href="{{ route('admin.reports.download', [$report, 'csv']) }}" class="badge badge-secondary">CSV</a>@endif
                            </div>
                        </td>
                        <td>{{ $report->generated_at?->format('d.m.Y H:i') ?? $report->created_at?->format('d.m.Y H:i') }}</td>
                        <td class="text-end">
                            <a href="{{ route('admin.reports.show', $report) }}" class="btn btn-sm btn-primary">Detay</a>
                        </td>
                    </tr>
                @empty
                    <tr><td colspan="8" class="text-center text-muted py-5">Henüz rapor yok.</td></tr>
                @endforelse
                </tbody>
            </table>
        </div>
        {{ $reports->links() }}
    </div>
</div>
