{{-- 테넌트 모달 - 구독 정보 탭 --}}
<div class="space-y-4">
    {{-- 헤더 --}}
    <div class="flex items-center justify-between">
        <h3 class="text-sm font-medium text-gray-700">구독 정보</h3>
    </div>

    {{-- 구독 상태 카드 --}}
    <div class="bg-gradient-to-r from-blue-50 to-indigo-50 rounded-lg p-4 border border-blue-100">
        <div class="flex items-center justify-between">
            <div>
                <span class="text-sm text-gray-500">현재 플랜</span>
                <h4 class="text-xl font-bold text-gray-900 mt-1">
                    {{ $subscription->plan_name ?? '기본 플랜' }}
                </h4>
            </div>
            <div class="text-right">
                @php
                    $statusColors = [
                        'active' => 'bg-green-100 text-green-800',
                        'trial' => 'bg-blue-100 text-blue-800',
                        'expired' => 'bg-red-100 text-red-800',
                        'cancelled' => 'bg-gray-100 text-gray-800',
                    ];
                    $statusLabels = [
                        'active' => '활성',
                        'trial' => '체험판',
                        'expired' => '만료',
                        'cancelled' => '취소됨',
                    ];
                    $status = $subscription->status ?? 'active';
                @endphp
                <span class="px-3 py-1 text-sm font-semibold rounded-full {{ $statusColors[$status] ?? 'bg-gray-100 text-gray-800' }}">
                    {{ $statusLabels[$status] ?? $status }}
                </span>
            </div>
        </div>
    </div>

    {{-- 구독 상세 정보 --}}
    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
        {{-- 기간 정보 --}}
        <div class="border border-gray-200 rounded-lg p-4">
            <h5 class="text-xs font-medium text-gray-500 uppercase mb-3">기간 정보</h5>
            <div class="space-y-2">
                <div class="flex justify-between text-sm">
                    <span class="text-gray-500">시작일</span>
                    <span class="text-gray-900">{{ $subscription->started_at ?? $tenant->created_at?->format('Y-m-d') ?? '-' }}</span>
                </div>
                <div class="flex justify-between text-sm">
                    <span class="text-gray-500">만료일</span>
                    <span class="text-gray-900">{{ $subscription->expires_at ?? '-' }}</span>
                </div>
                <div class="flex justify-between text-sm">
                    <span class="text-gray-500">갱신 예정일</span>
                    <span class="text-gray-900">{{ $subscription->next_billing_date ?? '-' }}</span>
                </div>
            </div>
        </div>

        {{-- 사용량 정보 --}}
        <div class="border border-gray-200 rounded-lg p-4">
            <h5 class="text-xs font-medium text-gray-500 uppercase mb-3">사용량</h5>
            <div class="space-y-3">
                {{-- 사용자 수 --}}
                <div>
                    <div class="flex justify-between text-sm mb-1">
                        <span class="text-gray-500">사용자</span>
                        <span class="text-gray-900">
                            {{ $usage->users_count ?? $tenant->users_count ?? 0 }} / {{ $subscription->max_users ?? '무제한' }}
                        </span>
                    </div>
                    @if(isset($subscription->max_users) && $subscription->max_users > 0)
                        @php
                            $usersPercent = min(100, (($usage->users_count ?? $tenant->users_count ?? 0) / $subscription->max_users) * 100);
                        @endphp
                        <div class="w-full bg-gray-200 rounded-full h-1.5">
                            <div class="bg-blue-600 h-1.5 rounded-full" style="width: {{ $usersPercent }}%"></div>
                        </div>
                    @endif
                </div>

                {{-- 저장 용량 --}}
                <div>
                    <div class="flex justify-between text-sm mb-1">
                        <span class="text-gray-500">저장 용량</span>
                        <span class="text-gray-900">
                            {{ $usage->storage_used ?? '0 MB' }} / {{ $subscription->max_storage ?? '무제한' }}
                        </span>
                    </div>
                    @if(isset($subscription->max_storage_mb) && $subscription->max_storage_mb > 0)
                        @php
                            $storagePercent = min(100, (($usage->storage_used_mb ?? 0) / $subscription->max_storage_mb) * 100);
                        @endphp
                        <div class="w-full bg-gray-200 rounded-full h-1.5">
                            <div class="bg-green-600 h-1.5 rounded-full" style="width: {{ $storagePercent }}%"></div>
                        </div>
                    @endif
                </div>
            </div>
        </div>
    </div>

    {{-- 포함된 기능 --}}
    <div class="border border-gray-200 rounded-lg p-4">
        <h5 class="text-xs font-medium text-gray-500 uppercase mb-3">포함된 기능</h5>
        <div class="grid grid-cols-2 md:grid-cols-3 gap-2">
            @php
                $features = $subscription->features ?? [
                    ['name' => '기본 기능', 'enabled' => true],
                    ['name' => '사용자 관리', 'enabled' => true],
                    ['name' => '부서 관리', 'enabled' => true],
                    ['name' => '역할 관리', 'enabled' => true],
                    ['name' => 'API 접근', 'enabled' => $subscription->has_api_access ?? false],
                    ['name' => '고급 보고서', 'enabled' => $subscription->has_advanced_reports ?? false],
                ];
            @endphp
            @foreach($features as $feature)
                <div class="flex items-center gap-2 text-sm">
                    @if($feature['enabled'] ?? false)
                        <svg class="w-4 h-4 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
                        </svg>
                        <span class="text-gray-900">{{ $feature['name'] }}</span>
                    @else
                        <svg class="w-4 h-4 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                        </svg>
                        <span class="text-gray-400">{{ $feature['name'] }}</span>
                    @endif
                </div>
            @endforeach
        </div>
    </div>
</div>
