{{-- 사원별 월간 요약 (HTMX로 로드) --}}
@php
    use App\Models\HR\Attendance;
@endphp

<div class="px-6 py-4 border-b border-gray-200">
    <h3 class="text-lg font-semibold text-gray-800">{{ $year }}년 {{ $month }}월 사원별 요약</h3>
</div>

@if(empty($summary))
<div class="px-6 py-12 text-center">
    <svg class="w-12 h-12 text-gray-300 mx-auto mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
    </svg>
    <p class="text-gray-500">해당 월의 근태 데이터가 없습니다.</p>
</div>
@else
<x-table-swipe>
    <table class="min-w-full">
        <thead class="bg-gray-50 border-b border-gray-200">
            <tr>
                <th class="px-6 py-3 text-left text-sm font-semibold text-gray-600">사원</th>
                <th class="px-6 py-3 text-left text-sm font-semibold text-gray-600">부서</th>
                <th class="px-4 py-3 text-center text-sm font-semibold text-gray-600">근무일</th>
                <th class="px-4 py-3 text-center text-sm font-semibold text-gray-600">총근무(h)</th>
                @foreach(Attendance::STATUS_MAP as $key => $label)
                    <th class="px-3 py-3 text-center text-sm font-semibold text-gray-600">{{ $label }}</th>
                @endforeach
            </tr>
        </thead>
        <tbody class="bg-white divide-y divide-gray-100">
            @foreach($summary as $item)
            <tr class="hover:bg-gray-50 transition-colors">
                <td class="px-6 py-3 whitespace-nowrap">
                    <div class="flex items-center gap-2">
                        <div class="shrink-0 w-7 h-7 rounded-full bg-blue-100 text-blue-600 flex items-center justify-center text-xs font-medium">
                            {{ mb_substr($item['name'], 0, 1) }}
                        </div>
                        <span class="text-sm font-medium text-gray-900">{{ $item['name'] }}</span>
                    </div>
                </td>
                <td class="px-6 py-3 whitespace-nowrap text-sm text-gray-700">{{ $item['department'] }}</td>
                <td class="px-4 py-3 text-center text-sm font-medium text-gray-700">{{ $item['total_days'] }}일</td>
                <td class="px-4 py-3 text-center text-sm font-medium text-gray-700">
                    {{ $item['total_minutes'] > 0 ? round($item['total_minutes'] / 60, 1) : '-' }}
                </td>
                @foreach(Attendance::STATUS_MAP as $key => $label)
                    @php $cnt = $item['statuses'][$key] ?? 0; @endphp
                    <td class="px-3 py-3 text-center text-sm {{ $cnt > 0 ? 'font-medium text-gray-800' : 'text-gray-300' }}">
                        {{ $cnt ?: '-' }}
                    </td>
                @endforeach
            </tr>
            @endforeach
        </tbody>
    </table>
</x-table-swipe>
@endif
