<div class="d-flex align-items-center mb-3">
    <a href="<?= url('/SuperAdmin') ?>" class="btn btn-sm btn-outline-secondary me-2"><i class="fas fa-arrow-left"></i></a>
    <h5 class="fw-bold mb-0"><?= $tenant ? 'Edit Tenant' : 'New Tenant' ?></h5>
</div>

<div class="rs-card p-3" style="max-width: 500px;">
    <form method="post" action="<?= url('/SuperAdmin/saveTenant') ?>">
        <input type="hidden" name="_csrf" value="<?= e($csrf) ?>">
        <input type="hidden" name="tenant_id" value="<?= (int) ($tenant['tenant_id'] ?? 0) ?>">

        <div class="mb-3">
            <label class="form-label small">Company Name</label>
            <input type="text" name="name" class="form-control" value="<?= e($tenant['name'] ?? '') ?>" required>
        </div>
        <div class="mb-3">
            <label class="form-label small">Subdomain <span class="text-muted">(optional)</span></label>
            <input type="text" name="subdomain" class="form-control" value="<?= e($tenant['subdomain'] ?? '') ?>" placeholder="e.g. acme">
        </div>
        <div class="mb-3">
            <label class="form-label small">Status</label>
            <select name="status" class="form-select">
                <option value="active" <?= ($tenant['status'] ?? '') === 'active' ? 'selected' : '' ?>>Active</option>
                <option value="inactive" <?= ($tenant['status'] ?? '') === 'inactive' ? 'selected' : '' ?>>Inactive</option>
                <option value="suspended" <?= ($tenant['status'] ?? '') === 'suspended' ? 'selected' : '' ?>>Suspended</option>
            </select>
        </div>

        <button type="submit" class="btn btn-primary">Save</button>
        <a href="<?= url('/SuperAdmin') ?>" class="btn btn-outline-secondary ms-2">Cancel</a>
    </form>
</div>