{{-- 테넌트 모달 - 부서 탭 --}}
<div class="space-y-4">
    {{-- 헤더 --}}
    <div class="flex items-center justify-between">
        <h3 class="text-sm font-medium text-gray-700">부서 목록</h3>
        <span class="text-xs text-gray-500">총 {{ $departments->count() }}개</span>
    </div>

    @if($departments->count() > 0)
        {{-- 부서 트리 구조 --}}
        <div class="overflow-hidden border border-gray-200 rounded-lg">
            <table class="min-w-full divide-y divide-gray-200">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">부서명</th>
                        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">코드</th>
                        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">상위 부서</th>
                        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">소속 인원</th>
                        <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">상태</th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200">
                    @foreach($departments as $department)
                        <tr class="hover:bg-gray-50">
                            <td class="px-4 py-2 whitespace-nowrap">
                                <div class="flex items-center">
                                    @if($department->depth > 0)
                                        <span class="text-gray-300 mr-1">
                                            @for($i = 0; $i < $department->depth; $i++)
                                                &nbsp;&nbsp;
                                            @endfor
                                            └
                                        </span>
                                    @endif
                                    <span class="text-sm font-medium text-gray-900">
                                        {{ $department->name }}
                                    </span>
                                </div>
                            </td>
                            <td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">
                                {{ $department->code ?? '-' }}
                            </td>
                            <td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">
                                {{ $department->parent?->name ?? '-' }}
                            </td>
                            <td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">
                                {{ $department->users_count ?? 0 }}명
                            </td>
                            <td class="px-4 py-2 whitespace-nowrap">
                                @if($department->is_active ?? true)
                                    <span class="px-2 py-0.5 text-xs font-semibold rounded-full bg-green-100 text-green-800">
                                        활성
                                    </span>
                                @else
                                    <span class="px-2 py-0.5 text-xs font-semibold rounded-full bg-gray-100 text-gray-800">
                                        비활성
                                    </span>
                                @endif
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    @else
        {{-- 빈 상태 --}}
        <div class="text-center py-8 text-gray-500">
            <svg class="w-12 h-12 mx-auto mb-4 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
            </svg>
            <p>등록된 부서가 없습니다.</p>
        </div>
    @endif
</div>