<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>Pachet: {{ $plan->name }}
                </h2>
                <p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
                    <a href="{{ route('dashboard') }}" class="text-blue-600 dark:text-blue-400 hover:underline">Dashboard</a>
                    <span class="mx-2">/</span>
                    <a href="{{ route('admin.dashboard') }}" class="text-blue-600 dark:text-blue-400 hover:underline">Admin</a>
                    <span class="mx-2">/</span>
                    <a href="{{ route('admin.plans.index') }}" class="text-blue-600 dark:text-blue-400 hover:underline">Pachete</a>
                    <span class="mx-2">/</span>
                    <span>{{ $plan->name }}</span>
                </p>
            </div>
            <div class="flex items-center gap-2">
                <a href="{{ route('admin.plans.edit', $plan) }}" class="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 font-semibold">
                    <i class="fas fa-edit mr-2"></i>Editează
                </a>
                <a href="{{ route('admin.plans.index') }}" class="inline-flex items-center justify-center w-10 h-10 rounded-lg bg-gray-50 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 border border-gray-200 dark:border-gray-700 transition" title="Înapoi">
                    <i class="fas fa-arrow-left"></i>
                </a>
            </div>
        </div>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
            <!-- Plan Details Card -->
            <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6">
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <h3 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">Detalii Pachet</h3>
                            <dl class="space-y-3">
                                <div>
                                    <dt class="text-sm text-gray-600 dark:text-gray-400">Nume</dt>
                                    <dd class="text-lg font-semibold text-gray-900 dark:text-gray-100">{{ $plan->name }}</dd>
                                </div>
                                <div>
                                    <dt class="text-sm text-gray-600 dark:text-gray-400">Slug</dt>
                                    <dd class="text-gray-900 dark:text-gray-100"><code class="bg-gray-100 dark:bg-gray-700 px-2 py-1 rounded">{{ $plan->slug }}</code></dd>
                                </div>
                                <div>
                                    <dt class="text-sm text-gray-600 dark:text-gray-400">Preț</dt>
                                    <dd class="text-2xl font-bold text-indigo-600 dark:text-indigo-400">
                                        @if($plan->price > 0)
                                            {{ number_format($plan->price, 2) }} RON/lună
                                        @else
                                            GRATUIT
                                        @endif
                                    </dd>
                                </div>
                                <div>
                                    <dt class="text-sm text-gray-600 dark:text-gray-400">Status</dt>
                                    <dd>
                                        @if($plan->is_active)
                                            <span class="px-3 py-1 bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200 rounded-full text-sm font-semibold">Activ</span>
                                        @else
                                            <span class="px-3 py-1 bg-gray-200 dark:bg-gray-600 text-gray-800 dark:text-gray-200 rounded-full text-sm font-semibold">Inactiv</span>
                                        @endif
                                    </dd>
                                </div>
                            </dl>
                        </div>

                        <div>
                            <h3 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">Limite Resurse</h3>
                            <div class="space-y-4">
                                <div class="flex items-center justify-between p-4 bg-blue-50 dark:bg-blue-900/30 rounded-lg">
                                    <div class="flex items-center">
                                        <i class="fas fa-globe text-blue-600 dark:text-blue-400 text-2xl mr-3"></i>
                                        <div>
                                            <p class="text-sm text-gray-600 dark:text-gray-400">Zone DNS</p>
                                            <p class="text-2xl font-bold text-gray-900 dark:text-gray-100">{{ $plan->dns_zones_limit }}</p>
                                        </div>
                                    </div>
                                </div>

                                <div class="flex items-center justify-between p-4 bg-green-50 dark:bg-green-900/30 rounded-lg">
                                    <div class="flex items-center">
                                        <i class="fas fa-network-wired text-green-600 dark:text-green-400 text-2xl mr-3"></i>
                                        <div>
                                            <p class="text-sm text-gray-600 dark:text-gray-400">Subdomenii</p>
                                            <p class="text-2xl font-bold text-gray-900 dark:text-gray-100">{{ $plan->subdomains_limit }}</p>
                                        </div>
                                    </div>
                                </div>

                                <div class="flex items-center justify-between p-4 bg-purple-50 dark:bg-purple-900/30 rounded-lg">
                                    <div class="flex items-center">
                                        <i class="fas fa-server text-purple-600 dark:text-purple-400 text-2xl mr-3"></i>
                                        <div>
                                            <p class="text-sm text-gray-600 dark:text-gray-400">Nameservere</p>
                                            <p class="text-2xl font-bold text-gray-900 dark:text-gray-100">{{ $plan->nameservers_limit }}</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    @if($plan->description)
                        <div class="mt-6 pt-6 border-t border-gray-200 dark:border-gray-700">
                            <h4 class="text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Descriere</h4>
                            <p class="text-gray-600 dark:text-gray-400">{{ $plan->description }}</p>
                        </div>
                    @endif
                </div>
            </div>

            <!-- Users with this plan -->
            <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6">
                    <h3 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">
                        Utilizatori cu acest pachet ({{ $plan->users->count() }})
                    </h3>

                    @if($plan->users->count() > 0)
                        <div class="overflow-x-auto">
                            <table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
                                <thead class="bg-gray-50 dark:bg-gray-700">
                                    <tr>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Utilizator</th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Zone DNS</th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Înregistrat</th>
                                        <th class="px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Acțiuni</th>
                                    </tr>
                                </thead>
                                <tbody class="bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700">
                                    @foreach($plan->users as $user)
                                        <tr>
                                            <td class="px-6 py-4 whitespace-nowrap">
                                                <div>
                                                    <div class="font-medium text-gray-900 dark:text-gray-100">{{ $user->name }}</div>
                                                    <div class="text-sm text-gray-600 dark:text-gray-400">{{ $user->email }}</div>
                                                </div>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap text-gray-900 dark:text-gray-100">
                                                {{ $user->dns_zones_count }}
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-600 dark:text-gray-400">
                                                {{ $user->created_at->format('d.m.Y') }}
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap text-right">
                                                <a href="{{ route('admin.users.show', $user) }}" class="text-indigo-600 dark:text-indigo-400 hover:text-indigo-900 dark:hover:text-indigo-300">
                                                    Detalii
                                                </a>
                                            </td>
                                        </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    @else
                        <p class="text-gray-600 dark:text-gray-400 text-center py-8">Niciun utilizator cu acest pachet</p>
                    @endif
                </div>
            </div>
        </div>
    </div>
</x-admin-layout>

