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

@section('title', 'کور پاڼه')

@section('page_title', 'لوی لار')

@section('main_container')
    <div class="container" dir="rtl">
        <section class="hero-wrapper hero-lite">
            <div class="hero-pattern"></div>
            <div class="hero-content narrow-content text-center">
                <div class="logo-circle">
                    <img src="{{ asset('front-end/images/sooma.png') }}" alt="سوما">
                </div>
                <span class="hero-kicker">پښتو تاریخي او ادبي شاعرۍ</span>
                <h1 class="hero-title">سوما</h1>
                <p class="hero-lead">یو ساده، سپک او ښکلی ادبي کور چې پکې شاعران، پیړۍ، کټګورۍ او شعرونه په اسانه موندل کېږي.</p>
            </div>
        </section>

        <section class="search-elegant search-panel search-panel-overlap">
            <div class="section-header compact mb-3">
                <i class="fas fa-search"></i>
                <h3>لټون</h3>
            </div>
            <form action="{{ route('public.poetry_search') }}" method="GET">
                <div class="row g-3 align-items-end">
                    <div class="col-12 col-md-3">
                        <label class="form-label">کټګورۍ</label>
                        <div class="input-icon-group">
                            <i class="fas fa-tag"></i>
                            <select name="category_id" class="form-select searchable-select">
                                <option value="any">ټولې کټګورۍ</option>
                                @foreach ($categories ?? [] as $cat)
                                    <option value="{{ $cat->id }}" {{ request('category_id') == $cat->id ? 'selected' : '' }}>{{ $cat->title_ps }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="col-12 col-md-3">
                        <label class="form-label">شاعر</label>
                        <div class="input-icon-group">
                            <i class="fas fa-user"></i>
                            <select name="poet_id" class="form-select searchable-select">
                                <option value="any">ټول شاعران</option>
                                @foreach ($poets ?? [] as $p)
                                    <option value="{{ $p->id }}" {{ request('poet_id') == $p->id ? 'selected' : '' }}>{{ $p->name }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="col-12 col-md-4">
                        <label class="form-label">کلیمه</label>
                        <div class="input-icon-group">
                            <i class="fas fa-feather-alt"></i>
                            <input type="text" name="keyword" class="form-control" placeholder="د شعر، مصرعې یا شاعر نوم..." value="{{ request('keyword') }}">
                        </div>
                    </div>
                    <div class="col-12 col-md-2">
                        <button type="submit" class="btn-gradient w-100"><i class="fas fa-search"></i> پلټنه</button>
                    </div>
                </div>
            </form>
        </section>

        <div class="quick-stats-grid">
            <div class="quick-stat"><strong>{{ ($poets ?? collect())->count() }}</strong><span>شاعران</span></div>
            <div class="quick-stat"><strong>{{ ($centries ?? collect())->count() }}</strong><span>پیړۍ</span></div>
            <div class="quick-stat"><strong>{{ ($categories ?? collect())->count() }}</strong><span>کټګورۍ</span></div>
        </div>

        <div class="section-header">
            <i class="fas fa-star"></i>
            <h3>مخکښ شاعران</h3>
        </div>
        <div class="poets-scroll simple-scroll">
            @foreach ($topPoets ?? $poets->take(8) as $row)
                <article class="poet-card poet-card-soft">
                    <img src="{{ asset('storage/' . $row->image) }}" class="avatar" alt="{{ $row->name }}">
                    <a href="{{ route('public.poet_details', $row->id) }}" class="name">{{ $row->name }}</a>
                </article>
            @endforeach
        </div>

        <div class="section-header">
            <i class="fas fa-hourglass-half"></i>
            <h3>د پیړۍ له مخې</h3>
        </div>
        <div class="century-chips">
            @foreach ($centries as $row)
                <a href="{{ route('public.category_related_general', $row->id) }}" class="chip">{{ $row->number }}</a>
            @endforeach
        </div>

        @foreach ($centries as $centry)
            <section class="century-card century-card-soft">
                <div class="century-heading-row">
                    <h4 class="century-title mb-0">{{ $centry->title_ps }}</h4>
                    <a href="{{ route('public.category_related_general', $centry->id) }}" class="text-link">ټوله پیړۍ</a>
                </div>
                <div class="poet-grid poet-grid-wide">
                    @foreach ($centry->poets->take(12) as $poet)
                        <article class="poet-card poet-card-soft">
                            <img src="{{ asset('storage/' . $poet->image) }}" class="avatar" alt="{{ $poet->name }}">
                            <a href="{{ route('public.poet_details', $poet->id) }}" class="name">{{ $poet->name }}</a>
                        </article>
                    @endforeach
                </div>
            </section>
        @endforeach

        <div class="section-header">
            <i class="fas fa-book-open"></i>
            <h3>د پښتو ولسي ادب</h3>
        </div>
        <div class="folk-grid">
            @foreach ($walasi_adab as $row)
                <article class="folk-item soft-panel">
                    <a href="{{ route('public.public_poetry_cat_details', $row->id) }}" class="folk-link">
                        <span class="folk-link-start"><i class="fas fa-feather-alt folk-icon"></i><span>{{ $row->name_ps }}</span></span>
                        <i class="fas fa-arrow-left folk-arrow"></i>
                    </a>
                </article>
            @endforeach
        </div>

        <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*') ? '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
