@extends('layouts.app')

@section('title', $news->title)

@section('content')
<!-- Page Header -->
<section class="bg-gradient-to-r from-primary-600 to-primary-700 py-16">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <a href="{{ route('news') }}" class="inline-flex items-center text-primary-100 hover:text-white mb-4">
            <svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/></svg>
            Back to News
        </a>
        <h1 class="text-3xl md:text-4xl font-bold text-white">{{ $news->title }}</h1>
        <p class="text-primary-100 mt-2">{{ $news->published_at?->format('F d, Y') ?? $news->created_at->format('F d, Y') }}</p>
    </div>
</section>

<section class="py-12">
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
        <article class="bg-white rounded-xl shadow-sm overflow-hidden">
            @if($news->image)
            <img src="{{ Storage::url($news->image) }}" alt="{{ $news->title }}" class="w-full h-64 md:h-96 object-cover">
            @endif
            <div class="p-6 lg:p-8">
                <div class="prose prose-primary max-w-none">
                    {!! $news->content !!}
                </div>
            </div>
        </article>

        @if($related->count() > 0)
        <div class="mt-12">
            <h2 class="text-2xl font-bold text-gray-900 mb-6">Related News</h2>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                @foreach($related as $item)
                <a href="{{ route('news.detail', $item->slug) }}" class="group bg-white rounded-xl shadow-sm overflow-hidden hover:shadow-lg transition">
                    @if($item->image)
                    <img src="{{ Storage::url($item->image) }}" alt="{{ $item->title }}" class="w-full h-32 object-cover">
                    @else
                    <div class="w-full h-32 bg-gradient-to-br from-primary-100 to-primary-200"></div>
                    @endif
                    <div class="p-4">
                        <p class="text-xs text-gray-500 mb-1">{{ $item->published_at?->format('M d, Y') }}</p>
                        <h3 class="font-medium text-gray-900 group-hover:text-primary-600 transition line-clamp-2">{{ $item->title }}</h3>
                    </div>
                </a>
                @endforeach
            </div>
        </div>
        @endif
    </div>
</section>
@endsection
