<x-app-layout>
    <x-slot name="header">
        <div class="flex justify-between items-center">
            <h2 class="font-semibold text-xl text-gray-800 leading-tight">
                {{ __('Detail Berita') }}
            </h2>
            <div class="flex space-x-2">
                <a href="{{ route('beritas.edit', $berita) }}" class="inline-flex items-center px-4 py-2 bg-yellow-600 text-white text-sm font-medium rounded-lg hover:bg-yellow-700 transition-colors">
                    <i class="fas fa-edit mr-2"></i>
                    Edit
                </a>
                <a href="{{ route('beritas.index') }}" class="inline-flex items-center px-4 py-2 bg-gray-600 text-white text-sm font-medium rounded-lg hover:bg-gray-700 transition-colors">
                    <i class="fas fa-arrow-left mr-2"></i>
                    Kembali
                </a>
            </div>
        </div>
    </x-slot>

    <div class="py-12">
        <div class="max-w-4xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-xl sm:rounded-2xl">
                <!-- Header with Image -->
                @if($berita->gambar)
                    <div class="relative h-64 md:h-80">
                        <img src="{{ asset('storage/' . $berita->gambar) }}" 
                             alt="{{ $berita->judul }}" 
                             class="w-full h-full object-cover">
                        <div class="absolute inset-0 bg-black bg-opacity-40"></div>
                        <div class="absolute bottom-0 left-0 right-0 p-6 text-white">
                            <div class="flex items-center space-x-4 mb-2">
                                @if($berita->status === 'published')
                                    <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-500 text-white">
                                        <i class="fas fa-check-circle mr-1"></i>
                                        Published
                                    </span>
                                @else
                                    <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-500 text-white">
                                        <i class="fas fa-edit mr-1"></i>
                                        Draft
                                    </span>
                                @endif
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-500 text-white">
                                    {{ $berita->kategori }}
                                </span>
                            </div>
                            <h1 class="text-3xl font-bold">{{ $berita->judul }}</h1>
                        </div>
                    </div>
                @else
                    <div class="bg-gray-100 p-6">
                        <div class="flex items-center space-x-4 mb-4">
                            @if($berita->status === 'published')
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
                                    <i class="fas fa-check-circle mr-1"></i>
                                    Published
                                </span>
                            @else
                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800">
                                    <i class="fas fa-edit mr-1"></i>
                                    Draft
                                </span>
                            @endif
                            <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
                                {{ $berita->kategori }}
                            </span>
                        </div>
                        <h1 class="text-3xl font-bold text-gray-800">{{ $berita->judul }}</h1>
                    </div>
                @endif

                <!-- Content -->
                <div class="p-8">
                    <!-- Meta Information -->
                    <div class="flex flex-wrap items-center justify-between text-sm text-gray-500 mb-6 pb-6 border-b border-gray-200">
                        <div class="flex items-center space-x-6">
                            <span class="flex items-center">
                                <i class="fas fa-user mr-2"></i>
                                {{ $berita->penulis }}
                            </span>
                            <span class="flex items-center">
                                <i class="fas fa-calendar mr-2"></i>
                                {{ $berita->created_at->format('d F Y') }}
                            </span>
                            <span class="flex items-center">
                                <i class="fas fa-clock mr-2"></i>
                                {{ $berita->created_at->format('H:i') }}
                            </span>
                        </div>
                        <div class="flex items-center">
                            <i class="fas fa-eye mr-2"></i>
                            <span>Dibuat {{ $berita->created_at->diffForHumans() }}</span>
                        </div>
                    </div>

                    <!-- Summary -->
                    <div class="bg-blue-50 border-l-4 border-blue-400 p-4 mb-6">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fas fa-info-circle text-blue-400"></i>
                            </div>
                            <div class="ml-3">
                                <h3 class="text-sm font-medium text-blue-800">Ringkasan</h3>
                                <div class="mt-2 text-sm text-blue-700">
                                    <p>{{ $berita->ringkasan }}</p>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Content -->
                    <div class="prose prose-lg max-w-none">
                        <div class="whitespace-pre-wrap text-gray-700 leading-relaxed">
                            {{ $berita->isi }}
                        </div>
                    </div>

                    <!-- Footer -->
                    <div class="mt-8 pt-6 border-t border-gray-200">
                        <div class="flex items-center justify-between">
                            <div class="text-sm text-gray-500">
                                <span>Terakhir diperbarui: {{ $berita->updated_at->format('d F Y H:i') }}</span>
                            </div>
                            <div class="flex space-x-2">
                                <a href="{{ route('beritas.edit', $berita) }}" 
                                   class="inline-flex items-center px-4 py-2 text-sm font-medium text-yellow-600 bg-yellow-50 rounded-lg hover:bg-yellow-100 transition-colors">
                                    <i class="fas fa-edit mr-2"></i>
                                    Edit Berita
                                </a>
                                <form action="{{ route('beritas.destroy', $berita) }}" method="POST" class="inline" 
                                      onsubmit="return confirm('Apakah Anda yakin ingin menghapus berita ini?')">
                                    @csrf
                                    @method('DELETE')
                                    <button type="submit" 
                                            class="inline-flex items-center px-4 py-2 text-sm font-medium text-red-600 bg-red-50 rounded-lg hover:bg-red-100 transition-colors">
                                        <i class="fas fa-trash mr-2"></i>
                                        Hapus Berita
                                    </button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</x-app-layout> 
