<x-filament-panels::page>
    @php($selectedException = $this->selectedFindingException())
    @php($environmentFilterChip = $this->environmentFilterChip())

    <x-filament::section>
        <div class="flex flex-col gap-3">
            <div class="text-lg font-semibold text-gray-900 dark:text-gray-100">
                Canonical risk-acceptance approvals
            </div>

            <div class="text-sm text-gray-600 dark:text-gray-300">
                Review pending requests, expiring governance, and lapsed exception coverage across entitled environments without leaving the Monitoring area.
            </div>

            <div class="text-sm text-gray-600 dark:text-gray-300">
                The focused review lane is bound to the <span class="font-mono text-xs">exception</span> query parameter. If that exception drops out of the current queue view, the page falls back to quiet monitoring mode without stale decision state.
            </div>

            @if ($environmentFilterChip !== null)
                @include('filament.partials.workspace-hub-environment-filter-chip', [
                    'label' => $environmentFilterChip['label'],
                    'clearUrl' => $environmentFilterChip['clear_url'],
                ])
            @endif
        </div>
    </x-filament::section>

    @if ($selectedException)
        <x-filament::section heading="Focused review lane">
            <x-slot name="description">
                Selection-bound decisions now define the active work lane. Scope, filters, and drilldowns stay visible without competing with the current review step.
            </x-slot>

            <div class="grid gap-6 xl:grid-cols-[minmax(0,2fr)_minmax(22rem,26rem)]">
                @include('filament.pages.monitoring.partials.finding-exception-queue-sidebar', [
                    'selectedException' => $selectedException,
                ])

                <div class="grid gap-4">
                    <div class="rounded-2xl border border-primary-200 bg-primary-50/80 p-4 shadow-sm dark:border-primary-500/30 dark:bg-primary-500/10">
                        <div class="text-sm font-semibold text-primary-900 dark:text-primary-100">
                            Decision lane
                        </div>

                        <div class="mt-2 text-sm text-primary-800 dark:text-primary-200">
                            @if ($selectedException->isPending())
                                Approve exception and Reject exception are the only promoted next steps while this request remains pending.
                            @else
                                This exception is no longer decision-ready. Use the selected context group to close details or drill into related records.
                            @endif
                        </div>
                    </div>

                    <div class="rounded-2xl border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-800 dark:bg-gray-900">
                        <div class="text-sm font-semibold text-gray-900 dark:text-gray-100">
                            Related drilldown
                        </div>
                        <div class="mt-2 text-sm text-gray-600 dark:text-gray-300">
                            Open environment detail and Open finding stay available for context, but they no longer share the same semantic lane as the review decision.
                        </div>
                    </div>
                </div>
            </div>
        </x-filament::section>
    @else
        <x-filament::section heading="Quiet monitoring mode">
            <x-slot name="description">
                Inspect an exception to enter the focused review lane. Scope, filters, and environment drilldowns stay secondary until one request is actively under review.
            </x-slot>

            <div class="text-sm text-gray-600 dark:text-gray-300">
                No exception is selected right now. Use Inspect exception from the queue to review one request in context.
            </div>
        </x-filament::section>
    @endif

    {{ $this->table }}
</x-filament-panels::page>
