@extends('layouts.window.theme')
@section("title", env("APP_NAME") . " :: Redefinir senha")
@section('content')

    <div class="container d-flex justify-content-center align-items-center min-vh-100">
        <div class="row w-100 justify-content-center">
            <div class="col-sm-12 col-md-8 col-lg-6">
                <div class="card shadow-lg">
                    <div class="card-header bg-primary text-white">
                        <h4 class="mb-0">Redefinir senha</h4>
                    </div>
                    <div class="card-body">
                        @if (session('error'))
                            <div class="alert alert-danger my-3">{{ session('error') }}</div>
                        @endif
                        <div class="text-center my-3">
                            <img src="{{ asset("pmar/assets/img/logo-pmar.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>
                        <form autocomplete="off" class="resetPassword" id="resetPassword" action="{{ route("paginas.fibromialgia.resetPassword") }}" method="post">
                            <br>
                            @csrf
                            <div class="mb-3">
                                <label for="password" class="form-label">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">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 btn-md w-100 m-auto btn-primary" type="submit" id="submitResetPassword">{{ __('Redefinir') }}</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <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>
@endsection
