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

@section('title', ($category->name_ps ?? $category->name_en ?? 'کټګوري') . ' | تفصیلات')

@section('page_title', $category->name_ps ?? $category->name_en ?? 'کټګوري')

@section('main_container')
<div class="container" dir="rtl">
    {{-- Back button --}}
    <div class="mb-3">
        <a href="{{ url()->previous() }}" class="btn-outline-secondary rounded-pill">
            <i class="fas fa-arrow-right ms-1"></i> شاته
        </a>
    </div>

    {{-- Category header card --}}
    <div class="century-card mb-4 p-4">
        <div class="d-flex align-items-center gap-3">
            <i class="fas fa-folder-open" style="font-size: 2.5rem; color: var(--adabi-gold);"></i>
            <div>
                <h2 class="fw-bold" style="color: var(--adabi-dark);">{{ $category->name_ps ?? $category->name_en }}</h2>
                <p class="text-muted mb-0">{{ $poetries->count() }} شعرونه</p>
            </div>
        </div>
    </div>

    {{-- Search input --}}
    <div class="search-elegant mb-4 p-3">
        <div class="input-icon-group">
            <i class="fas fa-search"></i>
            <input type="text" id="poetrySearch" class="form-control" placeholder="د شعر په لټه کې یاست؟ دلته ولیکئ...">
        </div>
    </div>

    {{-- Poetry list --}}
    <div id="poetryList">
        @if($poetries->count() > 0)
            @php $i = 1; @endphp
            @foreach($poetries as $poetry)
                <div class="folk-item poetry-item mb-3"
                     data-title="{{ $poetry->title }}"
                     data-number="{{ $i }}">
                    <a href="{{ route('public.public_poetry_details', $poetry->id) }}" class="folk-link">
                        <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">{{ $category->title_ps ?? 'شماره' }} {{ $i }}</span>
                            <i class="fas fa-arrow-left folk-arrow"></i>
                        </div>
                        <div class="d-flex w-100 text-muted small mt-1">
                            <span><i class="fas fa-tag ms-1"></i> {{ $poetry->title }}</span>
                        </div>
                    </a>
                </div>
                @php $i++; @endphp
            @endforeach
        @else
            <div class="alert alert-info text-center">
                <i class="fas fa-info-circle"></i> په دې کټګورۍ کې تر اوسه شعر نشته.
            </div>
        @endif
    </div>

    {{-- No results dynamic message --}}
    <div id="noResults" class="alert alert-info text-center" style="display: none;">
        <i class="fas fa-search"></i> ستاسو د لټون سره سم هیچ شعر و نه موندل شو.
    </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>
</div>
@endsection

