@extends('layouts.login.theme')
@section("title", env("APP_NAME") . " :: Área Restrita")
@section('content')
    <form autocomplete="off" class="resetPassword" id="resetPassword" action="{{ route("admin.resetPasswordUpdate") }}" method="post">
        <section class="d-flex align-items-center">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-12">
                        <div class="card-admin-login p-5">
                            @include("errors.messageFlash")
                            <div class="text-center">
                                <img src="{{ asset("pmar/assets/img/logo-angra-branco.svg") }}" class="card-img-top" title="{{ __("Prefeitura Municipal de Angra dos Reis") }}" alt="{{ __("Prefeitura Municipal de Angra dos Reis") }}" class="img-fluid text-center" style="width: 100%; height: 5rem;" />
                            </div>
                            <div class="card-body">
                                <h5 class="text-white card-title text-center">Redefinir Senha</h5>
                                <br>
                                @csrf
                                <div class="mb-3">
                                    <label for="password" class="form-label text-bold text-white">Nova senha:</label>
                                    <div class="input-group">
                                        <input type="password" class="form-control @error('password') is-invalid @enderror" name="password" id="password" autocomplete="off" value="{{ old('password') }}">
                                        <span class="input-group-text" id="basic-addon2">
                                            <button type="button" class="btn btn-outline-secondary" id="togglePassword">
                                                <i class="fa-solid fa-eye text-primary"></i>
                                            </button>
                                        </span>
                                    </div>
                                    <small class="text-danger text-bold small-login"></small>
                                    @error('password')
                                        <small class="text-danger text-bold">{{ $message }}</small>
                                    @enderror
                                </div>
                                <div class="mb-3">
                                    <label for="password" class="form-label text-bold text-white">Repetir Senha:</label>
                                    <div class="input-group">
                                        <input type="password" class="form-control @error('password_repeat') is-invalid @enderror" name="password_repeat" id="password_repeat" autocomplete="off" value="{{ old('password_repeat') }}">
                                        <span class="input-group-text" id="basic-addon2">
                                            <button type="button" class="btn btn-outline-secondary" id="togglePasswordRepeat">
                                                <i class="fa-solid fa-eye text-primary"></i>
                                            </button>
                                        </span>
                                    </div>
                                    <small class="text-danger text-bold small-password"></small>
                                    @error('password_repeat')
                                        <small class="text-danger text-bold">{{ $message }}</small>
                                    @enderror
                                </div>
                                <div>
                                    <button class="fs-4 rounded-4 btn m-auto btn-primary" type="submit" id="submitResetPassword">{{ __('Redefinir') }}</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </form>
@endsection
<script>
    document.addEventListener("DOMContentLoaded", function () {
        let togglePassword = document.getElementById('togglePassword');
        let passwordField = document.getElementById('password');
        
        let togglePasswordRepeat = document.getElementById('togglePasswordRepeat');
        let passwordFieldRepeat = document.getElementById('password_repeat');

        togglePassword.addEventListener('click', function() {
            let icon = this.querySelector('i');
            if (passwordField.type === 'password') {
                passwordField.type = 'text';
                icon.classList.remove('fa-eye');
                icon.classList.add('fa-eye-slash');
            } else {
                passwordField.type = 'password';
                icon.classList.remove('fa-eye-slash');
                icon.classList.add('fa-eye');
            }
        });
            
        togglePasswordRepeat.addEventListener('click', function() {
            let icon = this.querySelector('i');
            if (passwordFieldRepeat.type === 'password') {
                passwordFieldRepeat.type = 'text';
                icon.classList.remove('fa-eye');
                icon.classList.add('fa-eye-slash');
            } else {
                passwordFieldRepeat.type = 'password';
                icon.classList.remove('fa-eye-slash');
                icon.classList.add('fa-eye');
            }
        });
    });
</script>