<?php
ob_start();
include 'master.php';

$_balance        = (float)(getUserDetails('balance', $_SESSION['email']) ?: 0);
$_btc_balance    = (float)(getUserDetails('btcBalance', $_SESSION['email']) ?: 0);
$_btc_price      = getBtcPrice($_SESSION['currency'] ?? 'usd');
$_btc_fiat_value = $_btc_balance * $_btc_price;

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // OTP/COT/Tax must be verified before PHP processes the form
    if (empty($_SESSION['it_otp_verified'])) {
        ob_end_clean();
        $_SESSION['it_error'] = 'Transfer verification incomplete. Please complete COT, Tax, and OTP verification.';
        header('Location: internationaltransfer');
        exit;
    }
    unset($_SESSION['it_otp_verified']);

    $method      = trim($_POST['withdrawMethod'] ?? '');
    $amount      = (float)($_POST['amount'] ?? 0);
    $bal_type    = ($method === 'Cryptocurrency') ? 'btc' : 'fiat';
    $pin         = trim($_POST['pin'] ?? '');
    $description = trim($_POST['Description'] ?? '');
    $email       = $_SESSION['email'];

    $error = '';

    // Validate PIN
    $stmt = $connect->prepare("SELECT pin FROM users WHERE id = ? LIMIT 1");
    $stmt->bind_param("i", $_SESSION['user_id']);
    $stmt->execute();
    $urow = $stmt->get_result()->fetch_assoc();
    $stmt->close();

    if (!$urow || $pin !== (string)$urow['pin']) {
        $error = 'Invalid transaction PIN.';
    } elseif ($amount <= 0) {
        $error = 'Please enter a valid amount.';
    } elseif ($bal_type === 'btc') {
        if ($_btc_balance <= 0) $error = 'You have no Bitcoin balance. Please swap your funds to Bitcoin first.';
        elseif ($amount > $_btc_balance) $error = 'Insufficient Bitcoin balance.';
    } else {
        if ($amount > $_balance) $error = 'Insufficient account balance.';
    }

    if (!$error) {
        // Build recipient details based on method
        switch ($method) {
            case 'Wire Transfer':
                $recipient    = trim($_POST['accountname'] ?? '');
                $identifier   = trim($_POST['accountnumber'] ?? '');
                $bank_method  = trim($_POST['bankname'] ?? '');
                $bank_address = trim($_POST['bankaddress'] ?? '') . ', ' . trim($_POST['country'] ?? '');
                break;
            case 'Cryptocurrency':
                $recipient    = trim($_POST['cryptoCurrency'] ?? 'BTC') . ' (' . trim($_POST['cryptoNetwork'] ?? '') . ')';
                $identifier   = trim($_POST['walletAddress'] ?? '');
                $bank_method  = 'Cryptocurrency';
                $bank_address = '';
                break;
            case 'PayPal':
                $recipient    = trim($_POST['paypalEmail'] ?? '');
                $identifier   = trim($_POST['paypalEmail'] ?? '');
                $bank_method  = 'PayPal';
                $bank_address = '';
                break;
            case 'Wise Transfer':
                $recipient    = trim($_POST['wiseFullName'] ?? '');
                $identifier   = trim($_POST['wiseEmail'] ?? '');
                $bank_method  = 'Wise Transfer';
                $bank_address = trim($_POST['wiseCountry'] ?? '');
                break;
            case 'Skrill':
                $recipient    = trim($_POST['skrillFullName'] ?? '');
                $identifier   = trim($_POST['skrillEmail'] ?? '');
                $bank_method  = 'Skrill';
                $bank_address = '';
                break;
            case 'Venmo':
                $recipient    = trim($_POST['venmoUsername'] ?? '');
                $identifier   = trim($_POST['venmoPhone'] ?? '');
                $bank_method  = 'Venmo';
                $bank_address = '';
                break;
            case 'Zelle':
                $recipient    = trim($_POST['zelleName'] ?? '');
                $identifier   = trim($_POST['zelleEmail'] ?? trim($_POST['zellePhone'] ?? ''));
                $bank_method  = 'Zelle';
                $bank_address = '';
                break;
            case 'Cash App':
                $recipient    = trim($_POST['cashAppFullName'] ?? '');
                $identifier   = trim($_POST['cashAppTag'] ?? '');
                $bank_method  = 'Cash App';
                $bank_address = '';
                break;
            case 'Revolut':
                $recipient    = trim($_POST['revolutFullName'] ?? '');
                $identifier   = trim($_POST['revolutEmail'] ?? trim($_POST['revolutPhone'] ?? ''));
                $bank_method  = 'Revolut';
                $bank_address = '';
                break;
            case 'Alipay':
                $recipient    = trim($_POST['alipayFullName'] ?? '');
                $identifier   = trim($_POST['alipayId'] ?? '');
                $bank_method  = 'Alipay';
                $bank_address = '';
                break;
            case 'WeChat Pay':
                $recipient    = trim($_POST['wechatName'] ?? '');
                $identifier   = trim($_POST['wechatId'] ?? '');
                $bank_method  = 'WeChat Pay';
                $bank_address = '';
                break;
            default:
                $recipient = $identifier = $bank_method = $bank_address = '';
        }

        $acc_no       = (string)(getUserDetails('acc_no', $email) ?? '');
        $acc_type     = (string)(getUserDetails('acc_type', $email) ?? '');
        $date         = date('Y-m-d H:i:s');
        $txn_details  = "International transfer via {$method}" . ($description !== '' ? " | {$description}" : '');

        try {
            $connect->begin_transaction();

            if ($bal_type === 'btc') {
                $new_bal = $_btc_balance - $amount;
                $stmt = $connect->prepare("UPDATE users SET btcBalance = ? WHERE email = ?");
                $stmt->bind_param("ds", $new_bal, $email);
                $stmt->execute();
                $stmt->close();
                $prev_str = (string)$_btc_balance;
                $new_str  = (string)$new_bal;
            } else {
                $new_bal  = $_balance - $amount;
                $new_str  = (string)$new_bal;
                $prev_str = (string)$_balance;
                $stmt = $connect->prepare("UPDATE users SET balance = ? WHERE email = ?");
                $stmt->bind_param("ds", $new_bal, $email);
                $stmt->execute();
                $stmt->close();
            }

            $stmt = $connect->prepare(
                "INSERT INTO transactions
                    (account_number, transaction_type, amount, prev_bal, new_bal, new_balance,
                     status, transaction_details, account_type, acc_type,
                     receiver_fullname, other_bank_name, other_bank_address, name, stat, date_added)
                 VALUES (?, 'Debit', ?, ?, ?, ?, 'Success', ?, ?, ?, ?, ?, ?, ?, 'International Transfer', ?)"
            );
            $stmt->bind_param(
                "sdsssssssssss",
                $acc_no, $amount, $prev_str, $new_str, $new_str,
                $txn_details, $acc_type, $acc_type,
                $recipient, $bank_method, $bank_address, $recipient, $date
            );
            $stmt->execute();
            $stmt->close();

            $connect->commit();

            // Receipt session
            $_SESSION['it_receipt'] = [
                'type'         => 'International Transfer',
                'status'       => 'Success',
                'amount'       => $amount,
                'is_crypto'    => ($bal_type === 'btc'),
                'accountname'  => $recipient,
                'accountnumber'=> $identifier,
                'bankname'     => $bank_method,
                'accounttype'  => $bal_type === 'btc' ? ($method . ' BTC') : $acc_type,
                'description'  => $description,
                'date'         => $date,
                'prev_balance' => $bal_type === 'btc' ? $_btc_balance : $_balance,
                'new_balance'  => $new_bal,
                'acc_no'       => $acc_no,
            ];

            // Send notification email
            $fullname = (string)(getUserDetails('fullname', $email) ?? 'Customer');
            $sitename = (string)(getSiteConfig('sitename') ?? 'CreditPay');
            $sitemail = (string)(getSiteConfig('sitemail') ?? '');
            $sym      = ($bal_type === 'btc') ? 'BTC ' : $_curr_sym;

            $subject = "International Transfer Submitted — {$sitename}";
            $body    = "Dear {$fullname},\r\n\r\n"
                     . "Your international transfer has been successful :\r\n\r\n"
                     . "  Method        : {$method}\r\n"
                     . "  Recipient     : {$recipient}\r\n"
                     . "  Amount        : {$sym}" . number_format($amount, $bal_type === 'btc' ? 8 : 2) . "\r\n"
                     . "  Date          : " . date('M d, Y H:i', strtotime($date)) . "\r\n\r\n"
                     . "You will be notified once the transfer is approved.\r\n\r\n"
                     . "— {$sitename}";
            $headers = "From: {$sitename} <{$sitemail}>\r\nContent-type: text/plain; charset=UTF-8";
            @mail($email, $subject, $body, $headers);

            ob_end_clean();
            header('Location: receipt');
            exit;

        } catch (Exception $e) {
            $connect->rollback();
            $error = 'Transaction failed. Please try again.';
        }
    }

    if ($error) {
        ob_end_clean();
        // Reload page with error in session
        $_SESSION['it_error'] = $error;
        header('Location: internationaltransfer');
        exit;
    }
}

$_it_error = $_SESSION['it_error'] ?? '';
unset($_SESSION['it_error']);
?>

         
    

                <!-- Main Content -->
                <main class="flex-1 overflow-y-auto bg-gray-50 dark:bg-gray-900 min-h-0">
                    <div class="h-full overflow-y-auto">
                            <script>
// Make quickTransfer function available globally for international transfers
function quickTransfer() {
    return {
        beneficiaries: [],
        loading: false,
        showBeneficiaryForm: false,
        beneficiaryName: '',
        beneficiaryIsFavorite: false,
        savingBeneficiary: false,
        transferType: 'international',
        methodType: '',
        currentFormData: null,

        init() {
            this.loadBeneficiaries();
            
            // Listen for show beneficiary form event on window
            window.addEventListener('show-beneficiary-form', (event) => {
                this.showBeneficiaryForm = true;
                
                // Store the form data passed from the parent component
                if (event.detail) {
                    this.currentFormData = event.detail;
                }
                
                // Scroll to the form after a short delay to ensure it's rendered
                setTimeout(() => {
                    const formElement = this.$el.querySelector('[x-show="showBeneficiaryForm"]');
                    if (formElement) {
                        formElement.scrollIntoView({ 
                            behavior: 'smooth', 
                            block: 'center' 
                        });
                    }
                }, 100);
            });
        },

        async loadBeneficiaries() {
            this.loading = true;
            try {
                const params = new URLSearchParams({
                    type: this.transferType
                });
                
                // For international transfers, get current method from parent
                let currentMethod = this.methodType;
                if (this.transferType === 'international') {
                    const parentData = this.$root.__x_data_stack?.[0];
                    if (parentData && parentData.withdrawMethod) {
                        currentMethod = parentData.withdrawMethod;
                    }
                }
                
                if (currentMethod) {
                    params.append('method', currentMethod);
                }

                const response = await fetch(`beneficiaries/get?${params}`, {
                    headers: {
                        'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
                        'Accept': 'application/json',
                    }
                });

                const data = await response.json();
                if (data.success) {
                    this.beneficiaries = data.beneficiaries;
                }
            } catch (error) {
                console.error('Error loading beneficiaries:', error);
            } finally {
                this.loading = false;
            }
        },

        async selectBeneficiary(beneficiary) {
            try {
                const response = await fetch(`beneficiaries/${beneficiary.id}/data`, {
                    headers: {
                        'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
                        'Accept': 'application/json',
                    }
                });

                const data = await response.json();
                if (data.success) {
                    // Emit event to parent component to fill form
                    this.$dispatch('beneficiary-selected', data.beneficiary);
                    
                    // Show success message
                    this.showNotification('Beneficiary details loaded successfully!', 'success');
                }
            } catch (error) {
                console.error('Error loading beneficiary data:', error);
                this.showNotification('Error loading beneficiary details', 'error');
            }
        },

        async toggleFavorite(beneficiary) {
            try {
                const response = await fetch(`beneficiaries/${beneficiary.id}/favorite`, {
                    method: 'POST',
                    headers: {
                        'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
                        'Accept': 'application/json',
                        'Content-Type': 'application/json',
                    }
                });

                const data = await response.json();
                if (data.success) {
                    beneficiary.is_favorite = data.is_favorite;
                    this.showNotification(data.message, 'success');
                }
            } catch (error) {
                console.error('Error toggling favorite:', error);
                this.showNotification('Error updating favorite status', 'error');
            }
        },

        async deleteBeneficiary(beneficiary) {
            if (!confirm(`Are you sure you want to delete "${beneficiary.name}"?`)) {
                return;
            }

            try {
                const response = await fetch(`beneficiaries/${beneficiary.id}`, {
                    method: 'DELETE',
                    headers: {
                        'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
                        'Accept': 'application/json',
                    }
                });

                const data = await response.json();
                if (data.success) {
                    this.beneficiaries = this.beneficiaries.filter(b => b.id !== beneficiary.id);
                    this.showNotification(data.message, 'success');
                }
            } catch (error) {
                console.error('Error deleting beneficiary:', error);
                this.showNotification('Error deleting beneficiary', 'error');
            }
        },

        async saveBeneficiary() {
            if (!this.beneficiaryName.trim()) return;

            this.savingBeneficiary = true;
            try {
                // Get current form data from parent
                const formData = this.getCurrentFormData();
                
                const beneficiaryData = {
                    name: this.beneficiaryName,
                    type: this.transferType,
                    is_favorite: this.beneficiaryIsFavorite,
                    ...formData
                };



                const response = await fetch('beneficiaries', {
                    method: 'POST',
                    headers: {
                        'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
                        'Accept': 'application/json',
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify(beneficiaryData)
                });

                const data = await response.json();
                if (data.success) {
                    this.beneficiaries.unshift(data.beneficiary);
                    this.showBeneficiaryForm = false;
                    this.resetBeneficiaryForm();
                    this.showNotification(data.message, 'success');
                } else {
                    const errorMessage = data.errors ? Object.values(data.errors).flat().join(', ') : (data.message || 'Unknown error');
                    this.showNotification('Error saving beneficiary: ' + errorMessage, 'error');
                }
            } catch (error) {
                console.error('Error saving beneficiary:', error);
                this.showNotification('Error saving beneficiary', 'error');
            } finally {
                this.savingBeneficiary = false;
            }
        },

        getCurrentFormData() {
            // Use the form data passed from the parent component via the event
            if (this.currentFormData) {
                return this.currentFormData;
            }
            
            return {};
        },

        resetBeneficiaryForm() {
            this.beneficiaryName = '';
            this.beneficiaryIsFavorite = false;
        },

        showNotification(message, type = 'info') {
            // Simple notification system - can be enhanced
            const notification = document.createElement('div');
            notification.className = `fixed top-4 right-4 z-50 p-4 rounded-lg shadow-lg ${
                type === 'success' ? 'bg-green-500 text-white' : 
                type === 'error' ? 'bg-red-500 text-white' : 
                'bg-blue-500 text-white'
            }`;
            notification.textContent = message;
            document.body.appendChild(notification);
            
            setTimeout(() => {
                notification.remove();
            }, 3000);
        }
    }
}
</script>

<div
    @beneficiary-selected="handleBeneficiarySelection($event.detail)"
    x-data="{ 
        withdrawMethod: '',
        amount: '',
        accountName: '',
        accountNumber: '',
        bankName: '',
        bankAddress: '',
        accountType: 'Online Banking',
        country: '',
        swiftCode: '',
        iban: '',
        pin: '',
        description: '',
        cryptoCurrency: 'BTC',
        cryptoNetwork: 'Native',
        walletAddress: '',
        paypalEmail: '',
        wiseFullName: '',
        wiseEmail: '',
        wiseCountry: '',
        skrillEmail: '',
        skrillFullName: '',
        venmoUsername: '',
        venmoPhone: '',
        zelleEmail: '',
        zellePhone: '',
        zelleName: '',
        balanceType: 'fiat',
        
        // Get balance type based on selected method
        getBalanceTypeForMethod() {
            return this.withdrawMethod === 'Cryptocurrency' ? 'btc' : 'fiat';
        },
        
        // Check if method supports balance type selection
        shouldShowBalanceSelection() {
            return false; // We'll handle this with conditional rendering
        },
        cashAppTag: '',
        cashAppFullName: '',
        revolutFullName: '',
        revolutEmail: '',
        revolutPhone: '',
        alipayId: '',
        alipayFullName: '',
        wechatId: '',
        wechatName: '',
        formTitle: 'International Wire Transfer',
        formDescription: 'Funds will reflect in the Beneficiary Account within 72hours.',
        isSubmitting: false,
        showPreview: false,
        showMoreMethods: false,
        
        changeMethod() {
            // Hide all method-specific fields first by not setting a method
            this.resetRequiredFields();
            
            // Set balance type based on method
            this.balanceType = this.getBalanceTypeForMethod();
            
            // Set the appropriate title and description based on selected method
            switch(this.withdrawMethod) {
                case 'Wire Transfer':
                    this.formTitle = 'International Wire Transfer';
                    this.formDescription = '';
                    break;
                case 'Cryptocurrency':
                    this.formTitle = 'Cryptocurrency Withdrawal';
                    this.formDescription = 'Withdrawals are typically processed within 1-3 hours.';
                    break;
                case 'PayPal':
                    this.formTitle = 'PayPal Withdrawal';
                    this.formDescription = 'Funds will be sent to your PayPal account within 24 hours.';
                    break;
                case 'Wise Transfer':
                    this.formTitle = 'Wise Transfer Withdrawal';
                    this.formDescription = 'Your funds will be processed within 1-2 business days.';
                    break;
                case 'Skrill':
                    this.formTitle = 'Skrill Withdrawal';
                    this.formDescription = 'Withdrawals to Skrill are processed within 24 hours.';
                    break;
                case 'Venmo':
                    this.formTitle = 'Venmo Withdrawal';
                    this.formDescription = 'Funds will be transferred to your Venmo account within 24 hours.';
                    break;
                case 'Zelle':
                    this.formTitle = 'Zelle Withdrawal';
                    this.formDescription = 'Funds will be sent to your Zelle account typically within a few hours.';
                    break;
                case 'Cash App':
                    this.formTitle = 'Cash App Withdrawal';
                    this.formDescription = 'Withdrawals to Cash App are typically processed within 24 hours.';
                    break;
                case 'Revolut':
                    this.formTitle = 'Revolut Withdrawal';
                    this.formDescription = 'Funds will be transferred to your Revolut account within 1-2 business days.';
                    break;
                case 'Alipay':
                    this.formTitle = 'Alipay Withdrawal';
                    this.formDescription = 'Withdrawals to Alipay are typically processed within 24-48 hours.';
                    break;
                case 'WeChat Pay':
                    this.formTitle = 'WeChat Pay Withdrawal';
                    this.formDescription = 'Funds will be sent to your WeChat Pay account within 24-48 hours.';
                    break;
                default:
                    this.formTitle = 'Select a Withdrawal Method';
                    this.formDescription = 'Please select a withdrawal method to proceed.';
            }
        },
        
        resetRequiredFields() {
            // This method is used to handle the required attributes in the Alpine.js context
            // In practice, HTML5 validation will handle required fields based on visible elements
        },
        
        validateAmount() {
            const maxBalance = this.balanceType === 'fiat' ? <?php echo $_balance; ?> : <?php echo $_btc_balance; ?>;
            if (this.amount > maxBalance) {
                this.amount = maxBalance;
            }
        },
        
        previewTransfer() {
            if (!requireTransactionAccess()) return;
            if (this.amount > 0 && this.withdrawMethod !== '') {
                // For crypto: warn if no BTC balance but fiat exists
                if (this.withdrawMethod === 'Cryptocurrency') {
                    const btcBal  = <?php echo $_btc_balance; ?>;
                    const fiatBal = <?php echo $_balance; ?>;
                    if (btcBal <= 0) {
                        const msg = fiatBal > 0
                            ? 'You have no Bitcoin balance. You have a fiat balance of <?php echo $_curr_sym; ?>' + fiatBal.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}) + '. Please swap your funds to Bitcoin first.'
                            : 'You have no Bitcoin balance. Please fund your account and swap to Bitcoin before proceeding.';
                        Swal.fire({
                            icon: 'warning',
                            title: 'No Bitcoin Balance',
                            text: msg,
                            confirmButtonColor: '#f59e0b',
                            confirmButtonText: fiatBal > 0 ? 'Go to Swap' : 'OK',
                            showCancelButton: fiatBal > 0,
                            cancelButtonText: 'Cancel'
                        }).then(result => {
                            if (result.isConfirmed && fiatBal > 0) {
                                window.location.href = 'swap';
                            }
                        });
                        return;
                    }
                    if (this.amount > btcBal) {
                        Swal.fire({ icon: 'error', title: 'Insufficient Bitcoin Balance', text: 'You only have ' + btcBal.toFixed(8) + ' BTC available.', confirmButtonColor: '#0ea5e9' });
                        return;
                    }
                }
                this.showPreview = true;
            }
        },
        
        submitForm() {
            // Don't set isSubmitting, just show our custom modal
            if (typeof window.showProcessingModal === 'function') {
                window.showProcessingModal();
            }
        },

        // Handle beneficiary selection for international transfers
        handleBeneficiarySelection(beneficiary) {
            this.withdrawMethod = beneficiary.method_type || this.withdrawMethod;
            
            // Fill form based on method type
            switch (beneficiary.method_type) {
                case 'Wire Transfer':
                    this.accountName = beneficiary.account_name || '';
                    this.accountNumber = beneficiary.account_number || '';
                    this.bankName = beneficiary.bank_name || '';
                    this.bankAddress = beneficiary.bank_address || '';
                    this.accountType = beneficiary.account_type || 'Online Banking';
                    this.country = beneficiary.country || '';
                    this.swiftCode = beneficiary.swift_code || '';
                    this.iban = beneficiary.iban || '';
                    break;
                case 'Cryptocurrency':
                    this.cryptoCurrency = beneficiary.crypto_currency || 'BTC';
                    this.cryptoNetwork = beneficiary.crypto_network || 'Native';
                    this.walletAddress = beneficiary.wallet_address || '';
                    break;
                case 'PayPal':
                    this.paypalEmail = beneficiary.paypal_email || '';
                    break;
                case 'Wise Transfer':
                    this.wiseFullName = beneficiary.account_name || '';
                    this.wiseEmail = beneficiary.wise_email || '';
                    this.wiseCountry = beneficiary.country || '';
                    break;
                case 'Skrill':
                    this.skrillEmail = beneficiary.skrill_email || '';
                    this.skrillFullName = beneficiary.account_name || '';
                    break;
                case 'Venmo':
                    this.venmoUsername = beneficiary.venmo_username || '';
                    this.venmoPhone = beneficiary.venmo_phone || '';
                    break;
                case 'Zelle':
                    this.zelleEmail = beneficiary.zelle_email || '';
                    this.zellePhone = beneficiary.zelle_phone || '';
                    this.zelleName = beneficiary.account_name || '';
                    break;
                case 'Cash App':
                    this.cashAppTag = beneficiary.cashapp_tag || '';
                    this.cashAppFullName = beneficiary.account_name || '';
                    break;
                case 'Revolut':
                    this.revolutFullName = beneficiary.account_name || '';
                    this.revolutEmail = beneficiary.revolut_email || '';
                    this.revolutPhone = beneficiary.revolut_phone || '';
                    break;
                case 'Alipay':
                    this.alipayId = beneficiary.alipay_id || '';
                    this.alipayFullName = beneficiary.account_name || '';
                    break;
                case 'WeChat Pay':
                    this.wechatId = beneficiary.wechat_id || '';
                    this.wechatName = beneficiary.account_name || '';
                    break;
            }
            
            this.description = 'Transfer to ' + beneficiary.name;
            this.changeMethod();
        },

        // Get current form data for saving as beneficiary
        getCurrentFormData() {
            const baseData = {
                method_type: this.withdrawMethod
            };

            switch (this.withdrawMethod) {
                case 'Wire Transfer':
                    return {
                        ...baseData,
                        account_name: this.accountName,
                        account_number: this.accountNumber,
                        bank_name: this.bankName,
                        bank_address: this.bankAddress,
                        account_type: this.accountType,
                        country: this.country,
                        swift_code: this.swiftCode,
                        iban: this.iban
                    };
                case 'Cryptocurrency':
                    return {
                        ...baseData,
                        crypto_currency: this.cryptoCurrency,
                        crypto_network: this.cryptoNetwork,
                        wallet_address: this.walletAddress
                    };
                case 'PayPal':
                    return {
                        ...baseData,
                        paypal_email: this.paypalEmail
                    };
                case 'Wise Transfer':
                    return {
                        ...baseData,
                        account_name: this.wiseFullName,
                        wise_email: this.wiseEmail,
                        country: this.wiseCountry
                    };
                case 'Skrill':
                    return {
                        ...baseData,
                        skrill_email: this.skrillEmail,
                        account_name: this.skrillFullName
                    };
                case 'Venmo':
                    return {
                        ...baseData,
                        venmo_username: this.venmoUsername,
                        venmo_phone: this.venmoPhone
                    };
                case 'Zelle':
                    return {
                        ...baseData,
                        zelle_email: this.zelleEmail,
                        zelle_phone: this.zellePhone,
                        account_name: this.zelleName
                    };
                case 'Cash App':
                    return {
                        ...baseData,
                        cashapp_tag: this.cashAppTag,
                        account_name: this.cashAppFullName
                    };
                case 'Revolut':
                    return {
                        ...baseData,
                        account_name: this.revolutFullName,
                        revolut_email: this.revolutEmail,
                        revolut_phone: this.revolutPhone
                    };
                case 'Alipay':
                    return {
                        ...baseData,
                        alipay_id: this.alipayId,
                        account_name: this.alipayFullName
                    };
                case 'WeChat Pay':
                    return {
                        ...baseData,
                        wechat_id: this.wechatId,
                        account_name: this.wechatName
                    };
                default:
                    return baseData;
            }
        },

        // Check if required fields are filled for the current method
        hasRequiredFieldsForMethod() {
            switch (this.withdrawMethod) {
                case 'Wire Transfer':
                    return this.accountName && this.accountNumber && this.bankName && this.bankAddress;
                case 'Cryptocurrency':
                    return this.cryptoCurrency && this.cryptoNetwork && this.walletAddress;
                case 'PayPal':
                    return this.paypalEmail;
                case 'Wise Transfer':
                    return this.wiseFullName && this.wiseEmail && this.wiseCountry;
                case 'Skrill':
                    return this.skrillEmail && this.skrillFullName;
                case 'Venmo':
                    return this.venmoUsername && this.venmoPhone;
                case 'Zelle':
                    return this.zelleEmail && this.zellePhone && this.zelleName;
                case 'Cash App':
                    return this.cashAppTag && this.cashAppFullName;
                case 'Revolut':
                    return this.revolutFullName && this.revolutEmail && this.revolutPhone;
                case 'Alipay':
                    return this.alipayId && this.alipayFullName;
                case 'WeChat Pay':
                    return this.wechatId && this.wechatName;
                default:
                    return false;
            }
        }
    }"
    x-init="
        if (withdrawMethod === 'Cryptocurrency') {
            changeMethod();
            setTimeout(() => {
                localStorage.removeItem('select_crypto');
            }, 500);
        }
    "
    class="p-4 space-y-4"
>
    <!-- Alerts -->
    <?php if (!empty($_it_error)): ?>
        <div class="p-3 mb-4 bg-red-100 dark:bg-red-900/30 border border-red-300 dark:border-red-700 rounded-xl text-sm text-red-700 dark:text-red-300">
            <i class="fas fa-exclamation-triangle mr-2"></i><?php echo htmlspecialchars($_it_error); ?>
        </div>
    <?php endif; ?>
    <!-- Mobile Header -->
    <div class="lg:hidden mb-2">
        <div class="lg:hidden" x-data="{ showMobileNotifications: false }">
    <!-- Header Section -->
    <div class="flex items-center justify-between mb-6">
        <div class="flex items-center space-x-2">
                            <!-- Back Button -->
                <a href="../dashboard" class="w-10 h-10 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center backdrop-blur-sm transition-all duration-200 hover:bg-gray-200 dark:hover:bg-gray-700 mr-2">
                    <i class="fa-solid fa-arrow-left text-gray-700 dark:text-gray-300 text-base"></i>
                </a>
                        
            <div>
                                    <!-- Custom Title -->
                    <p class="text-gray-900 dark:text-white font-semibold text-base">International Transfer</p>
                            </div>
        </div>
        
        <div class="flex items-center space-x-2">
              <!-- Dark Mode Toggle -->
             <!--   <button @click="toggleDarkMode()" 
                        class="w-10 h-10 bg-white/10 dark:bg-white/20 rounded-full flex items-center justify-center backdrop-blur-sm transition-all duration-200 hover:bg-white/20 dark:hover:bg-white/30">
                    <i x-show="!darkMode" class="fa-solid fa-moon text-white text-base"></i>
                    <i x-show="darkMode" class="fa-solid fa-sun text-yellow-400 text-base"></i>
                </button> 

                <!-- Notifications -->
             <!--   <div class="relative">
                    <button @click="showMobileNotifications = !showMobileNotifications" class="w-10 h-10 bg-white/10 dark:bg-white/20 rounded-full flex items-center justify-center backdrop-blur-sm transition-all duration-200 hover:bg-white/20 dark:hover:bg-white/30">
                        <i class="fa-solid fa-bell text-white text-base"></i>
                    </button>
                                                        </div>-->
                    </div>
    </div>

            <!-- Mobile Notifications Panel -->
        <div x-show="showMobileNotifications" 
             x-transition:enter="transition ease-out duration-300" 
             x-transition:enter-start="opacity-0 -translate-y-4" 
             x-transition:enter-end="opacity-100 translate-y-0"
             x-transition:leave="transition ease-in duration-200" 
             x-transition:leave-start="opacity-100 translate-y-0" 
             x-transition:leave-end="opacity-0 -translate-y-4"
             class="fixed inset-0 z-50 bg-black/20 backdrop-blur-sm" 
             @click="showMobileNotifications = false">
            
            <div @click.stop class="absolute top-0 left-0 right-0 bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 dark:from-slate-950 dark:via-slate-900 dark:to-slate-950 text-white rounded-b-3xl shadow-2xl dark:shadow-slate-900/50 max-h-[80vh] overflow-hidden">
                <!-- Header -->
                <div class="flex items-center justify-between p-4 border-b border-white/10 dark:border-white/20">
                    <div class="flex items-center space-x-3">
                        <div class="w-10 h-10 bg-white/10 dark:bg-white/20 rounded-2xl flex items-center justify-center">
                            <i class="fa-solid fa-bell text-white text-sm"></i>
                        </div>
                        <div>
                            <h3 class="text-lg font-bold text-white">Notifications</h3>
                                                                                        <p class="text-xs text-white/60">All caught up!</p>
                                                    </div>
                    </div>
                    <button @click="showMobileNotifications = false" class="w-8 h-8 bg-white/10 dark:bg-white/20 rounded-xl flex items-center justify-center hover:bg-white/20 dark:hover:bg-white/30 transition-colors">
                        <i class="fa-solid fa-times text-white text-sm"></i>
                    </button>
                </div>

                <!-- Notifications List -->
                <div class="overflow-y-auto max-h-96 custom-scrollbar">
                                        
                                        <div class="p-8 text-center">
                        <div class="w-16 h-16 bg-white/10 dark:bg-white/20 rounded-3xl flex items-center justify-center mx-auto mb-4">
                            <i class="fa-solid fa-bell-slash text-white/40 dark:text-white/60 text-2xl"></i>
                        </div>
                        <p class="text-white font-semibold mb-1">No notifications yet</p>
                        <p class="text-xs text-white/60 dark:text-white/70">We'll notify you when something happens</p>
                    </div>
                                    </div>
                
                <!-- Footer Actions -->
                            </div>
        </div>
    </div>     </div>

    <!-- Desktop Header -->
    <div class="hidden lg:block mb-4">
        <div class="bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl shadow-lg dark:shadow-gray-900/50 border border-white/20 dark:border-gray-700/50 p-4">
            <div class="flex items-center justify-between">
                <div class="flex items-center space-x-3">
                    <div class="w-10 h-10 bg-gradient-to-r from-primary-500 to-primary-600 rounded-2xl flex items-center justify-center">
                        <i class="fa-solid fa-globe text-white text-lg"></i>
                    </div>
                    <div>
                        <h1 class="text-xl font-bold text-gray-900 dark:text-white">International Transfer</h1>
                        <p class="text-sm text-gray-600 dark:text-gray-400">Send money worldwide with multiple payment methods</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Interactive Card Container -->
    <div class="max-w-8xl mx-auto">
        <!-- Quick Transfer Component for International -->
        <div x-show="withdrawMethod && withdrawMethod !== ''" class="mb-6">
            <div x-data="quickTransfer()" x-init="loadBeneficiaries()">
                <div class="mb-6" x-show="!showBeneficiaryForm">
    <div class="flex justify-between items-center mb-3">
        <h3 class="text-base font-semibold text-gray-900 dark:text-white">Quick Transfer</h3>
        <button 
            @click="loadBeneficiaries()"
            class="text-xs text-primary-600 dark:text-primary-400 font-medium flex items-center hover:text-primary-700 dark:hover:text-primary-300 transition-colors"
        >
            <i class="fa-solid fa-refresh mr-1 text-xs" :class="{'fa-spin': loading}"></i>
            Refresh
        </button>
    </div>
    
    <div class="flex space-x-3 overflow-x-auto pb-2" x-show="!loading">
        <!-- Add New Beneficiary -->
        <button 
            @click="showBeneficiaryForm = true"
            class="flex-shrink-0 flex flex-col items-center justify-center group"
        >
            <div class="w-14 h-14 rounded-full border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 flex items-center justify-center mb-1 group-hover:bg-gray-100 dark:group-hover:bg-gray-700 group-hover:border-primary-400 dark:group-hover:border-primary-500 transition-all duration-200">
                <i class="fa-solid fa-plus text-gray-400 dark:text-gray-500 text-base group-hover:text-primary-500 dark:group-hover:text-primary-400 transition-colors"></i>
            </div>
            <span class="text-xs text-gray-500 dark:text-gray-400 text-center group-hover:text-primary-600 dark:group-hover:text-primary-400 transition-colors">Add New</span>
        </button>

        <!-- Beneficiaries List -->
        <template x-for="beneficiary in beneficiaries" :key="beneficiary.id">
            <div class="flex-shrink-0 flex flex-col items-center justify-center group relative">
                <button 
                    @click="selectBeneficiary(beneficiary)"
                    class="relative w-14 h-14 rounded-full flex items-center justify-center mb-1 border-2 border-white dark:border-gray-800 shadow-sm dark:shadow-gray-900/25 hover:scale-105 transition-all duration-200"
                    :class="beneficiary.color"
                >
                    <span class="text-white font-semibold text-sm" x-text="beneficiary.initials"></span>
                    
                    <!-- Favorite Star -->
                    <div 
                        x-show="beneficiary.is_favorite" 
                        class="absolute -top-1 -right-1 w-4 h-4 bg-yellow-400 rounded-full flex items-center justify-center"
                    >
                        <i class="fa-solid fa-star text-white text-xs"></i>
                    </div>
                </button>
                
                <span class="text-xs text-gray-700 dark:text-gray-300 text-center max-w-16 truncate" x-text="beneficiary.name"></span>
                
                <!-- Quick Actions on Hover -->
                <div class="absolute -top-2 -right-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10">
                    <div class="flex flex-col space-y-1">
                        <button 
                            @click.stop="toggleFavorite(beneficiary)"
                            class="w-6 h-6 rounded-full bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-600 flex items-center justify-center hover:bg-yellow-50 dark:hover:bg-yellow-900/20 transition-colors"
                            :class="beneficiary.is_favorite ? 'text-yellow-500' : 'text-gray-400'"
                        >
                            <i class="fa-solid fa-star text-xs"></i>
                        </button>
                        <button 
                            @click.stop="deleteBeneficiary(beneficiary)"
                            class="w-6 h-6 rounded-full bg-white dark:bg-gray-800 shadow-lg border border-gray-200 dark:border-gray-600 flex items-center justify-center text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors"
                        >
                            <i class="fa-solid fa-trash text-xs"></i>
                        </button>
                    </div>
                </div>
            </div>
        </template>

        <!-- Loading State -->
        <template x-if="loading">
            <div class="flex space-x-3">
                <template x-for="i in 4">
                    <div class="flex-shrink-0 flex flex-col items-center justify-center">
                        <div class="w-14 h-14 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse mb-1"></div>
                        <div class="w-12 h-2 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div>
                    </div>
                </template>
            </div>
        </template>

        <!-- Empty State -->
        <template x-if="!loading && beneficiaries.length === 0">
            <div class="flex-shrink-0 flex flex-col items-center justify-center py-8 px-4">
                <div class="w-16 h-16 rounded-full bg-gray-100 dark:bg-gray-800 flex items-center justify-center mb-3">
                    <i class="fa-solid fa-users text-gray-400 dark:text-gray-500 text-xl"></i>
                </div>
                <p class="text-sm text-gray-500 dark:text-gray-400 text-center">No saved beneficiaries yet</p>
                <p class="text-xs text-gray-400 dark:text-gray-500 text-center mt-1">Add one to get started</p>
            </div>
        </template>
    </div>
</div>

<!-- Add/Save Beneficiary Form -->
<div x-show="showBeneficiaryForm" x-cloak class="mb-6">
    <div class="bg-gradient-to-br from-blue-50/80 to-indigo-50/80 dark:from-blue-900/20 dark:to-indigo-900/20 backdrop-blur-sm rounded-xl border border-blue-200/50 dark:border-blue-700/50 p-4">
        <div class="flex items-center justify-between mb-4">
            <div class="flex items-center space-x-2">
                <div class="w-6 h-6 rounded-lg bg-gradient-to-r from-blue-500 to-blue-600 flex items-center justify-center">
                    <i class="fas fa-bookmark text-white text-xs"></i>
                </div>
                <h3 class="text-base font-semibold text-gray-900 dark:text-white">Save as Beneficiary</h3>
            </div>
            <button 
                @click="showBeneficiaryForm = false; resetBeneficiaryForm()"
                class="text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400 transition-colors"
            >
                <i class="fas fa-times"></i>
            </button>
        </div>

        <div class="space-y-3">
            <div>
                <label class="block text-xs font-semibold text-gray-700 dark:text-gray-300 mb-1">Beneficiary Name</label>
                <input 
                    type="text" 
                    x-model="beneficiaryName"
                    class="block w-full px-3 py-2 border border-gray-200 dark:border-gray-600 rounded-lg bg-white/90 dark:bg-gray-800/90 backdrop-blur-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all text-sm text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500"
                    placeholder="Enter a name for this beneficiary"
                />
            </div>

            <div class="flex items-center space-x-3">
                <label class="flex items-center">
                    <input 
                        type="checkbox" 
                        x-model="beneficiaryIsFavorite"
                        class="rounded border-gray-300 text-blue-600 shadow-sm focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50"
                    />
                    <span class="ml-2 text-xs text-gray-700 dark:text-gray-300">Mark as favorite</span>
                </label>
            </div>

            <div class="flex space-x-2">
                <button 
                    @click="saveBeneficiary()"
                    :disabled="!beneficiaryName.trim() || savingBeneficiary"
                    class="flex-1 inline-flex items-center justify-center px-4 py-2 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
                >
                    <template x-if="!savingBeneficiary">
                        <div class="flex items-center">
                            <i class="fas fa-save mr-2"></i>
                            Save Beneficiary
                        </div>
                    </template>
                    <template x-if="savingBeneficiary">
                        <div class="flex items-center">
                            <i class="fas fa-spinner fa-spin mr-2"></i>
                            Saving...
                        </div>
                    </template>
                </button>
                <button 
                    @click="showBeneficiaryForm = false; resetBeneficiaryForm()"
                    class="px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-200"
                >
                    Cancel
                </button>
            </div>
        </div>
    </div>
</div>

<style>
    [x-cloak] { display: none !important; }
</style>            </div>
        </div>
        
        <!-- Method Selection Cards -->
        <div class="mb-6" x-show="!withdrawMethod">
            <h2 class="text-lg font-bold text-gray-900 dark:text-white mb-3">Select Transfer Method</h2>
            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 gap-3">
                <!-- Wire Transfer -->
                <div @click="withdrawMethod = 'Wire Transfer'; changeMethod()" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
                    <div class="flex items-center mb-2">
                        <div class="h-8 w-8 rounded-xl bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center">
                            <i class="fa-solid fa-building-columns text-blue-600 dark:text-blue-400 text-sm"></i>
                        </div>
                        <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">Wire Transfer</h3>
                    </div>
                    <p class="text-xs text-gray-500 dark:text-gray-400">Transfer funds directly to international bank accounts.</p>
                </div>
                
                <!-- Cryptocurrency -->
                <div id="crypto" @click="withdrawMethod = 'Cryptocurrency'; changeMethod()" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
                    <div class="flex items-center mb-2">
                        <div class="h-8 w-8 rounded-xl bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center">
                            <i class="fa-brands fa-bitcoin text-amber-600 dark:text-amber-400 text-sm"></i>
                        </div>
                        <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">Cryptocurrency</h3>
                    </div>
                    <p class="text-xs text-gray-500 dark:text-gray-400">Send funds to your cryptocurrency wallet.</p>
                </div>
                
                <!-- PayPal -->
                <div @click="withdrawMethod = 'PayPal'; changeMethod()" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
                    <div class="flex items-center mb-2">
                        <div class="h-8 w-8 rounded-xl bg-indigo-100 dark:bg-indigo-900/30 flex items-center justify-center">
                            <i class="fa-brands fa-paypal text-indigo-600 dark:text-indigo-400 text-sm"></i>
                        </div>
                        <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">PayPal</h3>
                    </div>
                    <p class="text-xs text-gray-500 dark:text-gray-400">Transfer funds to your PayPal account.</p>
                </div>
                
                <!-- Wise Transfer -->
                <div @click="withdrawMethod = 'Wise Transfer'; changeMethod()" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
                    <div class="flex items-center mb-2">
                        <div class="h-8 w-8 rounded-xl bg-green-100 dark:bg-green-900/30 flex items-center justify-center">
                            <i class="fa-solid fa-money-bill-transfer text-green-600 dark:text-green-400 text-sm"></i>
                        </div>
                        <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">Wise Transfer</h3>
                    </div>
                    <p class="text-xs text-gray-500 dark:text-gray-400">Transfer with lower fees using Wise.</p>
                </div> 
                
                <!-- Cash App -->
                <div @click="withdrawMethod = 'Cash App'; changeMethod()" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
                    <div class="flex items-center mb-2">
                        <div class="h-8 w-8 rounded-xl bg-pink-100 dark:bg-pink-900/30 flex items-center justify-center">
                            <i class="fa-solid fa-dollar-sign text-pink-600 dark:text-pink-400 text-sm"></i>
                        </div>
                        <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">Cash App</h3>
                    </div>
                    <p class="text-xs text-gray-500 dark:text-gray-400">Quick transfers to your Cash App account.</p>
                </div> 
                
                <!-- More Options -->
                <div @click="showMoreMethods = true; withdrawMethod = ''" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
                    <div class="flex items-center mb-2">
                        <div class="h-8 w-8 rounded-xl bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center">
                           <i class="fa-solid fa-ellipsis text-amber-600 dark:text-amber-400 text-sm"></i>
                        </div>
                        <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">More Options</h3>
                    </div>
                    <p class="text-xs text-gray-500 dark:text-gray-400">Zelle, Venmo, Revolut, and more.</p>
                </div> 
            </div>
        </div>

        
        <div x-show="showMoreMethods" class="mb-6" x-transition>
    <div class="flex items-center mb-4">
        <button 
            @click="showMoreMethods = false" 
            class="mr-3 bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-full p-2 text-gray-500 dark:text-gray-400 border border-white/20 dark:border-gray-700/50 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"
        >
            <i class="fa-solid fa-arrow-left text-sm"></i>
        </button>
        <h2 class="text-lg font-bold text-gray-900 dark:text-white">Additional Transfer Methods</h2>
    </div>
    
    <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3">
        <!-- Skrill -->
        <div @click="withdrawMethod = 'Skrill'; changeMethod(); showMoreMethods = false" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
            <div class="flex items-center mb-2">
                <div class="h-8 w-8 rounded-xl bg-indigo-100 dark:bg-indigo-900/30 flex items-center justify-center">
                    <i class="fa-solid fa-wallet text-indigo-600 dark:text-indigo-400 text-sm"></i>
                </div>
                <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">Skrill</h3>
            </div>
            <p class="text-xs text-gray-500 dark:text-gray-400">Transfer funds to your Skrill account.</p>
        </div>
        
        <!-- Venmo -->
        <div @click="withdrawMethod = 'Venmo'; changeMethod(); showMoreMethods = false" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
            <div class="flex items-center mb-2">
                <div class="h-8 w-8 rounded-xl bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center">
                    <i class="fa-solid fa-mobile-screen text-blue-600 dark:text-blue-400 text-sm"></i>
                </div>
                <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">Venmo</h3>
            </div>
            <p class="text-xs text-gray-500 dark:text-gray-400">Send funds to your Venmo account.</p>
        </div>
        
        <!-- Zelle -->
        <div @click="withdrawMethod = 'Zelle'; changeMethod(); showMoreMethods = false" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
            <div class="flex items-center mb-2">
                <div class="h-8 w-8 rounded-xl bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center">
                    <i class="fa-solid fa-bolt text-purple-600 dark:text-purple-400 text-sm"></i>
                </div>
                <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">Zelle</h3>
            </div>
            <p class="text-xs text-gray-500 dark:text-gray-400">Quick transfers to your Zelle account.</p>
        </div>
        
        <!-- Revolut -->
        <div @click="withdrawMethod = 'Revolut'; changeMethod(); showMoreMethods = false" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
            <div class="flex items-center mb-2">
                <div class="h-8 w-8 rounded-xl bg-cyan-100 dark:bg-cyan-900/30 flex items-center justify-center">
                    <i class="fa-solid fa-credit-card text-cyan-600 dark:text-cyan-400 text-sm"></i>
                </div>
                <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">Revolut</h3>
            </div>
            <p class="text-xs text-gray-500 dark:text-gray-400">Transfer to your Revolut account with low fees.</p>
        </div>
        
        <!-- Alipay -->
        <div @click="withdrawMethod = 'Alipay'; changeMethod(); showMoreMethods = false" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
            <div class="flex items-center mb-2">
                <div class="h-8 w-8 rounded-xl bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center">
                    <i class="fa-solid fa-mobile-screen-button text-blue-600 dark:text-blue-400 text-sm"></i>
                </div>
                <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">Alipay</h3>
            </div>
            <p class="text-xs text-gray-500 dark:text-gray-400">Send funds to your Alipay account.</p>
        </div>
        
        <!-- WeChat Pay -->
        <div @click="withdrawMethod = 'WeChat Pay'; changeMethod(); showMoreMethods = false" class="cursor-pointer bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-white/20 dark:border-gray-700/50 p-3 hover:border-primary-500 dark:hover:border-primary-400 hover:shadow-lg dark:hover:shadow-gray-900/50 transition-all">
            <div class="flex items-center mb-2">
                <div class="h-8 w-8 rounded-xl bg-green-100 dark:bg-green-900/30 flex items-center justify-center">
                    <i class="fa-brands fa-weixin text-green-600 dark:text-green-400 text-sm"></i>
                </div>
                <h3 class="ml-3 font-medium text-gray-900 dark:text-white text-sm">WeChat Pay</h3>
            </div>
            <p class="text-xs text-gray-500 dark:text-gray-400">Transfer to your WeChat Pay wallet.</p>
        </div>
    </div>
</div>
        <div class="bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl shadow-lg dark:shadow-gray-900/50 border border-white/20 dark:border-gray-700/50 overflow-hidden" x-show="withdrawMethod && !showMoreMethods">
    <!-- Card Header with Method Icon -->
    <div class="relative bg-gradient-to-r from-primary-600 to-primary-700 dark:from-primary-500 dark:to-primary-600 p-6">
        <!-- Back Button -->
        <button 
            @click="withdrawMethod = ''" 
            class="absolute top-4 left-4 bg-white/20 dark:bg-white/10 rounded-full p-2 text-white hover:bg-white/30 dark:hover:bg-white/20 transition-colors"
        >
            <i class="fa-solid fa-arrow-left text-sm"></i>
        </button>
        
        <div class="flex flex-col items-center">
            <div class="bg-white/20 dark:bg-white/10 backdrop-blur-sm p-3 rounded-2xl mb-3">
                <template x-if="withdrawMethod === 'Wire Transfer'">
                    <i class="fa-solid fa-building-columns text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'Cryptocurrency'">
                    <i class="fa-brands fa-bitcoin text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'PayPal'">
                    <i class="fa-brands fa-paypal text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'Wise Transfer'">
                    <i class="fa-solid fa-money-bill-transfer text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'Skrill'">
                    <i class="fa-solid fa-wallet text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'Venmo'">
                    <i class="fa-solid fa-mobile-screen text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'Zelle'">
                    <i class="fa-solid fa-bolt text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'Cash App'">
                    <i class="fa-solid fa-dollar-sign text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'Revolut'">
                    <i class="fa-solid fa-credit-card text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'Alipay'">
                    <i class="fa-solid fa-mobile-screen-button text-white text-2xl"></i>
                </template>
                <template x-if="withdrawMethod === 'WeChat Pay'">
                    <i class="fa-brands fa-weixin text-white text-2xl"></i>
                </template>
            </div>
            <h2 class="text-xl font-bold text-white" x-text="formTitle">International Wire Transfer</h2>
            <p class="text-white/80 mt-1 text-center text-sm" x-text="formDescription">Funds will reflect in the Beneficiary Account within 72hours.</p>
        </div>
    </div>

    <!-- Form Content -->
    <div class="p-4 space-y-4">
        <form action="internationaltransfer" method="post" id="internationalTransferForm" @submit.prevent="previewTransfer()">
            <input type="hidden" name="withdrawMethod" :value="withdrawMethod">

            <!-- Balance Display (Method-specific) -->
            <div class="mb-4">
                <label class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2">Available Balance</label>
                
                <!-- Fiat Balance Display (for non-crypto methods) -->
                <div x-show="withdrawMethod !== 'Cryptocurrency'" class="bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-primary-500 ring-2 ring-primary-200 dark:ring-primary-800 p-3">
                    <div class="flex items-center">
                        <div class="w-8 h-8 rounded-xl flex items-center justify-center bg-blue-100 dark:bg-blue-900/30 mr-3">
                            <i class="fa-solid fa-building-columns text-blue-600 dark:text-blue-400 text-sm"></i>
                        </div>
                        <div>
                            <p class="text-xs text-gray-500 dark:text-gray-400">Account Balance</p>
                            <p class="text-lg font-bold text-gray-900 dark:text-white"><?php echo $_curr_sym . number_format($_balance, 2); ?></p>
                        </div>
                        <div class="ml-auto">
                            <div class="w-5 h-5 rounded-full border-2 bg-primary-500 border-primary-500 flex items-center justify-center">
                                <i class="fa-solid fa-check text-white text-xs"></i>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Bitcoin Balance Display (for crypto method only) -->
                <div x-show="withdrawMethod === 'Cryptocurrency'" class="bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl rounded-2xl border border-primary-500 ring-2 ring-primary-200 dark:ring-primary-800 p-3">
                    <div class="flex items-center">
                        <div class="w-8 h-8 rounded-xl flex items-center justify-center bg-amber-100 dark:bg-amber-900/30 mr-3">
                            <i class="fa-brands fa-bitcoin text-amber-600 dark:text-amber-400 text-sm"></i>
                        </div>
                        <div>
                            <p class="text-xs text-gray-500 dark:text-gray-400">Bitcoin Balance</p>
                            <p class="text-lg font-bold text-gray-900 dark:text-white"><?php echo number_format($_btc_balance, 8); ?> BTC</p>
                            <p class="text-xs text-gray-500 dark:text-gray-400">≈ <?php echo $_curr_sym . number_format($_btc_fiat_value, 2); ?></p>
                        </div>
                        <div class="ml-auto">
                            <div class="w-5 h-5 rounded-full border-2 bg-primary-500 border-primary-500 flex items-center justify-center">
                                <i class="fa-solid fa-check text-white text-xs"></i>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Hidden input to pass the balance type to the controller -->
                <input type="hidden" name="balance_type" x-model="balanceType">
            </div>

            <!-- Amount Input with Currency (Enhanced) -->
            <div class="mb-4 bg-gradient-to-br from-gray-50 to-white dark:from-gray-800/50 dark:to-gray-700/50 p-4 rounded-2xl border border-gray-100 dark:border-gray-700 shadow-sm">
                <label for="amount" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-2">Amount to Transfer</label>
                <div class="relative">
                    <div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
                        <span class="text-gray-500 text-lg font-bold" x-text="withdrawMethod === 'Cryptocurrency' ? '' : '<?php echo $_curr_sym; ?>'"></span>
                    </div>
                    <input 
                        type="number" 
                        name="amount" 
                        id="amount" 
                        x-model="amount"
                        @input="validateAmount()"
                        :min="withdrawMethod === 'Cryptocurrency' ? '0.00000001' : '1'"
                        :max="withdrawMethod === 'Cryptocurrency' ? '<?php echo $_btc_balance; ?>' : '<?php echo $_balance; ?>'"
                        :step="withdrawMethod === 'Cryptocurrency' ? '0.00000001' : '0.01'"
                        class="block w-full pl-12 pr-20 py-3 border-2 border-primary-100 dark:border-primary-800 rounded-lg bg-white dark:bg-gray-800 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-xl font-bold"
                        :placeholder="withdrawMethod === 'Cryptocurrency' ? '<?php echo number_format($_btc_balance, 8); ?>' : '0.00'"
                        required
                    />
                    <div class="absolute right-3 top-1/2 transform -translate-y-1/2 text-lg font-bold text-gray-400 pointer-events-none" x-text="withdrawMethod === 'Cryptocurrency' ? 'BTC' : ''"></div>
                </div>
                <div class="mt-2 flex items-center justify-between">
                    <!-- Quick Amount Buttons -->
                    <div class="flex space-x-2">
                        <template x-if="withdrawMethod !== 'Cryptocurrency'">
                            <div class="flex space-x-2">
                                <button type="button" @click="amount = '100'" class="px-2 py-1 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors"><?php echo $_curr_sym; ?>100</button>
                                <button type="button" @click="amount = '500'" class="px-2 py-1 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors"><?php echo $_curr_sym; ?>500</button>
                                <button type="button" @click="amount = '1000'" class="px-2 py-1 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors"><?php echo $_curr_sym; ?>1000</button>
                                <button type="button" @click="amount = '<?php echo $_balance; ?>'" class="px-2 py-1 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors">Max</button>
                            </div>
                        </template>
                        <template x-if="withdrawMethod === 'Cryptocurrency'">
                            <div class="flex space-x-2">
                                <button type="button" @click="amount = '0.001'" class="px-2 py-1 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors">0.001 BTC</button>
                                <button type="button" @click="amount = '0.01'" class="px-2 py-1 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors">0.01 BTC</button>
                                <button type="button" @click="amount = '0.1'" class="px-2 py-1 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors">0.1 BTC</button>
                                <button type="button" @click="amount = <?php echo number_format($_btc_balance, 8); ?>" class="px-2 py-1 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors">Max</button>
                            </div>
                        </template>
                    </div>
                </div>
                
                <!-- Conversion Preview -->
                <div class="mt-3 text-xs text-gray-600 dark:text-gray-400" x-show="amount && parseFloat(amount) > 0">
                    <template x-if="withdrawMethod !== 'Cryptocurrency'">
                        <p>Equivalent: <span class="font-medium" x-text="'≈ ' + (parseFloat(amount) / <?php echo (float)$_btc_price ?: 1; ?>).toLocaleString('en-US', {minimumFractionDigits: 8, maximumFractionDigits: 8}) + ' BTC'"></span></p>
                    </template>
                    <template x-if="withdrawMethod === 'Cryptocurrency'">
                        <p>Equivalent: <span class="font-medium" x-text="'≈ <?php echo $_curr_sym; ?>' + (parseFloat(amount) * <?php echo (float)$_btc_price ?: 0; ?>).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2})"></span></p>
                    </template>
                </div>
            </div>
        
            <!-- WIRE TRANSFER FIELDS -->
            <div x-show="withdrawMethod === 'Wire Transfer'" x-transition class="space-y-4 mt-4">
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div>
                        <label for="accountname" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Beneficiary Account Name</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-user text-gray-400 text-sm"></i>
                            </div>
                            <input 
                                type="text" 
                                name="accountname" 
                                id="accountname" 
                                x-model="accountName"
                                class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                                placeholder="Enter beneficiary's full name"
                                x-bind:required="withdrawMethod === 'Wire Transfer'"
                            />
                        </div>
                    </div>
                    
                    <div>
                        <label for="accountnumber" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Beneficiary Account Number</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-hashtag text-gray-400 text-sm"></i>
                            </div>
                            <input 
                                type="text" 
                                name="accountnumber" 
                                id="accountnumber" 
                                x-model="accountNumber"
                                class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                                placeholder="Enter account number"
                                x-bind:required="withdrawMethod === 'Wire Transfer'"
                            />
                        </div>
                    </div>
                </div>

                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div>
                        <label for="bankname" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Bank Name</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-building text-gray-400 text-sm"></i>
                            </div>
                            <input 
                                type="text" 
                                name="bankname" 
                                id="bankname" 
                                x-model="bankName"
                                class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                                placeholder="Enter bank name"
                                x-bind:required="withdrawMethod === 'Wire Transfer'"
                            />
                        </div>
                    </div>

                    <div>
                        <label for="bankaddress" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Bank Address</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-location-dot text-gray-400 text-sm"></i>
                            </div>
                            <input 
                                type="text" 
                                name="bankaddress" 
                                id="bankaddress" 
                                x-model="bankAddress"
                                class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                                placeholder="Enter bank address"
                                x-bind:required="withdrawMethod === 'Wire Transfer'"
                            />
                        </div>
                    </div>
                </div>
     
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div>
                        <label for="Accounttype" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Account Type</label>
                        <div class="relative rounded-lg shadow-sm">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-list text-gray-400 text-sm"></i>
                            </div>
                            <select 
                                name="Accounttype" 
                                id="Accounttype" 
                                x-model="accountType"
                                class="block w-full pl-10 pr-8 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all appearance-none text-sm"
                                x-bind:required="withdrawMethod === 'Wire Transfer'"
                            >
                                <option value="Online Banking">Online Banking</option>
                                <option value="Joint Account">Joint Account</option>
                                <option value="Checking">Checking</option>
                                <option value="Savings Account">Savings Account</option>
                            </select>
                            <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-chevron-down text-gray-400 text-sm"></i>
                            </div>
                        </div>
                    </div>

                    <div>
                        <label for="country" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Country</label>
                        <div class="relative rounded-lg shadow-sm">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-globe text-gray-400 text-sm"></i>
                            </div>
                            <div class="pl-10">
                                <select class="block w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all appearance-none" 
        type="text" 
        name="country" 
        autocomplete="country" 
        >
    <option value="Afghanistan">Afghanistan</option>
    <option value="Albania">Albania</option>
    <option value="Algeria">Algeria</option>
    <option value="American Samoa">American Samoa</option>
    <option value="Andorra">Andorra</option>
    <option value="Angola">Angola</option>
    <option value="Anguilla">Anguilla</option>
    <option value="Antarctica">Antarctica</option>
    <option value="Antigua and Barbuda">Antigua and Barbuda</option>
    <option value="Argentina">Argentina</option>
    <option value="Armenia">Armenia</option>
    <option value="Aruba">Aruba</option>
    <option value="Australia">Australia</option>
    <option value="Austria">Austria</option>
    <option value="Azerbaijan">Azerbaijan</option>
    <option value="Bahamas">Bahamas</option>
    <option value="Bahrain">Bahrain</option>
    <option value="Bangladesh">Bangladesh</option>
    <option value="Barbados">Barbados</option>
    <option value="Belarus">Belarus</option>
    <option value="Belgium">Belgium</option>
    <option value="Belize">Belize</option>
    <option value="Benin">Benin</option>
    <option value="Bermuda">Bermuda</option>
    <option value="Bhutan">Bhutan</option>
    <option value="Bolivia">Bolivia</option>
    <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
    <option value="Botswana">Botswana</option>
    <option value="Bouvet Island">Bouvet Island</option>
    <option value="Brazil">Brazil</option>
    <option value="British Indian Ocean Territory">British Indian Ocean Territory</option>
    <option value="Brunei Darussalam">Brunei Darussalam</option>
    <option value="Bulgaria">Bulgaria</option>
    <option value="Burkina Faso">Burkina Faso</option>
    <option value="Burundi">Burundi</option>
    <option value="Cambodia">Cambodia</option>
    <option value="Cameroon">Cameroon</option>
    <option value="Canada">Canada</option>
    <option value="Cape Verde">Cape Verde</option>
    <option value="Cayman Islands">Cayman Islands</option>
    <option value="Central African Republic">Central African Republic</option>
    <option value="Chad">Chad</option>
    <option value="Chile">Chile</option>
    <option value="China">China</option>
    <option value="Christmas Island">Christmas Island</option>
    <option value="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
    <option value="Colombia">Colombia</option>
    <option value="Comoros">Comoros</option>
    <option value="Congo">Congo</option>
    <option value="Cook Islands">Cook Islands</option>
    <option value="Costa Rica">Costa Rica</option>
    <option value="Croatia (Hrvatska)">Croatia (Hrvatska)</option>
    <option value="Cuba">Cuba</option>
    <option value="Cyprus">Cyprus</option>
    <option value="Czech Republic">Czech Republic</option>
    <option value="Denmark">Denmark</option>
    <option value="Djibouti">Djibouti</option>
    <option value="Dominica">Dominica</option>
    <option value="Dominican Republic">Dominican Republic</option>
    <option value="East Timor">East Timor</option>
    <option value="Ecuador">Ecuador</option>
    <option value="Egypt">Egypt</option>
    <option value="El Salvador">El Salvador</option>
    <option value="Equatorial Guinea">Equatorial Guinea</option>
    <option value="Eritrea">Eritrea</option>
    <option value="Estonia">Estonia</option>
    <option value="Ethiopia">Ethiopia</option>
    <option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
    <option value="Faroe Islands">Faroe Islands</option>
    <option value="Fiji">Fiji</option>
    <option value="Finland">Finland</option>
    <option value="France">France</option>
    <option value="France, Metropolitan">France, Metropolitan</option>
    <option value="French Guiana">French Guiana</option>
    <option value="French Polynesia">French Polynesia</option>
    <option value="French Southern Territories">French Southern Territories</option>
    <option value="Gabon">Gabon</option>
    <option value="Gambia">Gambia</option>
    <option value="Georgia">Georgia</option>
    <option value="Germany">Germany</option>
    <option value="Ghana">Ghana</option>
    <option value="Gibraltar">Gibraltar</option>
    <option value="Guernsey">Guernsey</option>
    <option value="Greece">Greece</option>
    <option value="Greenland">Greenland</option>
    <option value="Grenada">Grenada</option>
    <option value="Guadeloupe">Guadeloupe</option>
    <option value="Guam">Guam</option>
    <option value="Guatemala">Guatemala</option>
    <option value="Guinea">Guinea</option>
    <option value="Guinea-Bissau">Guinea-Bissau</option>
    <option value="Guyana">Guyana</option>
    <option value="Haiti">Haiti</option>
    <option value="Heard and Mc Donald Islands">Heard and Mc Donald Islands</option>
    <option value="Honduras">Honduras</option>
    <option value="Hong Kong">Hong Kong</option>
    <option value="Hungary">Hungary</option>
    <option value="Iceland">Iceland</option>
    <option value="India">India</option>
    <option value="Isle of Man">Isle of Man</option>
    <option value="Indonesia">Indonesia</option>
    <option value="Iran (Islamic Republic of)">Iran (Islamic Republic of)</option>
    <option value="Iraq">Iraq</option>
    <option value="Ireland">Ireland</option>
    <option value="Israel">Israel</option>
    <option value="Italy">Italy</option>
    <option value="Ivory Coast">Ivory Coast</option>
    <option value="Jersey">Jersey</option>
    <option value="Jamaica">Jamaica</option>
    <option value="Japan">Japan</option>
    <option value="Jordan">Jordan</option>
    <option value="Kazakhstan">Kazakhstan</option>
    <option value="Kenya">Kenya</option>
    <option value="Kiribati">Kiribati</option>
    <option value="Korea, Democratic People's Republic of">Korea, Democratic People's Republic of</option>
    <option value="Korea, Republic of">Korea, Republic of</option>
    <option value="Kosovo">Kosovo</option>
    <option value="Kuwait">Kuwait</option>
    <option value="Kyrgyzstan">Kyrgyzstan</option>
    <option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option>
    <option value="Latvia">Latvia</option>
    <option value="Lebanon">Lebanon</option>
    <option value="Lesotho">Lesotho</option>
    <option value="Liberia">Liberia</option>
    <option value="Libyan Arab Jamahiriya">Libyan Arab Jamahiriya</option>
    <option value="Liechtenstein">Liechtenstein</option>
    <option value="Lithuania">Lithuania</option>
    <option value="Luxembourg">Luxembourg</option>
    <option value="Macau">Macau</option>
    <option value="Macedonia">Macedonia</option>
    <option value="Madagascar">Madagascar</option>
    <option value="Malawi">Malawi</option>
    <option value="Malaysia">Malaysia</option>
    <option value="Maldives">Maldives</option>
    <option value="Mali">Mali</option>
    <option value="Malta">Malta</option>
    <option value="Marshall Islands">Marshall Islands</option>
    <option value="Martinique">Martinique</option>
    <option value="Mauritania">Mauritania</option>
    <option value="Mauritius">Mauritius</option>
    <option value="Mayotte">Mayotte</option>
    <option value="Mexico">Mexico</option>
    <option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
    <option value="Moldova, Republic of">Moldova, Republic of</option>
    <option value="Monaco">Monaco</option>
    <option value="Mongolia">Mongolia</option>
    <option value="Montenegro">Montenegro</option>
    <option value="Montserrat">Montserrat</option>
    <option value="Morocco">Morocco</option>
    <option value="Mozambique">Mozambique</option>
    <option value="Myanmar">Myanmar</option>
    <option value="Namibia">Namibia</option>
    <option value="Nauru">Nauru</option>
    <option value="Nepal">Nepal</option>
    <option value="Netherlands">Netherlands</option>
    <option value="Netherlands Antilles">Netherlands Antilles</option>
    <option value="New Caledonia">New Caledonia</option>
    <option value="New Zealand">New Zealand</option>
    <option value="Nicaragua">Nicaragua</option>
    <option value="Niger">Niger</option>
    <option value="Nigeria">Nigeria</option>
    <option value="Niue">Niue</option>
    <option value="Norfolk Island">Norfolk Island</option>
    <option value="Northern Mariana Islands">Northern Mariana Islands</option>
    <option value="Norway">Norway</option>
    <option value="Oman">Oman</option>
    <option value="Pakistan">Pakistan</option>
    <option value="Palau">Palau</option>
    <option value="Palestine">Palestine</option>
    <option value="Panama">Panama</option>
    <option value="Papua New Guinea">Papua New Guinea</option>
    <option value="Paraguay">Paraguay</option>
    <option value="Peru">Peru</option>
    <option value="Philippines">Philippines</option>
    <option value="Pitcairn">Pitcairn</option>
    <option value="Poland">Poland</option>
    <option value="Portugal">Portugal</option>
    <option value="Puerto Rico">Puerto Rico</option>
    <option value="Qatar">Qatar</option>
    <option value="Reunion">Reunion</option>
    <option value="Romania">Romania</option>
    <option value="Russian Federation">Russian Federation</option>
    <option value="Rwanda">Rwanda</option>
    <option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
    <option value="Saint Lucia">Saint Lucia</option>
    <option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option>
    <option value="Samoa">Samoa</option>
    <option value="San Marino">San Marino</option>
    <option value="Sao Tome and Principe">Sao Tome and Principe</option>
    <option value="Saudi Arabia">Saudi Arabia</option>
    <option value="Senegal">Senegal</option>
    <option value="Serbia">Serbia</option>
    <option value="Seychelles">Seychelles</option>
    <option value="Sierra Leone">Sierra Leone</option>
    <option value="Singapore">Singapore</option>
    <option value="Slovakia">Slovakia</option>
    <option value="Slovenia">Slovenia</option>
    <option value="Solomon Islands">Solomon Islands</option>
    <option value="Somalia">Somalia</option>
    <option value="South Africa">South Africa</option>
    <option value="South Georgia South Sandwich Islands">South Georgia South Sandwich Islands</option>
    <option value="South Sudan">South Sudan</option>
    <option value="Spain">Spain</option>
    <option value="Sri Lanka">Sri Lanka</option>
    <option value="St. Helena">St. Helena</option>
    <option value="St. Pierre and Miquelon">St. Pierre and Miquelon</option>
    <option value="Sudan">Sudan</option>
    <option value="Suriname">Suriname</option>
    <option value="Svalbard and Jan Mayen Islands">Svalbard and Jan Mayen Islands</option>
    <option value="Swaziland">Swaziland</option>
    <option value="Sweden">Sweden</option>
    <option value="Switzerland">Switzerland</option>
    <option value="Syrian Arab Republic">Syrian Arab Republic</option>
    <option value="Taiwan">Taiwan</option>
    <option value="Tajikistan">Tajikistan</option>
    <option value="Tanzania, United Republic of">Tanzania, United Republic of</option>
    <option value="Thailand">Thailand</option>
    <option value="Togo">Togo</option>
    <option value="Tokelau">Tokelau</option>
    <option value="Tonga">Tonga</option>
    <option value="Trinidad and Tobago">Trinidad and Tobago</option>
    <option value="Tunisia">Tunisia</option>
    <option value="Turkey">Turkey</option>
    <option value="Turkmenistan">Turkmenistan</option>
    <option value="Turks and Caicos Islands">Turks and Caicos Islands</option>
    <option value="Tuvalu">Tuvalu</option>
    <option value="Uganda">Uganda</option>
    <option value="Ukraine">Ukraine</option>
    <option value="United Arab Emirates">United Arab Emirates</option>
    <option value="United Kingdom">United Kingdom</option>
    <option value="United States">United States</option>
    <option value="United States minor outlying islands">United States minor outlying islands</option>
    <option value="Uruguay">Uruguay</option>
    <option value="Uzbekistan">Uzbekistan</option>
    <option value="Vanuatu">Vanuatu</option>
    <option value="Vatican City State">Vatican City State</option>
    <option value="Venezuela">Venezuela</option>
    <option value="Vietnam">Vietnam</option>
    <option value="Virgin Islands (British)">Virgin Islands (British)</option>
    <option value="Virgin Islands (U.S.)">Virgin Islands (U.S.)</option>
    <option value="Wallis and Futuna Islands">Wallis and Futuna Islands</option>
    <option value="Western Sahara">Western Sahara</option>
    <option value="Yemen">Yemen</option>
    <option value="Zaire">Zaire</option>
    <option value="Zambia">Zambia</option>
    <option value="Zimbabwe">Zimbabwe</option>
</select>                            </div>
                        </div>
                    </div>
                    
                </div>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div>
                        <label for="iban" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">IBAN Number</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-credit-card text-gray-400 text-sm"></i>
                            </div>
                            <input 
                                type="text" 
                                name="iban" 
                                id="iban" 
                                x-model="iban"
                                class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                                placeholder="Enter IBAN number"
                                maxlength="34"
                                x-bind:required="withdrawMethod === 'Wire Transfer'"
                            />
                        </div>
                        <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">International Bank Account Number</p>
                    </div>
                    
                    <div>
                        <label for="swiftcode" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">SWIFT Code</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-globe text-gray-400 text-sm"></i>
                            </div>
                            <input 
                                type="text" 
                                name="swiftcode" 
                                id="swiftcode" 
                                x-model="swiftCode"
                                class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                                placeholder="Enter SWIFT/BIC code"
                                maxlength="11"
                                x-bind:required="withdrawMethod === 'Wire Transfer'"
                            />
                        </div>
                        <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">8-11 character bank identifier code</p>
                    </div>
                </div>
            </div>
            
            <!-- CRYPTOCURRENCY FIELDS -->
            <div x-show="withdrawMethod === 'Cryptocurrency'" x-transition class="space-y-4 mt-4">
                <!-- Crypto Icon and Info -->
                <div class="flex items-center justify-center mb-4">
                    <div class="flex items-center h-16 px-4 bg-gray-50 dark:bg-gray-800/50 border border-gray-100 dark:border-gray-700 rounded-2xl">
                        <template x-if="cryptoCurrency === 'BTC'">
                            <div class="w-10 h-10 mr-4 rounded-full bg-amber-100 flex items-center justify-center">
                                <img src="https://cdn.jsdelivr.net/npm/cryptocurrency-icons@0.18.1/svg/color/btc.svg" alt="Bitcoin" class="h-6 w-6">
                            </div>
                        </template>
                        <!-- If more currencies enabled, include templates here -->
                        <div>
                            <div class="flex items-center">
                                <span class="text-lg font-bold mr-2" x-text="cryptoCurrency"></span>
                                <span class="text-sm text-gray-500" x-text="cryptoNetwork"></span>
                            </div>
                            <p class="text-sm text-gray-500">Select your preferred cryptocurrency and network</p>
                        </div>
                    </div>
                </div>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div>
                        <label for="cryptoCurrency" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Cryptocurrency</label>
                        <div class="relative rounded-lg shadow-sm">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-brands fa-bitcoin text-gray-400 text-sm"></i>
                            </div>
                            <select 
                                name="cryptoCurrency" 
                                id="cryptoCurrency" 
                                x-model="cryptoCurrency"
                                class="block w-full pl-10 pr-10 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all appearance-none text-sm"
                                x-bind:required="withdrawMethod === 'Cryptocurrency'"
                            >
                                <option value="BTC">Bitcoin (BTC)</option>
                                <!-- Add more <option> as needed -->
                            </select>
                            <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-chevron-down text-gray-400 text-sm"></i>
                            </div>
                        </div>
                    </div>
                    
                    <div>
                        <label for="cryptoNetwork" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Network</label>
                        <div class="relative rounded-lg shadow-sm">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-network-wired text-gray-400 text-sm"></i>
                            </div>
                            <select 
                                name="cryptoNetwork" 
                                id="cryptoNetwork" 
                                x-model="cryptoNetwork"
                                class="block w-full pl-10 pr-10 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all appearance-none text-sm"
                                x-bind:required="withdrawMethod === 'Cryptocurrency'"
                            >
                                <option value="Native">Native</option>
                                <!-- Add more network options if needed -->
                            </select>
                            <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-chevron-down text-gray-400 text-sm"></i>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Crypto Cards Display -->
                <div class="grid grid-cols-4 gap-2 mb-4">
                    <div @click="cryptoCurrency = 'BTC'" class="cursor-pointer p-2 rounded-lg border" :class="{'border-primary-500 bg-primary-50 dark:bg-primary-900/30 dark:border-primary-400': cryptoCurrency === 'BTC', 'border-gray-200 dark:border-gray-600': cryptoCurrency !== 'BTC'}">
                        <div class="flex flex-col items-center">
                            <img src="https://cdn.jsdelivr.net/npm/cryptocurrency-icons@0.18.1/svg/color/btc.svg" alt="Bitcoin" class="h-8 w-8 mb-1">
                            <span class="text-xs font-medium text-gray-900 dark:text-white">BTC</span>
                        </div>
                    </div>
                    <!-- Add more currency cards as needed -->
                </div>
                
                <div>
                    <label for="walletAddress" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Wallet Address</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-wallet text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="walletAddress" 
                            id="walletAddress" 
                            x-model="walletAddress"
                            class="block w-full pl-10 pr-10 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all font-mono text-sm"
                            placeholder="Enter wallet address"
                            x-bind:required="withdrawMethod === 'Cryptocurrency'"
                        />
                        <div class="absolute inset-y-0 right-0 pr-3 flex items-center">
                            <button 
                                type="button" 
                                class="text-gray-400 hover:text-gray-500 dark:hover:text-gray-300 focus:outline-none"
                                @click="navigator.clipboard.readText().then(text => walletAddress = text)"
                            >
                                <i class="fa-solid fa-clipboard text-sm"></i>
                            </button>
                        </div>
                    </div>
                    
                    <!-- Wallet Address Warning -->
                    <div class="mt-2 p-3 bg-yellow-50 dark:bg-yellow-900/30 border-l-4 border-yellow-400 dark:border-yellow-500 rounded-r-md">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fa-solid fa-triangle-exclamation text-yellow-500 dark:text-yellow-400 text-sm"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-xs text-yellow-700 dark:text-yellow-300">
                                    Double-check your wallet address. Transactions to incorrect addresses cannot be reversed.
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- PAYPAL FIELDS -->
            <div x-show="withdrawMethod === 'PayPal'" x-transition class="space-y-4 mt-4">
                <div class="flex items-center justify-center mb-4">
                    <div class="flex items-center h-16 px-4 bg-gray-50 dark:bg-gray-800/50 border border-gray-100 dark:border-gray-700 rounded-2xl">
                        <div class="w-8 h-8 mr-3 rounded-xl bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center">
                            <i class="fa-brands fa-paypal text-blue-600 dark:text-blue-400 text-sm"></i>
                        </div>
                        <div>
                            <div class="text-sm font-bold text-gray-900 dark:text-white">PayPal</div>
                            <p class="text-xs text-gray-500 dark:text-gray-400">Transfer funds to your PayPal account</p>
                        </div>
                    </div>
                </div>
                
                <div>
                    <label for="paypalEmail" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">PayPal Email</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-envelope text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="email" 
                            name="paypalEmail" 
                            id="paypalEmail" 
                            x-model="paypalEmail"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter PayPal email address"
                            x-bind:required="withdrawMethod === 'PayPal'"
                        />
                    </div>
                    
                    <!-- PayPal Email Note -->
                    <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Please ensure this is the email address associated with your PayPal account</p>
                </div>
            </div>
        
            <!-- WISE TRANSFER FIELDS -->
            <div x-show="withdrawMethod === 'Wise Transfer'" x-transition class="space-y-6 mt-6">
                <div class="flex items-center justify-center mb-6">
                    <div class="flex items-center h-20 px-6 bg-gray-50 border border-gray-100 rounded-lg">
                        <div class="w-10 h-10 mr-4 rounded-full bg-green-100 flex items-center justify-center">
                            <i data-lucide="wallet" class="h-6 w-6 text-green-600"></i>
                        </div>
                        <div>
                            <div class="text-lg font-bold">Wise Transfer</div>
                            <p class="text-sm text-gray-500">Formerly TransferWise - Low fee international transfers</p>
                        </div>
                    </div>
                </div>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <label for="wiseFullName" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Full Name</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-user text-gray-400 text-sm"></i>
                            </div>
                            <input 
                                type="text" 
                                name="wiseFullName" 
                                id="wiseFullName" 
                                x-model="wiseFullName"
                                class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                                placeholder="Enter your full name"
                                x-bind:required="withdrawMethod === 'Wise Transfer'"
                            />
                        </div>
                    </div>
                    
                    <div>
                        <label for="wiseEmail" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Email Address</label>
                        <div class="relative">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fa-solid fa-envelope text-gray-400 text-sm"></i>
                            </div>
                            <input 
                                type="email" 
                                name="wiseEmail" 
                                id="wiseEmail" 
                                x-model="wiseEmail"
                                class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                                placeholder="Enter your email address"
                                x-bind:required="withdrawMethod === 'Wise Transfer'"
                            />
                        </div>
                    </div>
                </div>
                
                <div>
                    <label for="wiseCountry" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Country</label>
                    <div class="relative rounded-lg shadow-sm">
                        <select class="block w-full px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all appearance-none" 
        type="text" 
        name="wiseCountry" 
        autocomplete="country" 
        >
    <option value="Afghanistan">Afghanistan</option>
    <option value="Albania">Albania</option>
    <option value="Algeria">Algeria</option>
    <option value="American Samoa">American Samoa</option>
    <option value="Andorra">Andorra</option>
    <option value="Angola">Angola</option>
    <option value="Anguilla">Anguilla</option>
    <option value="Antarctica">Antarctica</option>
    <option value="Antigua and Barbuda">Antigua and Barbuda</option>
    <option value="Argentina">Argentina</option>
    <option value="Armenia">Armenia</option>
    <option value="Aruba">Aruba</option>
    <option value="Australia">Australia</option>
    <option value="Austria">Austria</option>
    <option value="Azerbaijan">Azerbaijan</option>
    <option value="Bahamas">Bahamas</option>
    <option value="Bahrain">Bahrain</option>
    <option value="Bangladesh">Bangladesh</option>
    <option value="Barbados">Barbados</option>
    <option value="Belarus">Belarus</option>
    <option value="Belgium">Belgium</option>
    <option value="Belize">Belize</option>
    <option value="Benin">Benin</option>
    <option value="Bermuda">Bermuda</option>
    <option value="Bhutan">Bhutan</option>
    <option value="Bolivia">Bolivia</option>
    <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
    <option value="Botswana">Botswana</option>
    <option value="Bouvet Island">Bouvet Island</option>
    <option value="Brazil">Brazil</option>
    <option value="British Indian Ocean Territory">British Indian Ocean Territory</option>
    <option value="Brunei Darussalam">Brunei Darussalam</option>
    <option value="Bulgaria">Bulgaria</option>
    <option value="Burkina Faso">Burkina Faso</option>
    <option value="Burundi">Burundi</option>
    <option value="Cambodia">Cambodia</option>
    <option value="Cameroon">Cameroon</option>
    <option value="Canada">Canada</option>
    <option value="Cape Verde">Cape Verde</option>
    <option value="Cayman Islands">Cayman Islands</option>
    <option value="Central African Republic">Central African Republic</option>
    <option value="Chad">Chad</option>
    <option value="Chile">Chile</option>
    <option value="China">China</option>
    <option value="Christmas Island">Christmas Island</option>
    <option value="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
    <option value="Colombia">Colombia</option>
    <option value="Comoros">Comoros</option>
    <option value="Congo">Congo</option>
    <option value="Cook Islands">Cook Islands</option>
    <option value="Costa Rica">Costa Rica</option>
    <option value="Croatia (Hrvatska)">Croatia (Hrvatska)</option>
    <option value="Cuba">Cuba</option>
    <option value="Cyprus">Cyprus</option>
    <option value="Czech Republic">Czech Republic</option>
    <option value="Denmark">Denmark</option>
    <option value="Djibouti">Djibouti</option>
    <option value="Dominica">Dominica</option>
    <option value="Dominican Republic">Dominican Republic</option>
    <option value="East Timor">East Timor</option>
    <option value="Ecuador">Ecuador</option>
    <option value="Egypt">Egypt</option>
    <option value="El Salvador">El Salvador</option>
    <option value="Equatorial Guinea">Equatorial Guinea</option>
    <option value="Eritrea">Eritrea</option>
    <option value="Estonia">Estonia</option>
    <option value="Ethiopia">Ethiopia</option>
    <option value="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
    <option value="Faroe Islands">Faroe Islands</option>
    <option value="Fiji">Fiji</option>
    <option value="Finland">Finland</option>
    <option value="France">France</option>
    <option value="France, Metropolitan">France, Metropolitan</option>
    <option value="French Guiana">French Guiana</option>
    <option value="French Polynesia">French Polynesia</option>
    <option value="French Southern Territories">French Southern Territories</option>
    <option value="Gabon">Gabon</option>
    <option value="Gambia">Gambia</option>
    <option value="Georgia">Georgia</option>
    <option value="Germany">Germany</option>
    <option value="Ghana">Ghana</option>
    <option value="Gibraltar">Gibraltar</option>
    <option value="Guernsey">Guernsey</option>
    <option value="Greece">Greece</option>
    <option value="Greenland">Greenland</option>
    <option value="Grenada">Grenada</option>
    <option value="Guadeloupe">Guadeloupe</option>
    <option value="Guam">Guam</option>
    <option value="Guatemala">Guatemala</option>
    <option value="Guinea">Guinea</option>
    <option value="Guinea-Bissau">Guinea-Bissau</option>
    <option value="Guyana">Guyana</option>
    <option value="Haiti">Haiti</option>
    <option value="Heard and Mc Donald Islands">Heard and Mc Donald Islands</option>
    <option value="Honduras">Honduras</option>
    <option value="Hong Kong">Hong Kong</option>
    <option value="Hungary">Hungary</option>
    <option value="Iceland">Iceland</option>
    <option value="India">India</option>
    <option value="Isle of Man">Isle of Man</option>
    <option value="Indonesia">Indonesia</option>
    <option value="Iran (Islamic Republic of)">Iran (Islamic Republic of)</option>
    <option value="Iraq">Iraq</option>
    <option value="Ireland">Ireland</option>
    <option value="Israel">Israel</option>
    <option value="Italy">Italy</option>
    <option value="Ivory Coast">Ivory Coast</option>
    <option value="Jersey">Jersey</option>
    <option value="Jamaica">Jamaica</option>
    <option value="Japan">Japan</option>
    <option value="Jordan">Jordan</option>
    <option value="Kazakhstan">Kazakhstan</option>
    <option value="Kenya">Kenya</option>
    <option value="Kiribati">Kiribati</option>
    <option value="Korea, Democratic People's Republic of">Korea, Democratic People's Republic of</option>
    <option value="Korea, Republic of">Korea, Republic of</option>
    <option value="Kosovo">Kosovo</option>
    <option value="Kuwait">Kuwait</option>
    <option value="Kyrgyzstan">Kyrgyzstan</option>
    <option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option>
    <option value="Latvia">Latvia</option>
    <option value="Lebanon">Lebanon</option>
    <option value="Lesotho">Lesotho</option>
    <option value="Liberia">Liberia</option>
    <option value="Libyan Arab Jamahiriya">Libyan Arab Jamahiriya</option>
    <option value="Liechtenstein">Liechtenstein</option>
    <option value="Lithuania">Lithuania</option>
    <option value="Luxembourg">Luxembourg</option>
    <option value="Macau">Macau</option>
    <option value="Macedonia">Macedonia</option>
    <option value="Madagascar">Madagascar</option>
    <option value="Malawi">Malawi</option>
    <option value="Malaysia">Malaysia</option>
    <option value="Maldives">Maldives</option>
    <option value="Mali">Mali</option>
    <option value="Malta">Malta</option>
    <option value="Marshall Islands">Marshall Islands</option>
    <option value="Martinique">Martinique</option>
    <option value="Mauritania">Mauritania</option>
    <option value="Mauritius">Mauritius</option>
    <option value="Mayotte">Mayotte</option>
    <option value="Mexico">Mexico</option>
    <option value="Micronesia, Federated States of">Micronesia, Federated States of</option>
    <option value="Moldova, Republic of">Moldova, Republic of</option>
    <option value="Monaco">Monaco</option>
    <option value="Mongolia">Mongolia</option>
    <option value="Montenegro">Montenegro</option>
    <option value="Montserrat">Montserrat</option>
    <option value="Morocco">Morocco</option>
    <option value="Mozambique">Mozambique</option>
    <option value="Myanmar">Myanmar</option>
    <option value="Namibia">Namibia</option>
    <option value="Nauru">Nauru</option>
    <option value="Nepal">Nepal</option>
    <option value="Netherlands">Netherlands</option>
    <option value="Netherlands Antilles">Netherlands Antilles</option>
    <option value="New Caledonia">New Caledonia</option>
    <option value="New Zealand">New Zealand</option>
    <option value="Nicaragua">Nicaragua</option>
    <option value="Niger">Niger</option>
    <option value="Nigeria">Nigeria</option>
    <option value="Niue">Niue</option>
    <option value="Norfolk Island">Norfolk Island</option>
    <option value="Northern Mariana Islands">Northern Mariana Islands</option>
    <option value="Norway">Norway</option>
    <option value="Oman">Oman</option>
    <option value="Pakistan">Pakistan</option>
    <option value="Palau">Palau</option>
    <option value="Palestine">Palestine</option>
    <option value="Panama">Panama</option>
    <option value="Papua New Guinea">Papua New Guinea</option>
    <option value="Paraguay">Paraguay</option>
    <option value="Peru">Peru</option>
    <option value="Philippines">Philippines</option>
    <option value="Pitcairn">Pitcairn</option>
    <option value="Poland">Poland</option>
    <option value="Portugal">Portugal</option>
    <option value="Puerto Rico">Puerto Rico</option>
    <option value="Qatar">Qatar</option>
    <option value="Reunion">Reunion</option>
    <option value="Romania">Romania</option>
    <option value="Russian Federation">Russian Federation</option>
    <option value="Rwanda">Rwanda</option>
    <option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
    <option value="Saint Lucia">Saint Lucia</option>
    <option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option>
    <option value="Samoa">Samoa</option>
    <option value="San Marino">San Marino</option>
    <option value="Sao Tome and Principe">Sao Tome and Principe</option>
    <option value="Saudi Arabia">Saudi Arabia</option>
    <option value="Senegal">Senegal</option>
    <option value="Serbia">Serbia</option>
    <option value="Seychelles">Seychelles</option>
    <option value="Sierra Leone">Sierra Leone</option>
    <option value="Singapore">Singapore</option>
    <option value="Slovakia">Slovakia</option>
    <option value="Slovenia">Slovenia</option>
    <option value="Solomon Islands">Solomon Islands</option>
    <option value="Somalia">Somalia</option>
    <option value="South Africa">South Africa</option>
    <option value="South Georgia South Sandwich Islands">South Georgia South Sandwich Islands</option>
    <option value="South Sudan">South Sudan</option>
    <option value="Spain">Spain</option>
    <option value="Sri Lanka">Sri Lanka</option>
    <option value="St. Helena">St. Helena</option>
    <option value="St. Pierre and Miquelon">St. Pierre and Miquelon</option>
    <option value="Sudan">Sudan</option>
    <option value="Suriname">Suriname</option>
    <option value="Svalbard and Jan Mayen Islands">Svalbard and Jan Mayen Islands</option>
    <option value="Swaziland">Swaziland</option>
    <option value="Sweden">Sweden</option>
    <option value="Switzerland">Switzerland</option>
    <option value="Syrian Arab Republic">Syrian Arab Republic</option>
    <option value="Taiwan">Taiwan</option>
    <option value="Tajikistan">Tajikistan</option>
    <option value="Tanzania, United Republic of">Tanzania, United Republic of</option>
    <option value="Thailand">Thailand</option>
    <option value="Togo">Togo</option>
    <option value="Tokelau">Tokelau</option>
    <option value="Tonga">Tonga</option>
    <option value="Trinidad and Tobago">Trinidad and Tobago</option>
    <option value="Tunisia">Tunisia</option>
    <option value="Turkey">Turkey</option>
    <option value="Turkmenistan">Turkmenistan</option>
    <option value="Turks and Caicos Islands">Turks and Caicos Islands</option>
    <option value="Tuvalu">Tuvalu</option>
    <option value="Uganda">Uganda</option>
    <option value="Ukraine">Ukraine</option>
    <option value="United Arab Emirates">United Arab Emirates</option>
    <option value="United Kingdom">United Kingdom</option>
    <option value="United States">United States</option>
    <option value="United States minor outlying islands">United States minor outlying islands</option>
    <option value="Uruguay">Uruguay</option>
    <option value="Uzbekistan">Uzbekistan</option>
    <option value="Vanuatu">Vanuatu</option>
    <option value="Vatican City State">Vatican City State</option>
    <option value="Venezuela">Venezuela</option>
    <option value="Vietnam">Vietnam</option>
    <option value="Virgin Islands (British)">Virgin Islands (British)</option>
    <option value="Virgin Islands (U.S.)">Virgin Islands (U.S.)</option>
    <option value="Wallis and Futuna Islands">Wallis and Futuna Islands</option>
    <option value="Western Sahara">Western Sahara</option>
    <option value="Yemen">Yemen</option>
    <option value="Zaire">Zaire</option>
    <option value="Zambia">Zambia</option>
    <option value="Zimbabwe">Zimbabwe</option>
</select>                    </div>
                </div>
            </div>
            
            <!-- SKRILL FIELDS -->
            <div x-show="withdrawMethod === 'Skrill'" x-transition class="space-y-4 mt-4">
                <div>
                    <label for="skrillEmail" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Skrill Email</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-envelope text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="email" 
                            name="skrillEmail" 
                            id="skrillEmail" 
                            x-model="skrillEmail"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter Skrill email address"
                            x-bind:required="withdrawMethod === 'Skrill'"
                        />
                    </div>
                </div>
                
                <div>
                    <label for="skrillFullName" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Full Name</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-user text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="skrillFullName" 
                            id="skrillFullName" 
                            x-model="skrillFullName"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your full name"
                            x-bind:required="withdrawMethod === 'Skrill'"
                        />
                    </div>
                </div>
            </div>
            
            <!-- VENMO FIELDS -->
            <div x-show="withdrawMethod === 'Venmo'" x-transition class="space-y-4 mt-4">
                <div>
                    <label for="venmoUsername" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Venmo Username</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-at text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="venmoUsername" 
                            id="venmoUsername" 
                            x-model="venmoUsername"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter Venmo username"
                            x-bind:required="withdrawMethod === 'Venmo'"
                        />
                    </div>
                </div>
                
                <div>
                    <label for="venmoPhone" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Phone Number</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-phone text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="tel" 
                            name="venmoPhone" 
                            id="venmoPhone" 
                            x-model="venmoPhone"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter phone number associated with Venmo"
                            x-bind:required="withdrawMethod === 'Venmo'"
                        />
                    </div>
                </div>
            </div>
            
            <!-- ZELLE FIELDS -->
            <div x-show="withdrawMethod === 'Zelle'" x-transition class="space-y-4 mt-4">
                <div>
                    <label for="zelleEmail" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Zelle Email</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-envelope text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="email" 
                            name="zelleEmail" 
                            id="zelleEmail" 
                            x-model="zelleEmail"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter Zelle email address"
                            x-bind:required="withdrawMethod === 'Zelle'"
                        />
                    </div>
                </div>
                
                <div>
                    <label for="zellePhone" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Phone Number</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-phone text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="tel" 
                            name="zellePhone" 
                            id="zellePhone" 
                            x-model="zellePhone"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter phone number associated with Zelle"
                            x-bind:required="withdrawMethod === 'Zelle'"
                        />
                    </div>
                </div>
                
                <div>
                    <label for="zelleName" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Full Name</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-user text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="zelleName" 
                            id="zelleName" 
                            x-model="zelleName"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your full name"
                            x-bind:required="withdrawMethod === 'Zelle'"
                        />
                    </div>
                </div>
            </div>
            
            <!-- CASH APP FIELDS -->
            <div x-show="withdrawMethod === 'Cash App'" x-transition class="space-y-4 mt-4">
                <div>
                    <label for="cashAppTag" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1"><?php echo $_curr_sym ?>Cashtag</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-dollar-sign text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="cashAppTag" 
                            id="cashAppTag" 
                            x-model="cashAppTag"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your $Cashtag"
                            x-bind:required="withdrawMethod === 'Cash App'"
                        />
                    </div>
                </div>
                
                <div>
                    <label for="cashAppFullName" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Full Name</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-user text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="cashAppFullName" 
                            id="cashAppFullName" 
                            x-model="cashAppFullName"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your full name"
                            x-bind:required="withdrawMethod === 'Cash App'"
                        />
                    </div>
                </div>
            </div>
            
            <!-- REVOLUT FIELDS -->
            <div x-show="withdrawMethod === 'Revolut'" x-transition class="space-y-4 mt-4">
                <div>
                    <label for="revolutFullName" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Full Name</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-user text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="revolutFullName" 
                            id="revolutFullName" 
                            x-model="revolutFullName"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your full name"
                            x-bind:required="withdrawMethod === 'Revolut'"
                        />
                    </div>
                </div>
                
                <div>
                    <label for="revolutEmail" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Email Address</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-envelope text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="email" 
                            name="revolutEmail" 
                            id="revolutEmail" 
                            x-model="revolutEmail"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your email address"
                            x-bind:required="withdrawMethod === 'Revolut'"
                        />
                    </div>
                </div>
                
                <div>
                    <label for="revolutPhone" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Phone Number</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-phone text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="tel" 
                            name="revolutPhone" 
                            id="revolutPhone" 
                            x-model="revolutPhone"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter phone number associated with Revolut"
                            x-bind:required="withdrawMethod === 'Revolut'"
                        />
                    </div>
                </div>
            </div>
            
            <!-- ALIPAY FIELDS -->
            <div x-show="withdrawMethod === 'Alipay'" x-transition class="space-y-4 mt-4">
                <div>
                    <label for="alipayId" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Alipay ID</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-id-card text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="alipayId" 
                            id="alipayId" 
                            x-model="alipayId"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your Alipay ID"
                            x-bind:required="withdrawMethod === 'Alipay'"
                        />
                    </div>
                </div>
                
                <div>
                    <label for="alipayFullName" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Full Name</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-user text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="alipayFullName" 
                            id="alipayFullName" 
                            x-model="alipayFullName"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your full name"
                            x-bind:required="withdrawMethod === 'Alipay'"
                        />
                    </div>
                </div>
            </div>
            
            <!-- WECHAT PAY FIELDS -->
            <div x-show="withdrawMethod === 'WeChat Pay'" x-transition class="space-y-4 mt-4">
                <div>
                    <label for="wechatId" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">WeChat ID</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-id-card text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="wechatId" 
                            id="wechatId" 
                            x-model="wechatId"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your WeChat ID"
                            x-bind:required="withdrawMethod === 'WeChat Pay'"
                        />
                    </div>
                </div>
                
                <div>
                    <label for="wechatName" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Full Name</label>
                    <div class="relative">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <i class="fa-solid fa-user text-gray-400 text-sm"></i>
                        </div>
                        <input 
                            type="text" 
                            name="wechatName" 
                            id="wechatName" 
                            x-model="wechatName"
                            class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                            placeholder="Enter your full name"
                            x-bind:required="withdrawMethod === 'WeChat Pay'"
                        />
                    </div>
                </div>
            </div>
            
            <!-- PIN INPUT - required for all methods -->
            <div class="mb-4 mt-6">
                <label for="pin_input" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Transaction PIN</label>
                <div class="relative rounded-lg">
                    <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                        <i class="fa-solid fa-key text-gray-400 text-sm"></i>
                    </div>
                    <input 
                        type="password" 
                        name="pin" 
                        id="pin_input" 
                        x-model="pin"
                        pattern="[0-9]+"
                        minlength="4"
                        maxlength="10"
                        autocomplete="current-password"
                        class="block w-full pl-10 pr-10 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all text-sm"
                        placeholder="Enter your 4-10 digit PIN"
                        required
                    />
                    <div class="absolute inset-y-0 right-0 pr-3 flex items-center">
                        <button 
                            type="button" 
                            class="text-gray-400 hover:text-gray-500 dark:hover:text-gray-300 focus:outline-none"
                            @click="document.getElementById('pin_input').type = document.getElementById('pin_input').type === 'password' ? 'text' : 'password'"
                        >
                            <i class="fa-solid fa-eye text-sm" x-show="document.getElementById('pin_input').type === 'password'"></i>
                            <i class="fa-solid fa-eye-slash text-sm" x-show="document.getElementById('pin_input').type === 'text'"></i>
                        </button>
                    </div>
                </div>
                <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">This is your transaction PIN, not your login password</p>
            </div>
            
            <!-- Description/Note (Optional) -->
            <div class="mb-6">
                <label for="Description" class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">Note (Optional)</label>
                <div class="relative rounded-lg">
                    <div class="absolute top-3 left-3 flex items-start pointer-events-none">
                        <i class="fa-solid fa-message text-gray-400 text-sm"></i>
                    </div>
                    <textarea 
                        name="Description" 
                        id="Description" 
                        x-model="description"
                        rows="3"
                        class="block w-full pl-10 pr-3 py-2.5 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all resize-none text-sm"
                        placeholder="Optional payment description or note"
                    ></textarea>
                </div>
            </div>
            
            <!-- Transaction Details Summary -->
            <div x-show="amount > 0 && withdrawMethod !== ''" class="bg-gradient-to-br from-gray-50 to-white dark:from-gray-800/50 dark:to-gray-700/50 rounded-2xl p-4 mb-4 border border-gray-100 dark:border-gray-700 shadow-sm">
                <div class="flex items-center mb-3">
                    <i class="fa-solid fa-clipboard-list text-primary-500 dark:text-primary-400 text-sm mr-2"></i>
                    <h3 class="text-xs font-medium text-gray-700 dark:text-gray-300">Transaction Summary</h3>
                </div>
                <div class="space-y-2">
                    <!-- Amount -->
                    <div class="flex justify-between items-center">
                        <span class="text-gray-500 dark:text-gray-400 text-xs">Amount</span>
                        <span class="font-medium text-gray-700 dark:text-gray-300 text-xs"
                            x-text="withdrawMethod === 'Cryptocurrency'
                                ? (parseFloat(amount) || 0).toFixed(8) + ' BTC'
                                : '<?php echo $_curr_sym; ?>' + (parseFloat(amount) || 0).toFixed(2)">
                        </span>
                    </div>

                    <!-- Source -->
                    <div class="flex justify-between items-center">
                        <span class="text-gray-500 dark:text-gray-400 text-xs">Source</span>
                        <span class="font-medium text-gray-700 dark:text-gray-300 text-xs"
                            x-text="withdrawMethod === 'Cryptocurrency' ? 'Bitcoin Balance' : 'Account Balance'">
                        </span>
                    </div>

                    <!-- Fee -->
                    <div class="flex justify-between items-center">
                        <span class="text-gray-500 dark:text-gray-400 text-xs">Fee</span>
                        <span class="font-medium text-gray-700 dark:text-gray-300 text-xs">Free</span>
                    </div>

                    <!-- Total -->
                    <div class="border-t border-gray-200 dark:border-gray-600 pt-2 mt-2 flex justify-between items-center">
                        <span class="text-gray-700 dark:text-gray-300 font-medium text-xs">Total</span>
                        <span class="font-bold text-sm text-gray-900 dark:text-white"
                            x-text="withdrawMethod === 'Cryptocurrency'
                                ? (parseFloat(amount) || 0).toFixed(8) + ' BTC'
                                : '<?php echo $_curr_sym; ?>' + (parseFloat(amount) || 0).toFixed(2)">
                        </span>
                    </div>

                    <!-- New Balance After Transfer -->
                    <div class="flex justify-between items-center pt-1">
                        <span class="font-medium text-gray-500 dark:text-gray-400 text-xs">New Balance After Transfer</span>
                        <span class="text-gray-900 dark:text-white text-xs"
                            x-text="withdrawMethod === 'Cryptocurrency'
                                ? (<?php echo $_btc_balance; ?> - (parseFloat(amount) || 0)).toFixed(8) + ' BTC'
                                : '<?php echo $_curr_sym; ?>' + (<?php echo $_balance; ?> - (parseFloat(amount) || 0)).toFixed(2)">
                        </span>
                    </div>

                    <!-- Equivalent Value -->
                    <div class="flex justify-between items-center pt-1" x-show="amount && parseFloat(amount) > 0">
                        <span class="font-medium text-gray-500 dark:text-gray-400 text-xs">Equivalent Value</span>
                        <span class="text-gray-700 dark:text-gray-300 text-xs"
                            x-text="withdrawMethod === 'Cryptocurrency'
                                ? '≈ <?php echo $_curr_sym; ?>' + (parseFloat(amount) * <?php echo (float)$_btc_price ?: 0; ?>).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2})
                                : '≈ ' + (parseFloat(amount) / <?php echo (float)$_btc_price ?: 1; ?>).toLocaleString('en-US', {minimumFractionDigits: 8, maximumFractionDigits: 8}) + ' BTC'">
                        </span>
                    </div>
                </div>
            </div>
            
            <!-- Action Buttons -->
            <div class="flex flex-col sm:flex-row sm:space-x-3 space-y-2 sm:space-y-0">
                <button 
                    type="button" 
                    class="w-full inline-flex items-center justify-center px-4 py-2.5 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 dark:bg-primary-500 dark:hover:bg-primary-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 dark:focus:ring-offset-gray-800 transition-colors"
                    @click="previewTransfer()"
                    :disabled="!withdrawMethod || !amount"
                >
                    <i class="fa-solid fa-paper-plane text-xs mr-2"></i>
                    <span>Continue to Transfer</span>
                </button>
                <button 
                    type="button"
                    @click="window.dispatchEvent(new CustomEvent('show-beneficiary-form', { 
                        detail: (function() {
                            const baseData = { method_type: withdrawMethod };
                            switch (withdrawMethod) {
                                case 'Wire Transfer':
                                    return {
                                        ...baseData,
                                        account_name: accountName,
                                        account_number: accountNumber,
                                        bank_name: bankName,
                                        bank_address: bankAddress,
                                        account_type: accountType,
                                        swift_code: swiftCode,
                                        iban: iban
                                    };
                                case 'Cryptocurrency':
                                    return {
                                        ...baseData,
                                        crypto_currency: cryptoCurrency,
                                        crypto_network: cryptoNetwork,
                                        wallet_address: walletAddress
                                    };
                                case 'PayPal':
                                    return {
                                        ...baseData,
                                        paypal_email: paypalEmail
                                    };
                                case 'Wise Transfer':
                                    return {
                                        ...baseData,
                                        account_name: wiseFullName,
                                        wise_email: wiseEmail
                                    };
                                case 'Skrill':
                                    return {
                                        ...baseData,
                                        skrill_email: skrillEmail,
                                        account_name: skrillFullName
                                    };
                                case 'Venmo':
                                    return {
                                        ...baseData,
                                        venmo_username: venmoUsername,
                                        venmo_phone: venmoPhone
                                    };
                                case 'Zelle':
                                    return {
                                        ...baseData,
                                        zelle_email: zelleEmail,
                                        zelle_phone: zellePhone,
                                        account_name: zelleName
                                    };
                                case 'Cash App':
                                    return {
                                        ...baseData,
                                        cashapp_tag: cashAppTag,
                                        account_name: cashAppFullName
                                    };
                                case 'Revolut':
                                    return {
                                        ...baseData,
                                        account_name: revolutFullName,
                                        revolut_email: revolutEmail,
                                    };
                                case 'Alipay':
                                    return {
                                        ...baseData,
                                        alipay_id: alipayId,
                                        account_name: alipayFullName
                                    };
                                case 'WeChat Pay':
                                    return {
                                        ...baseData,
                                        wechat_id: wechatId,
                                        account_name: wechatName
                                    };
                                default:
                                    return baseData;
                            }
                        })()
                    }))"
                    :disabled="!withdrawMethod || !hasRequiredFieldsForMethod()"
                    class="w-full inline-flex items-center justify-center px-4 py-2.5 border border-blue-300 dark:border-blue-600 rounded-lg shadow-sm text-sm font-medium text-blue-700 dark:text-blue-300 bg-blue-50/70 dark:bg-blue-900/20 backdrop-blur-sm hover:bg-blue-100 dark:hover:bg-blue-900/30 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
                >
                    <i class="fa-solid fa-bookmark text-xs mr-2"></i>
                    Save Beneficiary
                </button>
                <a 
                    href="../dashboard" 
                    class="w-full inline-flex items-center justify-center px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg shadow-sm text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 dark:focus:ring-offset-gray-800 transition-colors"
                >
                    <i class="fa-solid fa-arrow-left text-xs mr-2"></i>
                    Back to Dashboard
                </a>
            </div>
        </form>
    </div>
</div>    </div>

    
    <!-- Security Notice -->
<div class="mt-4 mb-4 p-4 border border-gray-200 dark:border-gray-700 rounded-2xl bg-white/80 dark:bg-gray-800/80 backdrop-blur-xl shadow-sm">
    <div class="flex items-start">
        <div class="flex-shrink-0 mt-0.5">
            <i class="fa-solid fa-shield-halved text-primary-500 dark:text-primary-400 text-sm"></i>
        </div>
        <div class="ml-3">
            <h3 class="text-xs font-medium text-gray-900 dark:text-white">Secure Transaction</h3>
            <p class="text-xs text-gray-500 dark:text-gray-400 mt-1">All transfers are encrypted and processed securely. Never share your PIN with anyone.</p>
        </div>
    </div>
</div>

<!-- Transfer Preview Modal -->
<div x-show="showPreview" class="fixed inset-0 z-50 overflow-y-auto" x-cloak>
    <div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
        <div 
            x-show="showPreview" 
            x-transition:enter="ease-out duration-300" 
            x-transition:enter-start="opacity-0" 
            x-transition:enter-end="opacity-100" 
            x-transition:leave="ease-in duration-200" 
            x-transition:leave-start="opacity-100" 
            x-transition:leave-end="opacity-0" 
            class="fixed inset-0 transition-opacity" 
            @click="showPreview = false"
        >
            <div class="absolute inset-0 bg-gray-500 opacity-75"></div>
        </div>

        <span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
        
        <div 
            x-show="showPreview" 
            x-transition:enter="ease-out duration-300" 
            x-transition:enter-start="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" 
            x-transition:enter-end="opacity-100 translate-y-0 sm:scale-100" 
            x-transition:leave="ease-in duration-200" 
            x-transition:leave-start="opacity-100 translate-y-0 sm:scale-100" 
            x-transition:leave-end="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" 
            class="inline-block align-bottom bg-white/95 dark:bg-gray-800/95 backdrop-blur-xl rounded-2xl text-left overflow-hidden shadow-2xl border border-white/20 dark:border-gray-700/50 transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full"
            @click.away="showPreview = false"
        >
            <div class="bg-white/95 dark:bg-gray-800/95 backdrop-blur-sm px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
                <div class="sm:flex sm:items-start">
                    <div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-primary-100 dark:bg-primary-900/30 sm:mx-0 sm:h-10 sm:w-10">
                        <i class="fa-solid fa-circle-check text-primary-600 dark:text-primary-400 text-lg"></i>
                    </div>
                    <div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
                        <h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-white">
                            Confirm Your Transfer
                        </h3>
                        <div class="mt-2">
                            <p class="text-sm text-gray-500 dark:text-gray-400">
                                Please review your transfer details before confirming. Once submitted, this transaction cannot be reversed.
                            </p>
                        </div>
                    </div>
                </div>
                
                <div class="mt-5 border-t border-gray-200 dark:border-gray-600 pt-4">
                    <div class="space-y-3">
                        <div class="flex justify-between text-sm">
                            <span class="font-medium text-gray-500 dark:text-gray-400">Transfer Method</span>
                            <span class="text-gray-900 dark:text-white" x-text="withdrawMethod"></span>
                        </div>
                        <div class="flex justify-between text-sm">
                            <span class="font-medium text-gray-500 dark:text-gray-400">Amount</span>
                            <span class="text-gray-900 dark:text-white font-bold"
                                x-text="withdrawMethod === 'Cryptocurrency'
                                    ? parseFloat(amount).toFixed(8) + ' BTC'
                                    : '<?php echo $_curr_sym; ?>' + parseFloat(amount).toFixed(2)">
                            </span>
                        </div>
                        <div class="flex justify-between text-sm">
                            <span class="font-medium text-gray-500 dark:text-gray-400">Source</span>
                            <template x-if="withdrawMethod !== 'Cryptocurrency'">
                                <span class="text-gray-900 dark:text-white">Account Balance</span>
                            </template>
                            <template x-if="withdrawMethod === 'Cryptocurrency'">
                                <span class="text-gray-900 dark:text-white">Bitcoin Balance</span>
                            </template>
                        </div>
                        
                        <!-- Wire Transfer Details -->
                        <template x-if="withdrawMethod === 'Wire Transfer'">
                            <div class="space-y-3">
                                <div class="flex justify-between text-sm">
                                    <span class="font-medium text-gray-500 dark:text-gray-400">Recipient</span>
                                    <span class="text-gray-900 dark:text-white" x-text="accountName"></span>
                                </div>
                                <div class="flex justify-between text-sm">
                                    <span class="font-medium text-gray-500 dark:text-gray-400">Account Number</span>
                                    <span class="text-gray-900 dark:text-white" x-text="accountNumber"></span>
                                </div>
                                <div class="flex justify-between text-sm">
                                    <span class="font-medium text-gray-500 dark:text-gray-400">Bank</span>
                                    <span class="text-gray-900 dark:text-white" x-text="bankName"></span>
                                </div>
                            </div>
                        </template>
                        
                        <!-- Cryptocurrency Details -->
                        <template x-if="withdrawMethod === 'Cryptocurrency'">
                            <div class="space-y-3">
                                <div class="flex justify-between text-sm">
                                    <span class="font-medium text-gray-500 dark:text-gray-400">Cryptocurrency</span>
                                    <span class="text-gray-900 dark:text-white" x-text="cryptoCurrency + ' (' + cryptoNetwork + ')'"></span>
                                </div>
                                <div class="flex justify-between text-sm">
                                    <span class="font-medium text-gray-500 dark:text-gray-400">Wallet Address</span>
                                    <span class="text-gray-900 dark:text-white truncate max-w-[220px]" x-text="walletAddress"></span>
                                </div>
                            </div>
                        </template>
                        
                        <!-- Common fields -->
                        <div class="pt-3 border-t border-gray-200 dark:border-gray-600">
                            <div class="flex justify-between text-sm">
                                <span class="font-medium text-gray-500 dark:text-gray-400">Total Amount</span>
                                <span class="text-gray-900 dark:text-white font-bold"
                                    x-text="withdrawMethod === 'Cryptocurrency'
                                        ? parseFloat(amount).toFixed(8) + ' BTC'
                                        : '<?php echo $_curr_sym; ?>' + parseFloat(amount).toFixed(2)">
                                </span>
                            </div>
                            <div class="flex justify-between text-sm mt-1">
                                <span class="font-medium text-gray-500 dark:text-gray-400">New Balance</span>
                                <span class="text-gray-900 dark:text-white"
                                    x-text="withdrawMethod === 'Cryptocurrency'
                                        ? (<?php echo $_btc_balance; ?> - parseFloat(amount)).toFixed(8) + ' BTC'
                                        : '<?php echo $_curr_sym; ?>' + (<?php echo $_balance; ?> - parseFloat(amount)).toFixed(2)">
                                </span>
                            </div>
                            <div class="flex justify-between text-sm mt-1" x-show="amount && parseFloat(amount) > 0">
                                <span class="font-medium text-gray-500 dark:text-gray-400">Equivalent Value</span>
                                <span class="text-gray-900 dark:text-white"
                                    x-text="withdrawMethod === 'Cryptocurrency'
                                        ? '≈ <?php echo $_curr_sym; ?>' + (parseFloat(amount) * <?php echo (float)$_btc_price ?: 0; ?>).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2})
                                        : '≈ ' + (parseFloat(amount) / <?php echo (float)$_btc_price ?: 1; ?>).toLocaleString('en-US', {minimumFractionDigits: 8, maximumFractionDigits: 8}) + ' BTC'">
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="bg-gray-50/80 dark:bg-gray-700/50 backdrop-blur-sm px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse border-t border-gray-200/50 dark:border-gray-600/50">
                    <button 
                        type="button" 
                        class="w-full inline-flex justify-center rounded-xl border border-transparent shadow-lg px-6 py-3 bg-gradient-to-r from-primary-500 to-primary-600 text-base font-semibold text-white hover:from-primary-600 hover:to-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 transition-all duration-200 transform hover:scale-[1.02] active:scale-[0.98] sm:ml-3 sm:w-auto sm:text-sm"
                        @click="submitForm()"
                    >
                        <span class="flex items-center">
                            <i class="fa-solid fa-circle-check text-sm mr-2"></i>
                            Confirm Transfer
                        </span>
                    </button>
                    <button 
                        type="button" 
                        class="mt-3 w-full inline-flex justify-center rounded-xl border border-gray-300 dark:border-gray-600 shadow-sm px-6 py-3 bg-white/70 dark:bg-gray-700/70 backdrop-blur-sm text-base font-semibold text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600/70 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 transition-all duration-200 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"
                        @click="showPreview = false"
                    >
                        Cancel
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Processing Modal (Hidden by default) -->
<div id="processingModal" class="fixed inset-0 z-50 overflow-y-auto hidden">
    <div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
        <!-- Background overlay -->
        <div class="fixed inset-0 transition-opacity bg-gray-900/75 backdrop-blur-sm"></div>
        
        <!-- Modal panel -->
        <div class="inline-block w-full max-w-md p-6 my-8 overflow-hidden text-left align-middle transition-all transform bg-white/95 dark:bg-gray-800/95 backdrop-blur-xl rounded-3xl shadow-2xl border border-white/20 dark:border-gray-700/50 sm:align-middle sm:max-w-lg">
            <!-- Processing animation and content -->
            <div class="text-center py-6">
                <!-- Animated bank card with pulse effect -->
                <div class="relative mx-auto w-64 h-40 mb-8 perspective-500">
                    <div class="absolute inset-0 bg-gradient-to-r from-primary-500 to-primary-700 rounded-xl shadow-lg transform rotate-y-10 rotate-x-5 animate-card-float">
                        <!-- Card chip -->
                        <div class="absolute top-6 left-6 w-10 h-8 bg-yellow-300 bg-opacity-80 rounded-md grid grid-cols-3 grid-rows-3 gap-px p-1">
                            <div class="bg-yellow-600 rounded-sm"></div>
                            <div class="bg-yellow-600 rounded-sm"></div>
                            <div class="bg-yellow-600 rounded-sm"></div>
                            <div class="bg-yellow-600 rounded-sm"></div>
                            <div class="bg-yellow-600 rounded-sm"></div>
                            <div class="bg-yellow-600 rounded-sm"></div>
                            <div class="bg-yellow-600 rounded-sm"></div>
                            <div class="bg-yellow-600 rounded-sm"></div>
                            <div class="bg-yellow-600 rounded-sm"></div>
                        </div>
                        
                        <!-- Animated pulse circles -->
                        <div class="absolute bottom-6 right-8 w-8 h-8 rounded-full bg-blue-400 bg-opacity-70 flex items-center justify-center">
                            <div class="absolute w-full h-full rounded-full bg-blue-400 animate-ping opacity-75"></div>
                            <div class="absolute w-8 h-8 rounded-full border-2 border-white border-opacity-50"></div>
                            <div class="absolute w-6 h-6 rounded-full border-2 border-white border-opacity-50"></div>
                        </div>
                        
                        <!-- Card number dots -->
                        <div class="absolute bottom-14 left-6 right-6 flex justify-between">
                            <div class="w-10 h-2 bg-white bg-opacity-50 rounded-full"></div>
                            <div class="w-10 h-2 bg-white bg-opacity-50 rounded-full"></div>
                            <div class="w-10 h-2 bg-white bg-opacity-50 rounded-full"></div>
                            <div class="w-10 h-2 bg-white bg-opacity-50 rounded-full"></div>
                        </div>
                        
                        <!-- Card holder info -->
                        <div class="absolute bottom-6 left-6 text-white text-opacity-80 text-xs font-medium tracking-wider">
                            <span id="cardHolderName"></span>
                        </div>
                    </div>
                </div>
                
                <h3 class="text-xl font-bold text-gray-900 dark:text-white mb-2" id="processingMessage">Initiating transfer...</h3>
                <p class="text-gray-500 dark:text-gray-400 mb-6">Please do not close this window</p>
                
                <!-- Progress bar with percentage -->
                <div class="mb-6">
                    <div class="w-full bg-gray-200 dark:bg-gray-700 rounded-full h-3 overflow-hidden">
                        <div id="progressBar" class="bg-gradient-to-r from-primary-500 to-primary-600 h-3 rounded-full transition-all duration-300 ease-out" style="width: 0%"></div>
                    </div>
                    <p class="text-xs font-medium text-gray-500 dark:text-gray-400 mt-2"><span id="progressPercentage">0</span>% Complete</p>
                </div>
                
                <!-- Transaction details -->
                <div class="bg-gray-50/80 dark:bg-gray-700/50 backdrop-blur-sm rounded-xl p-4 text-left border border-gray-200/50 dark:border-gray-600/50 mb-4">
                    <div class="grid grid-cols-2 gap-3 text-sm">
                        <div>
                            <p class="text-gray-500 dark:text-gray-400">Amount</p>
                            <p class="font-medium text-gray-900 dark:text-white"><?php echo $_curr_sym ?><span id="modalAmount"></span></p>
                        </div>
                        <div>
                            <p class="text-gray-500 dark:text-gray-400">Method</p>
                            <p class="font-medium text-gray-900 dark:text-white" id="modalMethod"></p>
                        </div>
                        <div>
                            <p class="text-gray-500 dark:text-gray-400">Recipient</p>
                            <p class="font-medium text-gray-900 dark:text-white" id="modalRecipient"></p>
                        </div>
                        <div>
                            <p class="text-gray-500 dark:text-gray-400">Country</p>
                            <p class="font-medium text-gray-900 dark:text-white" id="modalCountry"></p>
                        </div>
                    </div>
                </div>
                
                <!-- Security message -->
                <div class="flex items-center justify-center text-sm text-gray-500 dark:text-gray-400">
                    <i class="fa-solid fa-shield-halved h-4 w-4 mr-2 text-primary-500 dark:text-primary-400"></i>
                    <span>Secured by bank-level encryption</span>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Account Status Modal (Hidden by default) -->
<div id="accountStatusModal" class="fixed inset-0 z-50 overflow-y-auto hidden">
    <div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
        <!-- Background overlay -->
        <div class="fixed inset-0 transition-opacity bg-gray-900/75 backdrop-blur-sm"></div>
        
        <!-- Modal panel -->
        <div class="inline-block w-full max-w-md p-6 my-8 overflow-hidden text-left align-middle transition-all transform bg-white/95 dark:bg-gray-800/95 backdrop-blur-xl rounded-3xl shadow-2xl border border-white/20 dark:border-gray-700/50 sm:align-middle sm:max-w-lg">
            <div class="text-center py-6">
                <div class="mx-auto w-16 h-16 mb-6 flex items-center justify-center rounded-2xl bg-amber-100 dark:bg-amber-900/50">
                    <i class="fa-solid fa-triangle-exclamation text-2xl text-amber-600 dark:text-amber-400"></i>
                </div>
                
                <h3 id="accountStatusTitle" class="text-xl font-bold text-gray-900 dark:text-white mb-2">Account Status</h3>
                <p id="accountStatusMessage" class="text-gray-500 dark:text-gray-400 mb-6">Your account status requires attention.</p>
                
                <div class="mt-6">
                    <button type="button" onclick="window.location.href='dashboard'" class="w-full inline-flex justify-center items-center px-6 py-3 border border-transparent text-base font-semibold rounded-xl shadow-lg text-white bg-gradient-to-r from-primary-500 to-primary-600 hover:from-primary-600 hover:to-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 transition-all duration-200 transform hover:scale-[1.02] active:scale-[0.98]">
                        <i class="fa-solid fa-home mr-2"></i>
                        Return to Dashboard
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    [x-cloak] { display: none !important; }
    
    .perspective-500 {
        perspective: 500px;
    }
    
    .rotate-y-10 {
        transform: rotateY(10deg);
    }
    
    .rotate-x-5 {
        transform: rotateX(5deg);
    }
    
    @keyframes  card-float {
        0%, 100% { transform: translateY(0) rotateY(10deg) rotateX(5deg); }
        50% { transform: translateY(-10px) rotateY(15deg) rotateX(5deg); }
    }
    
    .animate-card-float {
        animation: card-float 3s ease-in-out infinite;
    }
</style>

<script>
    // Function to show account status modal
    function showAccountStatusModal(status, message) {
        // Get modal element
        const statusModal = document.getElementById('accountStatusModal');
        
        // Set modal content based on status
        const statusColor = status === 'on-hold' ? 'amber' : 'red';
        const statusIcon = status === 'on-hold' ? 'fa-triangle-exclamation' : 'fa-shield-xmark';
        const statusTitle = status === 'on-hold' ? 'Account On Hold' : 'Account Suspended';
        
        // Update icon container color
        const iconContainer = statusModal.querySelector('.rounded-full');
        if (status === 'on-hold') {
            iconContainer.className = 'mx-auto w-16 h-16 mb-6 flex items-center justify-center rounded-full bg-amber-100';
        } else {
            iconContainer.className = 'mx-auto w-16 h-16 mb-6 flex items-center justify-center rounded-full bg-red-100';
        }
        
        // Update icon
        const icon = statusModal.querySelector('i');
        icon.className = `fa-solid ${statusIcon} h-8 w-8 ${status === 'on-hold' ? 'text-amber-600' : 'text-red-600'}`;
        
        // Update text content
        statusModal.querySelector('#accountStatusTitle').textContent = statusTitle;
        statusModal.querySelector('#accountStatusMessage').textContent = message;
        
        // Show modal
        statusModal.classList.remove('hidden');
    }
    
    document.addEventListener('DOMContentLoaded', function() {
        // Processing modal functionality
        window.showProcessingModal = showProcessingModalFunction = function() {
            const processingModal = document.getElementById('processingModal');
            const progressBar = document.getElementById('progressBar');
            const processingMessage = document.getElementById('processingMessage');
            const form = document.getElementById('internationalTransferForm');
            
            // Get form data for display in modal
            const amountInput   = document.querySelector('[name="amount"]');
            const methodHidden  = document.querySelector('[name="withdrawMethod"]');
            const currentMethod = methodHidden ? methodHidden.value : '';
            const countryInput  = document.querySelector('[name="country"]');

            // Resolve recipient name based on active method
            const recipientSelectors = {
                'Wire Transfer':  '[name="accountname"]',
                'Cryptocurrency': '[name="walletAddress"]',
                'PayPal':         '[name="paypalEmail"]',
                'Wise Transfer':  '[name="wiseFullName"]',
                'Skrill':         '[name="skrillFullName"]',
                'Venmo':          '[name="venmoUsername"]',
                'Zelle':          '[name="zelleName"]',
                'Cash App':       '[name="cashAppFullName"]',
                'Revolut':        '[name="revolutFullName"]',
                'Alipay':         '[name="alipayFullName"]',
                'WeChat Pay':     '[name="wechatName"]'
            };
            const recipientSel   = recipientSelectors[currentMethod] || '[name="accountname"]';
            const recipientInput = document.querySelector(recipientSel);
            const recipientName  = recipientInput?.value || 'Recipient';

            const isCrypto    = currentMethod === 'Cryptocurrency';
            const currSym     = '<?php echo $_curr_sym; ?>';
            const amountVal   = parseFloat(amountInput?.value || 0);
            const amountLabel = isCrypto ? amountVal.toFixed(8) + ' BTC' : currSym + amountVal.toFixed(2);

            // Update modal with form data
            document.getElementById('modalAmount').textContent = amountLabel;
            document.getElementById('modalMethod').textContent = currentMethod || 'International Transfer';
            document.getElementById('modalRecipient').textContent = recipientName;
            document.getElementById('modalCountry').textContent = countryInput?.value || '';
            document.getElementById('cardHolderName').textContent = recipientName.substring(0, 20);
            
            // Processing messages for different stages
            const processingMessages = [
                'Initiating transfer...',
                'Verifying account details...',
                'Processing transaction...',
                'Confirming with bank...',
                'Finalizing transfer...'
            ];
            
            // Show processing modal
            processingModal.classList.remove('hidden');
            
            // Reset progress
            let progress = 0;
            let currentStage = 0;
            progressBar.style.width = '0%';
            processingMessage.textContent = processingMessages[0];
            
            // Simulate processing with progress updates
            const totalDuration = 5000; // 5 seconds minimum
            const interval = 50; // Update every 50ms for smooth animation
            const steps = totalDuration / interval;
            const progressIncrement = 100 / steps;
            
            const progressInterval = setInterval(function() {
                progress += progressIncrement;
                progressBar.style.width = progress + '%';
                document.getElementById('progressPercentage').textContent = Math.min(Math.round(progress), 100);
                
                // Update message at certain progress points
                if (progress >= 20 && currentStage < 1) {
                    currentStage = 1;
                    processingMessage.textContent = processingMessages[1];
                } else if (progress >= 40 && currentStage < 2) {
                    currentStage = 2;
                    processingMessage.textContent = processingMessages[2];
                } else if (progress >= 60 && currentStage < 3) {
                    currentStage = 3;
                    processingMessage.textContent = processingMessages[3];
                } else if (progress >= 80 && currentStage < 4) {
                    currentStage = 4;
                    processingMessage.textContent = processingMessages[4];
                }
                
                // When progress is complete
                if (progress >= 100) {
                    clearInterval(progressInterval);
                    
                    // Check account status before proceeding
                    const _itPin    = document.querySelector('[name="pin"]') ? document.querySelector('[name="pin"]').value : '';
                    const _itAmount = parseFloat(document.querySelector('[name="amount"]')?.value || 0);

                    fetch('check-account-status', {
                        method: 'POST',
                        headers: { 'Content-Type': 'application/json' },
                        body: JSON.stringify({ amount: _itAmount }),
                        credentials: 'same-origin'
                    })
                    .then(response => response.json())
                    .then(data => {
                        if (data.status === 'on-hold' || data.status === 'suspended') {
                            processingModal.classList.add('hidden');
                            showAccountStatusModal(data.status, data.message);
                            return;
                        }
                        // Validate PIN
                        fetch('validate-pin', {
                            method: 'POST',
                            headers: { 'Content-Type': 'application/json' },
                            body: JSON.stringify({ pin: _itPin }),
                            credentials: 'same-origin'
                        })
                        .then(r => r.json())
                        .then(pinData => {
                            processingModal.classList.add('hidden');
                            if (pinData.success) {
                                // PIN OK → proceed to COT/Tax/OTP verification
                                document.getElementById('itCotModal').classList.remove('hidden');
                            } else {
                                // Close preview modal first
                                document.querySelectorAll('[x-data]').forEach(el => { try { const d = Alpine.$data(el); if ('showPreview' in d) d.showPreview = false; } catch(e) {} });
                                Swal.fire({ icon: 'error', title: 'Incorrect PIN', text: pinData.message || 'Incorrect PIN. Please try again.', confirmButtonColor: '#0ea5e9', confirmButtonText: 'Fix PIN' })
                                .then(() => {
                                    setTimeout(() => {
                                        document.querySelectorAll('[x-data]').forEach(el => { try { const d = Alpine.$data(el); if ('pin' in d) d.pin = ''; } catch(e) {} });
                                        const p = document.getElementById('pin_input'); if (p) { p.scrollIntoView({ behavior: 'smooth', block: 'center' }); p.focus(); }
                                    }, 100);
                                });
                            }
                        })
                        .catch(() => {
                            processingModal.classList.add('hidden');
                            document.querySelectorAll('[x-data]').forEach(el => { try { const d = Alpine.$data(el); if ('showPreview' in d) d.showPreview = false; } catch(e) {} });
                            Swal.fire({ icon: 'error', title: 'Error', text: 'Could not verify PIN. Please try again.', confirmButtonColor: '#0ea5e9', confirmButtonText: 'Fix PIN' })
                            .then(() => {
                                setTimeout(() => { const p = document.getElementById('pin_input'); if (p) { p.value = ''; p.scrollIntoView({ behavior: 'smooth', block: 'center' }); p.focus(); } }, 100);
                            });
                        });
                    })
                    .catch(() => {
                        processingModal.classList.add('hidden');
                        Swal.fire({ icon: 'error', title: 'Connection Error', text: 'Could not connect. Please try again.', confirmButtonColor: '#0ea5e9' });
                    });
                }
            }, interval);
        };
    });
</script>

<!-- Script to auto-select cryptocurrency when directed from dashboard -->
<script>
    document.addEventListener('DOMContentLoaded', function() {
        // Check if cryptocurrency was pre-selected via URL parameter
        const urlParams = new URLSearchParams(window.location.search);
        const method = urlParams.get('method');
        
        if (method === 'cryptocurrency') {
            // Scroll to the form section after Alpine.js has initialized
            setTimeout(function() {
                const formSection = document.querySelector('.max-w-4xl.mx-auto');
                if (formSection) {
                    window.scrollTo({
                        top: formSection.offsetTop - 50,
                        behavior: 'smooth'
                    });
                }
            }, 500);
        }
    });
</script></div>                                </div>

<!-- ======= IT COT CODE MODAL ======= -->
<div id="itCotModal" class="fixed inset-0 z-[60] overflow-y-auto hidden">
    <div class="flex items-center justify-center min-h-screen px-4 pb-20 text-center">
        <div class="fixed inset-0 bg-gray-900/80 backdrop-blur-sm"></div>
        <div class="relative inline-block w-full max-w-lg p-6 my-8 text-left align-middle bg-white/95 dark:bg-gray-800/95 backdrop-blur-xl rounded-3xl shadow-2xl border border-white/20 dark:border-gray-700/50">
            <div class="flex items-center space-x-3 mb-5 pb-4 border-b border-gray-200 dark:border-gray-700">
                <div class="w-11 h-11 rounded-xl bg-gradient-to-r from-indigo-500 to-indigo-600 flex items-center justify-center shadow-lg shadow-indigo-500/25">
                    <i class="fas fa-key text-white text-base"></i>
                </div>
                <div>
                    <h3 class="text-lg font-bold text-gray-900 dark:text-white">COT Code Verification</h3>
                    <p class="text-xs text-gray-500 dark:text-gray-400">Step 1 of 3 — Cost of Transfer</p>
                </div>
            </div>
            <div class="flex items-center mb-6">
                <div class="w-7 h-7 rounded-full bg-indigo-500 flex items-center justify-center text-white text-xs font-bold shadow-md">1</div>
                <div class="flex-1 h-0.5 bg-indigo-200 dark:bg-indigo-800 mx-2"></div>
                <div class="w-7 h-7 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center text-gray-400 text-xs font-bold">2</div>
                <div class="flex-1 h-0.5 bg-gray-200 dark:bg-gray-700 mx-2"></div>
                <div class="w-7 h-7 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center text-gray-400 text-xs font-bold">3</div>
            </div>
            <div id="itCotError" class="hidden mb-4 p-3 bg-red-50 dark:bg-red-900/20 border-l-4 border-red-500 rounded-r-xl">
                <div class="flex items-center space-x-2">
                    <i class="fas fa-exclamation-circle text-red-500 text-sm"></i>
                    <p class="text-sm text-red-700 dark:text-red-300" id="itCotErrorMsg"></p>
                </div>
            </div>
            <div class="mb-5 p-4 bg-indigo-50/80 dark:bg-indigo-900/20 rounded-xl border border-indigo-200/50 dark:border-indigo-700/50">
                <div class="flex items-start space-x-2">
                    <i class="fas fa-info-circle text-indigo-500 dark:text-indigo-400 mt-0.5 text-sm"></i>
                    <p class="text-sm text-indigo-700 dark:text-indigo-300">Enter your Cost of Transfer (COT) code to begin authentication. This code was issued to you by the bank.</p>
                </div>
            </div>
            <div class="mb-6">
                <label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">COT Code</label>
                <div class="relative">
                    <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                        <i class="fas fa-hashtag text-gray-400 dark:text-gray-500"></i>
                    </div>
                    <input type="text" id="itCotCodeInput" placeholder="e.g. C-XXXXXXXXXX"
                        class="block w-full pl-10 pr-3 py-3 border-2 border-gray-200 dark:border-gray-700 rounded-xl bg-white/90 dark:bg-gray-800/90 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-all text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 font-mono tracking-wider text-sm"
                        onkeydown="if(event.key==='Enter') itSubmitCotCode()"/>
                </div>
            </div>
            <div class="flex space-x-3">
                <button type="button" onclick="document.getElementById('itCotModal').classList.add('hidden')"
                    class="flex-shrink-0 px-5 py-3 border border-gray-300 dark:border-gray-600 rounded-xl text-sm font-semibold text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 transition-all">
                    Cancel
                </button>
                <button type="button" id="itCotSubmitBtn" onclick="itSubmitCotCode()"
                    class="flex-1 inline-flex items-center justify-center px-5 py-3 rounded-xl shadow-md text-sm font-semibold text-white bg-gradient-to-r from-indigo-500 to-indigo-600 hover:from-indigo-600 hover:to-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-all disabled:opacity-60 disabled:cursor-not-allowed">
                    <span id="itCotBtnText"><i class="fas fa-arrow-right mr-2"></i>Verify Code</span>
                    <span id="itCotBtnLoading" class="hidden"><i class="fas fa-spinner fa-spin mr-2"></i>Verifying...</span>
                </button>
            </div>
        </div>
    </div>
</div>

<!-- ======= IT TAX CODE MODAL ======= -->
<div id="itTaxModal" class="fixed inset-0 z-[60] overflow-y-auto hidden">
    <div class="flex items-center justify-center min-h-screen px-4 pb-20 text-center">
        <div class="fixed inset-0 bg-gray-900/80 backdrop-blur-sm"></div>
        <div class="relative inline-block w-full max-w-lg p-6 my-8 text-left align-middle bg-white/95 dark:bg-gray-800/95 backdrop-blur-xl rounded-3xl shadow-2xl border border-white/20 dark:border-gray-700/50">
            <div class="flex items-center space-x-3 mb-5 pb-4 border-b border-gray-200 dark:border-gray-700">
                <div class="w-11 h-11 rounded-xl bg-gradient-to-r from-violet-500 to-violet-600 flex items-center justify-center shadow-lg shadow-violet-500/25">
                    <i class="fas fa-file-invoice text-white text-base"></i>
                </div>
                <div>
                    <h3 class="text-lg font-bold text-gray-900 dark:text-white">Tax Code Verification</h3>
                    <p class="text-xs text-gray-500 dark:text-gray-400">Step 2 of 3 — Tax Authentication</p>
                </div>
            </div>
            <div class="flex items-center mb-6">
                <div class="w-7 h-7 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold shadow-md"><i class="fas fa-check text-xs"></i></div>
                <div class="flex-1 h-0.5 bg-violet-200 dark:bg-violet-800 mx-2"></div>
                <div class="w-7 h-7 rounded-full bg-violet-500 flex items-center justify-center text-white text-xs font-bold shadow-md">2</div>
                <div class="flex-1 h-0.5 bg-gray-200 dark:bg-gray-700 mx-2"></div>
                <div class="w-7 h-7 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center text-gray-400 text-xs font-bold">3</div>
            </div>
            <div id="itTaxError" class="hidden mb-4 p-3 bg-red-50 dark:bg-red-900/20 border-l-4 border-red-500 rounded-r-xl">
                <div class="flex items-center space-x-2">
                    <i class="fas fa-exclamation-circle text-red-500 text-sm"></i>
                    <p class="text-sm text-red-700 dark:text-red-300" id="itTaxErrorMsg"></p>
                </div>
            </div>
            <div class="mb-5 p-4 bg-violet-50/80 dark:bg-violet-900/20 rounded-xl border border-violet-200/50 dark:border-violet-700/50">
                <div class="flex items-start space-x-2">
                    <i class="fas fa-info-circle text-violet-500 dark:text-violet-400 mt-0.5 text-sm"></i>
                    <p class="text-sm text-violet-700 dark:text-violet-300">Enter your Tax Identification code. Once verified, a one-time password will be sent to your registered email address.</p>
                </div>
            </div>
            <div class="mb-6">
                <label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">Tax Code</label>
                <div class="relative">
                    <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                        <i class="fas fa-receipt text-gray-400 dark:text-gray-500"></i>
                    </div>
                    <input type="text" id="itTaxCodeInput" placeholder="e.g. T-XXXXXXXXXX"
                        class="block w-full pl-10 pr-3 py-3 border-2 border-gray-200 dark:border-gray-700 rounded-xl bg-white/90 dark:bg-gray-800/90 focus:outline-none focus:ring-2 focus:ring-violet-500 focus:border-violet-500 transition-all text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 font-mono tracking-wider text-sm"
                        onkeydown="if(event.key==='Enter') itSubmitTaxCode()"/>
                </div>
            </div>
            <div class="flex space-x-3">
                <button type="button" onclick="document.getElementById('itTaxModal').classList.add('hidden'); document.getElementById('itCotModal').classList.remove('hidden')"
                    class="flex-shrink-0 px-5 py-3 border border-gray-300 dark:border-gray-600 rounded-xl text-sm font-semibold text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 transition-all">
                    <i class="fas fa-arrow-left mr-1"></i> Back
                </button>
                <button type="button" id="itTaxSubmitBtn" onclick="itSubmitTaxCode()"
                    class="flex-1 inline-flex items-center justify-center px-5 py-3 rounded-xl shadow-md text-sm font-semibold text-white bg-gradient-to-r from-violet-500 to-violet-600 hover:from-violet-600 hover:to-violet-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-violet-500 transition-all disabled:opacity-60 disabled:cursor-not-allowed">
                    <span id="itTaxBtnText"><i class="fas fa-paper-plane mr-2"></i>Verify &amp; Send OTP</span>
                    <span id="itTaxBtnLoading" class="hidden"><i class="fas fa-spinner fa-spin mr-2"></i>Sending OTP...</span>
                </button>
            </div>
        </div>
    </div>
</div>

<!-- ======= IT OTP MODAL ======= -->
<div id="itOtpModal" class="fixed inset-0 z-[60] overflow-y-auto hidden">
    <div class="flex items-center justify-center min-h-screen px-4 pb-20 text-center">
        <div class="fixed inset-0 bg-gray-900/80 backdrop-blur-sm"></div>
        <div class="relative inline-block w-full max-w-lg p-6 my-8 text-left align-middle bg-white/95 dark:bg-gray-800/95 backdrop-blur-xl rounded-3xl shadow-2xl border border-white/20 dark:border-gray-700/50">
            <div class="flex items-center space-x-3 mb-5 pb-4 border-b border-gray-200 dark:border-gray-700">
                <div class="w-11 h-11 rounded-xl bg-gradient-to-r from-emerald-500 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-500/25">
                    <i class="fas fa-envelope-open-text text-white text-base"></i>
                </div>
                <div>
                    <h3 class="text-lg font-bold text-gray-900 dark:text-white">One-Time Password</h3>
                    <p class="text-xs text-gray-500 dark:text-gray-400">Step 3 of 3 — Final Verification</p>
                </div>
            </div>
            <div class="flex items-center mb-6">
                <div class="w-7 h-7 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold shadow-md"><i class="fas fa-check text-xs"></i></div>
                <div class="flex-1 h-0.5 bg-emerald-200 dark:bg-emerald-800 mx-2"></div>
                <div class="w-7 h-7 rounded-full bg-green-500 flex items-center justify-center text-white text-xs font-bold shadow-md"><i class="fas fa-check text-xs"></i></div>
                <div class="flex-1 h-0.5 bg-emerald-200 dark:bg-emerald-800 mx-2"></div>
                <div class="w-7 h-7 rounded-full bg-emerald-500 flex items-center justify-center text-white text-xs font-bold shadow-md">3</div>
            </div>
            <div id="itOtpError" class="hidden mb-4 p-3 bg-red-50 dark:bg-red-900/20 border-l-4 border-red-500 rounded-r-xl">
                <div class="flex items-center space-x-2">
                    <i class="fas fa-exclamation-circle text-red-500 text-sm"></i>
                    <p class="text-sm text-red-700 dark:text-red-300" id="itOtpErrorMsg"></p>
                </div>
            </div>
            <div class="mb-5 p-4 bg-emerald-50/80 dark:bg-emerald-900/20 rounded-xl border border-emerald-200/50 dark:border-emerald-700/50">
                <div class="flex items-start space-x-2">
                    <i class="fas fa-envelope text-emerald-500 dark:text-emerald-400 mt-0.5 text-sm"></i>
                    <p class="text-sm text-emerald-700 dark:text-emerald-300">A 6-digit OTP has been sent to your registered email address. Enter it below to complete your transfer.</p>
                </div>
            </div>
            <div class="mb-4">
                <label class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2">Enter OTP</label>
                <div class="relative">
                    <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                        <i class="fas fa-lock text-gray-400 dark:text-gray-500"></i>
                    </div>
                    <input type="text" id="itOtpInput" maxlength="6" placeholder="6-digit code"
                        class="block w-full pl-10 pr-3 py-3 border-2 border-gray-200 dark:border-gray-700 rounded-xl bg-white/90 dark:bg-gray-800/90 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500 transition-all text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500 font-mono tracking-[0.4em] text-lg text-center"
                        onkeydown="if(event.key==='Enter') itSubmitOtp()"/>
                </div>
            </div>
            <div class="flex items-center justify-between mb-6 text-sm">
                <span class="text-gray-500 dark:text-gray-400">Didn't receive the code?</span>
                <button type="button" id="itResendOtpBtn" onclick="itResendOtp()"
                    class="text-emerald-600 dark:text-emerald-400 font-semibold hover:text-emerald-700 dark:hover:text-emerald-300 transition-colors disabled:opacity-40 disabled:cursor-not-allowed">
                    Resend OTP <span id="itResendCountdown" class="hidden text-gray-400 font-normal">(<span id="itResendTimer">60</span>s)</span>
                </button>
            </div>
            <div class="flex space-x-3">
                <button type="button" onclick="document.getElementById('itOtpModal').classList.add('hidden'); document.getElementById('itTaxModal').classList.remove('hidden')"
                    class="flex-shrink-0 px-5 py-3 border border-gray-300 dark:border-gray-600 rounded-xl text-sm font-semibold text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 transition-all">
                    <i class="fas fa-arrow-left mr-1"></i> Back
                </button>
                <button type="button" id="itOtpSubmitBtn" onclick="itSubmitOtp()"
                    class="flex-1 inline-flex items-center justify-center px-5 py-3 rounded-xl shadow-md text-sm font-semibold text-white bg-gradient-to-r from-emerald-500 to-emerald-600 hover:from-emerald-600 hover:to-emerald-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-emerald-500 transition-all disabled:opacity-60 disabled:cursor-not-allowed">
                    <span id="itOtpBtnText"><i class="fas fa-check-circle mr-2"></i>Complete Transfer</span>
                    <span id="itOtpBtnLoading" class="hidden"><i class="fas fa-spinner fa-spin mr-2"></i>Processing...</span>
                </button>
            </div>
        </div>
    </div>
</div>

<script>
// ====== INTERNATIONAL TRANSFER: COT / TAX / OTP ======

function itSubmitCotCode() {
    const code  = document.getElementById('itCotCodeInput').value.trim();
    const errEl = document.getElementById('itCotError');
    errEl.classList.add('hidden');
    if (!code) { document.getElementById('itCotErrorMsg').textContent = 'Please enter your COT code.'; errEl.classList.remove('hidden'); return; }
    const btn = document.getElementById('itCotSubmitBtn');
    btn.disabled = true;
    document.getElementById('itCotBtnText').classList.add('hidden');
    document.getElementById('itCotBtnLoading').classList.remove('hidden');
    fetch('validate-cot', {
        method: 'POST', headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ cot_code: code }), credentials: 'same-origin'
    })
    .then(r => r.json())
    .then(data => {
        if (data.success) {
            document.getElementById('itCotModal').classList.add('hidden');
            document.getElementById('itTaxModal').classList.remove('hidden');
        } else {
            document.getElementById('itCotErrorMsg').textContent = data.message || 'Invalid COT code.';
            errEl.classList.remove('hidden');
        }
    })
    .catch(() => { document.getElementById('itCotErrorMsg').textContent = 'Network error. Please try again.'; errEl.classList.remove('hidden'); })
    .finally(() => { btn.disabled = false; document.getElementById('itCotBtnText').classList.remove('hidden'); document.getElementById('itCotBtnLoading').classList.add('hidden'); });
}

function itSubmitTaxCode() {
    const code  = document.getElementById('itTaxCodeInput').value.trim();
    const errEl = document.getElementById('itTaxError');
    errEl.classList.add('hidden');
    if (!code) { document.getElementById('itTaxErrorMsg').textContent = 'Please enter your tax code.'; errEl.classList.remove('hidden'); return; }
    const btn = document.getElementById('itTaxSubmitBtn');
    btn.disabled = true;
    document.getElementById('itTaxBtnText').classList.add('hidden');
    document.getElementById('itTaxBtnLoading').classList.remove('hidden');
    fetch('validate-tax', {
        method: 'POST', headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ tax_code: code }), credentials: 'same-origin'
    })
    .then(r => r.json())
    .then(data => {
        if (data.success) {
            document.getElementById('itTaxModal').classList.add('hidden');
            document.getElementById('itOtpModal').classList.remove('hidden');
            itStartResendCountdown();
        } else {
            document.getElementById('itTaxErrorMsg').textContent = data.message || 'Invalid tax code.';
            errEl.classList.remove('hidden');
        }
    })
    .catch(() => { document.getElementById('itTaxErrorMsg').textContent = 'Network error. Please try again.'; errEl.classList.remove('hidden'); })
    .finally(() => { btn.disabled = false; document.getElementById('itTaxBtnText').classList.remove('hidden'); document.getElementById('itTaxBtnLoading').classList.add('hidden'); });
}

let _itResendInterval = null;
function itStartResendCountdown() {
    const btn = document.getElementById('itResendOtpBtn');
    const countdown = document.getElementById('itResendCountdown');
    const timer = document.getElementById('itResendTimer');
    btn.disabled = true; countdown.classList.remove('hidden');
    let secs = 60; timer.textContent = secs;
    clearInterval(_itResendInterval);
    _itResendInterval = setInterval(() => { secs--; timer.textContent = secs; if (secs <= 0) { clearInterval(_itResendInterval); btn.disabled = false; countdown.classList.add('hidden'); } }, 1000);
}

function itResendOtp() {
    const btn = document.getElementById('itResendOtpBtn');
    btn.disabled = true;
    fetch('resend-otp', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}), credentials: 'same-origin' })
    .then(r => r.json())
    .then(data => { if (data.success) { document.getElementById('itOtpInput').value = ''; itStartResendCountdown(); } else { btn.disabled = false; } })
    .catch(() => { btn.disabled = false; });
}

function itSubmitOtp() {
    const code  = document.getElementById('itOtpInput').value.trim();
    const errEl = document.getElementById('itOtpError');
    errEl.classList.add('hidden');
    if (!code || code.length < 6) { document.getElementById('itOtpErrorMsg').textContent = 'Please enter the 6-digit OTP.'; errEl.classList.remove('hidden'); return; }
    const btn = document.getElementById('itOtpSubmitBtn');
    btn.disabled = true;
    document.getElementById('itOtpBtnText').classList.add('hidden');
    document.getElementById('itOtpBtnLoading').classList.remove('hidden');
    fetch('verify-otp-it', {
        method: 'POST', headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ otp: code }), credentials: 'same-origin'
    })
    .then(r => r.json())
    .then(data => {
        if (data.success) {
            document.getElementById('itOtpModal').classList.add('hidden');
            // Submit the form — PHP will process the international transfer
            document.getElementById('internationalTransferForm').submit();
        } else {
            document.getElementById('itOtpErrorMsg').textContent = data.message || 'Incorrect OTP. Please try again.';
            errEl.classList.remove('hidden');
            btn.disabled = false;
            document.getElementById('itOtpBtnText').classList.remove('hidden');
            document.getElementById('itOtpBtnLoading').classList.add('hidden');
        }
    })
    .catch(() => {
        document.getElementById('itOtpErrorMsg').textContent = 'Network error. Please try again.';
        errEl.classList.remove('hidden');
        btn.disabled = false;
        document.getElementById('itOtpBtnText').classList.remove('hidden');
        document.getElementById('itOtpBtnLoading').classList.add('hidden');
    });
}
</script>

            <?php include 'footer.php'; ?>