<x-layout :title="'搜索: ' . $query . ' - Muse'">
    <!-- Search Header -->
    <section class="relative overflow-hidden">
        <div class="absolute inset-0 bg-gradient-to-br from-rose-50 via-fuchsia-50/50 to-indigo-50"></div>
        
        <div class="relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12 lg:py-20">
            <div class="text-center max-w-2xl mx-auto">
                <div class="inline-flex items-center justify-center w-16 h-16 bg-stone-100 rounded-full mb-6">
                    <svg class="w-8 h-8 text-stone-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
                    </svg>
                </div>
                
                @if($query)
                    <h1 class="font-serif text-3xl sm:text-4xl font-bold text-stone-900 mb-4">
                        搜索结果: "{{ $query }}"
                    </h1>
                    <p class="text-stone-500">找到 {{ $posts->total() }} 篇相关文章</p>
                @else
                    <h1 class="font-serif text-3xl sm:text-4xl font-bold text-stone-900 mb-4">
                        搜索文章
                    </h1>
                @endif
                
                <!-- Search Form -->
                <form action="{{ route('search') }}" method="GET" class="mt-8 max-w-md mx-auto">
                    <div class="relative">
                        <input type="text" name="q" value="{{ $query }}" placeholder="输入关键词搜索..."
                               class="w-full pl-12 pr-4 py-4 text-lg bg-white border-0 rounded-2xl shadow-lg focus:ring-2 focus:ring-fuchsia-500/50 transition-all">
                        <svg class="absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-stone-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
                        </svg>
                    </div>
                </form>
            </div>
        </div>
    </section>
    
    <!-- Categories Pills -->
    @if($categories->isNotEmpty())
        <section class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
            <div class="flex flex-wrap items-center justify-center gap-3">
                <a href="{{ route('home') }}" 
                   class="px-5 py-2.5 text-sm font-medium rounded-full bg-white text-stone-700 hover:bg-stone-100 shadow-sm transition-all duration-300">
                    全部
                </a>
                @foreach($categories as $cat)
                    <a href="{{ route('category', $cat) }}" 
                       class="px-5 py-2.5 text-sm font-medium rounded-full bg-white text-stone-700 hover:bg-stone-100 shadow-sm transition-all duration-300">
                        {{ $cat->name }}
                    </a>
                @endforeach
            </div>
        </section>
    @endif
    
    <!-- Posts Grid -->
    <section class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pb-16">
        @if($posts->isNotEmpty())
            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 lg:gap-8">
                @foreach($posts as $post)
                    <x-post-card :post="$post" />
                @endforeach
            </div>
            
            <!-- Pagination -->
            <div class="mt-12">
                {{ $posts->withQueryString()->links() }}
            </div>
        @elseif($query)
            <div class="text-center py-20">
                <div class="w-20 h-20 mx-auto mb-6 bg-stone-100 rounded-full flex items-center justify-center">
                    <svg class="w-10 h-10 text-stone-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                    </svg>
                </div>
                <h3 class="text-xl font-medium text-stone-900 mb-2">未找到相关文章</h3>
                <p class="text-stone-500">尝试使用其他关键词搜索</p>
            </div>
        @endif
    </section>
</x-layout>

