@extends('layout.user')

@section('content')
<div class="max-w-3xl mx-auto px-3 py-3 space-y-3">
  <div class="flex items-center justify-between">
    <h1 class="text-lg font-extrabold text-slate-900">Achievement History</h1>
    <a href="{{ route('user.smart.leadership.index') }}" class="text-sm font-bold text-blue-700">Back</a>
  </div>

  @if(session('success'))
    <div class="rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-700">{{ session('success') }}</div>
  @endif
  @if(session('error'))
    <div class="rounded-lg border border-rose-200 bg-rose-50 px-3 py-2 text-sm text-rose-700">{{ session('error') }}</div>
  @endif

  <div class="rounded-xl border border-slate-200 bg-white overflow-hidden">
    <table class="w-full text-sm">
      <thead class="bg-slate-50 text-slate-600">
        <tr>
          <th class="px-3 py-2 text-left">লেভেল</th>
          <th class="px-3 py-2 text-left">রিওয়ার্ড</th>
          <th class="px-3 py-2 text-left">তারিখ</th>
        </tr>
      </thead>
      <tbody>
        @forelse($rewards as $r)
          @php
            $claimedAt = $r->claimed_at ?? $r->created_at;
          @endphp
          <tr class="border-t border-slate-100">
            <td class="px-3 py-2 font-semibold">#{{ $r->level }}</td>
            <td class="px-3 py-2">৳ {{ number_format((float) $r->amount, 2) }}</td>
            <td class="px-3 py-2">{{ $claimedAt ? $claimedAt->format('d M Y, h:i A') : '-' }}</td>
          </tr>
        @empty
          <tr>
            <td colspan="3" class="px-3 py-6 text-center text-slate-500">কোনো রিওয়ার্ড পাওয়া যায়নি।</td>
          </tr>
        @endforelse
      </tbody>
    </table>
  </div>
</div>
@endsection
