@php
    if (Auth('admin')->User()->dashboard_style == 'light') {
        $text = 'dark';
        $bg = 'light';
    } else {
        $text = 'light';
        $bg = 'dark';
    }
@endphp
@extends('layouts.app')
@section('content')
    @include('admin.topmenu')
    @include('admin.sidebar')
    <div class="main-panel">
        <div class="content">
            <div class="page-inner">
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="d-flex justify-content-between align-items-center mb-4">
                                    <div>
                                        <h1 class="title1 text-{{ $text }}">VIP Fan Card Plans</h1>
                                        <p class="text-{{ $text }} opacity-75">Manage membership tiers and pricing</p>
                                    </div>
                                    <a href="{{ route('admin.fan-card-plans.create') }}" class="btn btn-primary">
                                        <i class="fa fa-plus"></i> Add New Plan
                                    </a>
                                </div>
                                <x-danger-alert />
                                <x-success-alert />
                            </div>
                        </div>

                        @if($plans->count() > 0)
                            <div class="row">
                                @foreach($plans as $plan)
                                    <div class="col-md-4 mb-4">
                                        <div class="card shadow-sm h-100">
                                            <div class="card-body">
                                                <div class="d-flex justify-content-between align-items-start mb-3">
                                                    <div>
                                                        <h4 class="text-{{ $text }} mb-1">{{ $plan->name }}</h4>
                                                        @if($plan->is_featured)
                                                            <span class="badge badge-success">Recommended</span>
                                                        @endif
                                                        @if(!$plan->is_active)
                                                            <span class="badge badge-secondary">Inactive</span>
                                                        @endif
                                                    </div>
                                                    <div class="dropdown">
                                                        <button class="btn btn-sm btn-{{ $bg }}" type="button" data-toggle="dropdown">
                                                            <i class="fa fa-ellipsis-v"></i>
                                                        </button>
                                                        <div class="dropdown-menu dropdown-menu-right">
                                                            <a class="dropdown-item" href="{{ route('admin.fan-card-plans.edit', $plan->id) }}">
                                                                <i class="fa fa-edit"></i> Edit
                                                            </a>
                                                            <form action="{{ route('admin.fan-card-plans.toggle-status', $plan->id) }}" method="POST" class="d-inline">
                                                                @csrf
                                                                @method('PATCH')
                                                                <button type="submit" class="dropdown-item">
                                                                    <i class="fa fa-{{ $plan->is_active ? 'eye-slash' : 'eye' }}"></i> 
                                                                    {{ $plan->is_active ? 'Deactivate' : 'Activate' }}
                                                                </button>
                                                            </form>
                                                            <div class="dropdown-divider"></div>
                                                            <form action="{{ route('admin.fan-card-plans.destroy', $plan->id) }}" method="POST" 
                                                                  onsubmit="return confirm('Are you sure you want to delete this plan?');">
                                                                @csrf
                                                                @method('DELETE')
                                                                <button type="submit" class="dropdown-item text-danger">
                                                                    <i class="fa fa-trash"></i> Delete
                                                                </button>
                                                            </form>
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="mb-3">
                                                    <h2 class="text-{{ $text }}">
                                                        {{ $settings->currency }}{{ number_format($plan->price, 2) }}
                                                        <small class="text-muted">/year</small>
                                                    </h2>
                                                    <p class="text-muted small">+ {{ $settings->currency }}9.95 processing fee</p>
                                                </div>

                                                @if($plan->description)
                                                    <p class="text-{{ $text }} mb-3">{{ $plan->description }}</p>
                                                @endif

                                                @if($plan->discount_percentage > 0)
                                                    <div class="alert alert-info py-2 px-3 mb-3">
                                                        <i class="fa fa-percent"></i> {{ $plan->discount_percentage }}% discount on bookings
                                                    </div>
                                                @endif

                                                @if($plan->benefits && count($plan->benefits) > 0)
                                                    <div class="mb-3">
                                                        <h6 class="text-{{ $text }} mb-2">Benefits:</h6>
                                                        <ul class="list-unstyled mb-0">
                                                            @foreach($plan->benefits as $benefit)
                                                                <li class="mb-1 text-{{ $text }}">
                                                                    <i class="fa fa-check text-success"></i> {{ $benefit }}
                                                                </li>
                                                            @endforeach
                                                        </ul>
                                                    </div>
                                                @endif

                                                <div class="mt-3 pt-3 border-top">
                                                    <small class="text-muted">
                                                        <i class="fa fa-sort"></i> Order: {{ $plan->sort_order }} | 
                                                        <i class="fa fa-calendar"></i> Created: {{ $plan->created_at->format('M d, Y') }}
                                                    </small>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                @endforeach
                            </div>

                            <div class="mt-4">
                                {{ $plans->links() }}
                            </div>
                        @else
                            <div class="card">
                                <div class="card-body text-center py-5">
                                    <i class="fa fa-credit-card fa-3x text-muted mb-3"></i>
                                    <h4 class="text-{{ $text }}">No Fan Card Plans Yet</h4>
                                    <p class="text-muted mb-4">Create your first VIP fan card plan to get started</p>
                                    <a href="{{ route('admin.fan-card-plans.create') }}" class="btn btn-primary">
                                        <i class="fa fa-plus"></i> Create First Plan
                                    </a>
                                </div>
                            </div>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
