{{-- Shown only while a central admin is impersonating a tenant user --}}
@php
    $impersonator = session('impersonator');
    $admin = $impersonator['by_email'] ?? null;
@endphp

<div class="fi-impersonation-banner bg-danger-600 text-white text-sm shadow-sm">
    <div class="mx-auto flex max-w-7xl items-center justify-center gap-3 px-4 py-2">
        <x-filament::icon icon="heroicon-m-user-circle" class="h-4 w-4 shrink-0" />

        <span class="font-medium">
            You are viewing {{ auth('web')->user()?->name ?? 'this account' }} as a tenant user
            @if ($admin)
                (impersonating on behalf of {{ $admin }})
            @endif
        </span>

        <form method="post" action="{{ route('impersonate.stop') }}" class="inline">
            @csrf

            <x-filament::button
                type="submit"
                size="sm"
                color="white"
                icon="heroicon-m-arrow-uturn-left"
            >
                End impersonation
            </x-filament::button>
        </form>
    </div>
</div>
