@extends('layouts.admin', ['title' => 'إدارة الفئات | RaseedNow'])

@section('content')
    <section class="lc-page-shell">
        <div class="section-heading">
            <div>
                <span>Catalog</span>
                <h1>الفئات</h1>
            </div>
            <div class="flex flex-wrap gap-2">
                <a class="secondary-button" href="{{ route('admin.dashboard') }}">لوحة الإدارة</a>
                <a class="primary-button" href="{{ route('admin.categories.create') }}">فئة جديدة</a>
            </div>
        </div>

        @if(session('status'))
            <div class="mt-4 rounded border border-green-200 bg-green-50 p-3 text-sm text-green-700">{{ session('status') }}</div>
        @endif

        <form class="mt-5 flex gap-2" method="GET">
            <input class="h-11 flex-1 rounded border border-[#dfe2ea] px-4" name="q" value="{{ $query }}" placeholder="بحث في الفئات">
            <button class="secondary-button" type="submit">بحث</button>
        </form>

        <div class="surface mt-5 overflow-hidden p-4">
            <div class="ac-entity-list">
            @foreach($categories as $category)
                <div class="ac-entity-card category-card" style="--entity-color: {{ $category->color }}">
                    <div class="ac-entity-main">
                        <span class="ac-entity-icon" style="background: {{ $category->color }}"></span>
                        <div>
                            <strong>{{ $category->name_ar }}</strong>
                            <small>{{ $category->slug }}</small>
                        </div>
                    </div>
                    <div class="ac-entity-meta">
                        <span class="ac-badge blue">{{ $category->games_count }} لعبة</span>
                    </div>
                    <div class="ac-actions">
                        <a class="secondary-button info" href="{{ route('admin.categories.edit', $category) }}">تعديل</a>
                        <form method="POST" action="{{ route('admin.categories.destroy', $category) }}">
                            @csrf
                            @method('DELETE')
                            <button class="secondary-button danger" type="submit">تعطيل</button>
                        </form>
                    </div>
                </div>
            @endforeach
            </div>
            <div class="mt-4">{{ $categories->links() }}</div>
        </div>
    </section>
@endsection
