<?php
/** @var \BotGuard\Core\View $this @var \BotGuard\Core\Csrf $csrf @var array $data */
$this->layout('install.layout');
?>
<h2 class="h4 mb-1">Database Connection</h2>
<p class="text-secondary small mb-4">Enter your MySQL 8 details. We'll test the connection before continuing.</p>

<form method="post" action="/install/database" novalidate>
    <?= $csrf->field() ?>
    <div class="row g-3">
        <div class="col-md-8 mb-3">
            <label class="form-label">Host</label>
            <input type="text" name="db_host" class="form-control" value="<?= e($data['db_host'] ?? '127.0.0.1') ?>" required>
        </div>
        <div class="col-md-4 mb-3">
            <label class="form-label">Port</label>
            <input type="number" name="db_port" class="form-control" value="<?= e($data['db_port'] ?? 3306) ?>" required>
        </div>
    </div>
    <div class="mb-3">
        <label class="form-label">Database name</label>
        <input type="text" name="db_database" class="form-control" value="<?= e($data['db_database'] ?? 'botguard') ?>" required>
        <div class="form-text">The database must already exist. Create it with:
            <code>CREATE DATABASE botguard CHARACTER SET utf8mb4;</code></div>
    </div>
    <div class="row g-3">
        <div class="col-md-6 mb-3">
            <label class="form-label">Username</label>
            <input type="text" name="db_username" class="form-control" value="<?= e($data['db_username'] ?? 'root') ?>" required>
        </div>
        <div class="col-md-6 mb-3">
            <label class="form-label">Password</label>
            <input type="password" name="db_password" class="form-control" value="<?= e($data['db_password'] ?? '') ?>">
        </div>
    </div>
    <div class="d-flex justify-content-between mt-4">
        <a href="/install/requirements" class="btn btn-outline-secondary">Back</a>
        <button class="btn btn-primary" type="submit"><i class="bi bi-plug"></i> Test &amp; continue</button>
    </div>
</form>
