<div class="admin-grid admin-grid--two">
    <div class="admin-card admin-card--feature">
        <p class="admin-section-title">User details</p>
        <p class="admin-section-subtitle">Create a user account, assign the right workspace role, and keep login details organized.</p>

        <div class="mt-5 admin-form-grid">
            <div class="admin-field">
                <label for="user-name">Name</label>
                <input id="user-name" type="text" name="name" value="<?php echo e(old('name', $user->name ?? '')); ?>" required>
                <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><p class="admin-field__error"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
            </div>

            <div class="admin-field">
                <label for="user-email">Email</label>
                <input id="user-email" type="email" name="email" value="<?php echo e(old('email', $user->email ?? '')); ?>" required>
                <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><p class="admin-field__error"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
            </div>

            <div class="admin-field">
                <label for="user-password"><?php echo e(isset($user) ? 'New password' : 'Password'); ?></label>
                <input id="user-password" type="password" name="password" <?php echo e(isset($user) ? '' : 'required'); ?>>
                <p class="admin-field__hint"><?php echo e(isset($user) ? 'Leave empty to keep the current password.' : 'Use at least 8 characters.'); ?></p>
                <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><p class="admin-field__error"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
            </div>

            <div class="admin-field">
                <label for="user-password-confirmation">Confirm password</label>
                <input id="user-password-confirmation" type="password" name="password_confirmation" <?php echo e(isset($user) ? '' : 'required'); ?>>
            </div>
        </div>
    </div>

    <div class="admin-grid">
        <div class="admin-card">
            <p class="admin-section-title">Role assignment</p>
            <p class="admin-section-subtitle">Choose the permissions this user should have inside the CMS.</p>

            <div class="mt-5 admin-form-grid">
                <div class="admin-field">
                    <label for="user-role-id">Role</label>
                    <?php
                        $currentUser = $user ?? null;
                        $selectedRoleId = old(
                            'role_id',
                            $currentUser?->role_id
                                ?? $roles->firstWhere('slug', $currentUser?->role ?? null)?->id
                                ?? $roles->firstWhere('slug', 'user')?->id
                        );
                        $selectedRole = $roles->firstWhere('id', (int) $selectedRoleId);
                    ?>
                    <select id="user-role-id" name="role_id" required>
                        <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($role->id); ?>" <?php if((string) $selectedRoleId === (string) $role->id): echo 'selected'; endif; ?>><?php echo e($role->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                    <?php $__errorArgs = ['role_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><p class="admin-field__error"><?php echo e($message); ?></p><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>

            <?php if($selectedRole): ?>
                <div class="admin-card admin-card--subtle mt-5">
                    <p class="admin-section-title"><?php echo e($selectedRole->name); ?></p>
                    <p class="admin-section-subtitle mt-2"><?php echo e($selectedRole->description ?: 'This role can be customized from the role manager.'); ?></p>
                    <div class="mt-4 flex flex-wrap gap-2">
                        <span class="admin-badge admin-badge--preferred"><?php echo e($selectedRole->access_level); ?></span>
                        <span class="admin-badge admin-badge--read"><?php echo e($selectedRole->permissionCount()); ?> permissions</span>
                    </div>
                    <div class="mt-4 flex flex-wrap gap-2">
                        <?php $__empty_1 = true; $__currentLoopData = $selectedRole->grantedSections(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $section): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <span class="admin-badge admin-badge--archived"><?php echo e($section); ?></span>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <span class="admin-badge admin-badge--archived">No sections enabled yet</span>
                        <?php endif; ?>
                    </div>
                </div>
            <?php endif; ?>

            <div class="mt-5 flex flex-wrap gap-3">
                <button type="submit" class="admin-button"><?php echo e($submitLabel); ?></button>
                <a href="<?php echo e(route('admin.users.index')); ?>" class="admin-button admin-button--secondary">Back to users</a>
            </div>
        </div>

        <div class="admin-card">
            <p class="admin-section-title">Need another role?</p>
            <p class="admin-section-subtitle">Create or edit roles first, then assign them to users from this screen.</p>
            <div class="mt-4">
                <a href="<?php echo e(route('admin.roles.index')); ?>" class="admin-button admin-button--ghost">Open role manager</a>
            </div>
        </div>
    </div>
</div>
<?php /**PATH /home/xsoftdev/saleemsail.xsoftdevelop.com/resources/views/admin/users/partials/form.blade.php ENDPATH**/ ?>