<div class="row g-4">
    <div class="col-12">
        <div class="d-flex flex-column flex-lg-row justify-content-between align-items-lg-center gap-3 mb-2">
            <div>
                <h1 class="h3 mb-1">Diagnóstico do sistema</h1>
                <p class="text-muted mb-0">Use esta tela antes de publicar para validar ambiente, banco, uploads e rotas principais.</p>
            </div>
            <div class="d-flex gap-2 flex-wrap">
                <a href="<?= e(baseUrl('admin/admissoes')) ?>" class="btn btn-outline-secondary">Voltar ao painel</a>
                <a href="<?= e(baseUrl('admin/diagnostico')) ?>" class="btn btn-dark">Atualizar diagnóstico</a>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div class="card border-0 shadow-sm h-100">
            <div class="card-body">
                <div class="text-muted small mb-2">Checks aprovados</div>
                <div class="display-6 fw-semibold text-success"><?= e((string) $summary['ok']) ?></div>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div class="card border-0 shadow-sm h-100">
            <div class="card-body">
                <div class="text-muted small mb-2">Warnings</div>
                <div class="display-6 fw-semibold text-warning"><?= e((string) $summary['warning']) ?></div>
                <div class="small text-muted">Reservado para futuras checagens graduais.</div>
            </div>
        </div>
    </div>

    <div class="col-md-4">
        <div class="card border-0 shadow-sm h-100">
            <div class="card-body">
                <div class="text-muted small mb-2">Falhas críticas</div>
                <div class="display-6 fw-semibold text-danger"><?= e((string) $summary['error']) ?></div>
            </div>
        </div>
    </div>

    <div class="col-12">
        <div class="card border-0 shadow-sm">
            <div class="card-body p-0">
                <div class="table-responsive">
                    <table class="table table-hover align-middle mb-0">
                        <thead class="table-light">
                            <tr>
                                <th>Grupo</th>
                                <th>Check</th>
                                <th>Status</th>
                                <th>Detalhes</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($checks as $check): ?>
                                <tr>
                                    <td><span class="badge rounded-pill text-bg-light text-uppercase"><?= e($check['group']) ?></span></td>
                                    <td class="fw-semibold"><?= e($check['label']) ?></td>
                                    <td>
                                        <?php if ($check['status'] === 'ok'): ?>
                                            <span class="badge text-bg-success">OK</span>
                                        <?php elseif ($check['status'] === 'warning'): ?>
                                            <span class="badge text-bg-warning">Warning</span>
                                        <?php else: ?>
                                            <span class="badge text-bg-danger">Falha</span>
                                        <?php endif; ?>
                                    </td>
                                    <td class="text-muted small"><?= e($check['details']) ?></td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="col-12">
        <div class="alert alert-secondary rounded-4 mb-0">
            <div class="fw-semibold mb-2">Próximos passos recomendados</div>
            <ul class="mb-0 ps-3">
                <li>Rodar <code>php scripts/preflight.php</code> no servidor de homologação.</li>
                <li>Criar massa fake com <code>php scripts/seed_homologation.php --force</code>.</li>
                <li>Executar smoke test com <code>php scripts/run_smoke.php</code>.</li>
                <li>Conferir anexos, PDF e permissões de escrita em <code>storage/uploads</code>.</li>
            </ul>
        </div>
    </div>
</div>
