@extends('admin.layouts.app')
@section('title', 'Subscription Plans')
@section('content')
<div class="page-header d-print-none">
    <div class="container-xl">
        <div class="row g-2 align-items-center">
            <div class="col"><h2 class="page-title">Subscription Plans</h2></div>
            <div class="col-auto"><a href="{{ route('admin.subscriptions.create') }}" class="btn btn-primary">+ Add Plan</a></div>
        </div>
    </div>
</div>
<div class="page-body">
    <div class="row row-deck row-cards">
        @forelse($plans as $plan)
        <div class="col-md-4">
            <div class="card">
                <div class="card-body">
                    <div class="d-flex justify-content-between align-items-start mb-3">
                        <h3 class="mb-0">{{ $plan->name }}</h3>
                        <span class="badge bg-{{ $plan->is_active?'success':'secondary' }}-lt">{{ $plan->is_active?'Active':'Inactive' }}</span>
                    </div>
                    <div class="h2 text-primary mb-1">₹{{ number_format($plan->price, 2) }}</div>
                    <div class="text-muted mb-3">{{ $plan->duration_days }} days</div>
                    @if($plan->description)<p class="text-muted">{{ $plan->description }}</p>@endif
                    @if($plan->benefits)
                    <ul class="list-unstyled mb-3">
                        @foreach($plan->benefits as $benefit)
                        <li class="d-flex align-items-center gap-2 mb-1">
                            <span class="text-success">✓</span> {{ $benefit }}
                        </li>
                        @endforeach
                    </ul>
                    @endif
                    <div class="text-muted small mb-3">{{ $plan->user_subscriptions_count }} active subscribers</div>
                    <div class="d-flex gap-2">
                        <a href="{{ route('admin.subscriptions.edit', $plan) }}" class="btn btn-sm btn-outline-secondary">Edit</a>
                        <form action="{{ route('admin.subscriptions.destroy', $plan) }}" method="POST">
                            @csrf @method('DELETE')
                            <button class="btn btn-sm btn-outline-danger" onclick="return confirm('Delete this plan?')">Delete</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        @empty
        <div class="col-12">
            <div class="card">
                <div class="card-body text-center py-5">
                    <div class="text-muted mb-3">No subscription plans yet</div>
                    <a href="{{ route('admin.subscriptions.create') }}" class="btn btn-primary">Create First Plan</a>
                </div>
            </div>
        </div>
        @endforelse
    </div>
</div>
@endsection
