<div class="sa-card mb-8">
    <div class="flex justify-between items-center mb-6">
        <h3 class="text-xl font-bold">Platform Tenants</h3>
        <div class="flex gap-4">
            <div class="search-box">
                <input type="text" placeholder="Search businesses..." class="form-control" style="width: 260px;">
            </div>
            <button class="btn btn-outline btn-sm">Export XML/CSV</button>
        </div>
    </div>

    <div class="table-wrapper">
        <table>
            <thead>
                <tr>
                    <th>Business / URL</th>
                    <th>Email</th>
                    <th>Joined At</th>
                    <th>Plan</th>
                    <th>Status</th>
                    <th class="text-right">Action</th>
                </tr>
            </thead>
            <tbody>
                <?php if (empty($tenants)): ?>
                <tr>
                    <td colspan="6" class="p-8 text-center text-muted">No tenants found on the platform yet.</td>
                </tr>
                <?php else: foreach ($tenants as $t): ?>
                <tr>
                    <td>
                        <div class="font-bold"><?= e($t['business_name']) ?></div>
                        <div class="text-xs text-muted">/t/<?= e($t['slug']) ?></div>
                    </td>
                    <td class="text-sm"><?= e($t['business_email']) ?></td>
                    <td class="text-sm"><?= date('M j, Y', strtotime($t['created_at'])) ?></td>
                    <td><span class="badge badge-primary">Plan TBD</span></td>
                    <td>
                        <?php 
                        $statusBadge = [
                            'active'    => 'badge-success',
                            'trial'     => 'badge-info',
                            'suspended' => 'badge-danger',
                            'expired'   => 'badge-muted'
                        ];
                        $badge = $statusBadge[$t['status']] ?? 'badge-muted';
                        ?>
                        <span class="badge <?= $badge ?>"><?= ucfirst(e($t['status'])) ?></span>
                    </td>
                    <td class="text-right">
                        <a href="<?= APP_URL ?>/superadmin/tenants/<?= $t['id'] ?>" class="btn btn-ghost btn-sm">Details</a>
                    </td>
                </tr>
                <?php endforeach; endif; ?>
            </tbody>
        </table>
    </div>
</div>
