<!-- resources/views/content/authentications/auth-forgot-password-basic.blade.php -->

@extends('layouts/blankLayout')

@section('title', 'Forgot Password Basic - Pages')

@section('page-style')
<!-- Page -->
<link rel="stylesheet" href="{{asset('assets/vendor/css/pages/page-auth.css')}}">
@endsection

@section('content')
<div class="container-xxl">
  <div class="authentication-wrapper authentication-basic container-p-y">
    <div class="authentication-inner py-4">

      <!-- Forgot Password -->
      <div class="card">
        <div class="card-body">
          <!-- Logo -->
          <div class="app-brand justify-content-center">
            <a href="{{ url('/') }}" class="app-brand-link gap-2">
              <span class="app-brand-logo demo">
                <img src="{{ asset('assets/img/logo/seiza.png') }}" alt="Logo" width="100">
              </span>
            </a>
          </div>
          <!-- /Logo -->
          <h4 class="mb-2">Forgot Password? 🔒</h4>
          <p class="mb-4">Set your new password</p>

          @if (session('status'))
        <div class="alert alert-success" role="alert">
        {{ session('status') }}
        </div>
      @endif

          <form id="formAuthentication" class="mb-3" method="GET" onsubmit="return validateForm()">
            @csrf
            <div class="mb-3">
              <input type="hidden" class="form-control" id="email" name="email" value="{{$email}}" autofocus>
            </div>
            <div class="mb-3">
              <label for="password" class="form-label">Password</label>
              <input type="password" class="form-control" id="password" name="password"
                placeholder="Enter your new Password" autofocus>
              <div class="invalid-feedback" id="passwordError">Please enter a valid password.</div>
            </div>
            <div class="mb-3">
              <label for="password_confirmation" class="form-label">Password</label>
              <input type="password" class="form-control" id="password_confirmation" name="password_confirmation"
                placeholder="Re-enter your new Password" autofocus>
              <div class="invalid-feedback" id="confirmPasswordError">Password does not match.</div>
            </div>
            <button class="btn btn-primary d-grid w-100" type="submit">Reset Password</button>
          </form>

          <div class="text-center">
            <a href="{{ route('auth-login-basic') }}" class="d-flex align-items-center justify-content-center">
              <i class="bx bx-chevron-left scaleX-n1-rtl bx-sm"></i>
              Back to login
            </a>
          </div>
        </div>
      </div>
      <!-- /Forgot Password -->
    </div>
  </div>
</div>

<script>
  function validateForm() {
    const password = document.getElementById('password').value;
    const passwordError = document.getElementById('passwordError');
    const confirmPassword = document.getElementById('password_confirmation').value;
    const confirmPasswordError = document.getElementById('confirmPasswordError');

    if (password?.length > 0) {
      passwordError.style.display = 'none';
    } else {
      passwordError.style.display = 'block';
      return false;
    }

    if (password && (password == confirmPassword)) {
      confirmPasswordError.style.display = 'none';
    } else {
      confirmPasswordError.style.display = 'block';
      return false;
    }

    return true;
  }
</script>
@endsection