<?= $this->extend('layouts/app') ?>

<?= $this->section('content') ?>
<div class="core-card p-4">
    <form method="post" action="<?= site_url('/settings') ?>">
        <?= csrf_field() ?>
        <?php foreach ($groups as $group => $settings): ?>
            <h2 class="h5 mt-2 mb-3"><?= esc(ucfirst($group)) ?></h2>
            <div class="row g-3 mb-4">
                <?php foreach ($settings as $setting): ?>
                    <div class="col-md-6">
                        <label class="form-label" for="<?= esc($setting['setting_key']) ?>"><?= esc($setting['setting_key']) ?></label>
                        <input class="form-control" id="<?= esc($setting['setting_key']) ?>" name="settings[<?= esc($setting['setting_key']) ?>]" value="<?= (int) $setting['is_encrypted'] === 1 ? '' : esc($setting['setting_value'] ?? '') ?>" placeholder="<?= (int) $setting['is_encrypted'] === 1 ? 'Valeur chiffrée enregistrée' : '' ?>">
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endforeach; ?>
        <button class="btn btn-primary" type="submit">Enregistrer</button>
    </form>
</div>
<?= $this->endSection() ?>
