<?php $__env->startSection('title', 'Tenants Directory'); ?>

<?php $__env->startSection('content'); ?>
<div class="space-y-6">
    <div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
        <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">Master database of all registered typing center SaaS tenants.</p>
        </div>
        <a href="<?php echo e(route('platform.tenants.create')); ?>" class="inline-flex items-center px-4 py-2 bg-sky-600 hover:bg-sky-700 text-white font-semibold text-xs rounded-xl shadow-sm transition-all">
            + New Tenant Wizard
        </a>
    </div>

    <!-- Search & Filters Bar (Requirement 7) -->
    <div class="bg-white dark:bg-slate-800 rounded-3xl p-4 border border-slate-200 dark:border-slate-700/60 shadow-sm">
        <form action="<?php echo e(route('platform.tenants')); ?>" method="GET" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-5 gap-3 text-xs">
            <div>
                <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search ID, Company, TRN, License..." class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white">
            </div>

            <div>
                <select name="emirate" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white">
                    <option value="">All Emirates</option>
                    <option value="Dubai" <?php echo e(request('emirate') == 'Dubai' ? 'selected' : ''); ?>>Dubai</option>
                    <option value="Abu Dhabi" <?php echo e(request('emirate') == 'Abu Dhabi' ? 'selected' : ''); ?>>Abu Dhabi</option>
                    <option value="Sharjah" <?php echo e(request('emirate') == 'Sharjah' ? 'selected' : ''); ?>>Sharjah</option>
                </select>
            </div>

            <div>
                <select name="status" class="w-full px-3 py-2 bg-slate-50 dark:bg-slate-900 border border-slate-300 dark:border-slate-700 rounded-xl text-slate-900 dark:text-white">
                    <option value="">All Statuses</option>
                    <option value="active" <?php echo e(request('status') == 'active' ? 'selected' : ''); ?>>Active</option>
                    <option value="trial" <?php echo e(request('status') == 'trial' ? 'selected' : ''); ?>>Trial</option>
                    <option value="payment_due" <?php echo e(request('status') == 'payment_due' ? 'selected' : ''); ?>>Payment Due</option>
                    <option value="suspended" <?php echo e(request('status') == 'suspended' ? 'selected' : ''); ?>>Suspended</option>
                </select>
            </div>

            <div class="flex items-center space-x-2 rtl:space-x-reverse md:col-span-2">
                <button type="submit" class="w-full py-2 bg-sky-600 text-white font-bold rounded-xl hover:bg-sky-700">Filter Tenants</button>
                <a href="<?php echo e(route('platform.tenants')); ?>" class="py-2 px-3 bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-200 font-semibold rounded-xl">Clear</a>
            </div>
        </form>
    </div>

    <!-- Tenants Table (Requirement 7, 8) -->
    <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">Tenant Company</th>
                        <th class="px-6 py-4">TRN / License</th>
                        <th class="px-6 py-4">Emirate</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>
                        <th class="px-6 py-4 text-right rtl:text-left">Actions</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-slate-200 dark:divide-slate-700/60 font-medium">
                    <?php $__currentLoopData = $tenants; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tenant): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr class="hover:bg-slate-50 dark:hover:bg-slate-700/30 transition-colors">
                            <td class="px-6 py-4">
                                <div class="font-bold text-slate-900 dark:text-white"><?php echo e($tenant->company_name); ?></div>
                                <div class="text-[11px] text-slate-400 font-normal"><?php echo e($tenant->email); ?> • <?php echo e($tenant->mobile); ?></div>
                            </td>
                            <td class="px-6 py-4 font-mono">
                                <div class="text-slate-900 dark:text-white font-bold"><?php echo e($tenant->trn ?? 'N/A'); ?></div>
                                <div class="text-[10px] text-slate-400"><?php echo e($tenant->trade_license_number ?? 'No License'); ?></div>
                            </td>
                            <td class="px-6 py-4 text-slate-700 dark:text-slate-300 font-medium"><?php echo e($tenant->emirate); ?></td>
                            <td class="px-6 py-4">
                                <span class="font-bold text-sky-600 dark:text-sky-400"><?php echo e(count($tenant->branches)); ?> Branches</span>
                            </td>
                            <td class="px-6 py-4">
                                <span class="px-2.5 py-1 rounded-lg bg-purple-100 dark:bg-purple-950 text-purple-700 dark:text-purple-300 font-bold text-[11px]">
                                    <?php echo e($tenant->subscription->plan->name ?? 'Professional Plan'); ?>

                                </span>
                            </td>
                            <td class="px-6 py-4">
                                <?php if($tenant->status === 'active'): ?>
                                    <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>
                                <?php elseif($tenant->status === 'trial'): ?>
                                    <span class="px-2.5 py-0.5 rounded-full bg-sky-100 dark:bg-sky-950 text-sky-700 dark:text-sky-300 text-[10px] font-bold">Trial</span>
                                <?php elseif($tenant->status === 'payment_due'): ?>
                                    <span class="px-2.5 py-0.5 rounded-full bg-amber-100 dark:bg-amber-950 text-amber-700 dark:text-amber-300 text-[10px] font-bold">Payment Due</span>
                                <?php else: ?>
                                    <span class="px-2.5 py-0.5 rounded-full bg-rose-100 dark:bg-rose-950 text-rose-700 dark:text-rose-300 text-[10px] font-bold"><?php echo e(ucfirst($tenant->status)); ?></span>
                                <?php endif; ?>
                            </td>
                            <td class="px-6 py-4 text-right rtl:text-left space-x-2 rtl:space-x-reverse">
                                <a href="<?php echo e(route('platform.tenants.show', $tenant->id)); ?>" class="text-sky-600 hover:text-sky-800 dark:text-sky-400 font-bold">Tenant 360</a>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
        </div>
        <div class="p-4 border-t border-slate-200 dark:border-slate-700">
            <?php echo e($tenants->links()); ?>

        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\typingcenter\resources\views\platform\tenants\index.blade.php ENDPATH**/ ?>