<?= $this->extend('admin/layouts/main') ?>
<?= $this->section('content') ?>

<div class="row g-3 mb-3">
    <div class="col-lg-4">
        <div class="stat-card d-flex align-items-center justify-content-between">
            <div>
                <div class="stat-label">Control Database</div>
                <div class="fw-bold text-success"><i class="bi bi-check-circle-fill me-1"></i>Connected</div>
            </div>
        </div>
    </div>
    <div class="col-lg-4">
        <div class="stat-card">
            <div class="stat-label">PHP Version</div>
            <div class="fw-bold"><?= esc($phpVersion) ?></div>
        </div>
    </div>
    <div class="col-lg-4">
        <div class="stat-card">
            <div class="stat-label">CodeIgniter Version</div>
            <div class="fw-bold"><?= esc($ciVersion) ?></div>
        </div>
    </div>
</div>

<div class="card">
    <div class="card-header">Hotel Database Connectivity</div>
    <div class="table-responsive">
        <table class="table mb-0 align-middle">
            <thead><tr><th>Hotel</th><th>Database</th><th>Status</th></tr></thead>
            <tbody>
            <?php if (empty($checks)): ?>
                <tr><td colspan="3" class="text-center text-muted py-4">No active hotels to check.</td></tr>
            <?php endif; ?>
            <?php foreach ($checks as $c): ?>
                <tr>
                    <td><a href="<?= site_url('admin/tenants/' . $c['tenant']->id) ?>" class="text-decoration-none"><?= esc($c['tenant']->hotel_name) ?></a></td>
                    <td class="text-muted"><?= esc($c['tenant']->db_name) ?></td>
                    <td>
                        <?php if ($c['ok']): ?>
                            <span class="badge bg-success"><i class="bi bi-check-circle me-1"></i>OK</span>
                        <?php else: ?>
                            <span class="badge bg-danger"><i class="bi bi-x-circle me-1"></i>Unreachable</span>
                        <?php endif; ?>
                    </td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>

<?= $this->endSection() ?>
