<?php require __DIR__ . '/../layouts/header.php'; ?>

<div class="card border-0 shadow-sm rounded-4 mx-auto" style="max-width:900px;">
    <div class="card-body p-4">
        <h1 class="fw-bold mb-3"><?= e(trans('installer_wizard')) ?></h1>

        <?php if (!empty($installed)): ?>
            <div class="alert alert-info rounded-4"><?= e(trans('install_lock_exists')) ?></div>
        <?php else: ?>
            <div class="alert alert-warning rounded-4">Review checks, then run installer.</div>
        <?php endif; ?>

        <div class="table-responsive mb-4">
            <table class="table align-middle mb-0">
                <thead class="table-light">
                    <tr>
                        <th><?= e(trans('setting_key')) ?></th>
                        <th><?= e(trans('status')) ?></th>
                        <th><?= e(trans('setting_value')) ?></th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($checks as $row): ?>
                        <tr>
                            <td><?= e((string) $row['label']) ?></td>
                            <td>
                                <?php if (!empty($row['ok'])): ?>
                                    <span class="badge bg-success"><?= e(trans('health_ok')) ?></span>
                                <?php else: ?>
                                    <span class="badge bg-danger"><?= e(trans('health_fail')) ?></span>
                                <?php endif; ?>
                            </td>
                            <td><?= e((string) $row['value']) ?></td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>

        <?php if (empty($installed)): ?>
            <form method="post" action="<?= e(base_path('install')) ?>">
                <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
                <button type="submit" class="btn btn-success rounded-3"><?= e(trans('run_installer')) ?></button>
            </form>
        <?php endif; ?>
    </div>
</div>

<?php require __DIR__ . '/../layouts/footer.php'; ?>
