@extends('layouts.member')
@section('title', 'Your Benefits — JAM Members Club')

@section('content')
@php
    $user = auth()->user();
    $currentTier = $user->currentTier?->tier;

    $benefits = [
        'invited'   => ['Welcome breadbasket on every qualifying visit', 'Welcome drink for two on your first visit', '$5 off one dessert during your birthday period', '1-week early access to JAM events'],
        'indulged'  => ['Welcome breadbasket on every qualifying visit', 'Welcome drink for two on your first two visits', 'Complimentary birthday dessert', 'Birthday table setup (on request)', '20% discount on venue hire', '1-week early access to JAM events'],
        'limitless' => ['Welcome breadbasket on every qualifying visit', 'Welcome drink for two on every qualifying visit', 'Birthday upgrade: 2-course to 3-course meal', 'Birthday table setup (on request)', 'Anniversary table styling + private dining access', '50% discount on venue hire', 'Complimentary petit four with every visit', 'Priority last-minute bookings for two', '1-week early access to JAM events', 'Personalised milestone thank you cards'],
    ];
    $tiers = \App\Models\Tier::orderBy('display_order')->get();
@endphp

<div class="mb-8">
    <h1 class="text-3xl font-semibold" style="font-family: 'Playfair Display', serif;">Your Benefits</h1>
    <p class="text-white/40 text-sm mt-1">Current tier: <span class="text-white">{{ $currentTier?->name ?? 'Invited' }}</span></p>
</div>

<div class="grid grid-cols-3 gap-5">
    @foreach($tiers as $tier)
    @php $isCurrentTier = $currentTier?->id === $tier->id; @endphp
    <div class="bg-[#111111] border rounded-2xl p-6 transition-all
        {{ $isCurrentTier ? 'border-[#D4B84A]/50' : 'border-[#1e1e1e] opacity-60' }}">
        <div class="flex items-center justify-between mb-4">
            <h3 class="font-semibold {{ $isCurrentTier ? 'text-[#D4B84A]' : 'text-white/50' }}" style="font-family: 'Playfair Display', serif;">{{ $tier->name }}</h3>
            @if($isCurrentTier)
            <span class="px-2 py-0.5 rounded-full text-[10px] bg-[#D4B84A]/20 text-[#D4B84A] font-semibold tracking-wide">YOUR TIER</span>
            @endif
        </div>
        <ul class="space-y-3">
            @foreach($benefits[$tier->slug] ?? [] as $benefit)
            <li class="flex items-start gap-2.5">
                <span class="{{ $isCurrentTier ? 'text-[#D4B84A]' : 'text-white/20' }} text-xs mt-0.5 flex-shrink-0">✦</span>
                <p class="text-sm {{ $isCurrentTier ? 'text-white/80' : 'text-white/30' }}">{{ $benefit }}</p>
            </li>
            @endforeach
        </ul>
    </div>
    @endforeach
</div>
@endsection
