<div class="col card--ui" id="card--dashboard">

    <div class="container">

        @if (session()->has('error'))
            <div class="alert alert-danger" role="alert">
                {{ session()->get('error') }}
            </div>
        @endif

        <div class="row">
            <div class="col">

                <form wire:submit.prevent="save">

                    <div class="row mb-3 mt-5">
                        <h5 class="mb-3 mt-3 blu-text">Anagrafica</h5>
                        <div class="row">
                            <div class="col-md-6">
                                <label for="inputName" class="form-label">Nome</label>
                                <input class="form-control " type="text" id="name" placeholder="Nome"
                                    wire:model="name" {{ $editMode ? '' : 'disabled' }}>
                            </div>

                            <div class="col-md-6">
                                <label for="inputName" class="form-label">Cognome</label>
                                <input class="form-control" type="text" id="cognome" placeholder="Cognome"
                                    wire:model="cognome" {{ $editMode ? '' : 'disabled' }}>
                            </div>
                        </div>
                        <h5 class="mb-3 mt-4 blu-text">Contatti</h5>
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Telefono</label>
                                <input type="text" class="form-control" wire:model="telefono" {{ $editMode ? '' : 'disabled' }}>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Cellulare</label>
                                <input type="text"
                                       class="form-control @error('cellulare') is-invalid @enderror"
                                       wire:model="cellulare" {{ $editMode ? '' : 'disabled' }}>
                                @error('cellulare') <span class="text-danger">{{ $message }}</span> @enderror
                            </div>
                        </div>

                        <h5 class="mb-3 mt-4 blu-text">Credenziali di accesso</h5>
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Email</label>
                                <input type="email"
                                class="form-control @error('email') is-invalid @enderror"
                                wire:model="email" {{ $editMode ? '' : 'disabled' }}>
                                @error('email') <span class="text-danger">{{ $message }}</span> @enderror
                            </div>
                            <div class="col-md-6"></div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Password</label>
                                @if ($editMode)
                                <div class="password-wrapper">
                                @endif
                                    <input type="password" class="form-control @error('password') is-invalid @enderror" wire:model="password" {{ $editMode ? '' : 'disabled' }}>
                                @if ($editMode)
                                    <div class="password-eye" onclick="togglePassword(this)">
                                        <i class="fas fa-eye password-hidden"></i>
                                        <i class="fas fa-eye-slash password-shown"></i>
                                    </div>
                                </div>
                                @endif
                                @error('password') <span class="text-danger">{{ $message }}</span> @enderror
                                <small class="form-text text-muted">Lasciare vuoto per non modificare</small>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Conferma password</label>
                                @if ($editMode)
                                <div class="password-wrapper">
                                @endif
                                    <input type="password" class="form-control @error('password_confirmation') is-invalid @enderror" wire:model="password_confirmation" {{ $editMode ? '' : 'disabled' }}>
                                @if ($editMode)
                                    <div class="password-eye" onclick="togglePassword(this)">
                                        <i class="fas fa-eye password-hidden"></i>
                                        <i class="fas fa-eye-slash password-shown"></i>
                                    </div>
                                </div>
                                @endif
                                @error('password_confirmation') <span class="text-danger">{{ $message }}</span> @enderror
                                <small class="form-text text-muted">Lasciare vuoto per non modificare</small>
                            </div>
                        </div>
                    </div>

                    <div class="form--item" style="margin-top: 10px">
                        <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Chiudi</button>
                        @if ($editMode)
                            <button type="submit" class="btn--ui" wire:click.prevent="save()">Salva</button>
                        @else
                            <button type="button" class="btn--ui" wire:click="enableEditMode()">Modifica</button>
                        @endif
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>
<style>
    .blu-text {
        color: var(--color-blu) !important;
    }
</style>
