<?php $__env->startSection('title', session('locale') == 'bn' ? 'ম্যানেজ ডোমেইন' : 'Manage Domain'); ?>

<?php 
    $lang = session('locale', 'en'); 
    // Strict lock condition check (Status or Expiry)
    $is_locked = ($domain->status != 'active' || \Carbon\Carbon::parse($domain->expiry_date)->isPast());
?>

<?php $__env->startSection('content'); ?>

    <div class="flex flex-col md:flex-row md:items-end justify-between gap-4 mb-8">
        <div>
            <h1 class="text-3xl font-extrabold text-slate-800 dark:text-white tracking-tight"><?php echo e($domain->domain_name); ?></h1>
            <p class="text-sm text-slate-500 dark:text-slate-400 mt-1"><?php echo e($lang == 'bn' ? 'আপনার ডোমেইনের DNS এবং নেমসার্ভার ম্যানেজ করুন।' : 'Manage DNS records and nameservers for your domain.'); ?></p>
        </div>
        <div class="flex gap-3">
            <a href="<?php echo e(route('user.domain.index')); ?>" class="bg-white dark:bg-slate-800 border border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-700 px-4 py-2 rounded-xl text-sm font-medium text-slate-600 dark:text-slate-300 transition-colors shadow-sm">
                <i class="fas fa-arrow-left mr-2"></i> <?php echo e($lang == 'bn' ? 'ফিরে যান' : 'Back'); ?>

            </a>
            
            <button onclick="document.getElementById('renewModal').classList.remove('hidden')" class="bg-emerald-500 hover:bg-emerald-600 text-white font-bold px-4 py-2 rounded-xl shadow-lg shadow-emerald-500/30 transition-all hover:scale-[1.02] flex items-center gap-2">
                <i class="fas fa-sync-alt"></i> <?php echo e($lang == 'bn' ? 'রিনিউ করুন' : 'Renew'); ?>

            </button>
        </div>
    </div>

    <?php if(session('success')): ?>
        <div class="bg-emerald-50 dark:bg-emerald-500/10 border border-emerald-200 dark:border-emerald-500/20 text-emerald-600 dark:text-emerald-400 px-4 py-3 rounded-xl mb-6 flex items-center gap-3 shadow-sm">
            <i class="fas fa-check-circle text-lg"></i> <?php echo e(session('success')); ?>

        </div>
    <?php endif; ?>
    <?php if(session('error')): ?>
        <div class="bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20 text-red-600 dark:text-red-400 px-4 py-3 rounded-xl mb-6 flex items-center gap-3 shadow-sm">
            <i class="fas fa-exclamation-triangle text-lg"></i> <?php echo e(session('error')); ?>

        </div>
    <?php endif; ?>

    <?php if($is_locked): ?>
        <div class="bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800/50 rounded-2xl p-5 mb-8 flex items-start gap-4 shadow-sm animate-pulse">
            <div class="bg-red-100 dark:bg-red-800/50 p-3 rounded-xl text-red-600 dark:text-red-400">
                <i class="fas fa-lock text-xl"></i>
            </div>
            <div>
                <h3 class="text-red-800 dark:text-red-300 font-bold text-lg mb-1"><?php echo e($lang == 'bn' ? 'ডোমেইন লক করা আছে' : 'Domain Locked'); ?></h3>
                <p class="text-red-600 dark:text-red-200/80 text-sm"><?php echo e($lang == 'bn' ? 'আপনার ডোমেইনের মেয়াদ শেষ বা সাসপেন্ড করা হয়েছে। DNS পরিবর্তন করতে উপরের রিনিউ বাটন থেকে ডোমেইনটি রিনিউ করুন।' : 'Your domain is expired or suspended. Please renew using the button above to unlock DNS management.'); ?></p>
            </div>
        </div>
    <?php endif; ?>

    <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
        
        <div class="lg:col-span-1 relative h-fit">
            
            <?php if($is_locked): ?>
                <div class="absolute inset-0 z-10 bg-slate-50/60 dark:bg-[#0f172a]/70 backdrop-blur-[2px] rounded-2xl flex flex-col items-center justify-center">
                    <div class="bg-white dark:bg-slate-800 px-4 py-2 rounded-lg shadow-lg text-red-500 text-sm font-bold flex items-center gap-2">
                        <i class="fas fa-lock"></i> <?php echo e($lang == 'bn' ? 'লকড (রিনিউ করুন)' : 'Locked'); ?>

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

            <div class="bg-white dark:bg-[#0f172a] border border-slate-200 dark:border-[#1e293b] rounded-2xl p-6 shadow-sm sticky top-20">
                <h3 class="text-lg font-bold text-slate-800 dark:text-white mb-6 border-b border-slate-200 dark:border-slate-700 pb-3">
                    <i class="fas fa-server text-blue-500 dark:text-blue-400 mr-2"></i> <?php echo e($lang == 'bn' ? 'নেমসার্ভার সেটিং' : 'Nameservers'); ?>

                </h3>

                <form action="<?php echo e(route('user.domain.dns.update', $domain->id)); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <input type="hidden" name="action" value="update_ns">
                    
                    <div class="space-y-3 mb-6">
                        <label class="cursor-pointer block">
                            <input type="radio" name="ns_type" value="default" class="peer hidden" <?php echo e(!$is_custom_ns ? 'checked' : ''); ?> onchange="toggleNS('default')">
                            <div class="border-2 border-slate-200 dark:border-slate-700 rounded-xl p-4 peer-checked:border-blue-500 peer-checked:bg-blue-50 dark:peer-checked:bg-blue-500/10 transition-all flex items-center gap-3">
                                <i class="fas fa-cloud text-slate-400 peer-checked:text-blue-500 text-xl"></i>
                                <div>
                                    <div class="font-bold text-slate-800 dark:text-white text-sm"><?php echo e($lang == 'bn' ? 'ডিফল্ট হোস্টিং' : 'Default Hosting'); ?></div>
                                    <div class="text-xs text-slate-500 dark:text-slate-400"><?php echo e($lang == 'bn' ? 'রিকমেন্ডেড' : 'Recommended'); ?></div>
                                </div>
                            </div>
                        </label>

                        <label class="cursor-pointer block">
                            <input type="radio" name="ns_type" value="custom" class="peer hidden" <?php echo e($is_custom_ns ? 'checked' : ''); ?> onchange="toggleNS('custom')">
                            <div class="border-2 border-slate-200 dark:border-slate-700 rounded-xl p-4 peer-checked:border-blue-500 peer-checked:bg-blue-50 dark:peer-checked:bg-blue-500/10 transition-all flex items-center gap-3">
                                <i class="fas fa-tools text-slate-400 peer-checked:text-blue-500 text-xl"></i>
                                <div>
                                    <div class="font-bold text-slate-800 dark:text-white text-sm"><?php echo e($lang == 'bn' ? 'কাস্টম নেমসার্ভার' : 'Custom Nameservers'); ?></div>
                                </div>
                            </div>
                        </label>
                    </div>

                    <div id="customInputs" class="space-y-4 mb-6 p-4 bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-200 dark:border-slate-700" style="display: <?php echo e($is_custom_ns ? 'block' : 'none'); ?>;">
                        <div>
                            <label class="block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase mb-2">Nameserver 1</label>
                            <input type="text" name="ns1" value="<?php echo e($current_ns_records[0] ?? ''); ?>" class="w-full bg-white dark:bg-[#1e293b] border border-slate-200 dark:border-[#334155] text-slate-800 dark:text-white text-sm rounded-lg focus:ring-blue-500 p-2.5 outline-none" placeholder="ns1.example.com">
                        </div>
                        <div>
                            <label class="block text-xs font-bold text-slate-500 dark:text-slate-400 uppercase mb-2">Nameserver 2</label>
                            <input type="text" name="ns2" value="<?php echo e($current_ns_records[1] ?? ''); ?>" class="w-full bg-white dark:bg-[#1e293b] border border-slate-200 dark:border-[#334155] text-slate-800 dark:text-white text-sm rounded-lg focus:ring-blue-500 p-2.5 outline-none" placeholder="ns2.example.com">
                        </div>
                    </div>

                    <button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 rounded-xl shadow-lg shadow-blue-500/30 transition-all">
                        <?php echo e($lang == 'bn' ? 'সেভ করুন' : 'Save Nameservers'); ?>

                    </button>
                </form>
            </div>
        </div>

        <div class="lg:col-span-2 relative h-full">
            
            <?php if($is_locked): ?>
                <div class="absolute inset-0 z-10 bg-slate-50/60 dark:bg-[#0f172a]/70 backdrop-blur-[2px] rounded-2xl flex flex-col items-center justify-center">
                    <div class="bg-white dark:bg-slate-800 px-4 py-2 rounded-lg shadow-lg text-red-500 text-sm font-bold flex items-center gap-2">
                        <i class="fas fa-lock"></i> <?php echo e($lang == 'bn' ? 'লকড (রিনিউ করুন)' : 'Locked'); ?>

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

            <div class="bg-white dark:bg-[#0f172a] border border-slate-200 dark:border-[#1e293b] rounded-2xl shadow-sm overflow-hidden h-full flex flex-col">
                <div class="p-6 border-b border-slate-200 dark:border-[#1e293b] flex justify-between items-center bg-slate-50/50 dark:bg-slate-800/30">
                    <h3 class="text-lg font-bold text-slate-800 dark:text-white flex items-center gap-2">
                        <i class="fas fa-network-wired text-indigo-500 dark:text-indigo-400"></i> <?php echo e($lang == 'bn' ? 'DNS রেকর্ডস' : 'DNS Records'); ?>

                    </h3>
                    <button onclick="openModal('add')" class="bg-slate-800 dark:bg-white text-white dark:text-slate-800 text-sm font-bold px-4 py-2 rounded-lg transition-all hover:scale-[1.02] flex items-center gap-2 shadow-md">
                        <i class="fas fa-plus"></i> <span class="hidden sm:inline"><?php echo e($lang == 'bn' ? 'নতুন রেকর্ড' : 'Add Record'); ?></span>
                    </button>
                </div>
                
                <div class="overflow-x-auto flex-1">
                    <table class="w-full text-left text-sm text-slate-600 dark:text-slate-300">
                        <thead class="bg-slate-50 dark:bg-[#1e293b]/80 text-xs uppercase font-bold text-slate-500 dark:text-slate-400">
                            <tr>
                                <th class="px-6 py-4">Type</th>
                                <th class="px-6 py-4">Name</th>
                                <th class="px-6 py-4">Content</th>
                                <th class="px-6 py-4 text-center">Proxy</th>
                                <th class="px-6 py-4 text-right">Action</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-slate-200 dark:divide-[#1e293b]">
                            <?php $__empty_1 = true; $__currentLoopData = $dns_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dns): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr class="hover:bg-slate-50 dark:hover:bg-[#1e293b]/40 transition-colors">
                                <td class="px-6 py-4">
                                    <span class="bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 text-slate-700 dark:text-slate-300 px-2 py-1 rounded text-xs font-bold"><?php echo e($dns['type']); ?></span>
                                </td>
                                <td class="px-6 py-4 font-bold text-blue-600 dark:text-blue-400"><?php echo e($dns['name']); ?></td>
                                <td class="px-6 py-4 font-mono text-xs max-w-[150px] truncate" title="<?php echo e($dns['content']); ?>"><?php echo e($dns['content']); ?></td>
                                <td class="px-6 py-4 text-center">
                                    <?php if(isset($dns['proxied']) && $dns['proxied']): ?>
                                        <i class="fas fa-cloud text-orange-500"></i>
                                    <?php else: ?>
                                        <i class="fas fa-cloud text-slate-300 dark:text-slate-600"></i>
                                    <?php endif; ?>
                                </td>
                                <td class="px-6 py-4 text-right flex justify-end gap-2">
                                    <button onclick="openModal('edit', '<?php echo e($dns['id']); ?>', '<?php echo e($dns['type']); ?>', '<?php echo e($dns['name']); ?>', '<?php echo e($dns['content']); ?>', <?php echo e((isset($dns['proxied']) && $dns['proxied']) ? 'true' : 'false'); ?>, '<?php echo e($dns['priority'] ?? 10); ?>')" class="w-8 h-8 rounded bg-blue-50 dark:bg-blue-500/10 text-blue-600 dark:text-blue-400 hover:bg-blue-100 transition-colors">
                                        <i class="fas fa-edit"></i>
                                    </button>
                                    
                                    <form action="<?php echo e(route('user.domain.dns.update', $domain->id)); ?>" method="POST" onsubmit="return confirm('Are you sure?');">
                                        <?php echo csrf_field(); ?>
                                        <input type="hidden" name="action" value="delete_record">
                                        <input type="hidden" name="record_id" value="<?php echo e($dns['id']); ?>">
                                        <button type="submit" class="w-8 h-8 rounded bg-red-50 dark:bg-red-500/10 text-red-600 hover:bg-red-100 transition-colors">
                                            <i class="fas fa-trash"></i>
                                        </button>
                                    </form>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="5" class="px-6 py-12 text-center text-slate-500 dark:text-slate-400">
                                    <i class="fas fa-folder-open text-3xl mb-3 opacity-50 block"></i>
                                    <?php echo e($lang == 'bn' ? 'কোনো রেকর্ড পাওয়া যায়নি।' : 'No DNS records found.'); ?>

                                </td>
                            </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

    </div>

    <div id="renewModal" class="fixed inset-0 bg-black/60 backdrop-blur-sm z-50 hidden flex items-center justify-center p-4">
        <div class="bg-white dark:bg-[#0f172a] border border-slate-200 dark:border-[#1e293b] rounded-2xl shadow-2xl w-full max-w-lg overflow-hidden">
            <div class="bg-emerald-500 p-6 text-center text-white relative">
                <button onclick="document.getElementById('renewModal').classList.add('hidden')" class="absolute top-4 right-4 text-emerald-100 hover:text-white"><i class="fas fa-times text-xl"></i></button>
                <i class="fas fa-sync-alt text-4xl mb-3"></i>
                <h3 class="text-xl font-bold"><?php echo e($lang == 'bn' ? 'ডোমেইন রিনিউ করুন' : 'Renew Domain'); ?></h3>
                <p class="text-emerald-100 text-sm"><?php echo e($domain->domain_name); ?></p>
            </div>
            
            <form action="<?php echo e(route('user.domain.renew', $domain->id)); ?>" method="POST" class="p-6">
                <?php echo csrf_field(); ?>
                <div class="grid grid-cols-2 gap-4 mb-6">
                    <label class="cursor-pointer relative">
                        <input type="radio" name="months" value="1" class="peer hidden" checked onchange="calcRenew()">
                        <div class="border-2 border-slate-200 dark:border-slate-700 rounded-xl p-4 text-center peer-checked:border-emerald-500 peer-checked:bg-emerald-50 dark:peer-checked:bg-emerald-500/10 transition-all">
                            <span class="block font-bold text-slate-800 dark:text-white">1 <?php echo e($lang == 'bn' ? 'মাস' : 'Month'); ?></span>
                        </div>
                    </label>
                    <label class="cursor-pointer relative">
                        <input type="radio" name="months" value="3" class="peer hidden" onchange="calcRenew()">
                        <div class="border-2 border-slate-200 dark:border-slate-700 rounded-xl p-4 text-center peer-checked:border-emerald-500 peer-checked:bg-emerald-50 dark:peer-checked:bg-emerald-500/10 transition-all">
                            <span class="absolute -top-2 left-1/2 -translate-x-1/2 bg-rose-500 text-white text-[10px] font-bold px-2 py-0.5 rounded-full">SAVE 2%</span>
                            <span class="block font-bold text-slate-800 dark:text-white">3 <?php echo e($lang == 'bn' ? 'মাস' : 'Months'); ?></span>
                        </div>
                    </label>
                    <label class="cursor-pointer relative">
                        <input type="radio" name="months" value="6" class="peer hidden" onchange="calcRenew()">
                        <div class="border-2 border-slate-200 dark:border-slate-700 rounded-xl p-4 text-center peer-checked:border-emerald-500 peer-checked:bg-emerald-50 dark:peer-checked:bg-emerald-500/10 transition-all mt-2">
                            <span class="absolute -top-2 left-1/2 -translate-x-1/2 bg-rose-500 text-white text-[10px] font-bold px-2 py-0.5 rounded-full">SAVE 5%</span>
                            <span class="block font-bold text-slate-800 dark:text-white">6 <?php echo e($lang == 'bn' ? 'মাস' : 'Months'); ?></span>
                        </div>
                    </label>
                    <label class="cursor-pointer relative">
                        <input type="radio" name="months" value="12" class="peer hidden" onchange="calcRenew()">
                        <div class="border-2 border-slate-200 dark:border-slate-700 rounded-xl p-4 text-center peer-checked:border-emerald-500 peer-checked:bg-emerald-50 dark:peer-checked:bg-emerald-500/10 transition-all mt-2">
                            <span class="absolute -top-2 left-1/2 -translate-x-1/2 bg-rose-500 text-white text-[10px] font-bold px-2 py-0.5 rounded-full">SAVE 10%</span>
                            <span class="block font-bold text-slate-800 dark:text-white">1 <?php echo e($lang == 'bn' ? 'বছর' : 'Year'); ?></span>
                        </div>
                    </label>
                </div>

                <div class="bg-slate-50 dark:bg-slate-800/50 rounded-xl p-4 text-center border border-slate-200 dark:border-slate-700 mb-6">
                    <p class="text-xs text-slate-500 dark:text-slate-400 font-bold uppercase mb-1">Total Cost</p>
                    <h3 class="text-3xl font-black text-emerald-600 dark:text-emerald-400" id="renewTotalDisplay">৳0.00</h3>
                </div>

                <button type="submit" id="renewBtn" class="w-full bg-emerald-500 hover:bg-emerald-600 text-white font-bold py-3.5 rounded-xl shadow-lg transition-all">
                    <?php echo e($lang == 'bn' ? 'কনফার্ম করুন' : 'Confirm Renewal'); ?>

                </button>
            </form>
        </div>
    </div>

    <div id="dnsModal" class="fixed inset-0 bg-black/60 backdrop-blur-sm z-50 hidden flex items-center justify-center p-4">
        <div class="bg-white dark:bg-[#0f172a] border border-slate-200 dark:border-[#1e293b] rounded-2xl shadow-2xl w-full max-w-md overflow-hidden transform scale-95 opacity-0 transition-all" id="modalContent">
            <div class="flex justify-between items-center p-6 border-b border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-800/50">
                <h3 class="text-lg font-bold text-slate-800 dark:text-white" id="modalTitle">DNS Record</h3>
                <button onclick="closeModal()" class="text-slate-400 hover:text-white"><i class="fas fa-times text-xl"></i></button>
            </div>
            
            <form action="<?php echo e(route('user.domain.dns.update', $domain->id)); ?>" method="POST" class="p-6">
                <?php echo csrf_field(); ?>
                <input type="hidden" name="action" id="actionInput" value="add_record">
                <input type="hidden" name="record_id" id="recordIdInput" value="">
                
                <div class="space-y-4">
                    <div>
                        <label class="block text-xs font-bold text-slate-500 uppercase mb-2">Type</label>
                        <select name="type" id="dnsTypeSelect" class="w-full bg-slate-50 dark:bg-[#1e293b] border border-slate-200 dark:border-[#334155] text-slate-800 dark:text-white rounded-lg focus:ring-blue-500 p-2.5 outline-none" onchange="togglePriority()">
                            <option value="A">A</option><option value="CNAME">CNAME</option><option value="TXT">TXT</option><option value="MX">MX</option>
                        </select>
                    </div>
                    <div>
                        <label class="block text-xs font-bold text-slate-500 uppercase mb-2">Name</label>
                        <input type="text" name="record_name" id="nameInput" class="w-full bg-slate-50 dark:bg-[#1e293b] border border-slate-200 dark:border-[#334155] text-slate-800 dark:text-white rounded-lg focus:ring-blue-500 p-2.5 outline-none" required>
                    </div>
                    <div>
                        <label class="block text-xs font-bold text-slate-500 uppercase mb-2">Content</label>
                        <input type="text" name="content" id="contentInput" class="w-full bg-slate-50 dark:bg-[#1e293b] border border-slate-200 dark:border-[#334155] text-slate-800 dark:text-white rounded-lg focus:ring-blue-500 p-2.5 outline-none" required>
                    </div>
                    
                    <div id="priorityField" class="hidden">
                        <label class="block text-xs font-bold text-slate-500 uppercase mb-2">Priority</label>
                        <input type="number" name="priority" id="priorityInput" value="10" class="w-full bg-slate-50 dark:bg-[#1e293b] border border-slate-200 dark:border-[#334155] text-slate-800 dark:text-white rounded-lg focus:ring-blue-500 p-2.5 outline-none">
                    </div>

                    <div>
                        <label class="flex items-center justify-between p-3 border border-slate-200 dark:border-slate-700 rounded-lg cursor-pointer bg-slate-50 dark:bg-slate-800">
                            <div class="flex items-center gap-3">
                                <i class="fas fa-cloud text-orange-500 text-xl" id="proxyIcon"></i>
                                <div><div class="font-bold text-sm text-slate-800 dark:text-white" id="proxyText">Proxied</div></div>
                            </div>
                            <input type="checkbox" name="proxied" id="proxyCheck" class="w-5 h-5 accent-orange-500" checked onchange="toggleProxyUI()">
                        </label>
                    </div>
                </div>

                <button type="submit" id="submitBtn" class="w-full mt-6 bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 rounded-xl shadow-lg">Save Record</button>
            </form>
        </div>
    </div>

    <script>
        function toggleNS(type) { document.getElementById('customInputs').style.display = (type === 'custom') ? 'block' : 'none'; }
        
        const modal = document.getElementById('dnsModal');
        const modalContent = document.getElementById('modalContent');
        
        function openModal(mode, id='', type='A', name='', content='', proxied=true, priority=10) {
            document.getElementById('actionInput').value = (mode === 'edit') ? 'edit_record' : 'add_record';
            document.getElementById('recordIdInput').value = id;
            document.getElementById('dnsTypeSelect').value = type;
            document.getElementById('nameInput').value = name;
            document.getElementById('contentInput').value = content;
            document.getElementById('priorityInput').value = priority;
            document.getElementById('proxyCheck').checked = proxied;
            
            togglePriority(); toggleProxyUI();
            
            modal.classList.remove('hidden');
            setTimeout(() => { modalContent.classList.remove('scale-95', 'opacity-0'); modalContent.classList.add('scale-100', 'opacity-100'); }, 10);
        }

        function closeModal() {
            modalContent.classList.remove('scale-100', 'opacity-100');
            modalContent.classList.add('scale-95', 'opacity-0');
            setTimeout(() => { modal.classList.add('hidden'); }, 200);
        }

        function togglePriority() {
            const type = document.getElementById('dnsTypeSelect').value;
            document.getElementById('priorityField').style.display = (type === 'MX' || type === 'SRV') ? 'block' : 'none';
        }

        function toggleProxyUI() {
            const isChecked = document.getElementById('proxyCheck').checked;
            const icon = document.getElementById('proxyIcon');
            const text = document.getElementById('proxyText');
            
            if(isChecked) { icon.className = 'fas fa-cloud text-orange-500 text-xl'; text.innerText = 'Proxied'; } 
            else { icon.className = 'fas fa-cloud text-slate-400 text-xl'; text.innerText = 'DNS Only'; }
        }

        const renewBasePrice = <?php echo e($renew_base_price ?? 0); ?>;
        const userBal = <?php echo e(Auth::user()->balance); ?>;
        const l = "<?php echo e($lang); ?>";

        function calcRenew() {
            const radios = document.getElementsByName('months');
            let m = 1; for (const r of radios) { if(r.checked) m = parseInt(r.value); }
            let base = renewBasePrice * m;
            let disc = 0; if(m==3) disc=0.02; else if(m==6) disc=0.05; else if(m==12) disc=0.10;
            let total = base - (base * disc);
            document.getElementById('renewTotalDisplay').innerText = '৳' + total.toFixed(2);
            const btn = document.getElementById('renewBtn');
            if(userBal < total) {
                btn.disabled = true;
                btn.innerHTML = `Insufficient Funds`;
                btn.className = "w-full bg-slate-300 dark:bg-slate-700 text-slate-500 font-bold py-3.5 rounded-xl cursor-not-allowed";
            } else {
                btn.disabled = false;
                btn.innerHTML = l=='bn' ? 'কনফার্ম করুন' : 'Confirm Renewal';
                btn.className = "w-full bg-emerald-500 hover:bg-emerald-600 text-white font-bold py-3.5 rounded-xl shadow-lg";
            }
        }
        calcRenew();
    </script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('user.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/anstserv/public_html/resources/views/user/domains/manage.blade.php ENDPATH**/ ?>