{{-- 테넌트 모달 - 사용자 탭 --}}
<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">총 {{ $users->count() }}명</span>
    </div>

    @if($users->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>
                        <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($users as $user)
                        <tr class="hover:bg-gray-50">
                            <td class="px-4 py-2 whitespace-nowrap">
                                <span class="text-sm font-medium text-gray-900 cursor-pointer hover:text-blue-600"
                                      data-context-menu="user"
                                      data-entity-id="{{ $user->id }}"
                                      data-entity-name="{{ $user->name }}">
                                    {{ $user->name }}
                                </span>
                            </td>
                            <td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">
                                {{ $user->email }}
                            </td>
                            <td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">
                                {{ $user->department?->name ?? '-' }}
                            </td>
                            <td class="px-4 py-2 whitespace-nowrap">
                                @if($user->roles && $user->roles->count() > 0)
                                    <div class="flex flex-wrap gap-1">
                                        @foreach($user->roles->take(2) as $role)
                                            <span class="px-1.5 py-0.5 text-xs bg-blue-100 text-blue-800 rounded">
                                                {{ $role->name }}
                                            </span>
                                        @endforeach
                                        @if($user->roles->count() > 2)
                                            <span class="px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded">
                                                +{{ $user->roles->count() - 2 }}
                                            </span>
                                        @endif
                                    </div>
                                @else
                                    <span class="text-xs text-gray-400">-</span>
                                @endif
                            </td>
                            <td class="px-4 py-2 whitespace-nowrap">
                                @if($user->is_active)
                                    <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>
                            <td class="px-4 py-2 whitespace-nowrap text-sm text-gray-500">
                                {{ $user->created_at?->format('Y-m-d') ?? '-' }}
                            </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="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
            </svg>
            <p>등록된 사용자가 없습니다.</p>
        </div>
    @endif
</div>