<?php ob_start(); ?>

<h2><?= __('installer.db_title') ?></h2>
<p><?= __('installer.db_text') ?></p>

<?php if (!empty($error)): ?>
<div class="alert alert-error"><?= e($error) ?></div>
<?php endif; ?>

<form method="POST" action="/installer/step/3">
    <?= $csrf->field() ?>
    <div class="form-group">
        <label for="db_host"><?= __('installer.db_host') ?></label>
        <input type="text" id="db_host" name="db_host" value="<?= e($dbConfig['host'] ?? '127.0.0.1') ?>" required>
    </div>
    <div class="form-group">
        <label for="db_port"><?= __('installer.db_port') ?></label>
        <input type="number" id="db_port" name="db_port" value="<?= e($dbConfig['port'] ?? '3306') ?>" min="1" max="65535" required>
    </div>
    <div class="form-group">
        <label for="db_name"><?= __('installer.db_name') ?></label>
        <input type="text" id="db_name" name="db_name" value="<?= e($dbConfig['name'] ?? '') ?>" required>
    </div>
    <div class="form-group">
        <label for="db_user"><?= __('installer.db_user') ?></label>
        <input type="text" id="db_user" name="db_user" value="<?= e($dbConfig['user'] ?? '') ?>" required>
    </div>
    <div class="form-group">
        <label for="db_password"><?= __('installer.db_password') ?></label>
        <div class="iw-pw-wrap">
            <input type="password" id="db_password" name="db_password" value="<?= e($dbConfig['password'] ?? '') ?>">
            <button type="button" class="iw-pw-toggle" data-target="db_password" aria-label="Show password">
                <svg class="iw-pw-eye" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/><circle cx="12" cy="12" r="3"/></svg>
                <svg class="iw-pw-eye-off" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:none"><path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"/><path d="M14.084 14.158a3 3 0 0 1-4.242-4.242"/><path d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"/><path d="m2 2 20 20"/></svg>
            </button>
        </div>
    </div>
    <div class="form-group">
        <label for="db_prefix"><?= __('installer.db_prefix') ?></label>
        <input type="text" id="db_prefix" value="iw_" disabled style="opacity:0.6;">
        <input type="hidden" name="db_prefix" value="iw_">
        <small><?= __('installer.db_prefix_note') ?></small>
    </div>

    <div class="step-actions">
        <a href="/installer/step/2" class="btn btn-secondary"><?= __('installer.db_back') ?></a>
        <button type="submit" class="btn btn-primary"><?= __('installer.db_continue') ?></button>
    </div>
</form>

<?php $content = ob_get_clean(); include __DIR__ . '/layout.php'; ?>
