<?php
    $themeSid = (string) ($site_sid ?? request('sid'));
    $themeVariant = 'style1';
    if ($themeSid === 'pg_sid_7qcu15y1ippvtsh1wv3cbc70cugxp1ci') {
        $themeVariant = 'style2';
    }
?>
<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Yatirim Yap - <?php echo e($site_name ?? 'GarantiPay'); ?></title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
    <style>
        :root {
            --gold-500: #e0832f;
            --gold-600: #c97428;
            --gold-700: #b86522;
            --gold-glow: rgba(224, 131, 47, 0.35);
            --border: #3a2c23;
            --text: #f3eee8;
            --muted: #b8a998;
        }
        body {
            background:
                radial-gradient(800px 500px at 15% 10%, rgba(224, 131, 47, 0.18) 0%, rgba(15, 11, 7, 0) 55%),
                radial-gradient(1000px 700px at 85% 20%, rgba(150, 94, 40, 0.18) 0%, rgba(15, 11, 7, 0) 60%),
                linear-gradient(135deg, #0c0907 0%, #15100c 50%, #0a0705 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            padding: 20px;
            color: var(--text);
        }
        .payment-card {
            background: linear-gradient(180deg, #19110d 0%, #120c09 100%);
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(224, 131, 47, 0.12);
            overflow: hidden;
            border: 1px solid var(--border);
        }
        .greeting {
            text-align: center;
            font-size: 1.25rem;
            font-weight: 700;
            color: #fff;
            margin: 24px 0 10px;
        }
        .form-control {
            background: #140e0b;
            color: var(--text);
            border: 1px solid var(--border);
        }
        .form-control::placeholder {
            color: #8b7a6a;
        }
        .form-control:focus {
            border-color: var(--gold-500);
            box-shadow: 0 0 0 0.2rem rgba(224, 131, 47, 0.2);
            background: #17100c;
            color: var(--text);
        }
        .btn-primary {
            background: var(--gold-500);
            border: 1px solid var(--gold-600);
            color: #1a110b;
            padding: 12px 30px;
            font-weight: 700;
            letter-spacing: 0.02em;
        }
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 22px var(--gold-glow);
            background: var(--gold-600);
            border-color: var(--gold-700);
            color: #140b07;
        }
        .btn-success {
            background: var(--gold-500);
            border: 1px solid var(--gold-600);
            color: #1a110b;
            font-weight: 700;
        }
        .btn-success:hover {
            background: var(--gold-600);
            border-color: var(--gold-700);
            box-shadow: 0 10px 20px var(--gold-glow);
        }
        .btn-outline-secondary {
            border-color: var(--border);
            color: var(--text);
            background: transparent;
        }
        .btn-outline-secondary:hover {
            background: #201612;
            border-color: #5a4537;
            color: var(--text);
        }
        .btn-outline-primary {
            border-color: var(--gold-500);
            color: var(--gold-500);
            background: transparent;
        }
        .btn-outline-primary:hover {
            background: rgba(224, 131, 47, 0.12);
            border-color: var(--gold-600);
            color: #f7efe7;
        }
        .alert-info {
            background: #1a120e;
            border: 1px solid var(--border);
            color: #f1d9bf;
        }
        .text-muted {
            color: var(--muted) !important;
        }
        .amount-display {
            font-size: 2.3rem;
            font-weight: bold;
            color: var(--gold-500);
            text-align: center;
            margin: 20px 0;
            text-shadow: 0 0 18px rgba(224, 131, 47, 0.35);
        }
        .method-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
            margin-bottom: 16px;
        }
        .method-grid.single {
            grid-template-columns: 56px 1fr 56px;
        }
        .method-grid.single .method-btn {
            grid-column: 2;
            width: 40%;
            min-width: 260px;
            justify-self: center;
        }
        .method-grid.single .method-back-btn {
            grid-column: 1;
        }
        .method-back-btn {
            border: 1px solid var(--border);
            border-radius: 12px;
            background: #1a120e;
            color: var(--text);
            font-size: 1.3rem;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all .2s ease;
        }
        .method-back-btn:hover {
            border-color: var(--gold-500);
            transform: translateY(-1px);
        }
        .method-btn {
            border: 1px solid var(--border);
            border-radius: 12px;
            background: #1a120e;
            color: var(--text);
            font-weight: 700;
            padding: 14px 16px;
            text-align: center;
            transition: all .2s ease;
            cursor: pointer;
        }
        .method-btn:hover {
            border-color: var(--gold-500);
            transform: translateY(-1px);
        }
        .method-btn.active {
            background: linear-gradient(135deg, var(--gold-600) 0%, var(--gold-500) 100%);
            color: #140b07;
            border-color: var(--gold-600);
            box-shadow: 0 8px 20px var(--gold-glow);
        }
        .method-btn i {
            margin-right: 8px;
        }
        .bank-info {
            background: #17100c;
            border-left: 4px solid var(--gold-500);
            padding: 18px;
            border-radius: 10px;
            margin: 20px 0;
            border: 1px solid var(--border);
        }
        .bank-info-item {
            display: flex;
            justify-content: space-between;
            margin: 10px 0;
            padding: 10px;
            background: #1d140f;
            border-radius: 8px;
            border: 1px solid var(--border);
            gap: 10px;
        }
        .copy-btn {
            cursor: pointer;
            transition: all 0.2s;
        }
        .copy-btn:hover {
            transform: scale(1.06);
        }
        .crypto-list {
            display: flex;
            flex-direction: column;
            gap: 14px;
            margin: 18px 0;
        }
        .crypto-card {
            display: grid;
            grid-template-columns: 110px 1fr auto;
            gap: 14px;
            align-items: center;
            background: #17100c;
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 12px;
            cursor: pointer;
            transition: all .2s ease;
        }
        .crypto-card:hover {
            border-color: var(--gold-500);
            transform: translateY(-1px);
        }
        .crypto-card.active {
            border-color: var(--gold-500);
            box-shadow: 0 0 0 1px rgba(224, 131, 47, 0.35), 0 8px 18px rgba(0,0,0,.28);
        }
        .crypto-qr {
            width: 96px;
            height: 96px;
            border-radius: 8px;
            background: #fff;
            padding: 4px;
            object-fit: cover;
        }
        .crypto-coin-row {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 6px;
            font-size: 1.08rem;
            font-weight: 700;
        }
        .crypto-coin-icon {
            width: 22px;
            height: 22px;
            border-radius: 999px;
            object-fit: cover;
            background: #fff;
            border: 1px solid rgba(255,255,255,.35);
        }
        .crypto-address {
            word-break: break-all;
            font-size: .94rem;
            color: #f3eee8;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
        }
        .crypto-actions {
            display: flex;
            flex-direction: column;
            gap: 8px;
            min-width: 96px;
        }
        .swal-theme-popup {
            border-radius: 16px !important;
            border: 1px solid var(--border) !important;
            background: linear-gradient(180deg, #1b120d 0%, #120c09 100%) !important;
            color: var(--text) !important;
            box-shadow: 0 24px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(224, 131, 47, 0.18);
        }
        .swal-theme-toast {
            border-radius: 12px !important;
            padding: 0.8rem 1rem !important;
        }
        .swal-theme-title {
            color: #fff !important;
            font-weight: 700 !important;
        }
        .swal-theme-html {
            color: var(--text) !important;
        }
        .swal-theme-actions {
            gap: 10px;
        }
        .swal-theme-confirm,
        .swal-theme-cancel {
            border-radius: 10px !important;
            border: 1px solid transparent !important;
            font-weight: 700 !important;
            padding: 10px 18px !important;
            transition: all .18s ease;
        }
        .swal-theme-confirm {
            background: var(--gold-500) !important;
            border-color: var(--gold-600) !important;
            color: #1a110b !important;
        }
        .swal-theme-confirm:hover {
            background: var(--gold-600) !important;
            border-color: var(--gold-700) !important;
            color: #140b07 !important;
            box-shadow: 0 8px 20px var(--gold-glow);
        }
        .swal-theme-cancel {
            background: transparent !important;
            border-color: var(--border) !important;
            color: var(--text) !important;
        }
        .swal-theme-cancel:hover {
            background: #201612 !important;
            border-color: #5a4537 !important;
            color: var(--text) !important;
        }
        #step1 { display: block; }
        #step2 { display: none; }
        #step3 { display: none; }

        body.theme-style2 {
            --gold-500: #e32014;
            --gold-600: #c1170f;
            --gold-700: #980f0b;
            --gold-glow: rgba(227, 32, 20, 0.45);
            --border: #5c1412;
            --text: #f6f3f1;
            --muted: #c8aaaa;
            background:
                radial-gradient(800px 500px at 15% 10%, rgba(210, 20, 20, 0.28) 0%, rgba(5, 5, 5, 0) 55%),
                radial-gradient(1000px 700px at 85% 20%, rgba(145, 8, 8, 0.28) 0%, rgba(5, 5, 5, 0) 60%),
                linear-gradient(135deg, #030303 0%, #0a0a0a 50%, #020202 100%);
        }
        body.theme-style2 .payment-card {
            background: linear-gradient(180deg, #100909 0%, #070707 100%);
            border-color: #5c1412;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(227, 32, 20, 0.22);
        }
        body.theme-style2 .bank-info,
        body.theme-style2 .crypto-card,
        body.theme-style2 .method-btn {
            background: #110707;
            border-color: #4f1515;
        }
        body.theme-style2 .method-btn.active {
            background: #ffffff !important;
            color: #7a0c0c !important;
            border-color: #f4d9d9 !important;
            box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.65), 0 8px 20px rgba(255, 255, 255, 0.22);
        }
        body.theme-style2 .bank-info-item {
            background: #150909;
            border-color: #4f1515;
        }
        body.theme-style2 .form-control {
            background: #0f0707;
            border-color: #4f1515;
        }
        body.theme-style2 .form-control:focus {
            background: #120808;
            border-color: #e32014;
            box-shadow: 0 0 0 0.2rem rgba(227, 32, 20, 0.22);
        }
        body.theme-style2 .alert-info {
            background: #140909;
            border-color: #4f1515;
            color: #f5d7d7;
        }
        body.theme-style2 .btn-primary,
        body.theme-style2 .btn-success {
            color: #ffffff;
        }
        body.theme-style2 .btn-primary:hover,
        body.theme-style2 .btn-success:hover {
            color: #ffffff;
        }
        body.theme-style2 .swal-theme-popup {
            border-color: #5c1412 !important;
            background: linear-gradient(180deg, #110808 0%, #070707 100%) !important;
            box-shadow: 0 24px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(227, 32, 20, 0.24);
        }
        body.theme-style2 .swal-theme-confirm {
            background: #e32014 !important;
            border-color: #c1170f !important;
            color: #fff !important;
        }
        body.theme-style2 .swal-theme-confirm:hover {
            background: #c1170f !important;
            border-color: #980f0b !important;
            color: #fff !important;
        }
        body.theme-style2 .swal-theme-cancel {
            background: #110707 !important;
            border-color: #4f1515 !important;
            color: #f6f3f1 !important;
        }
        body.theme-style2 .swal-theme-cancel:hover {
            background: #190c0c !important;
            border-color: #732121 !important;
            color: #f6f3f1 !important;
        }
        /* Style 2 Neon Red Override */
        body.theme-style2 {
            --gold-500: #ff2a20;
            --gold-600: #e61111;
            --gold-700: #b80d0d;
            --gold-glow: rgba(255, 34, 22, 0.5);
            --border: #8f1616;
            --text: #fbf7f7;
            --muted: #d4b2b2;
            font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
            background:
                radial-gradient(700px 420px at 18% 10%, rgba(255, 30, 30, 0.42) 0%, rgba(8, 8, 8, 0) 58%),
                radial-gradient(920px 540px at 84% 20%, rgba(255, 8, 8, 0.34) 0%, rgba(8, 8, 8, 0) 60%),
                repeating-linear-gradient(122deg, rgba(255, 12, 12, 0.2) 0 2px, rgba(0, 0, 0, 0) 2px 34px),
                linear-gradient(145deg, #080808 0%, #0b0909 52%, #040404 100%);
        }
        body.theme-style2 .container {
            max-width: 540px;
        }
        body.theme-style2 .col-lg-8 {
            max-width: 500px;
        }
        body.theme-style2 .payment-card {
            position: relative;
            border-radius: 34px;
            border: 2px solid #bf1717;
            background: linear-gradient(180deg, #0a0707 0%, #050404 100%);
            box-shadow:
                0 28px 80px rgba(0, 0, 0, 0.8),
                0 0 0 1px rgba(255, 42, 28, 0.42),
                0 0 34px rgba(255, 20, 14, 0.34),
                inset 0 0 0 1px rgba(255, 30, 24, 0.18);
            animation: style2CardPulse 3s ease-in-out infinite alternate;
            overflow: visible;
            min-height: 680px;
        }
        body.theme-style2 .payment-card::before {
            content: "";
            position: absolute;
            inset: 8px;
            border-radius: 27px;
            border: 1px solid rgba(255, 24, 18, 0.52);
            pointer-events: none;
            box-shadow: inset 0 0 22px rgba(255, 18, 14, 0.22);
        }
        body.theme-style2 .greeting {
            font-size: 2.15rem;
            font-weight: 800;
            margin: 18px 0 10px;
            text-shadow: 0 0 16px rgba(255, 24, 18, 0.22);
            color: #fff;
            position: relative;
            z-index: 2;
        }
        body.theme-style2 .p-4 {
            padding: 1.25rem 1.4rem 1.5rem !important;
            position: relative;
            z-index: 2;
        }
        body.theme-style2 .method-grid {
            grid-template-columns: 1fr;
            gap: 18px;
            margin: 16px auto 22px;
            max-width: 410px;
        }
        body.theme-style2 .method-btn,
        body.theme-style2 #requestPaymentBtn,
        body.theme-style2 #confirmPaymentBtn,
        body.theme-style2 #returnToSiteBtn {
            border-radius: 20px;
            padding: 18px 20px;
            border: 1px solid #c11f1f;
            background:
                linear-gradient(180deg, rgba(82, 10, 10, 0.94) 0%, rgba(28, 7, 7, 0.98) 100%);
            color: #fff !important;
            font-size: 2rem;
            font-weight: 800;
            letter-spacing: 0;
            box-shadow:
                0 0 0 1px rgba(255, 34, 25, 0.3),
                inset 0 0 26px rgba(255, 14, 14, 0.16),
                0 12px 24px rgba(0, 0, 0, 0.55);
            text-shadow: 0 0 12px rgba(0, 0, 0, 0.48);
        }
        body.theme-style2 .method-btn i,
        body.theme-style2 #requestPaymentBtn i,
        body.theme-style2 #confirmPaymentBtn i,
        body.theme-style2 #returnToSiteBtn i {
            margin-right: 12px;
        }
        body.theme-style2 .method-btn:hover,
        body.theme-style2 .method-btn.active,
        body.theme-style2 #requestPaymentBtn:hover,
        body.theme-style2 #confirmPaymentBtn:hover,
        body.theme-style2 #returnToSiteBtn:hover {
            border-color: #ff3b2d;
            background: linear-gradient(180deg, rgba(96, 12, 12, 0.98) 0%, rgba(38, 8, 8, 0.98) 100%) !important;
            color: #fff !important;
            box-shadow:
                0 0 0 1px rgba(255, 76, 60, 0.52),
                0 0 25px rgba(255, 40, 28, 0.4),
                inset 0 0 28px rgba(255, 42, 30, 0.2);
            transform: translateY(-1px);
        }
        body.theme-style2 .amount-display {
            color: #ff4d45;
            text-shadow: 0 0 22px rgba(255, 42, 34, 0.48);
        }
        body.theme-style2 .btn-primary,
        body.theme-style2 .btn-success {
            background: linear-gradient(180deg, #ff2d22 0%, #d51511 100%);
            border-color: #ac1110;
            color: #fff !important;
            box-shadow: 0 10px 22px rgba(255, 24, 18, 0.34);
        }
        body.theme-style2 .btn-primary:hover,
        body.theme-style2 .btn-success:hover {
            background: linear-gradient(180deg, #ff4133 0%, #e11b15 100%);
            border-color: #bf1412;
        }
        body.theme-style2 .bank-info,
        body.theme-style2 .crypto-card {
            border-radius: 15px;
            border-color: #8d2020;
            background: linear-gradient(180deg, #130707 0%, #0a0505 100%);
        }
        body.theme-style2 .bank-info-item {
            border-radius: 10px;
            border-color: #782020;
            background: #170808;
        }
        body.theme-style2 .crypto-card.active {
            box-shadow:
                0 0 0 1px rgba(255, 45, 30, 0.55),
                0 0 20px rgba(255, 35, 20, 0.24),
                0 10px 22px rgba(0, 0, 0, 0.52);
        }
        @keyframes  style2CardPulse {
            from {
                box-shadow:
                    0 28px 80px rgba(0, 0, 0, 0.8),
                    0 0 0 1px rgba(255, 42, 28, 0.36),
                    0 0 28px rgba(255, 20, 14, 0.24),
                    inset 0 0 0 1px rgba(255, 30, 24, 0.14);
            }
            to {
                box-shadow:
                    0 28px 80px rgba(0, 0, 0, 0.8),
                    0 0 0 1px rgba(255, 58, 40, 0.52),
                    0 0 38px rgba(255, 18, 12, 0.38),
                    inset 0 0 0 1px rgba(255, 34, 28, 0.2);
            }
        }

        @media (max-width: 768px) {
            body.theme-style2 .greeting {
                font-size: 1.85rem;
            }
            body.theme-style2 .method-btn {
                font-size: 1.75rem;
                padding: 15px 16px;
            }
            body.theme-style2 .payment-card {
                min-height: 0;
                border-radius: 28px;
            }
            .method-grid {
                grid-template-columns: 1fr;
            }
            .crypto-card {
                grid-template-columns: 1fr;
                text-align: center;
            }
            .crypto-coin-row {
                justify-content: center;
            }
            .crypto-address {
                text-align: left;
            }
        }

        /* Style 2 Final Tuning */
        body.theme-style2 {
            position: relative;
            overflow-x: hidden;
            background:
                radial-gradient(760px 460px at 16% 8%, rgba(255, 34, 30, 0.44) 0%, rgba(8, 8, 8, 0) 58%),
                radial-gradient(980px 580px at 84% 18%, rgba(255, 14, 14, 0.36) 0%, rgba(8, 8, 8, 0) 60%),
                radial-gradient(420px 260px at 18% 78%, rgba(255, 28, 24, 0.18) 0%, rgba(0, 0, 0, 0) 74%),
                radial-gradient(460px 300px at 82% 82%, rgba(255, 24, 20, 0.16) 0%, rgba(0, 0, 0, 0) 74%),
                linear-gradient(145deg, #080808 0%, #0b0909 52%, #040404 100%);
        }
        body.theme-style2::before,
        body.theme-style2::after {
            content: "";
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 0;
        }
        body.theme-style2::before {
            background:
                radial-gradient(4px 4px at 11% 20%, rgba(255, 110, 86, 0.7) 0%, rgba(255, 24, 24, 0) 60%),
                radial-gradient(3px 3px at 22% 66%, rgba(255, 98, 72, 0.62) 0%, rgba(255, 24, 24, 0) 60%),
                radial-gradient(3px 3px at 38% 28%, rgba(255, 94, 70, 0.58) 0%, rgba(255, 24, 24, 0) 60%),
                radial-gradient(4px 4px at 66% 24%, rgba(255, 100, 74, 0.62) 0%, rgba(255, 24, 24, 0) 60%),
                radial-gradient(3px 3px at 82% 72%, rgba(255, 102, 75, 0.64) 0%, rgba(255, 24, 24, 0) 60%),
                radial-gradient(4px 4px at 90% 34%, rgba(255, 100, 72, 0.58) 0%, rgba(255, 24, 24, 0) 60%);
            opacity: 0.95;
            animation: style2Sparkle 2.6s ease-in-out infinite alternate;
        }
        body.theme-style2::after {
            background:
                radial-gradient(6px 6px at 8% 18%, rgba(255, 62, 48, 0.34) 0%, rgba(255, 24, 24, 0) 62%),
                radial-gradient(5px 5px at 17% 76%, rgba(255, 66, 52, 0.32) 0%, rgba(255, 24, 24, 0) 62%),
                radial-gradient(4px 4px at 31% 52%, rgba(255, 62, 50, 0.3) 0%, rgba(255, 24, 24, 0) 62%),
                radial-gradient(6px 6px at 46% 18%, rgba(255, 70, 54, 0.32) 0%, rgba(255, 24, 24, 0) 62%),
                radial-gradient(5px 5px at 63% 64%, rgba(255, 62, 48, 0.3) 0%, rgba(255, 24, 24, 0) 62%),
                radial-gradient(6px 6px at 74% 32%, rgba(255, 74, 58, 0.32) 0%, rgba(255, 24, 24, 0) 62%),
                radial-gradient(4px 4px at 88% 78%, rgba(255, 68, 52, 0.34) 0%, rgba(255, 24, 24, 0) 62%);
            opacity: 0.34;
            filter: blur(0.2px);
            animation: style2ParticleDrift 7.4s ease-in-out infinite alternate;
        }
        @keyframes  style2Sparkle {
            from { opacity: 0.58; filter: saturate(1); }
            to { opacity: 1; filter: saturate(1.45); }
        }
        @keyframes  style2ParticleDrift {
            from { transform: translate3d(0, 0, 0) scale(1); }
            to { transform: translate3d(-10px, 8px, 0) scale(1.03); }
        }

        body.theme-style2 .container,
        body.theme-style2 .row,
        body.theme-style2 .col-lg-8,
        body.theme-style2 .payment-card {
            position: relative;
            z-index: 1;
        }
        body.theme-style2 .container {
            max-width: 1140px !important;
        }
        body.theme-style2 .col-lg-8 {
            max-width: none !important;
        }
        body.theme-style2 .payment-card {
            overflow: visible;
            border-color: #be1d1d;
            box-shadow:
                0 30px 82px rgba(0, 0, 0, 0.82),
                0 0 0 1px rgba(255, 40, 30, 0.46),
                0 0 44px rgba(255, 18, 12, 0.32),
                inset 0 0 0 1px rgba(255, 36, 30, 0.18);
        }
        body.theme-style2 .greeting {
            position: relative;
            z-index: 2;
            text-shadow: 0 0 18px rgba(255, 30, 20, 0.32);
        }

        body.theme-style2 .method-grid {
            grid-template-columns: 1fr !important;
            max-width: none !important;
            gap: 14px;
        }
        body.theme-style2 .method-grid.single {
            grid-template-columns: 56px 1fr 56px !important;
            gap: 12px;
        }
        body.theme-style2 .method-grid.single .method-btn {
            grid-column: 2;
            width: 42%;
            min-width: 280px;
            justify-self: center;
        }
        body.theme-style2 .method-grid.single .method-back-btn {
            grid-column: 1;
        }
        body.theme-style2 .method-btn,
        body.theme-style2 .method-back-btn,
        body.theme-style2 #requestPaymentBtn,
        body.theme-style2 #confirmPaymentBtn,
        body.theme-style2 #returnToSiteBtn {
            position: relative;
            overflow: hidden;
            border-color: #d92a25;
            box-shadow:
                0 0 0 1px rgba(255, 44, 34, 0.5),
                inset 0 0 30px rgba(255, 18, 14, 0.2),
                0 12px 26px rgba(0, 0, 0, 0.56),
                0 0 26px rgba(255, 24, 18, 0.32);
        }
        body.theme-style2 .method-btn::before,
        body.theme-style2 .method-back-btn::before,
        body.theme-style2 #requestPaymentBtn::before,
        body.theme-style2 #confirmPaymentBtn::before,
        body.theme-style2 #returnToSiteBtn::before {
            content: "";
            position: absolute;
            top: -170%;
            left: -38%;
            width: 30%;
            height: 440%;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 158, 158, 0.48) 48%, rgba(255, 255, 255, 0) 100%);
            transform: rotate(20deg);
            animation: style2ButtonSweepLoop 5.2s ease-in-out infinite;
            pointer-events: none;
        }
        body.theme-style2 .method-btn::after,
        body.theme-style2 .method-back-btn::after,
        body.theme-style2 #requestPaymentBtn::after,
        body.theme-style2 #confirmPaymentBtn::after,
        body.theme-style2 #returnToSiteBtn::after {
            content: "";
            position: absolute;
            inset: 0;
            background:
                radial-gradient(4px 4px at 14% 28%, rgba(255, 80, 60, 0.42) 0%, rgba(255, 20, 20, 0) 62%),
                radial-gradient(3px 3px at 82% 66%, rgba(255, 84, 62, 0.38) 0%, rgba(255, 20, 20, 0) 62%);
            pointer-events: none;
            animation: style2ButtonSparkLoop 5.2s ease-in-out infinite;
        }
        body.theme-style2 #methodBankBtn::before {
            animation: style2ButtonSweepPhaseA 5.2s ease-in-out infinite;
        }
        body.theme-style2 #methodCryptoBtn::before {
            animation: style2ButtonSweepPhaseB 5.2s ease-in-out infinite;
        }
        body.theme-style2 #methodBankBtn::after {
            animation: style2ButtonSparkPhaseA 5.2s ease-in-out infinite;
        }
        body.theme-style2 #methodCryptoBtn::after {
            animation: style2ButtonSparkPhaseB 5.2s ease-in-out infinite;
        }
        body.theme-style2 .method-grid.single #methodBackBtn::before {
            animation: style2ButtonSweepSingleBack 5.2s ease-in-out infinite;
        }
        body.theme-style2 .method-grid.single #methodBackBtn::after {
            animation: style2ButtonSparkSingleBack 5.2s ease-in-out infinite;
        }
        body.theme-style2 .method-grid.single .method-btn:not(.d-none)::before {
            animation: style2ButtonSweepSingleMethod 5.2s ease-in-out infinite;
        }
        body.theme-style2 .method-grid.single .method-btn:not(.d-none)::after {
            animation: style2ButtonSparkSingleMethod 5.2s ease-in-out infinite;
        }
        body.theme-style2 #requestButtonWrap.d-grid #requestPaymentBtn::before {
            animation: style2ButtonSweepSingleRequest 5.2s ease-in-out infinite;
        }
        body.theme-style2 #requestButtonWrap.d-grid #requestPaymentBtn::after {
            animation: style2ButtonSparkSingleRequest 5.2s ease-in-out infinite;
        }
        @keyframes  style2ButtonSweepLoop {
            0% { left: -40%; opacity: 0; }
            7% { opacity: 0.95; }
            22% { left: 120%; opacity: 0; }
            100% { left: 120%; opacity: 0; }
        }
        @keyframes  style2ButtonSparkLoop {
            0%, 22% { opacity: 0.52; }
            30%, 100% { opacity: 0.18; }
        }
        @keyframes  style2ButtonSweepPhaseA {
            0%, 48% { left: -40%; opacity: 0; }
            6%, 54% { opacity: 0.95; }
            24%, 72% { left: 120%; opacity: 0; }
            100% { left: 120%; opacity: 0; }
        }
        @keyframes  style2ButtonSweepPhaseB {
            0%, 24.1%, 72.1% { left: -40%; opacity: 0; }
            30.1%, 78.1% { opacity: 0.95; }
            48.1%, 100% { left: 120%; opacity: 0; }
        }
        @keyframes  style2ButtonSparkPhaseA {
            0%, 24% { opacity: 0.56; }
            30%, 48% { opacity: 0.16; }
            54%, 72% { opacity: 0.56; }
            78%, 100% { opacity: 0.16; }
        }
        @keyframes  style2ButtonSparkPhaseB {
            0%, 24.1% { opacity: 0.16; }
            30.1%, 48.1% { opacity: 0.56; }
            54.1%, 72.1% { opacity: 0.16; }
            78.1%, 100% { opacity: 0.56; }
        }
        @keyframes  style2ButtonSweepSingleBack {
            0% { left: -40%; opacity: 0; }
            5% { opacity: 0.95; }
            28% { left: 120%; opacity: 0; }
            100% { left: 120%; opacity: 0; }
        }
        @keyframes  style2ButtonSweepSingleMethod {
            0%, 28.1% { left: -40%; opacity: 0; }
            33.1% { opacity: 0.95; }
            62.1% { left: 120%; opacity: 0; }
            100% { left: 120%; opacity: 0; }
        }
        @keyframes  style2ButtonSweepSingleRequest {
            0%, 62.1% { left: -40%; opacity: 0; }
            67.1% { opacity: 0.95; }
            100% { left: 120%; opacity: 0; }
        }
        @keyframes  style2ButtonSparkSingleBack {
            0%, 28% { opacity: 0.56; }
            33%, 100% { opacity: 0.16; }
        }
        @keyframes  style2ButtonSparkSingleMethod {
            0%, 28.1% { opacity: 0.16; }
            33.1%, 62.1% { opacity: 0.56; }
            67.1%, 100% { opacity: 0.16; }
        }
        @keyframes  style2ButtonSparkSingleRequest {
            0%, 62.1% { opacity: 0.16; }
            67.1%, 100% { opacity: 0.56; }
        }
        body.theme-style2 .method-btn.active {
            background: linear-gradient(180deg, #ffffff 0%, #f3ecec 100%) !important;
            color: #8b1010 !important;
            border-color: #ffffff !important;
            box-shadow:
                0 0 0 1px rgba(255, 255, 255, 0.9),
                0 0 24px rgba(255, 255, 255, 0.4),
                inset 0 0 14px rgba(255, 255, 255, 0.45);
            text-shadow: none;
        }

        @media (max-width: 768px) {
            body.theme-style2 {
                padding: 8px;
            }
            body.theme-style2 .container {
                max-width: 460px !important;
                padding-left: 6px;
                padding-right: 6px;
            }
            body.theme-style2 .col-lg-8 {
                max-width: 100% !important;
            }
            body.theme-style2 .payment-card {
                min-height: 0;
                border-radius: 28px;
            }
            body.theme-style2 .greeting {
                font-size: 1.9rem;
                margin: 6px 0 12px;
            }
            body.theme-style2 .p-4 {
                padding: 0.3rem 1rem 1.25rem !important;
            }
            body.theme-style2 .method-grid {
                grid-template-columns: 1fr !important;
                max-width: 100% !important;
                gap: 14px;
                margin-top: 10px;
            }
            body.theme-style2 .method-grid.single {
                grid-template-columns: 50px 1fr !important;
                gap: 10px;
            }
            body.theme-style2 .method-grid.single .method-btn {
                width: 100% !important;
                min-width: 0 !important;
            }
            body.theme-style2 .method-btn,
            body.theme-style2 #requestPaymentBtn {
                font-size: 1.72rem;
                padding: 16px 16px;
            }
        }

        /* Style2 Background FX */
        body.theme-style2::before {
            content: "" !important;
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 0;
            background:
                radial-gradient(circle at 10% 22%, rgba(255, 95, 74, 0.95) 0 2px, rgba(255, 24, 24, 0) 7px),
                radial-gradient(circle at 18% 72%, rgba(255, 90, 70, 0.85) 0 2px, rgba(255, 24, 24, 0) 7px),
                radial-gradient(circle at 36% 34%, rgba(255, 98, 76, 0.84) 0 2px, rgba(255, 24, 24, 0) 7px),
                radial-gradient(circle at 64% 28%, rgba(255, 104, 80, 0.88) 0 2px, rgba(255, 24, 24, 0) 7px),
                radial-gradient(circle at 82% 66%, rgba(255, 98, 74, 0.86) 0 2px, rgba(255, 24, 24, 0) 7px),
                radial-gradient(circle at 90% 38%, rgba(255, 106, 82, 0.9) 0 2px, rgba(255, 24, 24, 0) 7px),
                linear-gradient(132deg, rgba(255, 30, 24, 0) 34%, rgba(255, 48, 34, 0.42) 48%, rgba(255, 30, 24, 0) 62%),
                linear-gradient(118deg, rgba(255, 24, 20, 0) 60%, rgba(255, 44, 32, 0.34) 72%, rgba(255, 24, 20, 0) 84%),
                radial-gradient(760px 520px at 16% 10%, rgba(255, 24, 20, 0.35) 0%, rgba(8, 8, 8, 0) 62%),
                radial-gradient(960px 640px at 84% 20%, rgba(255, 16, 14, 0.3) 0%, rgba(8, 8, 8, 0) 64%);
            animation: style2BgPulse 3s ease-in-out infinite alternate;
        }
        body.theme-style2::after {
            content: "" !important;
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 0;
            background:
                radial-gradient(circle at 14% 84%, rgba(255, 120, 92, 0.42) 0 1px, rgba(255, 24, 24, 0) 5px),
                radial-gradient(circle at 28% 54%, rgba(255, 122, 96, 0.35) 0 1px, rgba(255, 24, 24, 0) 5px),
                radial-gradient(circle at 47% 22%, rgba(255, 116, 90, 0.38) 0 1px, rgba(255, 24, 24, 0) 5px),
                radial-gradient(circle at 58% 62%, rgba(255, 120, 94, 0.34) 0 1px, rgba(255, 24, 24, 0) 5px),
                radial-gradient(circle at 72% 40%, rgba(255, 124, 98, 0.36) 0 1px, rgba(255, 24, 24, 0) 5px),
                radial-gradient(circle at 88% 78%, rgba(255, 122, 96, 0.38) 0 1px, rgba(255, 24, 24, 0) 5px);
            animation: style2SparkDrift 6.8s ease-in-out infinite alternate;
        }
        @keyframes  style2BgPulse {
            from { opacity: 0.82; filter: saturate(1); }
            to { opacity: 1; filter: saturate(1.25); }
        }
        @keyframes  style2SparkDrift {
            from { transform: translate3d(0, 0, 0); opacity: 0.5; }
            to { transform: translate3d(-10px, 9px, 0); opacity: 0.9; }
        }
        body.theme-style2 .method-grid {
            gap: 10px !important;
        }
        body.theme-style2 .method-btn,
        body.theme-style2 #requestPaymentBtn,
        body.theme-style2 #confirmPaymentBtn,
        body.theme-style2 #returnToSiteBtn {
            font-size: 1.38rem !important;
            padding: 11px 14px !important;
            border-radius: 14px !important;
        }
        body.theme-style2 .method-back-btn {
            font-size: 1.05rem !important;
        }
        @media (max-width: 768px) {
            body.theme-style2 .method-btn,
            body.theme-style2 #requestPaymentBtn,
            body.theme-style2 #confirmPaymentBtn,
            body.theme-style2 #returnToSiteBtn {
                font-size: 1.18rem !important;
                padding: 10px 12px !important;
            }
            body.theme-style2 .method-back-btn {
                font-size: 0.95rem !important;
            }
        }
    </style>
</head>
<body class="theme-<?php echo e($themeVariant); ?>">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-8">
                <div class="payment-card">
                    <div class="text-center">
                        <?php if(!empty($site_logo_url)): ?>
                            <img src="<?php echo e($site_logo_url); ?>" alt="<?php echo e($site_name ?? 'Site'); ?> Logo" style="width: 40%; height: auto; padding-top: 22px;">
                        <?php else: ?>
                            <i class="bi bi-bank2" style="font-size:2.9rem;line-height:1;"></i>
                        <?php endif; ?>
                    </div>

                    <div class="greeting" id="greetingRow" style="display: none;">
                        Merhaba, <span class="name" id="greetingName">-</span>
                    </div>

                    <div class="p-4">
                        <div id="step1">
                            <form id="depositForm">
                                <input type="hidden" name="customer_player_id" id="customerPlayerId">
                                <input type="hidden" name="sid" id="siteSid" value="<?php echo e($site_sid ?? request('sid')); ?>">
                                <input type="hidden" name="trx" id="transactionTrx" value="<?php echo e(request('trx')); ?>">
                                <input type="hidden" name="payment_method" id="paymentMethod" value="">
                                <input type="hidden" id="customerName" name="customer_name">
                                <input type="hidden" name="deposit_guard_token" id="depositGuardToken" value="<?php echo e($deposit_guard_token ?? ''); ?>">
                                <div style="position:absolute;left:-9999px;opacity:0;pointer-events:none;" aria-hidden="true">
                                    <label for="companyWebsiteTrap">Website</label>
                                    <input type="text" name="company_website" id="companyWebsiteTrap" tabindex="-1" autocomplete="off">
                                </div>

                                <div class="method-grid" id="methodGrid">
                                    <button type="button" class="method-back-btn d-none" id="methodBackBtn" aria-label="Geri">
                                        <i class="bi bi-arrow-left"></i>
                                    </button>
                                    <button type="button" class="method-btn" data-method="bank" id="methodBankBtn">
                                        <i class="bi bi-bank"></i>Banka Havale
                                    </button>
                                    <button type="button" class="method-btn" data-method="crypto" id="methodCryptoBtn">
                                        <i class="bi bi-currency-bitcoin"></i>Kripto
                                    </button>
                                </div>

                                <div class="mb-3" id="amountBlock" style="display:none;">
                                    <label class="form-label fw-bold">Yatirim Tutari (TL) <span class="text-danger">*</span></label>
                                    <input type="text" id="depositAmount" name="amount" class="form-control form-control-lg" required placeholder="0">
                                </div>

                                <div class="d-none" id="requestButtonWrap">
                                    <button type="submit" id="requestPaymentBtn" class="btn btn-primary btn-lg">
                                        <i class="bi bi-arrow-right-circle me-2"></i>IBAN Iste
                                    </button>
                                </div>
                            </form>
                        </div>

                        <div id="step2">
                            <h4 class="mb-4" id="step2Title">Banka Hesabi Bilgileri</h4>

                            <div class="amount-display">
                                <span id="displayAmount">0</span> TL
                            </div>

                            <div class="alert alert-info" id="paymentInfoAlert">
                                <i class="bi bi-info-circle me-2"></i>
                                Asagidaki banka hesabina <strong>TAM OLARAK</strong> belirtilen tutari gonderin.
                            </div>

                            <div id="bankSection" class="bank-info">
                                <h5 class="mb-3"><i class="bi bi-bank me-2"></i>Gonderilecek Hesap</h5>

                                <div class="bank-info-item">
                                    <div>
                                        <small class="text-muted">Banka</small>
                                        <div class="fw-bold" id="bankName">-</div>
                                    </div>
                                </div>

                                <div class="bank-info-item">
                                    <div class="flex-grow-1">
                                        <small class="text-muted">IBAN</small>
                                        <div class="fw-bold" id="bankIban">-</div>
                                    </div>
                                    <div>
                                        <button type="button" class="btn btn-sm btn-outline-primary copy-btn" onclick="copyToClipboard('bankIban')">
                                            <i class="bi bi-clipboard"></i>
                                        </button>
                                    </div>
                                </div>

                                <div class="bank-info-item">
                                    <div class="flex-grow-1">
                                        <small class="text-muted">Hesap Sahibi</small>
                                        <div class="fw-bold" id="accountName">-</div>
                                    </div>
                                    <div>
                                        <button type="button" class="btn btn-sm btn-outline-primary copy-btn" onclick="copyToClipboard('accountName')">
                                            <i class="bi bi-clipboard"></i>
                                        </button>
                                    </div>
                                </div>

                                <div class="bank-info-item">
                                    <div class="flex-grow-1">
                                        <small class="text-muted">Aciklama</small>
                                        <div class="fw-bold" id="accountDescription">-</div>
                                    </div>
                                    <div>
                                        <button type="button" class="btn btn-sm btn-outline-primary copy-btn" onclick="copyToClipboard('accountDescription')">
                                            <i class="bi bi-clipboard"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>

                            <div id="cryptoSection" style="display:none;">
                                <div id="cryptoCards" class="crypto-list"></div>
                            </div>

                            <div class="d-grid gap-2">
                                <button type="button" class="btn btn-success btn-lg" id="confirmPaymentBtn" onclick="confirmPayment()">
                                    <i class="bi bi-check-circle me-2"></i>Odemeyi Yaptim
                                </button>
                                <button type="button" class="btn btn-outline-secondary" onclick="goToStep(1)">
                                    <i class="bi bi-arrow-left me-2"></i>Geri Don
                                </button>
                            </div>
                        </div>

                        <div id="step3">
                            <div class="text-center py-5">
                                <div class="mb-4">
                                    <i class="bi bi-check-circle-fill text-success" style="font-size: 5rem;"></i>
                                </div>
                                <h3 class="text-success mb-3">Islem Alindi</h3>
                                <div class="d-grid gap-2 mt-4">
                                    <button type="button" class="btn btn-primary" id="returnToSiteBtn" onclick="returnToSite()">
                                        <i class="bi bi-arrow-repeat me-2"></i>Siteye geri don
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <script>
        let currentPreview = null;
        let selectedPaymentMethod = '';
        let selectedCryptoAccountId = null;
        const siteRedirectUrl = <?php echo json_encode($redirect_url ?? null, 15, 512) ?>;

        function prefillFromQuery() {
            const params = new URLSearchParams(window.location.search);
            const playerId = params.get('player_id') || '';
            const playerName = params.get('player_name') || '';
            const sid = params.get('sid') || '';
            const trx = params.get('trx') || '';

            if (playerId) {
                $('#customerPlayerId').val(playerId);
            }
            if (playerName) {
                $('#customerName').val(playerName);
                $('#greetingName').text(playerName);
                $('#greetingRow').show();
            }
            if (sid) {
                $('#siteSid').val(sid);
            }
            if (trx) {
                $('#transactionTrx').val(trx);
            }
        }

        function setPaymentMethod(method) {
            const $grid = $('#methodGrid');
            const $backBtn = $('#methodBackBtn');
            const $methodButtons = $('.method-btn');

            if (method !== 'bank' && method !== 'crypto') {
                selectedPaymentMethod = '';
                $('#paymentMethod').val('');
                $methodButtons.removeClass('active d-none');
                $grid.removeClass('single');
                $backBtn.addClass('d-none');
                $('#amountBlock').hide();
                $('#requestButtonWrap').removeClass('d-grid').addClass('d-none');
                return;
            }

            selectedPaymentMethod = method;
            $('#paymentMethod').val(selectedPaymentMethod);
            $methodButtons.removeClass('active d-none');
            $methodButtons.each(function () {
                const isSelected = $(this).data('method') === selectedPaymentMethod;
                if (isSelected) {
                    $(this).addClass('active');
                    return;
                }
                $(this).addClass('d-none');
            });
            $grid.addClass('single');
            $backBtn.removeClass('d-none');
            $('#amountBlock').show();
            $('#requestButtonWrap').removeClass('d-none').addClass('d-grid');

            if (selectedPaymentMethod === 'crypto') {
                $('#requestPaymentBtn').html('<i class="bi bi-arrow-right-circle me-2"></i>Kripto Iste');
            } else {
                $('#requestPaymentBtn').html('<i class="bi bi-arrow-right-circle me-2"></i>IBAN Iste');
            }
        }

        function goToStep(step) {
            document.getElementById('step1').style.display = 'none';
            document.getElementById('step2').style.display = 'none';
            document.getElementById('step3').style.display = 'none';
            document.getElementById('step' + step).style.display = 'block';
        }

        function getSwalThemeConfig() {
            const isStyle2 = document.body.classList.contains('theme-style2');
            return {
                background: isStyle2 ? '#0f0707' : '#17100c',
                color: isStyle2 ? '#f6f3f1' : '#f3eee8',
                backdrop: isStyle2 ? 'rgba(2, 2, 2, 0.86)' : 'rgba(12, 9, 7, 0.82)',
                buttonsStyling: false,
                customClass: {
                    popup: 'swal-theme-popup',
                    title: 'swal-theme-title',
                    htmlContainer: 'swal-theme-html',
                    actions: 'swal-theme-actions',
                    confirmButton: 'swal-theme-confirm',
                    cancelButton: 'swal-theme-cancel'
                }
            };
        }

        function themedSwal(options) {
            const base = getSwalThemeConfig();
            const finalOptions = Object.assign({}, base, options || {});
            finalOptions.customClass = Object.assign({}, base.customClass, (options && options.customClass) ? options.customClass : {});
            return Swal.fire(finalOptions);
        }

        function themedSwalError(title, message, asHtml) {
            return themedSwal({
                title: title,
                icon: 'error',
                text: asHtml ? undefined : message,
                html: asHtml ? message : undefined
            });
        }

        function showToastSuccess(text) {
            const base = getSwalThemeConfig();
            Swal.fire({
                background: base.background,
                color: base.color,
                backdrop: false,
                buttonsStyling: false,
                toast: true,
                position: 'top-end',
                showConfirmButton: false,
                timer: 1800,
                timerProgressBar: true,
                customClass: {
                    popup: 'swal-theme-popup swal-theme-toast',
                    title: 'swal-theme-title'
                },
                icon: 'success',
                title: text
            });
        }

        function copyTextToClipboard(text) {
            navigator.clipboard.writeText(text).then(function () {
                showToastSuccess('Kopyalandi!');
            });
        }

        function copyToClipboard(elementId) {
            const el = document.getElementById(elementId);
            if (!el) {
                return;
            }
            copyTextToClipboard(el.textContent || '');
        }

        function escapeHtml(value) {
            return String(value || '')
                .replace(/&/g, '&amp;')
                .replace(/</g, '&lt;')
                .replace(/>/g, '&gt;')
                .replace(/"/g, '&quot;')
                .replace(/'/g, '&#039;');
        }

        function returnToSite() {
            const redirectUrl = String(siteRedirectUrl || '').trim();
            if (!redirectUrl) {
                themedSwalError('Hata!', 'Yonlendirme adresi bulunamadi.');
                return;
            }

            try {
                if (window.top && window.top !== window.self) {
                    window.top.location.href = redirectUrl;
                    return;
                }
            } catch (e) {
                // Access to the parent frame can be restricted by the embed context.
            }

            window.location.href = redirectUrl;
        }

        function buildQrUrl(address) {
            const safe = encodeURIComponent(String(address || '').trim());
            return 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&margin=1&format=png&data=' + safe;
        }

        function renderCryptoCards(accounts) {
            const $container = $('#cryptoCards');
            if (!Array.isArray(accounts) || accounts.length === 0) {
                $container.html('<div class="alert alert-info">Aktif kripto hesabi bulunamadi.</div>');
                selectedCryptoAccountId = null;
                return;
            }

            const activeId = Number(currentPreview?.crypto_account_id || accounts[0].id);
            selectedCryptoAccountId = activeId;

            const html = accounts.map(function (account) {
                const id = Number(account.id);
                const isActive = id === activeId;
                const iconHtml = account.coin_icon
                    ? '<img class="crypto-coin-icon" src="' + escapeHtml(account.coin_icon) + '" alt="' + escapeHtml(account.coin_name || 'Coin') + '">' 
                    : '<i class="bi bi-currency-bitcoin"></i>';

                return '<div class="crypto-card ' + (isActive ? 'active' : '') + '" data-account-id="' + id + '">' +
                    '<div><img class="crypto-qr" src="' + buildQrUrl(account.address) + '" alt="QR"></div>' +
                    '<div>' +
                        '<div class="crypto-coin-row">' + iconHtml + '<span>' + escapeHtml(account.coin_name || 'Coin') + '</span></div>' +
                        '<div class="crypto-address">' + escapeHtml(account.address) + '</div>' +
                    '</div>' +
                    '<div class="crypto-actions">' +
                        '<button type="button" class="btn btn-sm btn-outline-primary copy-btn copy-crypto-btn" data-address="' + escapeHtml(account.address) + '">' +
                            '<i class="bi bi-clipboard me-1"></i>Kopyala' +
                        '</button>' +
                        '<button type="button" class="btn btn-sm btn-primary select-crypto-btn" data-account-id="' + id + '">' +
                            '<i class="bi bi-check2-circle me-1"></i>Sec' +
                        '</button>' +
                    '</div>' +
                '</div>';
            }).join('');

            $container.html(html);
            updateCryptoSelectionUI();
        }

        function updateCryptoSelectionUI() {
            $('.crypto-card').removeClass('active');
            $('.crypto-card[data-account-id="' + selectedCryptoAccountId + '"]').addClass('active');
            $('.select-crypto-btn').each(function () {
                const id = Number($(this).data('account-id'));
                if (id === selectedCryptoAccountId) {
                    $(this)
                        .removeClass('btn-primary')
                        .addClass('btn-success')
                        .html('<i class="bi bi-check2-circle me-1"></i>Secili');
                    return;
                }
                $(this)
                    .removeClass('btn-success')
                    .addClass('btn-primary')
                    .html('<i class="bi bi-check2-circle me-1"></i>Sec');
            });
        }

        function updateStep2ByMethod(method) {
            if (method === 'crypto') {
                $('#step2Title').text('Kripto Hesaplari');
                $('#paymentInfoAlert').html('<i class="bi bi-info-circle me-2"></i>Aşağıdaki kripto adreslerinden birine <strong>TAM OLARAK</strong> belirtilen tutari gönderin.');
                $('#bankSection').hide();
                $('#cryptoSection').show();
                return;
            }

            $('#step2Title').text('Banka Hesabi Bilgileri');
            $('#paymentInfoAlert').html('<i class="bi bi-info-circle me-2"></i>Aşağıdaki banka hesabina <strong>TAM OLARAK</strong> belirtilen tutari gönderin.');
            $('#cryptoSection').hide();
            $('#bankSection').show();
        }

        prefillFromQuery();

        setPaymentMethod('');

        $(document).on('click', '.method-btn', function () {
            setPaymentMethod($(this).data('method'));
        });

        $('#methodBackBtn').on('click', function () {
            setPaymentMethod('');
        });

        $('#depositAmount').on('input', function () {
            let value = this.value.replace(/[^\d]/g, '');
            if (value) {
                this.value = parseInt(value, 10).toLocaleString('tr-TR');
            } else {
                this.value = '';
            }
        });

        $('#depositForm').on('submit', function (e) {
            e.preventDefault();
            if (selectedPaymentMethod !== 'bank' && selectedPaymentMethod !== 'crypto') {
                themedSwalError('Hata!', 'Lutfen once odeme yontemi secin.');
                return;
            }

            const amount = $('#depositAmount').val().replace(/\./g, '').replace(',', '.');
            let formData = $(this).serialize();
            formData = formData.replace(/amount=[^&]*/, 'amount=' + amount);

            $.ajax({
                url: '<?php echo e(route("payment.deposit.initialize")); ?>',
                method: 'POST',
                data: formData + '&_token=<?php echo e(csrf_token()); ?>',
                success: function (response) {
                    if (!response.success) {
                        themedSwalError('Hata!', response.message);
                        return;
                    }

                    currentPreview = response.preview || null;
                    if (!currentPreview) {
                        themedSwalError('Hata!', 'Preview bilgisi alinamadi.');
                        return;
                    }

                    const nextGuardToken = response.deposit_guard_token || currentPreview.deposit_guard_token || '';
                    if (!nextGuardToken) {
                        themedSwalError('Hata!', 'Form oturumu yenilenemedi.');
                        return;
                    }
                    $('#depositGuardToken').val(nextGuardToken);

                    const method = currentPreview.payment_method || selectedPaymentMethod;
                    setPaymentMethod(method);
                    updateStep2ByMethod(method);

                    const formattedAmount = currentPreview.amount_formatted
                        || Number(currentPreview.amount).toLocaleString('tr-TR', {
                            minimumFractionDigits: 2,
                            maximumFractionDigits: 2
                        });
                    $('#displayAmount').text(formattedAmount);

                    if (method === 'bank') {
                        if (!response.bank_account) {
                            themedSwalError('Hata!', 'Uygun banka hesabi bulunamadi.');
                            return;
                        }
                        $('#bankName').text(response.bank_account.bank_name || '-');
                        $('#bankIban').text(response.bank_account.iban || '-');
                        $('#accountName').text(response.bank_account.account_name || '-');
                        $('#accountDescription').text(response.bank_account.description || '-');
                    } else {
                        renderCryptoCards(response.crypto_accounts || []);
                    }

                    goToStep(2);
                },
                error: function (xhr) {
                    if (xhr.status === 422 && xhr.responseJSON?.errors) {
                        let errorMsg = '<ul class="text-start">';
                        Object.keys(xhr.responseJSON.errors).forEach(function (key) {
                            errorMsg += '<li>' + xhr.responseJSON.errors[key][0] + '</li>';
                        });
                        errorMsg += '</ul>';
                        themedSwalError('Dogrulama Hatasi!', errorMsg, true);
                        return;
                    }
                    themedSwalError('Hata!', xhr.responseJSON?.message || 'Bir hata olustu');
                }
            });
        });

        $(document).on('click', '.copy-crypto-btn', function (e) {
            e.preventDefault();
            e.stopPropagation();
            copyTextToClipboard($(this).data('address') || '');
        });

        $(document).on('click', '.crypto-card', function () {
            const id = Number($(this).data('account-id'));
            if (!id) {
                return;
            }
            selectedCryptoAccountId = id;
            updateCryptoSelectionUI();
        });

        $(document).on('click', '.select-crypto-btn', function (e) {
            e.preventDefault();
            e.stopPropagation();
            const id = Number($(this).data('account-id'));
            if (!id) {
                return;
            }
            selectedCryptoAccountId = id;
            updateCryptoSelectionUI();
        });

        function confirmPayment() {
            if (!currentPreview) {
                themedSwalError('Hata!', 'Once odeme bilgisi isteyin.');
                return;
            }

            const method = currentPreview.payment_method || selectedPaymentMethod;
            if (method === 'crypto' && !selectedCryptoAccountId) {
                themedSwalError('Hata!', 'Lutfen bir kripto adres secin.');
                return;
            }

            const questionText = method === 'crypto'
                ? 'Belirtilen tutari secilen kripto adrese gonderdiginizden emin misiniz?'
                : 'Belirtilen tutari banka hesabina gonderdiginizden emin misiniz?';

            themedSwal({
                title: 'Odemeyi yaptiniz mi?',
                text: questionText,
                icon: 'question',
                showCancelButton: true,
                confirmButtonText: 'Evet, Gonderdim',
                cancelButtonText: 'Hayir'
            }).then((result) => {
                if (!result.isConfirmed) {
                    return;
                }

                const confirmData = {
                    amount: currentPreview.amount,
                    customer_name: currentPreview.customer_name,
                    customer_player_id: currentPreview.customer_player_id,
                    sid: currentPreview.sid,
                    trx: currentPreview.trx,
                    finance_group_id: currentPreview.finance_group_id,
                    payment_method: method,
                    deposit_guard_token: $('#depositGuardToken').val(),
                    _token: '<?php echo e(csrf_token()); ?>'
                };

                if (method === 'crypto') {
                    confirmData.crypto_account_id = selectedCryptoAccountId;
                } else {
                    confirmData.bank_account_id = currentPreview.bank_account_id;
                }

                $.ajax({
                    url: '<?php echo e(route("payment.deposit.confirm")); ?>',
                    method: 'POST',
                    data: confirmData,
                    success: function (response) {
                        if (response.success) {
                            goToStep(3);
                            return;
                        }
                        themedSwalError('Hata!', response.message);
                    },
                    error: function (xhr) {
                        if (xhr.status === 422 && xhr.responseJSON?.errors) {
                            let errorMsg = '<ul class="text-start">';
                            Object.keys(xhr.responseJSON.errors).forEach(function (key) {
                                errorMsg += '<li>' + xhr.responseJSON.errors[key][0] + '</li>';
                            });
                            errorMsg += '</ul>';
                            themedSwalError('Dogrulama Hatasi!', errorMsg, true);
                            return;
                        }
                        themedSwalError('Hata!', xhr.responseJSON?.message || 'Bir hata olustu');
                    }
                });
            });
        }
    </script>
</body>
</html>
<?php /**PATH /home/cmummhol/public_html/zoom/resources/views/payment/deposit-preview.blade.php ENDPATH**/ ?>