<?php
require("header.php");
?>
    
    
    
    
    
    
  
  
  
  
  
  
    <!-- ==== PURCHASE PANEL ==== -->
    <div x-show="showPurchase" x-transition class="grid grid-cols-1 lg:grid-cols-3 gap-6">
        
        <!-- LEFT SIDE -->
        <div class="lg:col-span-2">
            <div class="bg-[#0F0A1F] rounded-2xl p-6 space-y-6">
                <div class="flex items-center justify-between">
                    <h3 class="text-lg font-medium">Investment Amount</h3>
                    <button @click="cancelPurchase()" class="text-gray-400 hover:text-gray-300 transition-colors">
                        <i class="fas fa-arrow-left"></i>
                    </button>
                </div>

                <div class="space-y-3">
                    <label class="text-sm text-gray-400">Custom Amount</label>
                    <div class="bg-[#1A1428] rounded-xl p-4">
                        <div class="relative">
                            <div class="absolute left-0 top-1/2 -translate-y-1/2 text-xl font-medium text-[#2FE6DE] px-4">
                                <?= $cur_symbol ?>
                            </div>
                            <input type="number"
                                x-model="amount"
                                class="w-full bg-transparent pl-12 text-xl font-medium focus:outline-none"
                                placeholder="Enter amount..."
                                :min="selectedData.min_amt * <?= $cur_rate ?> || 0"
                                :max="selectedData.max_amt * <?= $cur_rate ?> || 0">
                        </div>
                    </div>

                    <div class="flex flex-wrap gap-2 mt-3">
                        <template x-for="amt in quickAmounts" :key="amt">
                            <button type="button"
                                @click="amount = amt"
                                class="bg-[#1A1428] px-3 py-1.5 rounded-lg hover:bg-[#2FE6DE]/20 text-sm">
                                <?= $cur_symbol ?><span x-text="amt.toLocaleString()"></span>
                            </button>
                        </template>
                    </div>

                    <p class="text-gray-400 text-sm mt-3">
                        Available Balance: 
                        <span class="text-[#2FE6DE] font-medium">
                            <?= $cur_symbol ?><?= $balc ?>
                        </span>
                    </p>

                    <p x-show="errorMessage" class="text-red-400 text-sm mt-2" x-text="errorMessage"></p>
                </div>

                <button 
                    @click="confirmInvestment()" 
                    :disabled="loading"
                    class="w-full bg-gradient-to-r from-[#2FE6DE] to-[#2FE6DE]/80 text-black font-medium px-6 py-4 rounded-xl hover:brightness-110 transition-all flex items-center justify-center gap-2 disabled:opacity-50">
                    <span x-show="!loading">Confirm Investment</span>
                    <span x-show="loading">Processing...</span>
                </button>
            </div>
        </div>

        <!-- RIGHT SIDE -->
        <div class="lg:col-span-1">
            <div class="bg-[#0F0A1F] rounded-2xl p-6 space-y-4">
                <h3 class="text-lg font-medium">Investment Summary</h3>

                <div class="space-y-3">
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-400">Plan</span>
                        <span class="font-medium" x-text="selectedData.plan"></span>
                    </div>
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-400">Duration</span>
                        <span class="font-medium" x-text="convertDuration(selectedData.duration)"></span>
                    </div>
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-400">ROI</span>
                        <span class="font-medium text-[#2FE6DE]" x-text="selectedData.percentage + '%'"></span>
                    </div>
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-400">Min Amount</span>
                        <span class="font-medium" 
                              x-text="'<?= $cur_symbol ?>' + (selectedData.min_amt * <?= $cur_rate ?>).toLocaleString()"></span>
                    </div>
                    <div class="flex justify-between text-sm">
                        <span class="text-gray-400">Max Amount</span>
                        <span class="font-medium"
                              x-text="'<?= $cur_symbol ?>' + (selectedData.max_amt * <?= $cur_rate ?>).toLocaleString()"></span>
                    </div>
                    <div class="flex justify-between text-sm border-t border-gray-700 pt-2">
                        <span class="text-gray-400">Selected Amount</span>
                        <span class="font-medium text-[#2FE6DE]" x-text="'<?= $cur_symbol ?>' + Number(amount).toLocaleString()"></span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    
<?php require("footer.php"); ?>
