<div wire:ignore.self class="modal fade" tabindex="-1" role="dialog" id="theModal">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header bg-primary">
                <h5 class="modal-title">
                <b>Usuario</b> | {{ $selected_user_id > 0 ? 'EDITAR' : 'CREAR' }}
                </h5>
                <h6 class="text-center text-warning" wire:loading>ESPERE UN MOMENTO POR FAVOR</h6>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Nombre</label>
                            <input type="text" wire:model.lazy="first_name" class="form-control" placeholder="ej: Mauricio" maxlength="99">
                            @error('first_name')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Apellido</label>
                            <input type="text" wire:model.lazy="last_name" class="form-control" placeholder="ej:García" maxlength="99">
                            @error('last_name')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Documento</label>
                            <input type="text" wire:model.lazy="document" class="form-control" placeholder="ej: 111055698" maxlength="15">
                            @error('document')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Teléfono</label>
                            <input type="text" wire:model.lazy="phone" class="form-control" placeholder="ej: 3202568745" maxlength="15">
                            @error('phone')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Email</label>
                            <input type="text" wire:model.lazy="email" class="form-control" placeholder="ej: mg-net@hotmail.com" maxlength="99">
                            @error('email')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>
                    <div class="col-9 col-md-4">
                        <div class="form-group">
                            <label>Contraseña</label>
                            <div class="input-group">
                                <input type="password" wire:model.defer="password" id="password" class="form-control">
                                <span class="input-group-text" id='i-pa' onClick="togglePassword('password', 'i-pa')">
                                    <i class="fas fa-eye"></i>
                                </span>
                            </div>
                            @error('password')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>
                    <div class="col-3 col-md-2 d-flex align-items-center justify-content-center">
                        <button wire:click="generatePassword" class="btn btn-sm btn-primary">
                            <i class="fas fa-key"></i>
                        </button>
                    </div>
                    <div class="col-sm-12 col-md-6">
                        <label>Rol</label>
                        @if (auth()->user()->id != $selected_user_id)
                        <select wire:model.lazy="role" class="form-select">
                            <option value="">Seleccione un rol</option>
                            @foreach ($roles_company_all as $role)
                                <option value="{{ $role }}">{{ $role }}</option>
                            @endforeach
                        </select>
                        @else
                            <input type="text" wire:model.lazy="role" class="form-control" value="{{ $role }}" disabled>
                        @endif
                        @error('role')
                            <span class="text-danger er">{{ $message }}</span>
                        @enderror
                    </div>
                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Estado</label>
                            <select wire:model.lazy="status" class="form-select">
                                <option value="">Seleccionar</option>
                                <option value="ACTIVO">Activo</option>
                                <option value="INACTIVO">Inactivo</option>
                            </select>
                            @error('status')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-6">
                        <div class="form-group">
                            <label>Imagen de Perfil</label>
                            <input type="file" wire:model="image" class="form-control" accept=".png, .jpg">
                            @error('image')
                                <span class="text-danger er">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>

                    <div class="col-sm-12 col-md-12">
                        <div class="form-group">
                            <input type="checkbox" wire:model.lazy="send_mail"
                                class="m-2 checkbox_animated" id="send_mail"
                                title="Enviar datos de acceso"> <span class="small text-muted">Enviar email con datos de acceso al usuario</span>
                        </div>
                    </div>

                </div><!-- row -->
            </div><!-- modal-body -->
            @include('livewire.loading.component', ['targetLoading' => 'Store, Update']) <!--- component loading ,en targetLoading se coloca el nombre del metodo que se esta cargando --->
            <div class="modal-footer">
                <button type="button" class="btn btn-outline-primary" wire:click.prevent="resetUI()" data-bs-dismiss="modal">CERRAR</button>
                @if( $selected_user_id < 1 )
                    <button type="button" class="btn btn-primary close-modal" wire:click.prevent="Store()">GUARDAR</button>
                @else
                    <button type="button" class="btn btn-primary close-modal" wire:click.prevent="Update()">ACTUALIZAR</button>
                @endif
            </div><!-- modal-footer -->
        </div><!-- modal-content -->
    </div>
</div>

