<?php
/** @var \BotGuard\Core\View $this @var \BotGuard\Core\Csrf $csrf @var array $data @var array $timezones @var array $providers */
$this->layout('install.layout');
$selectedTz = $data['app_timezone'] ?? 'UTC';
$selectedProvider = $data['captcha_provider'] ?? 'puzzle';
?>
<h2 class="h4 mb-1">Website Settings</h2>
<p class="text-secondary small mb-4">Branding, base URL and the default verification challenge.</p>

<form method="post" action="/install/website" novalidate>
    <?= $csrf->field() ?>
    <div class="row g-3">
        <div class="col-md-6 mb-3">
            <label class="form-label">Site name</label>
            <input type="text" name="app_name" class="form-control" value="<?= e($data['app_name'] ?? 'BotGuard') ?>" required>
        </div>
        <div class="col-md-6 mb-3">
            <label class="form-label">Base URL</label>
            <input type="url" name="app_url" class="form-control" value="<?= e($data['app_url'] ?? '') ?>" placeholder="https://verify.example.com" required>
        </div>
    </div>
    <div class="row g-3">
        <div class="col-md-6 mb-3">
            <label class="form-label">Timezone</label>
            <select name="app_timezone" class="form-select">
                <?php foreach ($timezones as $tz): ?>
                    <option value="<?= e($tz) ?>" <?= $tz === $selectedTz ? 'selected' : '' ?>><?= e($tz) ?></option>
                <?php endforeach; ?>
            </select>
        </div>
        <div class="col-md-6 mb-3">
            <label class="form-label">Default challenge</label>
            <select name="captcha_provider" class="form-select">
                <?php foreach ($providers as $p): ?>
                    <option value="<?= e($p) ?>" <?= $p === $selectedProvider ? 'selected' : '' ?>>
                        <?= e(ucfirst($p)) ?><?= $p === 'puzzle' ? ' (self-hosted, no keys)' : ' (requires API keys)' ?>
                    </option>
                <?php endforeach; ?>
            </select>
        </div>
    </div>
    <div class="d-flex justify-content-between mt-4">
        <a href="/install/administrator" class="btn btn-outline-secondary">Back</a>
        <button class="btn btn-primary" type="submit">Review <i class="bi bi-arrow-right"></i></button>
    </div>
</form>
