<section class="page-header"><div><p class="eyebrow">Account</p><h1>My Profile</h1><p>Manage your email address and password.</p></div></section>
<?php if (!empty($message)): ?><div class="alert alert-success" role="status"><?= htmlspecialchars($message, ENT_QUOTES, 'UTF-8') ?></div><?php endif; ?>
<?php if (!empty($error)): ?><div class="alert alert-danger" role="alert"><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></div><?php endif; ?>
<section class="grid grid-2 section-gap">
    <article class="card"><div class="card-header"><div><h2>Account details</h2><p>Your basic CRM identity.</p></div></div><dl class="detail-list"><div><dt>Name</dt><dd><?= htmlspecialchars($user['full_name'], ENT_QUOTES, 'UTF-8') ?></dd></div><div><dt>Status</dt><dd><span class="badge badge-success"><?= htmlspecialchars(ucfirst($user['status']), ENT_QUOTES, 'UTF-8') ?></span></dd></div><div><dt>Roles</dt><dd><?= htmlspecialchars(implode(', ', array_column($user['roles'], 'display_name')), ENT_QUOTES, 'UTF-8') ?></dd></div></dl></article>
    <article class="card"><div class="card-header"><div><h2>Change email</h2><p>Confirm your current password before changing it.</p></div></div><form method="post" action="/crm/public/profile/email" class="form-stack"><input type="hidden" name="_csrf" value="<?= htmlspecialchars($csrf, ENT_QUOTES, 'UTF-8') ?>"><label class="form-field"><span>New email</span><input required type="email" name="email" value="<?= htmlspecialchars($user['email'], ENT_QUOTES, 'UTF-8') ?>"></label><label class="form-field"><span>Current password</span><input required type="password" name="current_password" autocomplete="current-password"></label><button class="btn btn-primary" type="submit">Update email</button></form></article>
    <article class="card"><div class="card-header"><div><h2>Change password</h2><p>Your password is stored only as a secure hash.</p></div></div><form method="post" action="/crm/public/profile/password" class="form-stack"><input type="hidden" name="_csrf" value="<?= htmlspecialchars($csrf, ENT_QUOTES, 'UTF-8') ?>"><label class="form-field"><span>Current password</span><input required type="password" name="current_password" autocomplete="current-password"></label><label class="form-field"><span>New password</span><input required minlength="12" type="password" name="new_password" autocomplete="new-password"></label><label class="form-field"><span>Confirm new password</span><input required minlength="12" type="password" name="password_confirmation" autocomplete="new-password"></label><button class="btn btn-primary" type="submit">Change password</button></form></article>
</section>
