<div class="flex items-start justify-between gap-4">
    <div class="min-w-0 space-y-2">
        @if (($reference['isLinkable'] ?? false) === true && filled(data_get($reference, 'linkTarget.url')))
            <a
                href="{{ data_get($reference, 'linkTarget.url') }}"
                class="text-sm font-semibold text-primary-600 hover:text-primary-500 hover:underline dark:text-primary-400"
            >
                {{ $reference['primaryLabel'] ?? 'Reference' }}
            </a>
        @else
            <div class="text-sm font-semibold text-gray-900 dark:text-white">
                {{ $reference['primaryLabel'] ?? 'Reference' }}
            </div>
        @endif

        @if (filled($reference['secondaryLabel'] ?? null))
            <div class="text-xs text-gray-500 dark:text-gray-400">
                {{ $reference['secondaryLabel'] }}
            </div>
        @endif

        @if (filled($reference['stateDescription'] ?? null))
            <div class="text-xs text-gray-600 dark:text-gray-300">
                {{ $reference['stateDescription'] }}
            </div>
        @endif

        @if (filled(data_get($reference, 'technicalDetail.fullId')))
            <div class="text-xs text-gray-500 dark:text-gray-400">
                ID: {{ data_get($reference, 'technicalDetail.displayId') ?: data_get($reference, 'technicalDetail.fullId') }}

                @if (filled(data_get($reference, 'technicalDetail.sourceHint')))
                    <span class="ml-2">{{ data_get($reference, 'technicalDetail.sourceHint') }}</span>
                @endif
            </div>
        @endif
    </div>

    <div class="flex shrink-0 items-center gap-2">
        @if ((data_get($reference, 'showStateBadge', false)) === true)
            <x-filament::badge
                :color="data_get($reference, 'stateColor', 'gray')"
                :icon="data_get($reference, 'stateIcon')"
                size="sm"
            >
                {{ data_get($reference, 'stateLabel', 'Unknown') }}
            </x-filament::badge>
        @endif

        @if (filled(data_get($reference, 'linkTarget.contextBadge')))
            <x-filament::badge color="gray" size="sm">
                {{ data_get($reference, 'linkTarget.contextBadge') }}
            </x-filament::badge>
        @endif

        @if (($reference['isLinkable'] ?? false) === true && filled(data_get($reference, 'linkTarget.actionLabel')))
            <a
                href="{{ data_get($reference, 'linkTarget.url') }}"
                class="text-xs font-medium text-primary-600 hover:text-primary-500 hover:underline dark:text-primary-400"
            >
                {{ data_get($reference, 'linkTarget.actionLabel') }}
            </a>
        @endif
    </div>
</div>
