<?php
/** @var \BotGuard\Core\View $this @var \BotGuard\Core\Csrf $csrf @var array|null $config */
$this->layout('layouts.app');
?>
<h1 class="h4 mb-3">Redirect Configuration</h1>

<div class="row g-4">
    <div class="col-lg-7">
        <div class="card border-0 shadow-sm">
            <div class="card-body">
                <form method="post" action="/dashboard/redirects" novalidate>
                    <?= $csrf->field() ?>
                    <div class="mb-3">
                        <label class="form-label">Primary destination URL</label>
                        <input type="url" name="primary_url" class="form-control"
                               value="<?= e($config['primary_url'] ?? '') ?>" placeholder="https://your-site.com/app" required>
                        <div class="form-text">Verified <strong>humans</strong> are redirected here.</div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Alternate destination URL</label>
                        <input type="url" name="alternate_url" class="form-control"
                               value="<?= e($config['alternate_url'] ?? '') ?>" placeholder="https://your-site.com/verify-failed">
                        <div class="form-text"><strong>Suspicious</strong> sessions are sent here (leave blank to show the block page).</div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Block message</label>
                        <textarea name="block_message" class="form-control" rows="2" maxlength="500"><?= e($config['block_message'] ?? '') ?></textarea>
                        <div class="form-text">Shown to <strong>bot</strong>-classified sessions on the block page.</div>
                    </div>
                    <button class="btn btn-primary" type="submit"><i class="bi bi-save"></i> Save configuration</button>
                </form>
            </div>
        </div>
    </div>
    <div class="col-lg-5">
        <div class="card border-0 bg-body-tertiary">
            <div class="card-body">
                <h6><i class="bi bi-info-circle text-primary"></i> How destinations are used</h6>
                <ul class="small text-secondary mb-0 ps-3">
                    <li><strong>Human</strong> (high score) &rarr; Primary URL</li>
                    <li><strong>Suspicious</strong> (mid score) &rarr; Alternate URL, or block page if unset</li>
                    <li><strong>Bot</strong> (low score) &rarr; Block page with your message</li>
                </ul>
                <hr>
                <p class="small text-secondary mb-0">Every decision is logged for auditing under
                    <a href="/dashboard/logs">Detection Logs</a>. Score bands are configured by your administrator.</p>
            </div>
        </div>
    </div>
</div>
