@extends('admin.layouts.app')

@section('title', 'Hero баннер')
@section('page_title', 'Hero баннерууд')

@section('content')

<div class="flex justify-end mb-6">
    <a href="{{ route('admin.heroes.create') }}" class="bg-nsma-red text-white font-semibold px-4 py-2 rounded-lg">+ Шинэ Hero</a>
</div>

<div class="grid md:grid-cols-2 gap-6">
    @forelse($heroes as $h)
        <div class="bg-nsma-dark text-white rounded-2xl p-6">
            <div class="flex items-center justify-between mb-4">
                <span class="text-xs px-2 py-1 rounded {{ $h->is_active ? 'bg-green-500' : 'bg-gray-600' }}">{{ $h->is_active ? 'Идэвхтэй' : 'Идэвхгүй' }}</span>
                <span class="text-xs text-gray-400">Эрэмбэ: {{ $h->sort_order }}</span>
            </div>
            <h3 class="text-2xl font-black mb-1">{{ $h->title_line_1 }}</h3>
            <h3 class="text-2xl font-black text-nsma-red mb-1">{{ $h->title_line_2 }}</h3>
            <h3 class="text-2xl font-black mb-3">{{ $h->title_line_3 }}</h3>
            <p class="text-sm text-gray-300 mb-4 line-clamp-2">{{ $h->description }}</p>
            @if($h->sideImageUrls())
                <div class="grid grid-cols-3 gap-1 mb-4">
                    @foreach(array_slice($h->sideImageUrls(), 0, 3) as $img)
                        <img src="{{ $img }}" class="w-full aspect-square object-cover rounded">
                    @endforeach
                </div>
            @endif
            <div class="flex gap-2">
                <a href="{{ route('admin.heroes.edit', $h) }}" class="px-3 py-1 text-xs bg-white text-nsma-dark rounded font-semibold">Засах</a>
                <form action="{{ route('admin.heroes.destroy', $h) }}" method="POST" class="inline" onsubmit="return confirm('Устгах уу?')">
                    @csrf @method('DELETE')
                    <button class="px-3 py-1 text-xs bg-red-500 text-white rounded">Устгах</button>
                </form>
            </div>
        </div>
    @empty
        <p class="col-span-2 text-center text-gray-500 py-12">Hero баннер нэмээгүй байна.</p>
    @endforelse
</div>

@endsection
