@php
    $breadcrumbs = [
        ['label' => __('common.home'), 'url' => route('dashboard.index')],
        ['label' => __('common.hr')],
        ['label' => __('hr_analytics.title')],
    ];
@endphp

<x-ui.layout.page :title="__('hr_analytics.title')" :subtitle="__('hr_analytics.subtitle')" page-icon="fe fe-trending-up" :breadcrumbs="$breadcrumbs">
    <div class="row g-3 mb-4">
        @foreach ($analytics['cards'] as $key => $value)
            <div class="col-md-3">
                <div class="card h-100"><div class="card-body">
                    <div class="text-muted small">{{ __("hr_analytics.metrics.$key") }}</div>
                    <div class="fs-2 fw-semibold">{{ $value }}</div>
                </div></div>
            </div>
        @endforeach
    </div>

    <div class="row g-3">
        @foreach (['headcount', 'turnover', 'payroll', 'overtime', 'leave', 'absenteeism'] as $trend)
            <div class="col-lg-6">
                <div class="card h-100">
                    <div class="card-header"><h3 class="card-title">{{ __("hr_analytics.metrics.$trend") }}</h3></div>
                    <div class="table-responsive"><table class="table table-sm table-vcenter mb-0">
                        <thead><tr><th>{{ __('hr_analytics.month') }}</th><th class="text-end">{{ __('hr_analytics.value') }}</th></tr></thead>
                        <tbody>@foreach ($analytics[$trend] as $month => $value)
                            <tr><td>{{ $month }}</td><td class="text-end">{{ $value }}</td></tr>
                        @endforeach</tbody>
                    </table></div>
                </div>
            </div>
        @endforeach

        @foreach (['departments', 'genders', 'funnel'] as $distribution)
            <div class="col-lg-4">
                <div class="card h-100">
                    <div class="card-header"><h3 class="card-title">{{ __("hr_analytics.metrics.$distribution") }}</h3></div>
                    <div class="list-group list-group-flush">
                        @forelse ($analytics[$distribution] as $label => $value)
                            <div class="list-group-item d-flex justify-content-between"><span>{{ $label }}</span><strong>{{ $value }}</strong></div>
                        @empty
                            <div class="list-group-item text-muted">{{ __('common.no_data') }}</div>
                        @endforelse
                    </div>
                </div>
            </div>
        @endforeach
    </div>
</x-ui.layout.page>
