@extends('front-end.layouts.apps')

@section('title', 'کټګورۍ')

@section('page_title', 'کټګورۍ')

@section('main_container')
<div class="container" dir="rtl">
    {{-- Page Header --}}
    <div class="section-header" style="margin-top: 20px;">
        <i class="fas fa-tags"></i>
        <h3>ټولې کټګورۍ</h3>
    </div>

    {{-- Search Filter --}}
    <div class="row justify-content-center mb-4">
        <div class="col-md-8">
            <form action="{{ route('public.categories') }}" method="GET" class="search-elegant p-3">
                <div class="input-group">
                    <span class="input-group-icon"><i class="fas fa-search"></i></span>
                    <input type="text" name="keyword" class="form-control" placeholder="د کټګورۍ نوم دلته ولیکئ..." value="{{ $keyword ?? '' }}">
                </div>
                <div class="text-center mt-3">
                    <button type="submit" class="btn-gradient" style="width: auto; padding: 10px 40px;">لټون</button>
                    @if(request()->has('keyword') && $keyword)
                        <a href="{{ route('public.categories') }}" class="btn btn-outline-secondary me-2">ټول وښایئ</a>
                    @endif
                </div>
            </form>
        </div>
    </div>

    {{-- Regular Poetry Categories --}}
    <div class="section-header">
        <i class="fas fa-book"></i>
        <h3>د شعرونو کټګورۍ</h3>
    </div>

    @if($categories->count() > 0)
        <div class="folk-grid mb-5">
            @foreach($categories as $cat)
                <div class="folk-item">
                    <a href="{{ route('public.poetry_by_category', $cat->id) }}" class="folk-link">
                        <i class="fas fa-folder-open folk-icon"></i>
                        <span>{{ $cat->title_ps ?? $cat->title }}</span>
                        <i class="fas fa-arrow-left folk-arrow"></i>
                    </a>
                </div>
            @endforeach
        </div>
        {{ $categories->appends(['keyword' => $keyword])->links('pagination::bootstrap-4') }}
    @else
        <p class="text-center text-muted py-4">د شعرونو کټګوري ونه موندل شوه.</p>
    @endif

    {{-- Folk Literature Categories --}}
    <div class="section-header">
        <i class="fas fa-leaf"></i>
        <h3>د ولسی ادب کټګورۍ</h3>
    </div>

    @if($publicCategories->count() > 0)
        <div class="folk-grid mb-5">
            @foreach($publicCategories as $pub)
                <div class="folk-item">
                    <a href="{{ route('public.poetry_by_category', $pub->id) }}" class="folk-link">
                        <i class="fas fa-book-open folk-icon"></i>
                        <span>{{ $pub->name_ps ?? $pub->name }}</span>
                        <i class="fas fa-arrow-left folk-arrow"></i>
                    </a>
                </div>
            @endforeach
        </div>
        {{ $publicCategories->appends(['keyword' => $keyword])->links('pagination::bootstrap-4') }}
    @else
        <p class="text-center text-muted py-4">د ولسی ادب کټګوري ونه موندل شوه.</p>
    @endif

    {{-- spacer for bottom nav --}}
    <div style="height: 20px;"></div>
</div>

{{-- Bottom Navigation (same as index) --}}
<nav class="bottom-nav">
    <a href="{{ url('/') }}" class="nav-item {{ request()->is('/') ? 'active' : '' }}">
        <i class="fas fa-home"></i>
        <span>کور</span>
    </a>
    <a href="{{ route('public.categories') }}" class="nav-item {{ request()->is('categories') || request()->is('categories*') ? 'active' : '' }}">
        <i class="fas fa-list-ul"></i>
        <span>کټګورۍ</span>
    </a>
    <a href="{{ route('public.poetry_search') }}" class="nav-item {{ request()->is('poetry/search') ? 'active' : '' }}">
        <i class="fas fa-search"></i>
        <span>لټون</span>
    </a>
    {{-- <a href="{{ route('profile') }}" class="nav-item ...">...</a> --}}
</nav>
@endsection

