@php
    $record = $getRecord();
    $running = \App\Models\Backup::where('schedule_id', $record->id)->running()->exists();

    if ($running) {
        $label = __('Running...');
        $color = 'warning';
    } elseif ($record->is_active) {
        $label = __('Active');
        $color = 'success';
    } else {
        $label = __('Disabled');
        $color = 'gray';
    }

    $colorClasses = match($color) {
        'success' => 'bg-success-50 text-success-600 ring-success-600/10 dark:bg-success-400/10 dark:text-success-400 dark:ring-success-400/30',
        'warning' => 'bg-warning-50 text-warning-600 ring-warning-600/10 dark:bg-warning-400/10 dark:text-warning-400 dark:ring-warning-400/30',
        default => 'bg-gray-50 text-gray-600 ring-gray-600/10 dark:bg-gray-400/10 dark:text-gray-400 dark:ring-gray-400/30',
    };
@endphp

<span class="fi-badge flex items-center justify-center gap-x-1 rounded-md text-xs font-medium ring-1 ring-inset px-1.5 min-w-[theme(spacing.5)] py-0.5 {{ $colorClasses }}">
    @if($running)
        <x-filament::icon
            icon="heroicon-o-arrow-path"
            class="h-3 w-3 animate-spin"
        />
    @endif
    <span>{{ $label }}</span>
</span>
