<div class="user-edit">
    <x-title>
        Editing User: {{ $user->name_first }} {{ $user->name_last }}

        <x-slot:buttons>
            <a href="{{ route('admin.users.show', $user) }}"
               class="btn btn-outline-secondary">
                View Profile
            </a>
        </x-slot:buttons>
    </x-title>

    @if(session('success'))
        <div class="alert alert-success">
            {{ session('success') }}
        </div>
    @endif

    <div class="row">
        <div class="col-12 col-md-9">
            <div class="card">
                <div class="card-body">

                    <div class="row mb-3">
                        <div class="col-6">
                            <label class="form-label">First Name</label>
                            <input class="form-control" wire:model.defer="name_first">
                        </div>

                        <div class="col-6">
                            <label class="form-label">Last Name</label>
                            <input class="form-control" wire:model.defer="name_last">
                        </div>
                    </div>

                    <div class="mb-3">
                        <label class="form-label">Email</label>
                        <input class="form-control" wire:model.defer="email">
                    </div>

                    <div class="mb-3">
                        <label class="form-label">
                            New Password
                            <span class="text-muted small">(optional)</span>
                        </label>
                        <input type="password"
                               class="form-control"
                               wire:model.defer="password">
                    </div>

                    <div class="mb-4">
                        <label class="form-label">Roles</label>
                        <div class="d-flex flex-wrap gap-3">
                            @foreach($allRoles as $role)
                                <div class="form-check">
                                    <input class="form-check-input"
                                           type="checkbox"
                                           wire:model.defer="roles"
                                           value="{{ $role->name }}">
                                    <label class="form-check-label">
                                        {{ $role->name }}
                                    </label>
                                </div>
                            @endforeach
                        </div>
                    </div>

                    <div class="d-flex justify-content-end">
                        <button class="btn btn-primary"
                                wire:click="save">
                            Save Changes
                        </button>
                    </div>

                </div>
            </div>
        </div>

        {{-- SIDEBAR --}}
        <div class="col-12 col-md-3">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">Editing</h4>
                    <hr>

                    <p class="text-muted small mb-0">
                        Role changes apply immediately and may
                        affect system access.
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>
