@extends('layouts.app')

@section('title', 'SaaS Tenants Directory')

@section('content')
<div class="space-y-6">
    <div>
        <h1 class="text-xl font-bold text-slate-900 dark:text-white">Typing Center Tenants Directory</h1>
        <p class="text-xs text-slate-500 dark:text-slate-400">All registered tenant organizations on the SaaS platform.</p>
    </div>

    <div class="bg-white dark:bg-slate-800 rounded-3xl border border-slate-200 dark:border-slate-700/60 shadow-sm overflow-hidden">
        <div class="overflow-x-auto">
            <table class="w-full text-left rtl:text-right text-xs">
                <thead class="bg-slate-50 dark:bg-slate-900/60 border-b border-slate-200 dark:border-slate-700 text-slate-500 uppercase tracking-wider font-bold">
                    <tr>
                        <th class="px-6 py-4">Company Name</th>
                        <th class="px-6 py-4">Emirate</th>
                        <th class="px-6 py-4">TRN</th>
                        <th class="px-6 py-4">Branches</th>
                        <th class="px-6 py-4">Subscription Plan</th>
                        <th class="px-6 py-4">Status</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-slate-200 dark:divide-slate-700/60 font-medium">
                    @foreach($tenants as $tenant)
                        <tr class="hover:bg-slate-50 dark:hover:bg-slate-700/30">
                            <td class="px-6 py-4">
                                <div class="font-bold text-slate-900 dark:text-white">{{ $tenant->company_name }}</div>
                                <div class="text-[11px] text-slate-400 font-normal">{{ $tenant->email }}</div>
                            </td>
                            <td class="px-6 py-4 font-semibold text-slate-700 dark:text-slate-300">{{ $tenant->emirate }}</td>
                            <td class="px-6 py-4 font-mono font-bold text-slate-700 dark:text-slate-300">{{ $tenant->trn ?? 'N/A' }}</td>
                            <td class="px-6 py-4 font-bold text-sky-600">{{ count($tenant->branches) }} Branches</td>
                            <td class="px-6 py-4">
                                <span class="px-2.5 py-0.5 rounded-full bg-purple-100 dark:bg-purple-950 text-purple-700 dark:text-purple-300 text-[10px] font-bold">
                                    {{ $tenant->subscription->plan->name ?? 'Professional Plan' }}
                                </span>
                            </td>
                            <td class="px-6 py-4">
                                <span class="px-2.5 py-0.5 rounded-full bg-emerald-100 dark:bg-emerald-950 text-emerald-700 dark:text-emerald-300 text-[10px] font-bold">Active</span>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
        <div class="p-4 border-t border-slate-200 dark:border-slate-700">
            {{ $tenants->links() }}
        </div>
    </div>
</div>
@endsection
