<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" href="{{asset('/images/logo.png')}}">
    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link href="{{ asset('css/fontsawesome/all.css') }}" rel="stylesheet">
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
    <div class="wrap-login mx-3">
        <div class="d-flex justify-content-center align-items-center">
            <div class="body-login">
                <div class="w-100">
                    <div class="box-img mb-4">
                        <img src="{{asset('images/logo.png')}}" alt="Logo"/>
                    </div>
                    <form method="POST" action="{{ route('login') }}">
                        @csrf
                        <div class="mb-3">
                            <label for="" class="form-label">Username</label>
                            <input id="email" type="text" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" autofocus>
                            @error('email')
                                <div class="invalid-feedback" role="alert">
                                    <small>{{ $message }}</small>
                                </div>
                            @enderror
                        </div>

                        <div class="mb-4">
                            <label for="" class="form-label">Password</label>
                            <div class="position-relative">
                                <input id="password" type="password" class="form-control password-input @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
                                <span class="password-toggle-btn" id="eye-icon-btn" onclick="togglePasswordVisibility()" role="button"> <i class="fa fa-eye-slash"></i></span>
                                @error('password')
                                    <div class="invalid-feedback" role="alert">
                                        <small>{{ $message }}</small>
                                    </div>
                                @enderror
                            </div>
                        </div>

                        <button type="submit" class="btn w-100 rounded-2 text-white" style="background-color: #B8860B">
                        Log In
                        </button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>


<script>
    document.addEventListener('DOMContentLoaded', function() {
    var passwordField = document.getElementById('password');
    var eyeIconBtn = document.getElementById('eye-icon-btn');

    if (passwordField.value === '') {
        eyeIconBtn.style.display = 'none';
    }

    passwordField.addEventListener('input', function() {
        if (passwordField.value === '') {
            eyeIconBtn.style.display = 'none';
        } else {
            eyeIconBtn.style.display = 'block';
        }
    });
});

function togglePasswordVisibility() {
    var passwordField = document.getElementById('password');
    var eyeIcon = document.querySelector('.password-toggle-btn i');

    if (passwordField.type === 'password') {
        passwordField.type = 'text';
        eyeIcon.classList.remove('fa-eye-slash');
        eyeIcon.classList.add('fa-eye');
    } else {
        passwordField.type = 'password';
        eyeIcon.classList.remove('fa-eye');
        eyeIcon.classList.add('fa-eye-slash');
    }
}


</script>
</html>
