<?php
/**
 * Compte administrateur : changement de mot de passe.
 * @var ?string $flash
 * @var list<string> $errors
 */

use App\Core\Auth;
use App\Core\Csrf;
?>
<h2 class="h2 mb-3">Mon compte</h2>

<?php if (!empty($errors)): ?>
    <div class="alert alert-danger"><?php foreach ($errors as $er): ?><div><?= e($er) ?></div><?php endforeach; ?></div>
<?php endif; ?>

<div class="row row-cards">
    <div class="col-lg-6">
        <div class="card">
            <div class="card-header"><h3 class="card-title">Changer le mot de passe</h3></div>
            <div class="card-body">
                <p class="text-secondary small mb-3">Connecté en tant que <strong><?= e(Auth::name() !== '' ? Auth::name() : 'Admin') ?></strong>.</p>
                <form method="post" action="<?= e(base_url('admin/account/password')) ?>" autocomplete="off">
                    <?= Csrf::field() ?>
                    <div class="mb-3">
                        <label class="form-label">Mot de passe actuel</label>
                        <input type="password" name="current_password" class="form-control" required autocomplete="current-password">
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Nouveau mot de passe</label>
                        <input type="password" name="new_password" class="form-control" required minlength="8" autocomplete="new-password">
                        <div class="form-hint mt-1">Au moins 8 caractères. Les caractères spéciaux et accents sont acceptés.</div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Confirmer le nouveau mot de passe</label>
                        <input type="password" name="confirm_password" class="form-control" required autocomplete="new-password">
                    </div>
                    <button type="submit" class="btn btn-primary"><i class="ti ti-device-floppy me-1"></i>Mettre à jour</button>
                </form>
            </div>
        </div>
    </div>
</div>
