<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Forgot Password</title>
  <link rel="icon" href="/admin/images/favicon.ico" type="image/x-icon">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">

  <style>
    body {
      font-family: Arial, sans-serif;
      background-image: url('/admin/images/BGZIPCK.png'); /* same as login */
      background-size: cover;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
    }

    .forgot-container {
      background: rgba(255, 255, 255, 0.1);
      /* backdrop-filter: blur(8px); */
      border-radius: 12px;
      border :2px solid rgba(255, 255, 255, 0.3);
      box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
      padding: 50px;
      width: 560px;
     
      box-sizing: border-box;
      text-align: center;
    }

    .forgot-container h2 {
      color: black;
      font-size: 24px;
      margin-bottom: 20px;
    }

    .form-group {
      margin-bottom: 15px;
      text-align: left;
    }

    .form-group label {
      display: block;
      margin-bottom: 5px;
      color: black;
      font-weight: 600;
    }

     .form-group input {
      width: 95%;
      height: 45px;
      padding: 0px 20px 0px 12px;
      border: 1px solid #ddd;
      background-color:#E8F0FE;
      border-radius: 8px;
      font-size: 15px;
      outline: none;
      transition: 0.3s;
    }

   .login-button {
      width: 100%;
      height: 42px;
      background: #4d6c1f;
      border: none;
      border-radius: 8px;
      color: #fff;
      font-size: 16px;
      font-weight: bold;
      cursor: pointer;
      transition: 0.3s;
    }

    .login-button:hover {
      background: #27ae60;
    }

    .back-to-login {
      display: block;
      margin-top: 20px;
      text-align: center;
      color: black;
      text-decoration: none;
      font-weight: 600;
    }

    .back-to-login:hover {
      text-decoration: underline;
    }
     .form-group input:focus {
      border-color: #4d6c1f;
      box-shadow: 0 0 6px rgba(245, 124, 0, 0.4);
    }

    /* Toast */
    .toast {
      visibility: hidden;
      max-width: 50%;
      margin: 0 auto;
      background-color: #333;
      color: #fff;
      text-align: center;
      border-radius: 5px;
      padding: 26px;
      position: fixed;
      z-index: 1;
      right: 10px;
      top: 30px;
      font-size: 17px;
      transform: translateX(-50%);
    }

    .toast.show {
      visibility: visible;
      animation: fadein 0.5s, fadeout 0.5s 2.5s;
    }

    @keyframes fadein {
      from {
        right: 0;
        opacity: 0;
      }

      to {
        right: 10px;
        opacity: 1;
      }
    }

    @keyframes fadeout {
      from {
        right: 10px;
        opacity: 1;
      }

      to {
        right: 0;
        opacity: 0;
      }
    }

    .toast-success {
      background-color: rgb(13, 223, 13);
    }

    .toast-error {
      background-color: red;
    }
  </style>
</head>

<body>
  <div class="forgot-container">
    <h2>Forgot Password</h2>
    <form id="forgotForm" class="form-horizontal" action="/auth/v1/sendpassword" method="POST">
      <div class="form-group">
        <label for="inputEmail">Email</label>
        <input type="email" name="email" required id="inputEmail"
          oninput="this.value = this.value.toLowerCase()" placeholder="Enter your email">
      </div>
      <button type="submit" class="login-button" id="submitBtn">Submit</button>
    </form>
    <a href="/auth/v1/login" class="back-to-login">← Back to Login</a>
  </div>

  <!-- Toast -->
  <div id="toast" class="toast"></div>

  <script>
    function showToast(message, type) {
      const toast = document.getElementById('toast');
      toast.className = 'toast show ' + (type === 'success' ? 'toast-success' : 'toast-error');
      toast.textContent = message;

      setTimeout(function () {
        toast.className = toast.className.replace('show', '');
      }, 3000);
    }

    // From backend
    const error = '{{error}}';
    const success = '{{success}}';

    if (error) {
      showToast(error, 'error');
    } else if (success) {
      showToast(success, 'success');
    }
  </script>
  <script>
  const form = document.getElementById("forgotForm");
  const submitBtn = document.getElementById("submitBtn");

  form.addEventListener("submit", function () {
    submitBtn.disabled = true;       // disable button
    submitBtn.innerText = "Sending..."; // show feedback
  });

  const error = '{{error}}';
    const success = '{{success}}';

    if (error) {
      showToast(error, 'error');
    } else if (success) {
      showToast(success, 'success');
    }
</script>
</body>

</html>
