<?php $__env->startSection('title', 'Client Profile: ' . $user->username); ?>

<?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">Client Profile</h1>
            <p class="text-slate-400 mt-1 text-sm">Manage balance, domains and account access for <?php echo e($user->username); ?>.</p>
        </div>
        <div class="flex gap-3">
            <a href="<?php echo e(route('admin.users.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> Back
            </a>
            
            <form action="<?php echo e(route('admin.users.impersonate', $user->id)); ?>" method="POST" target="_blank">
                <?php echo csrf_field(); ?>
                <button type="submit" class="bg-gradient-to-r from-indigo-500 to-blue-600 hover:from-indigo-600 hover:to-blue-700 text-white px-5 py-2 rounded-xl text-sm font-bold shadow-lg shadow-blue-500/30 transition-all hover:scale-105 flex items-center gap-2">
                    <i class="fas fa-sign-in-alt"></i> Direct Login
                </button>
            </form>
        </div>
    </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">
            <i class="fas fa-check-circle"></i> <?php echo e(session('success')); ?>

        </div>
    <?php endif; ?>
    <?php if(session('error')): ?>
        <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">
            <i class="fas fa-exclamation-triangle"></i> <?php echo e(session('error')); ?>

        </div>
    <?php endif; ?>

    <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
        
        <div class="space-y-6">
            
            <div class="bg-slate-800/40 border border-slate-700 rounded-2xl p-6 shadow-lg">
                <div class="flex items-center gap-4 mb-6 pb-6 border-b border-slate-700/50">
                    <div class="w-16 h-16 rounded-full bg-gradient-to-br from-slate-600 to-slate-800 border-2 border-slate-500 flex items-center justify-center text-white text-2xl font-bold shadow-md">
                        <?php echo e(strtoupper(substr($user->username, 0, 1))); ?>

                    </div>
                    <div>
                        <h2 class="text-xl font-bold text-white"><?php echo e($user->username); ?></h2>
                        <p class="text-emerald-400 text-sm font-medium">Status: <?php echo e(ucfirst($user->status)); ?></p>
                    </div>
                </div>
                
                <div class="space-y-4 text-sm">
                    <div class="flex justify-between">
                        <span class="text-slate-400">Email</span>
                        <span class="text-white font-medium"><?php echo e($user->email); ?></span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-slate-400">Phone</span>
                        <span class="text-white font-medium"><?php echo e($user->phone ?? 'N/A'); ?></span>
                    </div>
                    <div class="flex justify-between">
                        <span class="text-slate-400">Joined</span>
                        <span class="text-white font-medium"><?php echo e(date('d M Y', strtotime($user->created_at))); ?></span>
                    </div>
                    <div class="flex justify-between items-center bg-slate-900/50 p-3 rounded-lg border border-slate-700 mt-4">
                        <span class="text-slate-400 font-semibold">Current Balance</span>
                        <span class="text-2xl font-extrabold text-emerald-400">৳<?php echo e(number_format($user->balance, 2)); ?></span>
                    </div>
                </div>
            </div>

            <div class="bg-slate-800/40 border border-slate-700 rounded-2xl p-6 shadow-lg">
                <h3 class="text-lg font-bold text-white mb-4"><i class="fas fa-wallet text-yellow-500 mr-2"></i> Manage Balance</h3>
                
                <form action="<?php echo e(route('admin.users.balance', $user->id)); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <div class="mb-4">
                        <label class="block text-xs font-medium text-slate-400 uppercase tracking-wider mb-2">Action</label>
                        <select name="action" class="w-full bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2.5 outline-none">
                            <option value="add">Add Balance (+)</option>
                            <option value="subtract">Deduct Balance (-)</option>
                        </select>
                    </div>
                    <div class="mb-4">
                        <label class="block text-xs font-medium text-slate-400 uppercase tracking-wider mb-2">Amount (BDT)</label>
                        <input type="number" name="amount" min="1" step="any" class="w-full bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2.5 outline-none" placeholder="100.00" required>
                    </div>
                    <div class="mb-6">
                        <label class="block text-xs font-medium text-slate-400 uppercase tracking-wider mb-2">Description (Optional)</label>
                        <input type="text" name="description" class="w-full bg-slate-900 border border-slate-700 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2.5 outline-none" placeholder="e.g. Refund or Bonus">
                    </div>
                    <button type="submit" class="w-full bg-emerald-500 hover:bg-emerald-600 text-white font-bold py-2.5 rounded-lg transition-colors">
                        Update Balance
                    </button>
                </form>
            </div>

        </div>

        <div class="lg:col-span-2">
            <div class="bg-slate-800/40 border border-slate-700 rounded-2xl p-6 shadow-lg h-full">
                <h3 class="text-lg font-bold text-white mb-6 flex items-center justify-between">
                    <span><i class="fas fa-globe text-blue-400 mr-2"></i> Client Domains</span>
                    <span class="bg-blue-500/20 text-blue-400 text-xs px-2 py-1 rounded border border-blue-500/30"><?php echo e($domains->count()); ?> Total</span>
                </h3>

                <div class="overflow-x-auto">
                    <table class="w-full text-left text-sm text-slate-300">
                        <thead class="bg-slate-800/80 text-xs uppercase font-semibold text-slate-400">
                            <tr>
                                <th class="px-4 py-3">Domain Name</th>
                                <th class="px-4 py-3">Price/Mo</th>
                                <th class="px-4 py-3">Expiry Date</th>
                                <th class="px-4 py-3 text-right">Status</th>
                            </tr>
                        </thead>
                        <tbody class="divide-y divide-slate-700/50">
                            <?php $__empty_1 = true; $__currentLoopData = $domains; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $domain): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr class="hover:bg-slate-800/50 transition-colors">
                                <td class="px-4 py-4 font-medium text-blue-400">
                                    <a href="http://<?php echo e($domain->domain_name); ?>" target="_blank" class="hover:underline"><?php echo e($domain->domain_name); ?> <i class="fas fa-external-link-alt text-[10px] ml-1"></i></a>
                                </td>
                                <td class="px-4 py-4">৳<?php echo e($domain->monthly_price); ?></td>
                                <td class="px-4 py-4 text-slate-400">
                                    <?php echo e(date('d M, Y', strtotime($domain->expiry_date))); ?>

                                    <?php if($domain->expiry_date < now()): ?>
                                        <span class="text-red-400 ml-1 text-xs">(Expired)</span>
                                    <?php endif; ?>
                                </td>
                                <td class="px-4 py-4 text-right">
                                    <?php if($domain->status == 'active'): ?>
                                        <span class="bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 px-2 py-1 rounded text-xs">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"><?php echo e(ucfirst($domain->status)); ?></span>
                                    <?php endif; ?>
                                </td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="4" class="py-8 text-center text-slate-500">
                                    <i class="fas fa-folder-open text-4xl mb-3 opacity-50 block"></i>
                                    This client hasn't purchased any domains yet.
                                </td>
                            </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </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/users/show.blade.php ENDPATH**/ ?>