<?php require dirname(__DIR__) . '/layouts/app.php'; ?>

<section class="page-heading">
    <div>
        <p class="eyebrow">Compte</p>
        <h1>Profil utilisateur</h1>
    </div>
    <span class="role-badge"><?= e($user['role'] ?? '') ?></span>
</section>

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

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

<form class="form-panel" method="post" action="<?= url('/profile/update') ?>">
    <input type="hidden" name="_token" value="<?= csrf_token() ?>">

    <div class="form-grid">
        <label>
            Nom
            <input type="text" name="name" value="<?= e($user['name']) ?>" required>
        </label>

        <label>
            Email
            <input type="email" name="email" value="<?= e($user['email']) ?>" required>
        </label>
    </div>

    <section class="permissions-panel">
        <h2>Changer le mot de passe</h2>
        <div class="form-grid">
            <label>
                Mot de passe actuel
                <input type="password" name="current_password">
            </label>

            <label>
                Nouveau mot de passe
                <input type="password" name="new_password">
            </label>

            <label>
                Confirmer le nouveau mot de passe
                <input type="password" name="new_password_confirmation">
            </label>
        </div>
    </section>

    <div class="form-actions">
        <button type="submit">Enregistrer</button>
    </div>
</form>

<?php require dirname(__DIR__) . '/layouts/app_footer.php'; ?>
