{{--
    文件功能：婚礼红包领取明细页

    @author   ChatRoom Laravel
    @version  1.0.0
--}}

@extends('admin.layouts.app')

@section('title', '婚礼红包明细')

@section('content')

    <div class="flex items-center justify-between mb-5">
        <div>
            <h2 class="text-xl font-bold text-gray-800">🎁 红包领取明细</h2>
            <p class="text-sm text-gray-500 mt-1">
                {{ $ceremony->marriage?->user?->username }} × {{ $ceremony->marriage?->partner?->username }}
                — {{ $ceremony->tier?->icon }} {{ $ceremony->tier?->name ?? '婚礼' }}
                · 总额 <strong class="text-amber-600">{{ number_format($ceremony->total_amount) }} 金</strong>
            </p>
        </div>
        <a href="{{ route('admin.marriages.ceremonies') }}" class="text-sm text-indigo-600 hover:underline">← 返回婚礼列表</a>
    </div>

    {{-- 汇总 --}}
    <div class="grid grid-cols-3 gap-4 mb-5">
        <div class="bg-white rounded-xl border shadow-sm p-4 text-center">
            <div class="text-2xl font-bold text-indigo-600">{{ $ceremony->online_count ?? 0 }}</div>
            <div class="text-xs text-gray-500 mt-1">在线人数</div>
        </div>
        <div class="bg-white rounded-xl border shadow-sm p-4 text-center">
            <div class="text-2xl font-bold text-green-600">{{ $ceremony->claimed_count }}</div>
            <div class="text-xs text-gray-500 mt-1">已领取人数</div>
        </div>
        <div class="bg-white rounded-xl border shadow-sm p-4 text-center">
            <div class="text-2xl font-bold text-amber-600">{{ number_format($ceremony->claimed_amount) }}</div>
            <div class="text-xs text-gray-500 mt-1">已领取金额</div>
        </div>
    </div>

    <div class="bg-white rounded-xl shadow-sm border overflow-hidden">
        <div class="overflow-x-auto">
            <table class="w-full text-sm">
                <thead class="bg-gray-50 text-xs uppercase text-gray-600">
                    <tr>
                        <th class="px-4 py-3 text-left">用户</th>
                        <th class="px-4 py-3 text-center">分配金额</th>
                        <th class="px-4 py-3 text-center">状态</th>
                        <th class="px-4 py-3 text-left">领取时间</th>
                    </tr>
                </thead>
                <tbody class="divide-y">
                    @forelse ($claims as $claim)
                        <tr class="hover:bg-gray-50">
                            <td class="px-4 py-3 font-bold">{{ $claim->user?->username }}</td>
                            <td class="px-4 py-3 text-center font-bold text-amber-600">
                                {{ number_format($claim->amount) }} 金
                            </td>
                            <td class="px-4 py-3 text-center">
                                @if ($claim->claimed)
                                    <span class="px-2 py-0.5 rounded-full text-xs bg-green-100 text-green-700 font-bold">✅
                                        已领取</span>
                                @else
                                    <span class="px-2 py-0.5 rounded-full text-xs bg-gray-100 text-gray-500">未领取</span>
                                @endif
                            </td>
                            <td class="px-4 py-3 text-xs text-gray-500">
                                {{ $claim->claimed_at?->format('H:i:s') ?? '—' }}
                            </td>
                        </tr>
                    @empty
                        <tr>
                            <td colspan="4" class="px-4 py-12 text-center text-gray-400">暂无领取记录</td>
                        </tr>
                    @endforelse
                </tbody>
            </table>
        </div>
        @if ($claims->hasPages())
            <div class="px-4 py-4 border-t">{{ $claims->links() }}</div>
        @endif
    </div>

@endsection
