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

<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="fw-bold mb-0"><?= e(trans('system_health')) ?></h1>
    <a href="<?= e(base_path('admin')) ?>" class="btn ec-btn btn-outline-secondary rounded-3"><?= e(trans('back')) ?></a>
</div>


<div class="ec-card   mb-4">
    <div class="ec-card-body d-flex gap-2 flex-wrap">
        <a href="<?= e(base_path('install')) ?>" class="btn ec-btn btn-outline-primary rounded-3"><?= e(trans('installer')) ?></a>
        <a href="<?= e(base_path('upgrade')) ?>" class="btn ec-btn btn-outline-success rounded-3"><?= e(trans('upgrade')) ?></a>
        <a href="<?= e(base_path('admin/custom-fields')) ?>" class="btn ec-btn btn-outline-dark rounded-3"><?= e(trans('custom_fields')) ?></a>
    </div>
</div>

<div class="row g-4 mb-4">
    <div class="col-lg-7">
        <div class="ec-card  ">
            <div class="ec-card-body">
                <h3 class="h5 fw-bold mb-3"><?= e(trans('environment_check')) ?></h3>
                <div class="table-responsive">
                    <table class="table ec-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 $key => $row): ?>
                                <tr>
                                    <td><?= e((string) $row['label']) ?></td>
                                    <td>
                                        <?php if (!empty($row['ok'])): ?>
                                            <span class="badge ec-badge bg-success"><?= e(trans('health_ok')) ?></span>
                                        <?php else: ?>
                                            <span class="badge ec-badge bg-danger"><?= e(trans('health_fail')) ?></span>
                                        <?php endif; ?>
                                    </td>
                                    <td><?= e((string) $row['value']) ?></td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div class="col-lg-5">
        <div class="ec-card   mb-4">
            <div class="ec-card-body">
                <h3 class="h5 fw-bold mb-3"><?= e(trans('backup_tools')) ?></h3>
                <form method="post" action="<?= e(base_path('admin/system/backup')) ?>">
                    <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
                    <button type="submit" class="btn ec-btn btn-outline-dark rounded-3 w-100"><?= e(trans('run_backup')) ?></button>
                </form>
            </div>
        </div>

        <div class="ec-card  ">
            <div class="ec-card-body">
                <h3 class="h5 fw-bold mb-3"><?= e(trans('demo_seed')) ?></h3>
                <form method="post" action="<?= e(base_path('admin/system/demo-seed')) ?>">
                    <input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
                    <button type="submit" class="btn ec-btn btn-outline-primary rounded-3 w-100"><?= e(trans('run_demo_seed')) ?></button>
                </form>
            </div>
        </div>
    </div>
</div>

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