<?php $title = 'AdminSB Pro - Edit User'; ?>

<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-gray-800">Edit User: <?= htmlspecialchars($user->name) ?></h1>
    <a href="<?= $baseUrl ?>/users" class="btn btn-secondary btn-sm"><i class="fas fa-arrow-left"></i> Back to Users</a>
</div>

<div class="card shadow mb-4">
    <div class="card-header py-3"><h6 class="m-0 font-weight-bold text-primary">User Information</h6></div>
    <div class="card-body">
        <form method="POST" action="<?= $baseUrl ?>/users/<?= $user->id ?>/update">
            <div class="form-group">
                <label>Full Name</label>
                <input type="text" class="form-control" name="name" value="<?= htmlspecialchars($user->name) ?>" required>
            </div>
            <div class="form-group">
                <label>Email</label>
                <input type="email" class="form-control" name="email" value="<?= htmlspecialchars($user->email) ?>" required>
            </div>
            <div class="form-group">
                <label>Password (leave blank to keep current)</label>
                <input type="password" class="form-control" name="password" placeholder="Leave blank to keep current">
            </div>
            <div class="form-group">
                <label>Role</label>
                <select class="form-control" name="role">
                    <option value="member" <?= in_array($user->role, ['member', 'viewer', 'editor'], true) ? 'selected' : '' ?>>Member</option>
                    <option value="admin" <?= $user->role === 'admin' ? 'selected' : '' ?>>Admin</option>
                </select>
            </div>
            <div class="form-group">
                <label>Status</label>
                <select class="form-control" name="status">
                    <option value="active" <?= $user->status === 'active' ? 'selected' : '' ?>>Active</option>
                    <option value="inactive" <?= $user->status === 'inactive' ? 'selected' : '' ?>>Inactive</option>
                </select>
            </div>
            <button type="submit" class="btn btn-primary">Update User</button>
            <a href="<?= $baseUrl ?>/users" class="btn btn-secondary">Cancel</a>
        </form>
    </div>
</div>
