@if(!empty($categories) && $categories->isNotEmpty())
<section class="rounded-[24px] border border-white/[0.06] bg-white/[0.025] p-5">
    <div class="mb-4 flex items-center justify-between gap-3">
        <h2 class="text-sm font-semibold uppercase tracking-[0.18em] text-white/45">Categories</h2>
        <span class="text-xs text-white/30">{{ $categories->count() }}</span>
    </div>
    <div class="space-y-1.5">
    @foreach($categories as $cat)
        <a href="{{ route('news.category', $cat->slug) }}" class="flex items-center justify-between rounded-2xl px-3 py-2.5 text-sm text-white/65 transition hover:bg-white/[0.04] hover:text-white">
            <span>{{ $cat->name }}</span>
            <span class="rounded-full border border-white/[0.06] bg-white/[0.04] px-2 py-0.5 text-[11px] text-white/45">{{ number_format((int) ($cat->published_articles_count ?? 0)) }}</span>
        </a>
    @endforeach
    </div>
</section>
@endif

@if(!empty($trending) && $trending->isNotEmpty())
<section class="rounded-[24px] border border-white/[0.06] bg-white/[0.025] p-5">
    <div class="mb-4 flex items-center gap-2 text-sm font-semibold uppercase tracking-[0.18em] text-white/45">
        <i class="fa-solid fa-fire text-[11px] text-rose-300"></i>
        Trending
    </div>
    <div class="space-y-3">
    @foreach($trending as $item)
        <a href="{{ route('news.show', $item->slug) }}" class="block rounded-2xl border border-white/[0.04] bg-black/10 px-4 py-3 transition hover:border-white/[0.08] hover:bg-white/[0.03]">
            <div class="flex items-start justify-between gap-3">
                <span class="text-sm font-medium leading-6 text-white/80">{{ Str::limit($item->title, 70) }}</span>
                <span class="shrink-0 rounded-full border border-sky-400/20 bg-sky-500/10 px-2 py-0.5 text-[11px] text-sky-200">{{ number_format((int) $item->views) }}</span>
            </div>
            <p class="mt-1 text-xs text-white/35">{{ $item->published_at?->diffForHumans() }}</p>
        </a>
    @endforeach
    </div>
</section>
@endif

@if(!empty($tags) && $tags->isNotEmpty())
<section class="rounded-[24px] border border-white/[0.06] bg-white/[0.025] p-5">
    <div class="mb-4 flex items-center gap-2 text-sm font-semibold uppercase tracking-[0.18em] text-white/45">
        <i class="fa-solid fa-tags text-[11px] text-sky-300"></i>
        Topics
    </div>
    <div class="flex flex-wrap gap-2">
    @foreach($tags as $tag)
        <a href="{{ route('news.tag', $tag->slug) }}" class="inline-flex items-center rounded-full border border-white/[0.08] bg-white/[0.03] px-3 py-1.5 text-xs font-medium text-white/60 transition hover:border-white/[0.14] hover:bg-white/[0.06] hover:text-white">#{{ $tag->name }}</a>
    @endforeach
    </div>
</section>
@endif

<section class="rounded-[24px] border border-amber-400/20 bg-amber-500/10 p-5 text-center">
    <p class="text-xs font-semibold uppercase tracking-[0.18em] text-amber-100/70">Stay updated</p>
    <a href="{{ route('news.rss') }}" class="mt-3 inline-flex items-center gap-2 rounded-full border border-amber-300/25 bg-amber-500/10 px-4 py-2 text-sm font-medium text-amber-100 transition hover:bg-amber-500/20" target="_blank" rel="noopener noreferrer">
        <i class="fa-solid fa-rss text-xs"></i>
        RSS Feed
    </a>
</section>
