@extends('layouts.portal')
@section('title', 'Raporlarım')
@section('content')
<div class="d-flex align-items-start justify-content-between flex-wrap gap-3 mb-4">
    <div>
        <h2 class="mb-1">Raporlarım</h2>
        <p class="portal-muted mb-0">Oluşturulan PDF, Excel, CSV ve HTML rapor arşivi.</p>
    </div>
</div>

@include('portal.partials-client-filter')

<div class="card soft-panel">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table">
                <thead>
                <tr>
                    <th>Müşteri</th>
                    <th>Rapor Türü</th>
                    <th>Tarih Aralığı</th>
                    <th>Durum</th>
                    <th>Oluşturma</th>
                    <th class="text-end">İşlem</th>
                </tr>
                </thead>
                <tbody>
                @forelse($reports as $report)
                    <tr>
                        <td>{{ $report->client?->company_name }}</td>
                        <td>{{ ucfirst($report->report_type) }}</td>
                        <td>{{ optional($report->date_from)->format('d.m.Y') }} - {{ optional($report->date_to)->format('d.m.Y') }}</td>
                        <td><span class="badge badge-light">{{ $report->status }}</span></td>
                        <td>{{ $report->generated_at ? $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('portal.reports.show', $report) }}" class="btn btn-sm btn-primary">Detay</a></td>
                    </tr>
                @empty
                    <tr><td colspan="6" class="text-center text-muted py-5">Henüz rapor bulunamadı.</td></tr>
                @endforelse
                </tbody>
            </table>
        </div>
        {{ $reports->links() }}
    </div>
</div>
@endsection
