<x-site-layout title="{{ $programme->title }}" meta-description="{{ Str::limit($programme->description, 160) }}">
    {{-- Hero Section — Advocacy Style --}}
    <div class="relative bg-gradient-to-r from-green-700 to-emerald-800 shadow-xl">
        @if($programme->banner_image || $programme->featured_image)
            <div class="absolute inset-0">
                <img src="{{ $programme->banner_image ?? $programme->featured_image }}" 
                     alt="{{ $programme->title }}"
                     class="w-full h-full object-cover opacity-20">
            </div>
        @endif
        <div class="relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
            <div class="text-center">
                <div class="flex flex-wrap justify-center gap-3 mb-4">
                    <span class="inline-block px-4 py-1 bg-white/20 text-white rounded-full text-sm font-semibold">
                        {{ $programme->category->name ?? 'Mentorship Programme' }}
                    </span>
                    @if($programme->is_featured)
                        <span class="inline-block px-4 py-1 bg-yellow-400/90 text-yellow-900 rounded-full text-sm font-semibold">
                            <i class="fas fa-star mr-1"></i> Featured
                        </span>
                    @endif
                    @if($programme->is_active && $programme->is_registration_open)
                        <span class="inline-block px-4 py-1 bg-blue-400/90 text-white rounded-full text-sm font-semibold">
                            Open for Registration
                        </span>
                    @endif
                    @if($programme->is_free)
                        <span class="inline-block px-4 py-1 bg-green-400/90 text-white rounded-full text-sm font-semibold">
                            <i class="fas fa-gift mr-1"></i> Free
                        </span>
                    @else
                        <span class="inline-block px-4 py-1 bg-purple-400/90 text-white rounded-full text-sm font-semibold">
                            {{ number_format($programme->fee_amount, 0) }} {{ $programme->currency }}
                        </span>
                    @endif
                </div>
                <h1 class="text-4xl md:text-5xl font-serif font-bold text-white mb-4">
                    {{ $programme->title }}
                </h1>
                <p class="text-xl text-green-100 max-w-3xl mx-auto mb-8">
                    {{ Str::limit($programme->description, 200) }}
                </p>
                @if($canApply)
                    <a href="{{ route('mentorship.public.apply', ['programme_id' => $programme->id]) }}" 
                       class="inline-flex items-center px-8 py-3 bg-yellow-400 text-green-900 rounded-lg font-semibold hover:bg-yellow-300 transition shadow-lg">
                        <i class="fas fa-user-plus mr-2"></i> Apply Now
                    </a>
                @else
                    <span class="inline-flex items-center px-8 py-3 bg-white/20 text-white rounded-lg font-semibold backdrop-blur">
                        <i class="fas fa-lock mr-2"></i> Registration Closed
                    </span>
                @endif
            </div>
        </div>
    </div>

    {{-- Breadcrumb --}}
    <div class="bg-gray-50 border-b border-gray-200">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-3">
            <nav class="flex items-center space-x-2 text-sm text-gray-600" aria-label="Breadcrumb">
                <a href="{{ url('/') }}" class="hover:text-green-600 transition flex items-center">
                    <i class="fas fa-home mr-1"></i>Home
                </a>
                <i class="fas fa-chevron-right text-gray-400 text-xs"></i>
                <a href="{{ route('mentorship.public.index') }}" class="hover:text-green-600 transition">Mentorship</a>
                <i class="fas fa-chevron-right text-gray-400 text-xs"></i>
                <span class="text-gray-900 font-medium">{{ Str::limit($programme->title, 50) }}</span>
            </nav>
        </div>
    </div>

    {{-- Programme Header --}}
    <section class="py-12 bg-white">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
                {{-- Main Content --}}
                <div class="lg:col-span-2">
                    <div class="flex flex-wrap items-center gap-2 mb-4">
                        <span class="px-3 py-1 bg-green-100 text-green-700 rounded-full text-sm font-medium">
                            {{ $programme->category->name ?? 'General' }}
                        </span>
                        @if($programme->is_featured)
                            <span class="px-3 py-1 bg-yellow-100 text-yellow-700 rounded-full text-sm font-medium">
                                <i class="fas fa-star mr-1"></i> Featured
                            </span>
                        @endif
                        @if($programme->is_active && $programme->is_registration_open)
                            <span class="px-3 py-1 bg-blue-100 text-blue-700 rounded-full text-sm font-medium">
                                Open for Registration
                            </span>
                        @endif
                    </div>

                    <h1 class="text-3xl md:text-4xl font-bold text-gray-900 mb-4">{{ $programme->title }}</h1>
                    
                    <p class="text-xl text-gray-600 mb-8">{{ Str::limit($programme->description, 200) }}</p>

                    {{-- Quick Stats --}}
                    <div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
                        <div class="text-center p-4 bg-gray-50 rounded-xl">
                            <i class="fas fa-clock text-green-600 text-xl mb-2"></i>
                            <div class="text-lg font-semibold text-gray-900">{{ $programme->duration_text }}</div>
                            <div class="text-sm text-gray-500">Duration</div>
                        </div>
                        <div class="text-center p-4 bg-gray-50 rounded-xl">
                            <i class="fas fa-video text-green-600 text-xl mb-2"></i>
                            <div class="text-lg font-semibold text-gray-900 capitalize">{{ str_replace('_', ' ', $programme->session_type) }}</div>
                            <div class="text-sm text-gray-500">Sessions</div>
                        </div>
                        <div class="text-center p-4 bg-gray-50 rounded-xl">
                            <i class="fas fa-users text-green-600 text-xl mb-2"></i>
                            <div class="text-lg font-semibold text-gray-900">{{ $programme->applications_count ?? 0 }}</div>
                            <div class="text-sm text-gray-500">Applied</div>
                        </div>
                        <div class="text-center p-4 bg-gray-50 rounded-xl">
                            <i class="fas fa-certificate text-green-600 text-xl mb-2"></i>
                            <div class="text-lg font-semibold text-gray-900">
                                @if($programme->certificate_enabled)
                                    {{ ucfirst($programme->certificate_orientation) }}
                                @else
                                    None
                                @endif
                            </div>
                            <div class="text-sm text-gray-500">Certificate</div>
                        </div>
                    </div>
                </div>

                {{-- Sidebar --}}
                <div class="lg:col-span-1">
                    <div class="bg-white rounded-2xl shadow-lg border border-gray-100 p-6 sticky top-6">
                        <div class="text-center mb-6">
                            @if($programme->is_free)
                                <div class="text-4xl font-bold text-green-600 mb-1">Free</div>
                                <p class="text-gray-500">No payment required</p>
                            @else
                                <div class="text-4xl font-bold text-gray-900 mb-1">
                                    {{ number_format($programme->fee_amount, 2) }}
                                </div>
                                <p class="text-gray-500">{{ $programme->currency }}</p>
                                @if($programme->fee_description)
                                    <p class="text-sm text-gray-600 mt-2">{{ $programme->fee_description }}</p>
                                @endif
                            @endif
                        </div>

                        @if($canApply)
                            <a href="{{ route('mentorship.public.apply', ['programme_id' => $programme->id]) }}" 
                               class="block w-full text-center px-6 py-4 bg-green-600 text-white rounded-xl font-semibold hover:bg-green-700 transition mb-4">
                                <i class="fas fa-user-plus mr-2"></i>
                                Apply Now
                            </a>
                        @else
                            <div class="text-center px-6 py-4 bg-gray-100 text-gray-500 rounded-xl mb-4">
                                <i class="fas fa-lock mr-2"></i>
                                Registration Closed
                            </div>
                        @endif

                        <div class="space-y-4 text-sm">
                            <div class="flex justify-between">
                                <span class="text-gray-500">Start Date</span>
                                <span class="font-medium">{{ $programme->programme_start?->format('M d, Y') ?? 'TBA' }}</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-gray-500">End Date</span>
                                <span class="font-medium">{{ $programme->programme_end?->format('M d, Y') ?? 'TBA' }}</span>
                            </div>
                            <div class="flex justify-between">
                                <span class="text-gray-500">Registration Ends</span>
                                <span class="font-medium">{{ $programme->registration_end?->format('M d, Y') ?? 'Open' }}</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    {{-- Programme Details --}}
    <section class="py-12 bg-gray-50">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
                <div class="lg:col-span-2 space-y-8">
                    {{-- Description --}}
                    <div class="bg-white rounded-2xl shadow-sm p-6">
                        <h2 class="text-xl font-bold text-gray-900 mb-4">About This Programme</h2>
                        <div class="prose prose-green max-w-none text-gray-600">
                            {!! $programme->description !!}
                        </div>
                    </div>

                    {{-- Objectives --}}
                    @if($programme->objectives)
                        <div class="bg-white rounded-2xl shadow-sm p-6">
                            <h2 class="text-xl font-bold text-gray-900 mb-4">Learning Objectives</h2>
                            <div class="prose prose-green max-w-none text-gray-600">
                                {!! nl2br(e($programme->objectives)) !!}
                            </div>
                        </div>
                    @endif

                    {{-- Requirements --}}
                    @if($programme->requirements)
                        <div class="bg-white rounded-2xl shadow-sm p-6">
                            <h2 class="text-xl font-bold text-gray-900 mb-4">Requirements</h2>
                            <div class="prose prose-green max-w-none text-gray-600">
                                {!! nl2br(e($programme->requirements)) !!}
                            </div>
                        </div>
                    @endif
                </div>

                {{-- Right Sidebar --}}
                <div class="lg:col-span-1">
                    {{-- Programme Type --}}
                    <div class="bg-white rounded-2xl shadow-sm p-6 mb-6">
                        <h3 class="text-lg font-bold text-gray-900 mb-4">Programme Details</h3>
                        <div class="space-y-4">
                            <div>
                                <span class="text-gray-500 text-sm">Programme Type</span>
                                <p class="font-medium capitalize">{{ str_replace('_', ' ', $programme->programme_type) }}</p>
                            </div>
                            <div>
                                <span class="text-gray-500 text-sm">Session Type</span>
                                <p class="font-medium capitalize">{{ str_replace('_', ' ', $programme->session_type) }}</p>
                            </div>
                            @if($programme->venue)
                                <div>
                                    <span class="text-gray-500 text-sm">Venue</span>
                                    <p class="font-medium">{{ $programme->venue }}</p>
                                </div>
                            @endif
                            <div>
                                <span class="text-gray-500 text-sm">Expected Sessions</span>
                                <p class="font-medium">{{ $programme->sessions_count ?? 'Flexible' }}</p>
                            </div>
                        </div>
                    </div>

                    {{-- Share --}}
                    <div class="bg-white rounded-2xl shadow-sm p-6">
                        <h3 class="text-lg font-bold text-gray-900 mb-4">Share This Programme</h3>
                        <div class="flex gap-2">
                            <button onclick="shareOnTwitter()" class="flex-1 p-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition">
                                <i class="fab fa-twitter"></i>
                            </button>
                            <button onclick="shareOnLinkedIn()" class="flex-1 p-3 bg-blue-700 text-white rounded-lg hover:bg-blue-800 transition">
                                <i class="fab fa-linkedin"></i>
                            </button>
                            <button onclick="copyLink()" class="flex-1 p-3 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 transition">
                                <i class="fas fa-link"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    {{-- Related Programmes --}}
    @if($relatedProgrammes->count() > 0)
        <section class="py-12 bg-white">
            <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
                <h2 class="text-2xl font-bold text-gray-900 mb-8">Related Programmes</h2>
                <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
                    @foreach($relatedProgrammes as $related)
                        <a href="{{ route('mentorship.public.programme', $related) }}" 
                           class="block p-4 bg-gray-50 rounded-xl hover:bg-green-50 transition">
                            <h3 class="font-semibold text-gray-900 mb-2">{{ $related->title }}</h3>
                            <div class="flex items-center justify-between text-sm text-gray-500">
                                <span>{{ $related->duration_text }}</span>
                                <span class="font-medium {{ $related->is_free ? 'text-green-600' : 'text-purple-600' }}">
                                    {{ $related->is_free ? 'Free' : number_format($related->fee_amount, 0) . ' ' . $related->currency }}
                                </span>
                            </div>
                        </a>
                    @endforeach
                </div>
            </div>
        </section>
    @endif
</x-site-layout>

@push('scripts')
<script>
    function shareOnTwitter() {
        window.open('https://twitter.com/intent/tweet?text=' + encodeURIComponent('{{ $programme->title }}') + '&url=' + encodeURIComponent(window.location.href), '_blank');
    }

    function shareOnLinkedIn() {
        window.open('https://www.linkedin.com/sharing/share-offsite/?url=' + encodeURIComponent(window.location.href), '_blank');
    }

    function copyLink() {
        navigator.clipboard.writeText(window.location.href);
        alert('Link copied to clipboard!');
    }
</script>
@endpush
