<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ __('frontend.membership.title') }}</title>
    <style>
        body { font-family: system-ui, sans-serif; max-width: 720px; margin: 2rem auto; padding: 0 1rem; color: #1a2a33; }
        .plan { border: 1px solid #d5dee3; border-radius: 8px; padding: 1rem 1.25rem; margin: 1rem 0; }
        .price { font-size: 1.4rem; font-weight: 700; }
        .meta { color: #5b6b75; font-size: 0.92rem; }
        .btn { display: inline-block; margin-top: 0.75rem; padding: 0.55rem 1rem; background: #0f3d4c; color: #fff; text-decoration: none; border-radius: 6px; }
        .status { background: #eef7f6; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1.25rem; }
    </style>
</head>
<body>
    <h1>{{ __('frontend.membership.title') }}</h1>

    <div class="status">
        @if(($status['active'] ?? false))
            <p>{{ __('frontend.membership.active', ['plan' => $status['plan_name'] ?? '—']) }}</p>
            @if(!empty($status['expires_at']))
                <p class="meta">{{ __('frontend.membership.expires', ['date' => $status['expires_at']]) }}</p>
            @else
                <p class="meta">{{ __('frontend.membership.lifetime') }}</p>
            @endif
        @else
            <p>{{ __('frontend.membership.inactive') }}</p>
        @endif
        <p class="meta"><a href="{{ url('/?action=profile') }}">{{ __('frontend.membership.back_profile') }}</a></p>
    </div>

    @forelse($plans as $plan)
        <article class="plan">
            <h2>{{ $plan->name }}</h2>
            <p class="price">{{ $plan->currency }} {{ $plan->price }}</p>
            <p class="meta">
                @if($plan->duration_days)
                    {{ __('frontend.membership.days', ['days' => $plan->duration_days]) }}
                @else
                    {{ __('frontend.membership.lifetime') }}
                @endif
            </p>
            @if($plan->description)
                <p>{{ $plan->description }}</p>
            @endif
            <a class="btn" href="{{ url('/plugins/payment/checkout').'?'.http_build_query([
                'product_type' => 'membership',
                'product_id' => $plan->id,
                'return_url' => url('/plugins/membership'),
            ]) }}">{{ __('frontend.membership.subscribe') }}</a>
        </article>
    @empty
        <p>{{ __('frontend.membership.no_plans') }}</p>
    @endforelse
</body>
</html>
