@extends('layouts.frontend')

@section('title', $portfolio->title . ' — NSMA')

@section('content')

<section class="py-12 lg:py-16">
    <div class="max-w-6xl mx-auto px-4 lg:px-8">
        <a href="{{ route('portfolio.index') }}" class="inline-flex items-center gap-2 text-sm text-gray-500 hover:text-nsma-red mb-6">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/></svg>
            Бүх ажлууд
        </a>

        <div class="grid lg:grid-cols-3 gap-8 mb-10">
            <div class="lg:col-span-2">
                <img src="{{ $portfolio->coverImageUrl() }}" alt="{{ $portfolio->title }}" class="w-full rounded-2xl object-cover max-h-[500px]" onerror="this.style.background='linear-gradient(135deg,#0F1729,#FF3D3D)'; this.removeAttribute('src')">
            </div>
            <div class="lg:col-span-1 bg-gray-50 rounded-2xl p-6">
                <h1 class="text-2xl lg:text-3xl font-black mb-2">{{ $portfolio->title }}</h1>
                @if($portfolio->subtitle) <p class="text-gray-600 mb-4">{{ $portfolio->subtitle }}</p> @endif
                <dl class="space-y-3 text-sm">
                    @if($portfolio->client_name)
                    <div class="flex justify-between border-b border-gray-200 pb-2">
                        <dt class="text-gray-500">Харилцагч</dt><dd class="font-semibold">{{ $portfolio->client_name }}</dd>
                    </div>
                    @endif
                    @if($portfolio->category)
                    <div class="flex justify-between border-b border-gray-200 pb-2">
                        <dt class="text-gray-500">Ангилал</dt><dd class="font-semibold">{{ $portfolio->category->name }}</dd>
                    </div>
                    @endif
                    @if($portfolio->completed_at)
                    <div class="flex justify-between">
                        <dt class="text-gray-500">Огноо</dt><dd class="font-semibold">{{ $portfolio->completed_at->format('Y/m') }}</dd>
                    </div>
                    @endif
                </dl>
            </div>
        </div>

        @if($portfolio->description)
            <div class="prose prose-lg max-w-none mb-10">
                {!! $portfolio->description !!}
            </div>
        @endif

        @if(! empty($portfolio->galleryUrls()))
            <div class="grid grid-cols-2 lg:grid-cols-3 gap-4">
                @foreach($portfolio->galleryUrls() as $g)
                    <div class="aspect-[4/3] rounded-xl overflow-hidden">
                        <img src="{{ $g }}" alt="" class="w-full h-full object-cover">
                    </div>
                @endforeach
            </div>
        @endif
    </div>
</section>

@if($related->count())
<section class="py-16 bg-gray-50">
    <div class="max-w-7xl mx-auto px-4 lg:px-8">
        <h3 class="text-2xl font-bold mb-8">Холбогдох ажлууд</h3>
        <div class="grid md:grid-cols-3 gap-6">
            @foreach($related as $r)
                <a href="{{ route('portfolio.show', $r->slug) }}" class="block aspect-[4/5] rounded-xl overflow-hidden relative group">
                    <img src="{{ $r->coverImageUrl() }}" alt="" class="w-full h-full object-cover">
                    <div class="absolute inset-0 bg-gradient-to-t from-black/80 to-transparent flex items-end p-5">
                        <h4 class="text-white font-bold">{{ $r->title }}</h4>
                    </div>
                </a>
            @endforeach
        </div>
    </div>
</section>
@endif

@endsection
