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

@section('title', $category->title_ps ?? $category->title)

@section('page_title', $category->title_ps ?? $category->title)

@section('main_container')
<div class="container" dir="rtl">
    {{-- Header with category name and back button --}}
    <div class="d-flex align-items-center justify-content-between mt-3 mb-4">
        <div class="section-header" style="margin-bottom: 0;">
            <i class="fas fa-folder-open"></i>
            <h3>{{ $category->title_ps ?? $category->title }}</h3>
        </div>
        <a href="{{ route('public.categories') }}" class="btn btn-outline-secondary rounded-pill">
            <i class="fas fa-arrow-right ms-1"></i> ټولې کټګورۍ
        </a>
    </div>

    {{-- Poetry count --}}
    <p class="text-muted mb-4">
        <i class="fas fa-feather-alt"></i> ټول شعرونه: {{ $poetries->total() }}
    </p>

    {{-- Poetry list --}}
    @if($poetries->count() > 0)
        <div class="row">
            @foreach($poetries as $poetry)
                <div class="col-12 col-md-6 mb-3">
                    <div class="folk-item poetry-item">
                        <a href="{{ route('public.poet_poetry_details_single', $poetry->id) }}" class="folk-link" style="flex-direction: column; align-items: start; gap: 5px;">
                            <div class="d-flex w-100 align-items-center">
                                <i class="fas fa-star folk-icon" style="font-size: 1.5rem;"></i>
                                <span class="fw-bold" style="font-size: 1.1rem;">{{ $poetry->title ?? 'بې نوم' }}</span>
                                <i class="fas fa-arrow-left folk-arrow"></i>
                            </div>
                            <div class="d-flex w-100 text-muted small">
                                <span><i class="fas fa-user ms-1"></i> {{ $poetry->poet->name ?? 'نامعلوم شاعر' }}</span>
                                @if($poetry->created_at)
                                    <span class="me-3"><i class="fas fa-calendar ms-1"></i> {{ $poetry->created_at->format('Y/m/d') }}</span>
                                @endif
                            </div>
                            @if($poetry->description)
                                <p class="text-muted mt-2 mb-0 small">{{ Str::limit($poetry->description, 80) }}</p>
                            @endif
                        </a>
                    </div>
                </div>
            @endforeach
        </div>

        {{-- Pagination --}}
        <div class="d-flex justify-content-center mt-4">
            {{ $poetries->links('pagination::bootstrap-4') }}
        </div>
    @else
        <div class="alert alert-info text-center">
            <i class="fas fa-info-circle"></i> په دې کټګورۍ کې تر اوسه شعر نشته.
        </div>
    @endif

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

{{-- Bottom Navigation --}}
<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>
</nav>
@endsection

