@php
    $siteName = AleshaSetting::get('site_name', config('app.name'));
    $tagline  = AleshaSetting::get('site_tagline', '');
    $footerMenu = AleshaMenu::where('location', 'footer')->with('items')->first();
@endphp

<footer class="bg-gray-950 text-gray-400 mt-24">
    <div class="max-w-6xl mx-auto px-4 sm:px-6 py-16">
        <div class="grid grid-cols-1 md:grid-cols-3 gap-10 mb-12">
            {{-- Brand --}}
            <div class="md:col-span-1">
                <a href="/" class="inline-flex items-center gap-2 font-bold text-lg text-white mb-3">
                    <div class="w-7 h-7 rounded-lg bg-indigo-500 flex items-center justify-center">
                        <span class="text-white text-xs font-black">{{ substr($siteName, 0, 1) }}</span>
                    </div>
                    {{ $siteName }}
                </a>
                @if($tagline)
                <p class="text-sm text-gray-500 leading-relaxed">{{ $tagline }}</p>
                @endif
            </div>

            {{-- Footer Nav --}}
            @if($footerMenu && $footerMenu->items->count())
            <div>
                <h4 class="text-xs font-semibold text-gray-300 uppercase tracking-widest mb-4">Navigation</h4>
                <ul class="space-y-2">
                    @foreach($footerMenu->items as $item)
                    <li>
                        <a href="{{ $item->url }}" target="{{ $item->target }}"
                           class="text-sm text-gray-500 hover:text-white transition-colors">
                            {{ $item->label }}
                        </a>
                    </li>
                    @endforeach
                </ul>
            </div>
            @endif

            {{-- Recent Posts --}}
            @php $recentPosts = AleshaPost::ofType('post')->published()->latest('published_at')->take(3)->get(); @endphp
            @if($recentPosts->count())
            <div>
                <h4 class="text-xs font-semibold text-gray-300 uppercase tracking-widest mb-4">Recent Posts</h4>
                <ul class="space-y-3">
                    @foreach($recentPosts as $rp)
                    <li>
                        <a href="/{{ $rp->content_type }}/{{ $rp->slug }}" class="text-sm text-gray-500 hover:text-white transition-colors line-clamp-2 leading-relaxed">
                            {{ $rp->title }}
                        </a>
                        <p class="text-xs text-gray-600 mt-0.5">{{ $rp->published_at?->format('M d, Y') }}</p>
                    </li>
                    @endforeach
                </ul>
            </div>
            @endif
        </div>

        <div class="border-t border-gray-800 pt-8 flex flex-col sm:flex-row items-center justify-between gap-3">
            <p class="text-xs text-gray-600">
                &copy; {{ date('Y') }} {{ $siteName }}. All rights reserved.
            </p>
            <p class="text-xs text-gray-700">
                Powered by <span class="text-gray-500">AleshaCMS</span>
            </p>
        </div>
    </div>
</footer>
