<?php $__env->startSection('title', 'Master Domains'); ?>

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

    <div class="flex flex-col md:flex-row md:justify-between md:items-end mb-8 gap-4">
        <div>
            <h1 class="text-3xl font-extrabold text-white tracking-tight">Master Domains</h1>
            <p class="text-slate-400 mt-1 text-sm">Add and manage root domains with their Cloudflare API credentials & pricing.</p>
        </div>
        <a href="<?php echo e(route('admin.domains.index')); ?>" class="bg-slate-800 border border-slate-700 hover:bg-slate-700 px-4 py-2 rounded-xl text-sm font-medium text-slate-300 transition-colors">
            <i class="fas fa-arrow-left mr-2"></i> Client Domains
        </a>
    </div>

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

        </div>
    <?php endif; ?>
    <?php if($errors->any()): ?>
        <div class="bg-red-500/10 border border-red-500/20 text-red-400 px-4 py-3 rounded-xl mb-6 flex items-center gap-3 shadow-sm">
            <i class="fas fa-exclamation-triangle"></i> Please check the form fields and try again.
        </div>
    <?php endif; ?>

    <div class="grid grid-cols-1 xl:grid-cols-3 gap-6">
        
        <div class="bg-slate-800/40 border border-slate-700 rounded-2xl p-6 shadow-lg h-fit sticky top-20">
            <h2 class="text-lg font-bold text-white mb-6 border-b border-slate-700 pb-3">
                <i class="fas fa-plus-circle text-blue-400 mr-2"></i> Add New Extension
            </h2>
            
            <form action="<?php echo e(route('admin.extensions.store')); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <div class="space-y-4">
                    <div>
                        <label class="block text-xs font-bold text-slate-400 uppercase mb-2">Domain Name</label>
                        <input type="text" name="domain_name" class="w-full bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-blue-500 p-2.5 outline-none" placeholder="e.g. sitebd.top" required>
                    </div>
                    <div>
                        <label class="block text-xs font-bold text-slate-400 uppercase mb-2">Monthly Price (BDT)</label>
                        <input type="number" name="price_per_month" class="w-full bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-emerald-500 p-2.5 outline-none" placeholder="e.g. 25.00" required>
                    </div>
                    <div>
                        <label class="block text-xs font-bold text-slate-400 uppercase mb-2">Cloudflare Email</label>
                        <input type="email" name="cloudflare_email" class="w-full bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-blue-500 p-2.5 outline-none" placeholder="Cloudflare account email" required>
                    </div>
                    <div>
                        <label class="block text-xs font-bold text-slate-400 uppercase mb-2">Cloudflare Zone ID</label>
                        <input type="text" name="cloudflare_zone_id" class="w-full bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-blue-500 p-2.5 outline-none font-mono" placeholder="e.g. 2d682b03afac..." required>
                    </div>
                    <div>
                        <label class="block text-xs font-bold text-slate-400 uppercase mb-2">Cloudflare Global API Key</label>
                        <input type="text" name="cloudflare_api_key" class="w-full bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-blue-500 p-2.5 outline-none font-mono" placeholder="e.g. 83bb6bddae..." required>
                    </div>
                    <div>
                        <label class="block text-xs font-bold text-slate-400 uppercase mb-2">Status</label>
                        <select name="status" class="w-full bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-blue-500 p-2.5 outline-none">
                            <option value="active">Active (Available for purchase)</option>
                            <option value="inactive">Inactive (Hidden)</option>
                        </select>
                    </div>
                    <button type="submit" class="w-full mt-2 bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 rounded-xl shadow-lg shadow-blue-600/20 transition-all hover:scale-[1.02]">
                        Add Master Domain
                    </button>
                </div>
            </form>
        </div>

        <div class="xl:col-span-2">
            <div class="bg-slate-800/40 border border-slate-700 rounded-2xl overflow-hidden shadow-lg">
                <div class="p-6 border-b border-slate-700 bg-slate-800/50">
                    <h2 class="text-lg font-bold text-white"><i class="fas fa-server text-emerald-400 mr-2"></i> Configured Extensions</h2>
                </div>

                <div class="p-6 space-y-6">
                    <?php $__empty_1 = true; $__currentLoopData = $extensions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ext): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <div class="bg-slate-900 border border-slate-700 rounded-xl p-5 relative group transition-colors hover:border-slate-500">
                        <div class="flex justify-between items-start mb-4">
                            <div class="flex items-center gap-3">
                                <div class="w-10 h-10 rounded-lg bg-blue-500/10 text-blue-400 flex items-center justify-center font-bold text-lg">
                                    .<?php echo e(substr($ext->domain_name, 0, 1)); ?>

                                </div>
                                <div>
                                    <h3 class="text-xl font-bold text-white">.<?php echo e($ext->domain_name); ?></h3>
                                    <p class="text-xs text-slate-500">Added: <?php echo e(date('d M Y', strtotime($ext->created_at))); ?></p>
                                </div>
                            </div>
                            <div class="flex gap-2">
                                <?php if($ext->status == 'active'): ?>
                                    <span class="bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 px-2 py-1 rounded text-xs font-bold h-fit"><i class="fas fa-check-circle"></i> Active</span>
                                <?php else: ?>
                                    <span class="bg-red-500/10 text-red-400 border border-red-500/20 px-2 py-1 rounded text-xs font-bold h-fit"><i class="fas fa-times-circle"></i> Inactive</span>
                                <?php endif; ?>
                                
                                <form action="<?php echo e(route('admin.extensions.delete', $ext->id)); ?>" method="POST" onsubmit="return confirm('Are you sure you want to delete this master domain? It might break existing client domains!');">
                                    <?php echo csrf_field(); ?>
                                    <button type="submit" class="bg-red-500/10 text-red-400 hover:bg-red-500 hover:text-white px-2 py-1 rounded transition-colors text-sm h-fit">
                                        <i class="fas fa-trash"></i>
                                    </button>
                                </form>
                            </div>
                        </div>

                        <form action="<?php echo e(route('admin.extensions.update', $ext->id)); ?>" method="POST" class="border-t border-slate-700/50 pt-4 mt-2">
                            <?php echo csrf_field(); ?>
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4">
                                <div>
                                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Domain Name</label>
                                    <input type="text" name="domain_name" value="<?php echo e($ext->domain_name); ?>" class="w-full bg-slate-800 border border-slate-600 text-white text-sm rounded focus:ring-blue-500 p-2 outline-none" required>
                                </div>
                                <div>
                                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Monthly Price (BDT)</label>
                                    <input type="number" name="price_per_month" value="<?php echo e($ext->price_per_month); ?>" class="w-full bg-slate-800 border border-slate-600 text-white text-sm rounded focus:ring-emerald-500 p-2 outline-none" required>
                                </div>
                                <div>
                                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">CF Email</label>
                                    <input type="email" name="cloudflare_email" value="<?php echo e($ext->cloudflare_email); ?>" class="w-full bg-slate-800 border border-slate-600 text-white text-sm rounded focus:ring-blue-500 p-2 outline-none" required>
                                </div>
                                <div>
                                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">Status</label>
                                    <select name="status" class="w-full bg-slate-800 border border-slate-600 text-white text-sm rounded focus:ring-blue-500 p-2 outline-none">
                                        <option value="active" <?php echo e($ext->status == 'active' ? 'selected' : ''); ?>>Active</option>
                                        <option value="inactive" <?php echo e($ext->status == 'inactive' ? 'selected' : ''); ?>>Inactive</option>
                                    </select>
                                </div>
                                <div class="md:col-span-2">
                                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">CF Zone ID</label>
                                    <input type="text" name="cloudflare_zone_id" value="<?php echo e($ext->cloudflare_zone_id); ?>" class="w-full bg-slate-800 border border-slate-600 text-white text-sm rounded focus:ring-blue-500 p-2 outline-none font-mono" required>
                                </div>
                                <div class="md:col-span-2">
                                    <label class="block text-[10px] font-bold text-slate-500 uppercase mb-1">CF Global API Key</label>
                                    <input type="text" name="cloudflare_api_key" value="<?php echo e($ext->cloudflare_api_key); ?>" class="w-full bg-slate-800 border border-slate-600 text-white text-sm rounded focus:ring-blue-500 p-2 outline-none font-mono" required>
                                </div>
                            </div>
                            <button type="submit" class="bg-slate-700 hover:bg-emerald-600 text-white text-xs font-bold py-2 px-4 rounded transition-colors">
                                <i class="fas fa-save mr-1"></i> Save Changes
                            </button>
                        </form>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <div class="text-center py-10 text-slate-500">
                        <i class="fas fa-exclamation-circle text-4xl mb-3 opacity-50"></i>
                        <p>No master domains configured yet.</p>
                        <p class="text-xs mt-1">Use the form on the left to add your first domain extension.</p>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>

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

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/anstserv/shop.bd1b.com/resources/views/admin/extensions/index.blade.php ENDPATH**/ ?>