{{-- 테넌트 모달 - 기본 정보 + 탭 구조 --}}
<div class="p-6">
    {{-- 삭제된 테넌트 경고 배너 --}}
    @if($tenant->deleted_at)
        <div class="mb-4 p-4 bg-red-50 border border-red-200 rounded-lg">
            <div class="flex items-center justify-between">
                <div class="flex items-center gap-3">
                    <svg class="w-6 h-6 text-red-600 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
                    </svg>
                    <div>
                        <p class="text-sm font-semibold text-red-800">이 테넌트는 삭제되었습니다.</p>
                        <p class="text-xs text-red-600 mt-0.5">
                            삭제일: {{ $tenant->deleted_at->format('Y-m-d H:i') }}
                            @if($tenant->deletedByUser)
                                · 삭제자: {{ $tenant->deletedByUser->name }}
                            @endif
                        </p>
                    </div>
                </div>
                <button type="button"
                        onclick="event.stopPropagation(); confirmRestore({{ $tenant->id }}, '{{ $tenant->company_name }}')"
                        class="px-3 py-1.5 text-sm font-medium text-white bg-green-600 rounded-lg hover:bg-green-700 transition-colors">
                    복원하기
                </button>
            </div>
        </div>
    @endif

    {{-- 상단: 기본 정보 카드 --}}
    <div class="bg-gray-50 rounded-lg p-4 mb-6">
        <div class="flex gap-4">
            {{-- 좌측: 아이콘 --}}
            <div class="flex-shrink-0">
                <div class="w-20 h-20 bg-blue-100 rounded-lg flex items-center justify-center">
                    <svg class="w-10 h-10 text-blue-600" 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>
                </div>
            </div>

            {{-- 우측: 정보 테이블 --}}
            <div class="flex-1">
                <table class="w-full text-sm">
                    <tbody>
                        <tr>
                            <td class="py-1 pr-4 text-gray-500 w-24">회사명</td>
                            <td class="py-1 font-medium text-gray-900">{{ $tenant->company_name }}</td>
                            <td class="py-1 pr-4 text-gray-500 w-24">코드</td>
                            <td class="py-1 font-medium text-gray-900">{{ $tenant->code }}</td>
                            <td class="py-1 pr-4 text-gray-500 w-24">유형</td>
                            <td class="py-1">
                                @php
                                    $typeLabels = ['STD' => '일반', 'TPL' => '템플릿', 'HQ' => '본사'];
                                    $typeColors = [
                                        'STD' => 'bg-gray-100 text-gray-800',
                                        'TPL' => 'bg-purple-100 text-purple-800',
                                        'HQ' => 'bg-blue-100 text-blue-800'
                                    ];
                                    $type = $tenant->tenant_type ?? 'STD';
                                @endphp
                                <span class="px-2 py-0.5 text-xs font-semibold rounded-full {{ $typeColors[$type] ?? 'bg-gray-100 text-gray-800' }}">
                                    {{ $typeLabels[$type] ?? $type }}
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td class="py-1 pr-4 text-gray-500">대표자</td>
                            <td class="py-1 text-gray-900">{{ $tenant->ceo_name ?? '-' }}</td>
                            <td class="py-1 pr-4 text-gray-500">사업자번호</td>
                            <td class="py-1 text-gray-900">{{ $tenant->business_num ?? '-' }}</td>
                            <td class="py-1 pr-4 text-gray-500">상태</td>
                            <td class="py-1">
                                <span class="px-2 py-0.5 text-xs font-semibold rounded-full
                                    {{ $tenant->status_badge_color === 'success' ? 'bg-green-100 text-green-800' : '' }}
                                    {{ $tenant->status_badge_color === 'warning' ? 'bg-yellow-100 text-yellow-800' : '' }}
                                    {{ $tenant->status_badge_color === 'error' ? 'bg-red-100 text-red-800' : '' }}">
                                    {{ $tenant->status_label }}
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td class="py-1 pr-4 text-gray-500">이메일</td>
                            <td class="py-1 text-gray-900">{{ $tenant->email ?? '-' }}</td>
                            <td class="py-1 pr-4 text-gray-500">전화번호</td>
                            <td class="py-1 text-gray-900">{{ $tenant->phone ?? '-' }}</td>
                            <td class="py-1 pr-4 text-gray-500">등록일</td>
                            <td class="py-1 text-gray-900">{{ $tenant->created_at?->format('Y-m-d') ?? '-' }}</td>
                        </tr>
                        <tr>
                            <td class="py-1 pr-4 text-gray-500">주소</td>
                            <td colspan="5" class="py-1 text-gray-900">{{ $tenant->address ?? '-' }}</td>
                        </tr>
                    </tbody>
                </table>

                {{-- 저장소 사용량 --}}
                <div class="mt-4 pt-4 border-t border-gray-200">
                    <div class="flex items-center justify-between mb-2">
                        <span class="text-sm font-medium text-gray-700">저장소 사용량</span>
                        <span class="text-sm text-gray-500">{{ $tenant->storage_usage_formatted }}</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-3">
                        <div class="h-3 rounded-full transition-all duration-300
                            {{ $tenant->storage_badge_color === 'error' ? 'bg-red-500' : '' }}
                            {{ $tenant->storage_badge_color === 'warning' ? 'bg-yellow-500' : '' }}
                            {{ $tenant->storage_badge_color === 'success' ? 'bg-green-500' : '' }}"
                             style="width: {{ min($tenant->storage_usage_percent, 100) }}%"></div>
                    </div>
                    <div class="flex items-center justify-between mt-1">
                        <span class="text-xs text-gray-500">{{ $tenant->storage_usage_percent }}% 사용</span>
                        @if($tenant->storage_usage_percent >= 90)
                        <span class="text-xs text-red-600 font-medium">용량 부족 경고</span>
                        @elseif($tenant->storage_usage_percent >= 70)
                        <span class="text-xs text-yellow-600 font-medium">용량 주의</span>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>

    {{-- 탭 메뉴 --}}
    <div class="border-b border-gray-200 mb-4">
        <nav class="flex -mb-px gap-1">
            <button type="button"
                    data-tab-btn="users"
                    onclick="TenantModal.switchTab('users')"
                    class="px-4 py-2 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">
                사용자 <span class="ml-1 px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded">{{ $tenant->users_count ?? 0 }}</span>
            </button>
            <button type="button"
                    data-tab-btn="departments"
                    onclick="TenantModal.switchTab('departments')"
                    class="px-4 py-2 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">
                부서 <span class="ml-1 px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded">{{ $tenant->departments_count ?? 0 }}</span>
            </button>
            <button type="button"
                    data-tab-btn="roles"
                    onclick="TenantModal.switchTab('roles')"
                    class="px-4 py-2 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">
                역할 <span class="ml-1 px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded">{{ $tenant->roles_count ?? 0 }}</span>
            </button>
            <button type="button"
                    data-tab-btn="menus"
                    onclick="TenantModal.switchTab('menus')"
                    class="px-4 py-2 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">
                메뉴 <span class="ml-1 px-1.5 py-0.5 text-xs bg-gray-100 text-gray-600 rounded">{{ $tenant->menus_count ?? 0 }}</span>
            </button>
            <button type="button"
                    data-tab-btn="subscription"
                    onclick="TenantModal.switchTab('subscription')"
                    class="px-4 py-2 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">
                구독 정보
            </button>
        </nav>
    </div>

    {{-- 탭 콘텐츠 --}}
    <div id="tenant-modal-tab-content" class="min-h-[200px]">
        <div class="text-center py-12 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="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
            </svg>
            <p>위 탭을 선택하여 상세 정보를 확인하세요.</p>
        </div>
    </div>

</div>