<?php $__env->startSection('title', $user->full_name . ' — JAM Admin'); ?>
<?php $__env->startSection('page-title', $user->full_name); ?>

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


<?php if(session('success')): ?>
<div class="bg-green-900/20 border border-green-700/40 rounded-xl px-5 py-3 mb-6 text-green-400 text-sm">
    <?php echo e(session('success')); ?>

</div>
<?php endif; ?>
<?php if(session('error')): ?>
<div class="bg-red-900/20 border border-red-700/40 rounded-xl px-5 py-3 mb-6 text-red-400 text-sm">
    <?php echo e(session('error')); ?>

</div>
<?php endif; ?>

<div x-data="{ suspendModal: false, debitModal: false }" class="space-y-6">

    
    <div class="flex items-start justify-between">
        <div>
            <a href="<?php echo e(route('admin.members.index')); ?>" class="text-white/30 hover:text-white text-xs transition-colors inline-flex items-center gap-1 mb-3">
                <svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/></svg>
                Members
            </a>
            <h2 class="text-2xl font-semibold" style="font-family: 'Playfair Display', serif;"><?php echo e($user->full_name); ?></h2>
            <p class="text-white/40 text-sm mt-1">
                <?php echo e($user->membership_number); ?>

                · Joined <?php echo e($user->enrolled_at?->format('d M Y')); ?>

                · <?php echo e($user->email); ?>

            </p>
        </div>
        <div class="flex items-center gap-2">
            <a href="<?php echo e(route('admin.tiers.evaluate', $user)); ?>"
               class="border border-[#2a2a2a] hover:border-[#D4B84A]/40 text-white/40 hover:text-[#D4B84A] text-xs tracking-wide uppercase px-4 py-2.5 rounded-full transition-colors">
                Evaluate Tier
            </a>
            <a href="<?php echo e(route('admin.members.edit', $user)); ?>"
               class="border border-[#2a2a2a] hover:border-[#D4B84A]/50 text-white/50 hover:text-[#D4B84A] text-xs tracking-wide uppercase px-4 py-2.5 rounded-full transition-colors">
                Edit
            </a>
            <?php if($user->status === 'active'): ?>
            <button @click="suspendModal = true"
                    class="border border-orange-800/50 hover:border-orange-500/60 text-orange-400/60 hover:text-orange-400 text-xs tracking-wide uppercase px-4 py-2.5 rounded-full transition-colors">
                Suspend
            </button>
            <form method="POST" action="<?php echo e(route('admin.members.deactivate', $user)); ?>">
                <?php echo csrf_field(); ?>
                <button type="submit" onclick="return confirm('Deactivate <?php echo e($user->full_name); ?>? They will not be able to log in.')"
                        class="border border-red-800/50 hover:border-red-600 text-red-400/60 hover:text-red-400 text-xs tracking-wide uppercase px-4 py-2.5 rounded-full transition-colors">
                    Deactivate
                </button>
            </form>
            <?php else: ?>
            <form method="POST" action="<?php echo e(route('admin.members.reactivate', $user)); ?>">
                <?php echo csrf_field(); ?>
                <button type="submit"
                        class="border border-green-800/50 hover:border-green-500 text-green-400/60 hover:text-green-400 text-xs tracking-wide uppercase px-4 py-2.5 rounded-full transition-colors">
                    Reactivate
                </button>
            </form>
            <?php endif; ?>
        </div>
    </div>

    
    <div class="grid grid-cols-4 gap-4">
        <div class="bg-[#111111] border border-[#1e1e1e] rounded-xl p-5">
            <p class="text-white/40 text-xs tracking-widest uppercase mb-2">Points Balance</p>
            <p class="text-3xl font-semibold text-[#D4B84A]"><?php echo e(number_format($user->points_balance)); ?></p>
            <p class="text-white/25 text-xs mt-1">Expires <?php echo e($user->points_expiry_date?->format('d M Y')); ?></p>
        </div>
        <div class="bg-[#111111] border border-[#1e1e1e] rounded-xl p-5">
            <p class="text-white/40 text-xs tracking-widest uppercase mb-2">Tier</p>
            <p class="text-lg font-semibold text-white"><?php echo e($user->currentTier?->tier?->name ?? 'Invited'); ?></p>
            <p class="text-white/25 text-xs mt-1">Since <?php echo e($user->currentTier?->assigned_at?->format('M Y') ?? $user->enrolled_at?->format('M Y')); ?></p>
        </div>
        <div class="bg-[#111111] border border-[#1e1e1e] rounded-xl p-5">
            <p class="text-white/40 text-xs tracking-widest uppercase mb-2">Total Visits</p>
            <p class="text-3xl font-semibold text-white"><?php echo e($user->visits()->count()); ?></p>
        </div>
        <div class="bg-[#111111] border border-[#1e1e1e] rounded-xl p-5">
            <p class="text-white/40 text-xs tracking-widest uppercase mb-2">Status</p>
            <span class="inline-block px-3 py-1 rounded-full text-xs font-medium mt-1
                <?php echo e($user->status === 'active' ? 'bg-green-900/40 text-green-400' : ($user->status === 'suspended' ? 'bg-orange-900/40 text-orange-400' : 'bg-red-900/40 text-red-400')); ?>">
                <?php echo e(ucfirst($user->status)); ?>

            </span>
            <?php if($user->suspension_reason): ?>
            <p class="text-white/30 text-xs mt-2 leading-relaxed"><?php echo e($user->suspension_reason); ?></p>
            <?php endif; ?>
        </div>
    </div>

    
    <div class="grid grid-cols-3 gap-5">

        
        <div class="col-span-2 bg-[#111111] border border-[#1e1e1e] rounded-xl p-6">
            <h3 class="text-sm font-medium mb-5">Add Points (Record Visit)</h3>
            <?php if($errors->any()): ?>
            <div class="bg-red-900/20 border border-red-800/50 rounded-lg p-3 mb-4">
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <p class="text-red-400 text-xs"><?php echo e($error); ?></p>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
            <?php endif; ?>
            <form method="POST" action="<?php echo e(route('admin.points.credit', $user)); ?>" class="space-y-4">
                <?php echo csrf_field(); ?>
                <div class="grid grid-cols-2 gap-4">
                    <div>
                        <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Spend Amount ($)</label>
                        <input type="number" name="spend_amount" step="0.01" min="0.01"
                               placeholder="150.00"
                               class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-[#D4B84A] rounded-lg px-4 py-2.5 text-sm text-white outline-none transition-colors placeholder-white/20">
                        <p class="text-white/25 text-xs mt-1">Points = $1 spend = 1 point</p>
                    </div>
                    <div>
                        <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Visit Date</label>
                        <input type="date" name="visit_date" value="<?php echo e(date('Y-m-d')); ?>"
                               class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-[#D4B84A] rounded-lg px-4 py-2.5 text-sm text-white outline-none transition-colors"
                               style="color-scheme: dark;">
                    </div>
                </div>
                <div>
                    <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Admin Note (optional)</label>
                    <input type="text" name="admin_note" placeholder="e.g. Anniversary dinner, Table 4"
                           class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-[#D4B84A] rounded-lg px-4 py-2.5 text-sm text-white outline-none transition-colors placeholder-white/20">
                </div>
                <div class="flex items-center justify-between">
                    <label class="flex items-center gap-2.5 cursor-pointer">
                        <input type="checkbox" name="note_visible_to_member" value="1" class="w-4 h-4 accent-[#D4B84A]">
                        <span class="text-xs text-white/40">Show note to member</span>
                    </label>
                    <button type="submit"
                            class="bg-[#D4B84A] hover:bg-[#E8D080] text-black font-semibold text-xs tracking-widest uppercase px-6 py-2.5 rounded-full transition-colors">
                        Add Points
                    </button>
                </div>
            </form>

            <div class="border-t border-[#1e1e1e] mt-6 pt-5">
                <div class="flex items-center justify-between mb-1">
                    <h4 class="text-sm font-medium text-white/60">Deduct Points</h4>
                    <button @click="debitModal = true"
                            class="border border-red-800/50 hover:border-red-600/60 text-red-400/50 hover:text-red-400 text-xs tracking-wide uppercase px-4 py-2 rounded-full transition-colors">
                        Deduct
                    </button>
                </div>
                <p class="text-white/25 text-xs">Current balance: <?php echo e(number_format($user->points_balance)); ?> pts</p>
            </div>
        </div>

        
        <div class="bg-[#111111] border border-[#1e1e1e] rounded-xl p-6">
            <h3 class="text-sm font-medium mb-4">Member Details</h3>
            <div class="space-y-4">
                <?php $__currentLoopData = [
                    ['Email', $user->email],
                    ['Phone', $user->phone ?? '—'],
                    ['DOB', $user->dob?->format('d M Y')],
                    ['Enrolled', $user->enrolled_at?->format('d M Y')],
                ]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as [$label, $value]): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div>
                    <p class="text-white/30 text-xs uppercase tracking-wide"><?php echo e($label); ?></p>
                    <p class="text-white text-sm mt-0.5"><?php echo e($value); ?></p>
                </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>
    </div>

    
    <div class="bg-[#111111] border border-[#1e1e1e] rounded-xl">
        <div class="flex items-center justify-between px-6 py-4 border-b border-[#1e1e1e]">
            <h3 class="text-sm font-medium">Points History</h3>
            <a href="<?php echo e(route('admin.points.history', $user)); ?>" class="text-[#D4B84A] text-xs hover:text-[#E8D080] transition-colors">View full history →</a>
        </div>
        <div class="divide-y divide-[#1e1e1e]">
            <?php $__empty_1 = true; $__currentLoopData = $recentTransactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tx): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <div class="flex items-center justify-between px-6 py-3.5">
                <div class="flex items-center gap-4">
                    <span class="w-7 h-7 rounded-full flex items-center justify-center text-xs
                        <?php echo e($tx->isCredit() ? 'bg-[#D4B84A]/10 text-[#D4B84A]' : 'bg-red-900/30 text-red-400'); ?>">
                        <?php echo e($tx->isCredit() ? '+' : '−'); ?>

                    </span>
                    <div>
                        <p class="text-white text-sm"><?php echo e($tx->description); ?></p>
                        <p class="text-white/30 text-xs mt-0.5">
                            <?php echo e($tx->created_at->format('d M Y · h:i A')); ?>

                            <?php if($tx->admin): ?> · by <?php echo e($tx->admin->name); ?> <?php endif; ?>
                            <?php if($tx->admin_note): ?> · <em class="text-white/40"><?php echo e($tx->admin_note); ?></em> <?php endif; ?>
                        </p>
                    </div>
                </div>
                <div class="text-right">
                    <p class="font-semibold text-sm <?php echo e($tx->isCredit() ? 'text-[#D4B84A]' : 'text-red-400'); ?>">
                        <?php echo e($tx->isCredit() ? '+' : '−'); ?><?php echo e(number_format($tx->amount)); ?>

                    </p>
                    <p class="text-white/25 text-xs">Bal: <?php echo e(number_format($tx->balance_after)); ?></p>
                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <div class="px-6 py-8 text-center text-white/30 text-sm">No transactions yet.</div>
            <?php endif; ?>
        </div>
    </div>

    
    <div class="bg-[#111111] border border-[#1e1e1e] rounded-xl">
        <div class="px-6 py-4 border-b border-[#1e1e1e]">
            <h3 class="text-sm font-medium">Tier History</h3>
        </div>
        <div class="divide-y divide-[#1e1e1e]">
            <?php $__empty_1 = true; $__currentLoopData = $user->tiers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $memberTier): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <div class="flex items-center justify-between px-6 py-3.5">
                <div class="flex items-center gap-3">
                    <span class="px-2.5 py-1 rounded-full text-xs border
                        <?php echo e($memberTier->tier?->slug === 'limitless' ? 'border-[#D4B84A]/50 text-[#D4B84A]' : ($memberTier->tier?->slug === 'indulged' ? 'border-blue-400/30 text-blue-300' : 'border-white/20 text-white/50')); ?>">
                        <?php echo e($memberTier->tier?->name); ?>

                    </span>
                    <?php if($memberTier->is_current): ?>
                    <span class="text-[10px] text-[#D4B84A] uppercase tracking-widest">Current</span>
                    <?php endif; ?>
                </div>
                <div class="text-right">
                    <p class="text-white/50 text-xs"><?php echo e($memberTier->assigned_at?->format('d M Y')); ?></p>
                    <p class="text-white/30 text-xs capitalize"><?php echo e(str_replace('_', ' ', $memberTier->assignment_type)); ?></p>
                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <div class="px-6 py-6 text-center text-white/30 text-sm">No tier history.</div>
            <?php endif; ?>
        </div>
    </div>

    
    <div x-show="suspendModal" x-cloak
         class="fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4"
         @keydown.escape.window="suspendModal = false">
        <div class="bg-[#111111] border border-[#2a2a2a] rounded-2xl p-8 w-full max-w-md" @click.stop>
            <h3 class="text-lg font-semibold mb-1" style="font-family: 'Playfair Display', serif;">Suspend Member</h3>
            <p class="text-white/40 text-sm mb-6"><?php echo e($user->full_name); ?> will not be able to log in while suspended.</p>
            <form method="POST" action="<?php echo e(route('admin.members.suspend', $user)); ?>" class="space-y-4">
                <?php echo csrf_field(); ?>
                <div>
                    <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Reason *</label>
                    <textarea name="reason" rows="3" required
                              class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-orange-500/50 rounded-lg px-4 py-3 text-sm text-white outline-none transition-colors resize-none"
                              placeholder="Reason for suspension…"></textarea>
                </div>
                <div>
                    <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Suspend Until (optional)</label>
                    <input type="date" name="suspended_until"
                           class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-orange-500/50 rounded-lg px-4 py-3 text-sm text-white outline-none transition-colors"
                           style="color-scheme: dark;">
                </div>
                <div class="flex justify-end gap-3 pt-2">
                    <button type="button" @click="suspendModal = false"
                            class="px-5 py-2.5 rounded-full border border-[#2a2a2a] text-white/50 text-sm hover:text-white transition-colors">
                        Cancel
                    </button>
                    <button type="submit"
                            class="px-5 py-2.5 rounded-full bg-orange-600 hover:bg-orange-500 text-white text-sm font-semibold transition-colors">
                        Suspend
                    </button>
                </div>
            </form>
        </div>
    </div>

    
    <div x-show="debitModal" x-cloak
         class="fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4"
         @keydown.escape.window="debitModal = false">
        <div class="bg-[#111111] border border-[#2a2a2a] rounded-2xl p-8 w-full max-w-md" @click.stop>
            <h3 class="text-lg font-semibold mb-1" style="font-family: 'Playfair Display', serif;">Deduct Points</h3>
            <p class="text-white/40 text-sm mb-6">Current balance: <span class="text-white font-medium"><?php echo e(number_format($user->points_balance)); ?> pts</span></p>
            <form method="POST" action="<?php echo e(route('admin.points.debit', $user)); ?>" class="space-y-4">
                <?php echo csrf_field(); ?>
                <div>
                    <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Points to Deduct *</label>
                    <input type="number" name="amount" min="1" max="<?php echo e($user->points_balance); ?>" required
                           class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-red-500/50 rounded-lg px-4 py-3 text-sm text-white outline-none transition-colors">
                </div>
                <div>
                    <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Reason *</label>
                    <textarea name="reason" rows="3" required
                              class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-red-500/50 rounded-lg px-4 py-3 text-sm text-white outline-none transition-colors resize-none"
                              placeholder="Reason for deduction…"></textarea>
                </div>
                <div class="flex items-center gap-2.5">
                    <input type="checkbox" name="note_visible_to_member" value="1" id="visible_debit" class="w-4 h-4 accent-[#D4B84A]">
                    <label for="visible_debit" class="text-xs text-white/40">Show reason to member</label>
                </div>
                <div class="flex justify-end gap-3 pt-2">
                    <button type="button" @click="debitModal = false"
                            class="px-5 py-2.5 rounded-full border border-[#2a2a2a] text-white/50 text-sm hover:text-white transition-colors">
                        Cancel
                    </button>
                    <button type="submit"
                            class="px-5 py-2.5 rounded-full bg-red-700 hover:bg-red-600 text-white text-sm font-semibold transition-colors">
                        Deduct Points
                    </button>
                </div>
            </form>
        </div>
    </div>

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

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /Volumes/aslam/ASLAM E/jam/jam_loyality2/resources/views/admin/members/show.blade.php ENDPATH**/ ?>