<table class="table table-bordered table-nowrap">
    <thead>
        <tr>
            <th style="text-align: center; font-size: 26px; font-weight: bold" colspan="{{ 8 + @$data['totalDays'] }}">
                {{ @$data['title'] }}
            </th>
        </tr>
        <tr>
            <th style="text-align: center; font-size: 13px" colspan="{{ 8 + @$data['totalDays'] }}">
                {{ _trans('common.Generated At :') }} {{ \Carbon\Carbon::now()->format('d F Y, H:i A') }} {{ _trans('common.By : ') }}
                <strong>{{ auth()->user()->name }}</strong>
            </th>
        </tr>
    </thead>
    <thead>
        <tr>
            <th><b>{{ _trans('common.Employee') }}</b></th>
            <th><b>{{ _trans('common.Department') }}</b></th>
            <th><b>{{ _trans('common.Designation') }}</b></th>
            @for ($i = 1; $i <= $data['totalDays']; $i++)
                <th style="text-align: center; width: 50px"><b>{{ $i }}</b></th>
            @endfor
            <th style="background: #dbfdb8; text-align: center; width: 50px">{{ _trans('common.TP') }}</th>
            <th style="background: #fca9a9; text-align: center; width: 50px">{{ _trans('common.TA') }}</th>
            <th style="background: #fcfa95; text-align: center; width: 50px">{{ _trans('common.TW') }}</th>
            <th style="background: #fca9a9; text-align: center; width: 50px">{{ _trans('common.TH') }}</th>
            <th style="background: #c5ddfd; text-align: center; width: 50px">{{ _trans('common.TL') }}</th>
        </tr>
    </thead>
    <tbody>
        @forelse (@$data['reports'] ?? [] as $report)
            <tr>
                <td>
                    {{ @$report['employee_name'] }} {{ @$report['employee_id'] ? '[' . $report['employee_id'] . ']' : '' }}
                </td>
                <td>
                    {{ @$report['department'] }}
                </td>
                <td>
                    {{ @$report['designation'] }}
                </td>

                {{-- Render "Not Joined" days --}}
                @if (!empty($report['month_statuses']['totalNotJoin']))
                    <td colspan="{{ $report['month_statuses']['totalNotJoin'] }}" style="text-align: center; width: 50px">
                        {{ _trans("common.Not Joined") }}
                    </td>
                @endif

                {{-- Render remaining statuses --}}
                @foreach ($report['month_statuses']['statuses'] ?? [] as $key => $monthStatus)
                    @if ($key >= $report['month_statuses']['totalNotJoin'])
                        <td style="text-align: center; width: 50px">
                            {!! $monthStatus !!}
                        </td>
                    @endif
                @endforeach

                {{-- Totals --}}
                <td style="background: #e2ffc5; text-align: center; width: 50px">{{ @$report['month_statuses']['totalPresent'] }}</td>
                <td style="background: #ffb8b8; text-align: center; width: 50px">{{ @$report['month_statuses']['totalAbsent'] }}</td>
                <td style="background: #fffda1; text-align: center; width: 50px">{{ @$report['month_statuses']['totalWeekend'] }}</td>
                <td style="background: #ffb8b8; text-align: center; width: 50px">{{ @$report['month_statuses']['totalHoliday'] }}</td>
                <td style="background: #d5e7ff; text-align: center; width: 50px">{{ @$report['month_statuses']['totalLeave'] }}</td>
            </tr>
        @empty
            <tr>
                <td colspan="{{ 8 + @$data['totalDays'] }}" style="background: #ffb8b8; text-align: center;">
                    {{ _trans('common.No data found!') }}
                </td>
            </tr>
        @endforelse
    </tbody>
</table>
