{{--
    文件功能：婚礼仪式记录页（含红包分发详情链接）

    @author   ChatRoom Laravel
    @version  1.0.0
--}}

@extends('admin.layouts.app')

@section('title', '婚礼红包记录')

@section('content')
    @php require resource_path('views/admin/partials/list-theme.php'); @endphp

    <div class="{{ $adminListPageClass }}">
        <div class="{{ $adminListHeaderCardClass }}">
            <div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
                <div>
                    <h2 class="{{ $adminListHeaderTitleClass }}">🎊 婚礼红包记录</h2>
                    <p class="{{ $adminListHeaderSubtitleClass }}">统一查看婚礼红包发放进度与领取详情。</p>
                </div>
                <a href="{{ route('admin.marriages.index') }}" class="{{ $adminListSecondaryButtonClass }}">返回总览</a>
            </div>
        </div>

        <div class="{{ $adminListCardClass }}">
            <div class="{{ $adminListSectionHeadClass }}">
                <div>
                    <h3 class="{{ $adminListSectionTitleClass }}">婚礼红包列表</h3>
                    <p class="{{ $adminListSectionDescClass }}">保留婚礼状态色彩与金额语义，其他布局统一到后台列表样式。</p>
                </div>
            </div>
            <div class="{{ $adminListTableWrapClass }}">
                <table class="{{ $adminListTableClass }}">
                    <thead>
                        <tr class="{{ $adminListTableHeadRowClass }}">
                            <th class="{{ $adminListTableHeadCellClass }}">ID</th>
                            <th class="{{ $adminListTableHeadCellClass }}">新人</th>
                            <th class="{{ $adminListTableHeadCellClass }}">档位</th>
                            <th class="{{ $adminListTableHeadCellClass }} text-center">总金额</th>
                            <th class="{{ $adminListTableHeadCellClass }} text-center">在线人数</th>
                            <th class="{{ $adminListTableHeadCellClass }} text-center">领取进度</th>
                            <th class="{{ $adminListTableHeadCellClass }} text-center">状态</th>
                            <th class="{{ $adminListTableHeadCellClass }}">时间</th>
                            <th class="{{ $adminListTableHeadCellClass }} text-center">详情</th>
                        </tr>
                    </thead>
                    <tbody class="{{ $adminListTableBodyClass }}">
                        @forelse ($ceremonies as $c)
                            <tr class="{{ $adminListTableRowClass }}">
                                <td class="px-4 py-3 {{ $adminListSecondaryTextClass }} {{ $adminListNumericTextClass }}">{{ $c->id }}</td>
                                <td class="px-4 py-3">
                                    <span class="{{ $adminListPrimaryTextClass }}">{{ $c->marriage?->user?->username }}</span>
                                    <span class="mx-1 text-gray-400">×</span>
                                    <span class="{{ $adminListPrimaryTextClass }}">{{ $c->marriage?->partner?->username }}</span>
                                </td>
                                <td class="px-4 py-3 {{ $adminListBodyTextClass }}">
                                    {{ $c->tier?->icon }} {{ $c->tier?->name ?? '—' }}
                                </td>
                                <td class="px-4 py-3 text-center font-semibold text-amber-600">
                                    {{ number_format($c->total_amount) }} 金
                                </td>
                                <td class="px-4 py-3 text-center {{ $adminListBodyTextClass }}">
                                    {{ $c->online_count ?? '—' }}
                                </td>
                                <td class="px-4 py-3 text-center">
                                    @if ($c->total_amount > 0)
                                        <div class="text-xs text-gray-600">
                                            {{ $c->claimed_count }} / {{ $c->online_count ?? '?' }} 人
                                        </div>
                                        <div class="text-xs font-semibold text-emerald-600">
                                            {{ number_format($c->claimed_amount) }} / {{ number_format($c->total_amount) }}
                                        </div>
                                    @else
                                        <span class="text-gray-300 text-xs">无红包</span>
                                    @endif
                                </td>
                                <td class="px-4 py-3 text-center">
                                    <span
                                        class="{{ $adminListBadgeBaseClass }} {{ match ($c->status) {
                                            'completed' => 'border-green-200 bg-green-100 text-green-700',
                                            'active' => 'border-blue-200 bg-blue-100 text-blue-700',
                                            'pending' => 'border-amber-200 bg-amber-100 text-amber-700',
                                            'expired' => 'border-gray-200 bg-gray-100 text-gray-500',
                                            'cancelled' => 'border-red-200 bg-red-100 text-red-600',
                                            default => 'border-gray-200 bg-gray-100 text-gray-600',
                                        } }}">
                                        {{ ['completed' => '已完成', 'active' => '进行中', 'pending' => '待触发', 'expired' => '已过期', 'cancelled' => '已取消'][$c->status] ?? $c->status }}
                                    </span>
                                </td>
                                <td class="px-4 py-3 {{ $adminListSecondaryTextClass }}">
                                    {{ $c->ceremony_at?->format('Y-m-d H:i') }}
                                </td>
                                <td class="px-4 py-3 text-center">
                                @if ($c->total_amount > 0)
                                    <a href="{{ route('admin.marriages.claim-detail', $c->id) }}"
                                        class="{{ $adminListActionButtonClass }} bg-indigo-50 text-indigo-600 hover:bg-indigo-600 hover:text-white">明细</a>
                                @else
                                    <span class="text-gray-300 text-xs">—</span>
                                @endif
                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="9" class="{{ $adminListEmptyClass }}">暂无婚礼记录</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
            @if ($ceremonies->hasPages())
                <div class="{{ $adminListPaginationClass }}">{{ $ceremonies->links() }}</div>
            @endif
        </div>
    </div>

@endsection
