<?php if (isset($component)) { $__componentOriginal951024bfcf58033c82ac11d797616473 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal951024bfcf58033c82ac11d797616473 = $attributes; } ?>
<?php $component = App\View\Components\UserLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('user-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\UserLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
    <main class="w-full mx-auto h-auto bg-gray-100 text-gray-900 dark:bg-gray-900 dark:text-white transition-all duration-300">
        <!-- Header -->
        <div class="flex items-center justify-between p-4">
            <a href="<?php echo e(route('card.index')); ?>" class="text-gray-400 hover:text-gray-300">
                <i class="fas fa-arrow-left text-xl"></i>
            </a>
            <h1 class="text-xl font-semibold">Add Money</h1>
            <div class="w-8"></div>
        </div>

        <!-- Card Balance -->
        <div class="p-4">
            <div class="w-full bg-gradient-to-br from-purple-900 to-purple-700 rounded-xl p-6 mb-6">
                <div class="text-white">
                    <div class="text-sm">Current Balance</div>
                    <div class="text-3xl font-bold">$<?php echo e(number_format($card->balance, 2)); ?></div>
                </div>
            </div>

            <!-- Fund Form -->
            <form action="<?php echo e(route('card.fund')); ?>" method="POST" class="space-y-6">
                <?php echo csrf_field(); ?>

                <!-- Amount Input -->
                <div>
                    <label class="block text-sm font-medium mb-2">Amount to Add</label>
                    <div class="relative">
                        <span class="absolute left-3 top-3 text-gray-400">$</span>
                        <input type="number" 
                               name="amount" 
                               step="0.01" 
                               min="1" 
                               class="w-full bg-white dark:bg-gray-800 border border-gray-700 rounded-lg p-3 pl-8" 
                               placeholder="0.00"
                               required>
                        <div id="conversionInfo" class="mt-2 text-sm text-gray-400"></div>
                    </div>
                </div>

                <!-- Asset Selection -->
                <div>
                    <label class="block text-sm font-medium mb-2">Select Asset</label>
                    <div class="space-y-4">
                       <?php $__currentLoopData = ['btc', 'usdt_trc20', 'usdt_bep20', 'usdt_erc20', 'eth', 'trx', 'bnb', 'dot', 'bch', 'ltc', 'xlm', 'xrp', 'dash', 'sol']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $crypto): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <?php if($cryptoAsset->{$crypto . '_status'}): ?>
        <?php
            $balance = $cryptoAsset->{$crypto . '_balance'};
            
            // Handle USDT networks and other cryptos differently
            if (str_starts_with($crypto, 'usdt_')) {
                $cryptoName = 'tether';
            } else {
                $cryptoMap = [
                    'btc' => 'bitcoin',
                    'eth' => 'ethereum',
                    'trx' => 'tron',
                    'bnb' => 'binancecoin',
                    'dot' => 'polkadot',
                    'bch' => 'bitcoin-cash',
                    'ltc' => 'litecoin',
                    'xlm' => 'stellar',
                    'xrp' => 'ripple',
                    'dash' => 'dash',
                    'sol' => 'solana'
                ];
                $cryptoName = $cryptoMap[$crypto] ?? $crypto;
            }
            
            $price = $prices[$cryptoName]['usd'] ?? 0;
            $usdValue = $balance * $price;
            $cryptoSymbol = strtoupper(explode('_', $crypto)[0]);
        ?>
        <label class="flex items-center justify-between p-4 bg-white dark:bg-gray-800 border border-gray-700 rounded-lg cursor-pointer hover:bg-gray-750">
            <div class="flex items-center flex-1">
                <img src="<?php echo e(asset($crypto . '-icon.png')); ?>" alt="<?php echo e($cryptoSymbol); ?>" class="w-8 h-8 mr-3">
                <div class="min-w-0">
                    <div class="font-medium"><?php echo e(strtoupper(ucfirst(str_replace('_', ' ', $crypto)))); ?></div>
                    <div class="text-sm text-gray-400 truncate">
                        Available: <?php echo e(number_format($balance, 4)); ?> <?php echo e($cryptoSymbol); ?>

                        <span class="text-gray-500">(≈ $<?php echo e(number_format($usdValue, 2)); ?>)</span>
                    </div>
                </div>
            </div>
            <input type="radio" 
                   name="crypto" 
                   value="<?php echo e($crypto); ?>" 
                   class="form-radio text-blue-500 ml-4"
                   data-price="<?php echo e($price); ?>"
                   data-balance="<?php echo e($balance); ?>"
                   data-symbol="<?php echo e($cryptoSymbol); ?>">
        </label>
    <?php endif; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                </div>

                <!-- Submit Button -->
                <button type="submit" 
                        class="w-full bg-blue-500 hover:bg-blue-600 text-white font-semibold py-4 px-4 rounded-lg transition duration-200">
                    Add Money
                </button>
            </form>
        </div>

        <!-- Information Section -->
        <div class="p-4 mt-4">
            <div class="bg-white dark:bg-gray-800 rounded-lg p-4">
                <h3 class="font-medium mb-2">Important Information</h3>
                <ul class="text-sm text-gray-400 space-y-2">
                    <li class="flex items-start">
                        <i class="fas fa-info-circle mt-1 mr-2"></i>
                        <span>The conversion rate is based on the current market price</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-clock mt-1 mr-2"></i>
                        <span>Processing time: Instant</span>
                    </li>
                    <li class="flex items-start">
                        <i class="fas fa-shield-alt mt-1 mr-2"></i>
                        <span>Your transaction is secure and encrypted</span>
                    </li>
                </ul>
            </div>
        </div>

        <!-- Success/Error Messages -->
        <?php if(session('success')): ?>
        <div class="fixed top-10 right-4 bg-green-500 text-white px-6 py-3 rounded-lg shadow-lg" id="successMessage">
            <?php echo e(session('success')); ?>

        </div>
        <?php endif; ?>

        <?php if(session('error')): ?>
        <div class="fixed top-10 right-4 bg-red-500 text-white px-6 py-3 rounded-lg shadow-lg" id="errorMessage">
            <?php echo e(session('error')); ?>

        </div>
        <?php endif; ?>
    </main>

    <script>
        // Auto-hide flash messages
        document.addEventListener('DOMContentLoaded', function() {
            const messages = document.querySelectorAll('#successMessage, #errorMessage');
            messages.forEach(message => {
                setTimeout(() => {
                    message.style.opacity = '0';
                    message.style.transition = 'opacity 0.5s ease-in-out';
                    setTimeout(() => message.remove(), 500);
                }, 3000);
            });

            // Real-time conversion handling
            const amountInput = document.querySelector('input[name="amount"]');
            const cryptoRadios = document.querySelectorAll('input[name="crypto"]');
            const conversionInfo = document.getElementById('conversionInfo');
            
            function updateConversion() {
                const amount = parseFloat(amountInput.value) || 0;
                const selectedCrypto = document.querySelector('input[name="crypto"]:checked');
                
                if (selectedCrypto && amount > 0) {
                    const price = parseFloat(selectedCrypto.dataset.price);
                    const balance = parseFloat(selectedCrypto.dataset.balance);
                    const symbol = selectedCrypto.dataset.symbol;
                    const requiredCrypto = amount / price;
                    
                    conversionInfo.textContent = `≈ ${requiredCrypto.toFixed(8)} ${symbol}`;
                    
                    if (requiredCrypto > balance) {
                        conversionInfo.className = 'mt-2 text-sm text-red-500';
                        conversionInfo.textContent += ' (Insufficient balance)';
                    } else {
                        conversionInfo.className = 'mt-2 text-sm text-gray-400';
                    }
                } else {
                    conversionInfo.textContent = '';
                }
            }
            
            amountInput.addEventListener('input', updateConversion);
            cryptoRadios.forEach(radio => radio.addEventListener('change', updateConversion));

            // Form validation
            document.querySelector('form').addEventListener('submit', function(e) {
                const amount = parseFloat(amountInput.value) || 0;
                const selectedCrypto = document.querySelector('input[name="crypto"]:checked');
                
                if (!selectedCrypto) {
                    e.preventDefault();
                    alert('Please select a cryptocurrency');
                    return;
                }
                
                if (amount <= 0) {
                    e.preventDefault();
                    alert('Please enter a valid amount');
                    return;
                }

                const price = parseFloat(selectedCrypto.dataset.price);
                const balance = parseFloat(selectedCrypto.dataset.balance);
                const requiredCrypto = amount / price;
                
                if (requiredCrypto > balance) {
                    e.preventDefault();
                    alert('Insufficient balance');
                    return;
                }
            });
        });
    </script>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal951024bfcf58033c82ac11d797616473)): ?>
<?php $attributes = $__attributesOriginal951024bfcf58033c82ac11d797616473; ?>
<?php unset($__attributesOriginal951024bfcf58033c82ac11d797616473); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal951024bfcf58033c82ac11d797616473)): ?>
<?php $component = $__componentOriginal951024bfcf58033c82ac11d797616473; ?>
<?php unset($__componentOriginal951024bfcf58033c82ac11d797616473); ?>
<?php endif; ?><?php /**PATH /home/blockcino/public_html/resources/views/user/card/add-money.blade.php ENDPATH**/ ?>