<x-app-layout>
    <x-slot name="header">
        <x-admin.partials.page-header title="Standards" subtitle="Manage standard → subject → chapter → topic hierarchy">
            <x-slot name="actions">
                <a href="{{ route('admin.standards.create') }}" class="admin-btn-primary">
                    <svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
                    Add Standard
                </a>
            </x-slot>
        </x-admin.partials.page-header>
    </x-slot>

    <div class="admin-page">
        @include('admin.partials.alert')

        <div class="admin-card">
            <div class="admin-card-top"></div>
            <div class="admin-card-header">
                <div>
                    <h3 class="font-bold text-slate-900">All Standards</h3>
                    <p class="text-xs text-slate-500 mt-0.5">{{ $standards->count() }} standards configured</p>
                </div>
            </div>
            <div class="admin-table-wrap">
                <table class="admin-table">
                    <thead>
                        <tr>
                            <th>Standard</th>
                            <th>Subjects</th>
                            <th>Order</th>
                            <th>Status</th>
                            <th class="text-right">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse ($standards as $standard)
                            <tr>
                                <td class="font-semibold text-slate-900">{{ $standard->name }}</td>
                                <td><span class="admin-badge-slate">{{ $standard->subjects_count }} subjects</span></td>
                                <td>{{ $standard->sort_order }}</td>
                                <td>
                                    @if ($standard->is_active)
                                        <span class="admin-badge-green">Active</span>
                                    @else
                                        <span class="admin-badge-slate">Inactive</span>
                                    @endif
                                </td>
                                <td class="text-right">
                                    <div class="admin-action-group justify-end">
                                        <a href="{{ route('admin.standards.subjects.index', $standard) }}" class="admin-action-icon-btn admin-action-icon-btn--view" title="Subjects" aria-label="Subjects">
                                            <svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16"/></svg>
                                        </a>
                                        <x-admin.action-edit :href="route('admin.standards.edit', $standard)" label="Edit standard" />
                                        <x-admin.action-delete :action="route('admin.standards.destroy', $standard)" label="Delete standard" confirm="Delete standard and all related content?" />
                                    </div>
                                </td>
                            </tr>
                        @empty
                            @include('admin.partials.empty-row', ['colspan' => 5, 'message' => 'No standards yet', 'hint' => 'Add standards or run the database seeder.'])
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</x-app-layout>
