<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>DULLAH XMD Verification Check</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.js"></script>

  <style>
    /* Global Styles */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: 'Poppins', sans-serif;
    }

    body {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      background: #0d0d0d;
      overflow: hidden;
    }

    /* Background Image */
    .background {
      position: absolute;
      width: 100%;
      height: 100%;
      overflow: hidden;
    }

    .bg-img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      filter: blur(5px);
      position: absolute;
    }

    /* Container */
    .container {
      position: relative;
      z-index: 1;
      background: rgba(0, 0, 0, 0.8);
      padding: 30px;
      border-radius: 10px;
      text-align: center;
      width: 100%;
      max-width: 400px;
      box-shadow: 0 4px 10px rgba(255, 255, 255, 0.1);
    }

    .title {
      color: #ffffff;
      font-size: 22px;
      margin-bottom: 20px;
      font-weight: bold;
    }

    /* Input Field */
    .input-container input {
      width: 100%;
      padding: 12px;
      border-radius: 5px;
      border: none;
      font-size: 16px;
      outline: none;
      text-align: center;
      background: #222;
      color: white;
    }

    .input-container input::placeholder {
      color: rgba(255, 255, 255, 0.5);
    }

    /* Deploy Button */
    button {
      width: 100%;
      padding: 12px;
      margin-top: 15px;
      background: #ff9800;
      color: white;
      font-size: 16px;
      font-weight: bold;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      transition: 0.3s ease-in-out;
    }

    button:hover {
      background: #e68900;
    }

    button i {
      margin-right: 8px;
    }

    button:disabled {
      background: gray;
      cursor: not-allowed;
    }

    /* Responsive */
    @media screen and (max-width: 480px) {
      .container {
        width: 90%;
      }
    }
  </style>
</head>
<body>

  <div class="background">
    <img class="bg-img" src="https://files.catbox.moe/533oqh.jpg" alt="Background">
  </div>

  <div class="container">
    <h2 class="title">DULLAH XMD VERIFICATION</h2>
    <form id="usernameForm">
      <div class="input-container">
        <input type="text" id="name" name="username" required placeholder="GitHub Username">
      </div>
      <button type="button" id="deployButton" onclick="verify();">
        <i class="fas fa-cloud-upload-alt"></i> Deploy
      </button>
    </form>
  </div>

  <script>
    async function verify() {
      const username = document.getElementById('name').value;
      const deployButton = document.getElementById("deployButton");

      if (username.length > 0) {
        deployButton.disabled = true;
        deployButton.innerHTML = "<i class='fas fa-spinner fa-spin'></i> Verifying...";

        try {
          // Check if the forked repo exists
          await axios.get(`https://api.github.com/repos/${username}/DULLAH-XMD`);

          // Redirect to Heroku deployment
          location.replace(`https://dashboard.heroku.com/new?template=https://github.com/${username}/DULLAH-XMD`);
        } catch (error) {
          if (error.response && error.response.status === 404) {
            alert("You haven't forked the main repo. Tap OK to fork it.");
            window.open('https://github.com/abdallahsalimjuma/DULLAH-XMD/fork', '_blank');
          } else {
            alert("An error occurred. Please try again.");
          }
        } finally {
          deployButton.disabled = false;
          deployButton.innerHTML = "<i class='fas fa-cloud-upload-alt'></i> Deploy";
        }
      }
    }
  </script>

</body>
</html>