@php
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('hr_reports.title'), 'url' => route('hr.reports.index')],
        ['label' => $report->label()],
    ];
    $first = $rows->first();
    $columns = $first ? array_keys((array) $first) : [];
@endphp

<x-ui.layout.page :title="$report->label()" :subtitle="__('hr_reports.filtered_data')" page-icon="fe fe-file-text" :breadcrumbs="$breadcrumbs">
    <div class="card mb-3">
        <div class="card-body">
            <form method="GET" action="{{ route('hr.reports.show', $report) }}" class="row g-3 align-items-end">
                <div class="col-md-3">
                    <x-ui.form.input name="date_from" type="date" :label="__('hr_reports.filters.date_from')" :value="$filters['date_from'] ?? null" />
                </div>
                <div class="col-md-3">
                    <x-ui.form.input name="date_to" type="date" :label="__('hr_reports.filters.date_to')" :value="$filters['date_to'] ?? null" />
                </div>
                <div class="col-md-3">
                    <label class="form-label">{{ __('hr_reports.filters.department') }}</label>
                    <select class="form-select" name="department_id">
                        <option value="">{{ __('common.all') }}</option>
                        @foreach ($departments as $department)
                            <option value="{{ $department->id }}" @selected(($filters['department_id'] ?? null) == $department->id)>{{ $department->name }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="col-md-3">
                    <x-ui.buttons.primary type="submit" icon="fe fe-filter">{{ __('common.filter') }}</x-ui.buttons.primary>
                </div>
            </form>
        </div>
    </div>

    <div class="card">
        <div class="table-responsive">
            <table class="table table-vcenter mb-0">
                <thead><tr>@foreach ($columns as $column)<th>{{ __("hr_reports.columns.$column") }}</th>@endforeach</tr></thead>
                <tbody>
                    @forelse ($rows as $row)
                        <tr>
                            @foreach ($columns as $column)
                                <td>{{ is_bool($row->{$column}) ? ($row->{$column} ? __('common.yes') : __('common.no')) : ($row->{$column} ?? '—') }}</td>
                            @endforeach
                        </tr>
                    @empty
                        <tr><td class="text-center text-muted py-5">{{ __('common.no_data') }}</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
        @if ($rows->hasPages())<div class="card-footer">{{ $rows->links() }}</div>@endif
    </div>
</x-ui.layout.page>
