<x-admin-layout>
    <x-slot name="header">
        <div class="flex justify-between items-center">
            <div>
                <h2 class="font-semibold text-lg text-gray-800 dark:text-gray-200 leading-tight">
                    <i class="fas fa-tachometer-alt mr-2"></i>{{ __('Pachete Reseller') }}
                </h2>
                <p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
                    <a href="{{ route('admin.dashboard') }}" class="text-blue-600 dark:text-blue-400 hover:underline">Dashboard</a>
                    <span class="mx-2">/</span>
                    <span>Pachete Reseller</span>
                </p>
            </div>
            <a href="{{ route('admin.reseller-plans.create') }}" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg inline-flex items-center">
                <i class="fas fa-plus mr-2"></i>
                Pachet Nou
            </a>
        </div>
    </x-slot>

    <div class="py-6">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            @if (session('success'))
                <div class="mb-4 bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative" role="alert">
                    <span class="block sm:inline">{{ session('success') }}</span>
                </div>
            @endif

            @if (session('error'))
                <div class="mb-4 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
                    <span class="block sm:inline">{{ session('error') }}</span>
                </div>
            @endif

            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                @forelse($resellerPlans as $plan)
                    <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                        <div class="p-6">
                            <div class="flex justify-between items-start mb-4">
                                <div>
                                    <h3 class="text-xl font-bold text-gray-900 dark:text-gray-100">
                                        {{ $plan->name }}
                                    </h3>
                                    <p class="text-sm text-gray-600 dark:text-gray-400">
                                        {{ $plan->resellers_count }} reselleri
                                    </p>
                                </div>
                                <span class="px-3 py-1 text-xs font-semibold rounded-full {{ $plan->is_active ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-800' }}">
                                    {{ $plan->is_active ? 'Activ' : 'Inactiv' }}
                                </span>
                            </div>

                            <div class="mb-4">
                                <div class="text-3xl font-bold text-purple-600 dark:text-purple-400">
                                    @if($plan->price > 0)
                                        {{ number_format($plan->price, 2) }} RON
                                        <span class="text-sm text-gray-600 dark:text-gray-400">/lună</span>
                                    @else
                                        GRATUIT
                                    @endif
                                </div>
                            </div>

                            <div class="space-y-2 mb-4">
                                <div class="flex items-center text-sm text-gray-700 dark:text-gray-300">
                                    <i class="fas fa-users w-5 text-blue-600"></i>
                                    <span class="ml-2">Max {{ $plan->max_clients }} clienți</span>
                                </div>
                                <div class="flex items-center text-sm text-gray-700 dark:text-gray-300">
                                    <i class="fas fa-globe w-5 text-green-600"></i>
                                    <span class="ml-2">{{ $plan->dns_zones_per_client }} zone DNS / client</span>
                                </div>
                                <div class="flex items-center text-sm text-gray-700 dark:text-gray-300">
                                    <i class="fas fa-sitemap w-5 text-orange-600"></i>
                                    <span class="ml-2">{{ $plan->subdomains_per_client }} subdomenii / client</span>
                                </div>
                                <div class="flex items-center text-sm text-gray-700 dark:text-gray-300">
                                    <i class="fas fa-server w-5 text-indigo-600"></i>
                                    <span class="ml-2">{{ $plan->nameservers_per_client }} nameservere / client</span>
                                </div>
                            </div>

                            @if($plan->description)
                                <p class="text-sm text-gray-600 dark:text-gray-400 mb-4">{{ $plan->description }}</p>
                            @endif

                            <div class="flex gap-2">
                                <a href="{{ route('admin.reseller-plans.show', $plan) }}" class="flex-1 inline-flex items-center justify-center px-4 py-2 rounded-lg bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 hover:bg-blue-100 dark:hover:bg-blue-900/40 border border-blue-200 dark:border-blue-800 transition text-sm font-medium">
                                    <i class="fas fa-eye mr-1"></i> Detalii
                                </a>
                                <a href="{{ route('admin.reseller-plans.edit', $plan) }}" class="flex-1 inline-flex items-center justify-center px-4 py-2 rounded-lg bg-indigo-50 dark:bg-indigo-900/20 text-indigo-600 dark:text-indigo-400 hover:bg-indigo-100 dark:hover:bg-indigo-900/40 border border-indigo-200 dark:border-indigo-800 transition text-sm font-medium">
                                    <i class="fas fa-edit mr-1"></i> Editează
                                </a>
                                @if($plan->resellers_count == 0)
                                    <form action="{{ route('admin.reseller-plans.destroy', $plan) }}" method="POST" class="flex-1" onsubmit="return confirm('Sigur vrei să ștergi pachetul {{ $plan->name }}?');">
                                        @csrf
                                        @method('DELETE')
                                        <button type="submit" class="w-full inline-flex items-center justify-center px-4 py-2 rounded-lg bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 hover:bg-red-100 dark:hover:bg-red-900/40 border border-red-200 dark:border-red-800 transition text-sm font-medium">
                                            <i class="fas fa-trash mr-1"></i> Șterge
                                        </button>
                                    </form>
                                @else
                                    <button disabled class="flex-1 bg-gray-400 text-white px-4 py-2 rounded-lg text-sm cursor-not-allowed" title="Nu poți șterge un pachet cu reselleri">
                                        <i class="fas fa-lock mr-1"></i> Blocat
                                    </button>
                                @endif
                            </div>
                        </div>
                    </div>
                @empty
                    <div class="col-span-3 bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg p-6">
                        <p class="text-center text-gray-600 dark:text-gray-400">
                            Nu există pachete reseller create.
                            <a href="{{ route('admin.reseller-plans.create') }}" class="text-blue-600 hover:text-blue-700">Creează primul pachet</a>
                        </p>
                    </div>
                @endforelse
            </div>
        </div>
    </div>
</x-admin-layout>
