<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Robux Shop</title>
    <style>
        body {
            background-color: #111111;
            color: #fff;
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: none; /* Hide body until logged in */
        }
        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 20px;
            background-color: #222222;
            border-bottom: 2px solid #ffcc00;
        }
        header h1 {
            font-size: 24px;
            color: #ffcc00;
        }
        header nav a {
            color: #ffcc00;
            text-decoration: none;
            margin-left: 15px;
        }
        .basket {
            position: relative;
            cursor: pointer;
            margin-right: 10px;
        }
        .checkout {
            background-color: #ffcc00;
            border: none;
            color: #fff;
            padding: 10px 20px;
            font-size: 18px;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        .checkout:hover {
            background-color: #e6b800;
        }
        .shop-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            margin: 20px;
        }
        .shop-item {
            background-color: #1e1e1e;
            border-radius: 8px;
            width: 300px;
            margin: 15px;
            padding: 15px;
            text-align: center;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }
        .shop-item img {
            width: 100%;
            border-radius: 5px;
            max-height: 200px;
            object-fit: cover;
            margin-bottom: 10px;
        }
        .shop-item h2 {
            font-size: 22px;
            margin: 10px 0;
            color: #ffcc00;
        }
        .shop-item .price {
            font-size: 18px;
            color: #ffcc00;
            display: inline-block;
            margin-left: 10px;
        }
        .shop-item .stock {
            font-size: 18px;
            display: block;
            margin-top: 5px;
        }
        .in-stock {
            color: #00ff00;
        }
        .out-of-stock {
            color: #ff0000;
        }
        .shop-item button {
            background-color: #ffcc00;
            border: none;
            color: #fff;
            padding: 12px 24px;
            font-size: 18px;
            border-radius: 5px;
            cursor: pointer;
            margin-top: auto;
            transition: background-color 0.3s ease;
        }
        .shop-item button:hover {
            background-color: #e6b800;
        }

        /* Login Overlay */
        .login-overlay {
            display: flex;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.9);
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }
        .login-box {
            background-color: #222222;
            padding: 20px;
            border-radius: 8px;
            color: #ffcc00;
            text-align: center;
        }
        .login-box input {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ffcc00;
            border-radius: 5px;
            background-color: #444444;
            color: #ffffff;
        }
        .login-box button {
            background-color: #ffcc00;
            border: none;
            color: #fff;
            padding: 12px 24px;
            font-size: 18px;
            border-radius: 5px;
            cursor: pointer;
            width: 100%;
            margin-top: 15px;
        }
        .login-box button:hover {
            background-color: #e6b800;
        }

        footer {
            background-color: #222222;
            color: #ffcc00;
            text-align: center;
            padding: 15px 0;
            position: fixed;
            bottom: 0;
            width: 100%;
            font-size: 14px;
        }
        footer img {
            width: 20px;
            vertical-align: middle;
            margin-right: 5px;
        }
    </style>
</head>
<body>

<!-- Login Overlay -->
<div class="login-overlay" id="login-overlay">
    <div class="login-box">
        <h2>Enter Login Code</h2>
        <input type="text" id="login-code" placeholder="Enter your code here" required>
        <button onclick="validateLogin()">Submit</button>
    </div>
</div>

<header>
    <h1>Robux Shop</h1>
    <div>
        <div class="basket" onclick="openBasketWindow()">
            🛒 Basket
        </div>
        <button class="checkout" onclick="toggleCheckout()">Checkout</button>
    </div>
    <nav>
        <a href="#">Terms</a>
        <a href="#">Reviews</a>
    </nav>
</header>

<div class="shop-container">
    <div class="shop-item">
        <img src="Wave.png" alt="Wave Executor">
        <h2>Wave Executor</h2>
        <span class="price">749 Robux</span>
        <span class="stock in-stock">In stock</span>
        <button onclick="toggleOptions('wave', 749)">Buy</button>
    </div>
    <div class="shop-item">
        <img src="SynapseZ.png" alt="Synapse Z Executor">
        <h2>Synapse Z Executor</h2>
        <span class="price">649 Robux</span>
        <span class="stock in-stock">In stock</span>
        <button onclick="toggleOptions('synapse', 649)">Buy</button>
    </div>
    <div class="shop-item">
        <img src="AWP.png" alt="AWP Executor">
        <h2>AWP Executor</h2>
        <span class="price">699 Robux</span>
        <span class="stock in-stock">In stock</span>
        <button onclick="toggleOptions('awp', 699)">Buy</button>
    </div>
    <div class="shop-item">
        <img src="Seliware.png" alt="Seliware Executor">
        <h2>Seliware Executor</h2>
        <span class="price">999 Robux</span>
        <span class="stock in-stock">In stock</span>
        <button onclick="toggleOptions('seliware', 999)">Buy</button>
    </div>
    <div class="shop-item">
        <img src="Nihon.png" alt="Nihon Executor">
        <h2>Nihon Executor</h2>
        <span class="price">649 Robux</span>
        <span class="stock in-stock">In stock</span>
        <button onclick="toggleOptions('nihon', 649)">Buy</button>
    </div>
    <div class="shop-item">
        <img src="Moonlight.png" alt="Moonlight Arsenal Script">
        <h2>Moonlight: Arsenal Script</h2>
        <span class="price">999 Robux</span>
        <span class="stock in-stock">In stock</span>
        <button onclick="window.location.href='BuyMoonlightArsenalScriptPerm.html'">Buy</button>
    </div>
    <div class="shop-item">
        <img src="Pulse.png" alt="Pulse Universal Script">
        <h2>Pulse Universal Script</h2>
        <span class="price">1000 Robux</span>
        <span class="stock in-stock">In stock</span>
        <button onclick="toggleOptions('pulse')">Buy</button>
    </div>
</div>

<footer>
    <p>Copyright https://pulsekeys.store </p>
</footer>

<!-- Individual Purchase Options -->
<div class="purchase-options" id="wave-options">
    <div class="options-container">
        <button class="close-button" onclick="toggleOptions('wave')">X</button>
        <h2>Wave Executor - Choose your plan</h2>
        <p>1 Week: 777 Robux</p>
        <button onclick="addToBasket('Wave Executor', 777)">Add to Basket</button>
        <p>1 Month: 2545 Robux</p>
        <button onclick="addToBasket('Wave Executor', 2545)">Add to Basket</button>
    </div>
</div>

<div class="purchase-options" id="synapse-options">
    <div class="options-container">
        <button class="close-button" onclick="toggleOptions('synapse')">X</button>
        <h2>Synapse Z Executor - Choose your plan</h2>
        <p>1 Week: 650 Robux</p>
        <button onclick="addToBasket('Synapse Z Executor', 650)">Add to Basket</button>
        <p>1 Month: 2100 Robux</p>
        <button onclick="addToBasket('Synapse Z Executor', 2100)">Add to Basket</button>
    </div>
</div>

<div class="purchase-options" id="awp-options">
    <div class="options-container">
        <button class="close-button" onclick="toggleOptions('awp')">X</button>
        <h2>AWP Executor - Choose your plan</h2>
        <p>1 Week: 700 Robux</p>
        <button onclick="addToBasket('AWP Executor', 700)">Add to Basket</button>
        <p>1 Month: 2500 Robux</p>
        <button onclick="addToBasket('AWP Executor', 2500)">Add to Basket</button>
    </div>
</div>

<div class="purchase-options" id="seliware-options">
    <div class="options-container">
        <button class="close-button" onclick="toggleOptions('seliware')">X</button>
        <h2>Seliware Executor - Choose your plan</h2>
        <p>1 Week: 1000 Robux</p>
        <button onclick="addToBasket('Seliware Executor', 1000)">Add to Basket</button>
        <p>1 Month: 3000 Robux</p>
        <button onclick="addToBasket('Seliware Executor', 3000)">Add to Basket</button>
    </div>
</div>

<div class="purchase-options" id="nihon-options">
    <div class="options-container">
        <button class="close-button" onclick="toggleOptions('nihon')">X</button>
        <h2>Nihon Executor - Choose your plan</h2>
        <p>1 Week: 650 Robux</p>
        <button onclick="addToBasket('Nihon Executor', 650)">Add to Basket</button>
        <p>1 Month: 2300 Robux</p>
        <button onclick="addToBasket('Nihon Executor', 2300)">Add to Basket</button>
    </div>
</div>

<!-- New Purchase Options for Pulse Universal Script -->
<div class="purchase-options" id="pulse-options">
    <div class="options-container">
        <button class="close-button" onclick="toggleOptions('pulse')">X</button>
        <h2>Pulse Universal Script - Choose your plan</h2>
        <p>1 Week: 100 Robux</p>
        <button onclick="addToBasket('Pulse Universal Script', 100)">Add to Basket</button>
        <p>1 Month: 500 Robux</p>
        <button onclick="addToBasket('Pulse Universal Script', 500)">Add to Basket</button>
        <p>Permanent: 1000 Robux</p>
        <button onclick="addToBasket('Pulse Universal Script', 1000)">Add to Basket</button>
    </div>
</div>

<div class="purchase-options" id="checkout-options">
    <div class="options-container">
        <button class="close-button" onclick="toggleCheckout()">X</button>
        <h2>Checkout</h2>
        <input type="text" id="coupon-code" placeholder="Enter coupon code (optional)">
        <input type="text" id="card-number" placeholder="Credit Card Number" required>
        <input type="text" id="card-expiry" placeholder="MM/YY" required>
        <input type="text" id="card-cvc" placeholder="CVC" required>
        <input type="text" id="location" placeholder="Billing Address" required>
        <input type="email" id="email" placeholder="Email Address" required>
        <button onclick="completePurchase()">Purchase</button>
    </div>
</div>

<script>
    let basket = [];
    let isFree = false;
    const correctCode = "83290ufrkjghfnksjdgh45ihghkgjerhkdjgho54ihkjdfgkjhrkj";

    function validateLogin() {
        const enteredCode = document.getElementById('login-code').value;
        if (enteredCode === correctCode) {
            document.getElementById('login-overlay').style.display = 'none'; // Hide the login overlay
            document.body.style.display = 'block'; // Show the main content
        } else {
            alert('Incorrect login code. Please try again.');
        }
    }

    function toggleOptions(item) {
        var options = document.getElementById(item + '-options');
        if (options.style.display === 'none' || options.style.display === '') {
            options.style.display = 'flex';
        } else {
            options.style.display = 'none';
        }
    }

    function addToBasket(itemName, price) {
        if (isFree) price = 0;
        basket.push({ name: itemName, price: price, image: document.querySelector(`[alt="${itemName}"]`).src });
        updateBasket();
        toggleOptions(itemName.toLowerCase().replace(' ', ''));
    }

    function updateBasket() {
        // This function is currently not being used. You can implement it if needed.
    }

    function openBasketWindow() {
        const basketWindow = window.open("", "Basket", "width=600,height=400");
        basketWindow.document.write(`
            <html>
                <head>
                    <title>Your Basket</title>
                    <style>
                        body { font-family: Arial, sans-serif; background-color: #111111; color: white; }
                        .basket-container { padding: 20px; }
                        h2 { color: #ffcc00; }
                        img { width: 50px; vertical-align: middle; }
                    </style>
                </head>
                <body>
                    <div class="basket-container">
                        <h2>Your Basket</h2>
                        <div id="basket-items-in-new-window">Loading...</div>
                        <p>Total: <span id="total-price-in-new-window">0</span> Robux</p>
                        <button onclick="toggleCheckout()">Checkout</button> 
                    </div>
                </body>
            </html>
        `);
        basketWindow.document.close();

        const basketItemsContainer = basketWindow.document.getElementById('basket-items-in-new-window');
        const totalPriceElement = basketWindow.document.getElementById('total-price-in-new-window');
        basketItemsContainer.innerHTML = '';
        let total = 0;

        basket.forEach(item => {
            total += item.price;
            basketItemsContainer.innerHTML += `<div><img src="${item.image}" alt="${item.name}"> ${item.name} - ${item.price} Robux</div>`;
        });

        totalPriceElement.innerText = total;
    }

    function toggleCheckout() {
        const checkoutSummary = document.getElementById('checkout-options');
        if (checkoutSummary.style.display === 'none' || checkoutSummary.style.display === '') {
            checkoutSummary.style.display = 'flex';
        } else {
            checkoutSummary.style.display = 'none';
        }
    }

    async function completePurchase() {
        const couponCode = document.getElementById('coupon-code').value;
        const cardNumber = document.getElementById('card-number').value;
        const cardExpiry = document.getElementById('card-expiry').value;
        const cardCvc = document.getElementById('card-cvc').value;
        const location = document.getElementById('location').value;
        const email = document.getElementById('email').value;

        if (!cardNumber || !cardExpiry || !cardCvc || !location || !email) {
            alert("Please fill out all fields.");
            return;
        }

        if (couponCode === 'doopp') {
            isFree = true;
            alert("All items will be free!");
        }

        try {
            const response = await fetch('YOUR_BACKEND_ENDPOINT', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({ email: email })
            });

            if (response.ok) {
                alert(`Thank you for your purchase! Please check your email (${email}) for your account recovery information.`);
            } else {
                alert("There was an issue sending your recovery information. Please try again.");
            }
        
            basket = [];
            updateBasket();
            toggleCheckout();
        } catch (error) {
            console.error("Error during purchase:", error);
            alert("An error occurred. Please try again later.");
        }
    }

    // Show the login overlay at the start
    document.getElementById('login-overlay').style.display = 'flex';
</script>
</body>
</html>