{{--
    Renders any status enum consistently.

        <x-status-badge :status="$asset->status" />
        <x-status-badge :status="$employee->status" :icon="false" />

    The label and colour come from the enum itself (App\Enums\HasBadge), so a
    status looks identical in every list, detail page, report and export without
    any view knowing the mapping.

    Plain strings are accepted for values that have not been promoted to an enum
    yet; they render neutrally rather than breaking the page.

    For a status that has no enum behind it — "Active" / "Disabled" on a user —
    use <x-badge> instead.
--}}
@props([
    'status',
    'icon' => true,
])

@php
    $isEnum = $status instanceof \App\Enums\HasBadge;

    $label = $isEnum ? $status->label() : (string) $status;
    $color = $isEnum ? $status->color() : 'secondary';
    $iconName = $isEnum ? $status->icon() : null;
@endphp

<span {{ $attributes->merge(['class' => 'badge text-bg-'.$color]) }}>
    @if ($icon && $iconName)
        <i class="bi bi-{{ $iconName }}" aria-hidden="true"></i>
    @endif{{ $label }}</span>
