{{-- 
    Public Publishing Page Show
    Public page with dynamic content blocks
    Uses <x-site-layout> for SEO and public access
    
    Uses: <x-site-layout>
    Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
--}}
<x-site-layout 
    title="{{ $metaTitle ?? $page->title }}"
    meta-description="{{ $metaDescription ?? $page->meta_description ?? '' }}"
    :theme-css-variables="!empty($themeColors) ? collect($themeColors)->mapWithKeys(fn($v, $k) => ['--theme-'.$k => $v])->all() : null"
>

    {{-- SEO Structured Data --}}
    @php
        $seoScript = !empty($page->seo_meta) ? json_encode([
            '@context' => 'https://schema.org',
            '@type' => 'WebPage',
            'name' => $page->meta_title ?? $page->title,
            'description' => $page->meta_description ?? '',
            'datePublished' => $page->published_at?->toIso8601String(),
            'dateModified' => $page->updated_at->toIso8601String(),
            'author' => ['@type' => 'Organization', 'name' => config('app.name')],
        ], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) : null;
    @endphp
    @if($seoScript)
        {!! '<script type="application/ld+json">' . $seoScript . '</script>' !!}
    @endif

    {{-- Preview Banner --}}
    @isset($isPreview)
        <div class="bg-yellow-500 text-white text-center py-2 text-sm">
            <i class="fas fa-eye mr-2"></i>
            {{ __('This is a preview. Changes are not yet published.') }}
        </div>
    @endisset

    {{-- 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>
                <span class="text-gray-900 font-medium">{{ $page->title }}</span>
            </nav>
        </div>
    </div>

    {{-- Render dynamic content blocks from the model. --}}
    @if(!empty($page->content_blocks) && count($page->content_blocks) > 0)
        {!! $page->renderBlocks() !!}
    @endif

    {{-- No Content Fallback --}}
    @if(!$page->content_blocks || count($page->content_blocks) === 0)
        <section class="py-24 text-center">
            <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
                <i class="fas fa-file-alt text-6xl text-gray-300 mb-4"></i>
                <h2 class="text-2xl font-bold text-theme-heading">{{ __('Content Coming Soon') }}</h2>
                <p class="text-theme-body mt-2">{{ __('This page is being updated. Please check back later.') }}</p>
            </div>
        </section>
    @endif
</x-site-layout>
