<div class="fleet-ops-widget fleet-ops-issues-insights flex flex-col h-full {{@class}}" ...attributes>
    <div class="flex items-center justify-between px-3 py-1.5 border dark:border-gray-700 border-gray-200 dark:bg-gray-800 bg-gray-50 rounded-t-md shadow-sm">
        <span class="text-xs font-bold text-black dark:text-gray-100">{{t "widget.issues-insights.title"}}</span>
        <FaIcon @icon="triangle-exclamation" class="text-gray-400" />
    </div>

    <div class="flex-1 p-2.5 border border-t-0 dark:border-gray-700 border-gray-200 rounded-b-md bg-white dark:bg-gray-900 min-h-0">
        {{#if this.load.isRunning}}
            <div class="flex items-center justify-center h-full"><Spinner /></div>
        {{else if this.error}}
            <div class="flex items-center justify-center h-full text-xs text-red-500">{{this.error}}</div>
        {{else if this.data}}
            <div class="grid grid-cols-2 gap-2 h-full">
                <div class="min-h-0">
                    {{#if this.categoryDatasets}}
                        <Chart @type="doughnut" @labels={{this.categoryLabels}} @datasets={{this.categoryDatasets}} @options={{this.categoryOptions}} />
                    {{else}}
                        <div class="flex items-center justify-center h-full text-[10px] text-gray-500">No issues yet.</div>
                    {{/if}}
                </div>
                <div class="flex flex-col justify-around gap-1.5">
                    <div>
                        <div class="text-[9px] uppercase text-gray-500 dark:text-gray-400 leading-none">Open</div>
                        <div class="text-lg font-bold text-amber-500 leading-tight">{{this.data.open}}</div>
                    </div>
                    <div>
                        <div class="text-[9px] uppercase text-gray-500 dark:text-gray-400 leading-none">Resolved (30d)</div>
                        <div class="text-lg font-bold text-green-500 leading-tight">{{this.data.resolved_this_period}}</div>
                    </div>
                    <div>
                        <div class="text-[9px] uppercase text-gray-500 dark:text-gray-400 leading-none">Avg Resolve</div>
                        <div class="text-sm font-bold text-black dark:text-gray-100 leading-tight">{{this.resolutionDisplay}}</div>
                    </div>
                    <div class="flex flex-wrap gap-1">
                        <Badge @status="danger" @text={{concat "H " this.data.by_priority.high}} @hideIcon={{true}} @disableHumanize={{true}} @wrapperClass="text-[9px] px-1 py-0" />
                        <Badge @status="warning" @text={{concat "M " this.data.by_priority.medium}} @hideIcon={{true}} @disableHumanize={{true}} @wrapperClass="text-[9px] px-1 py-0" />
                        <Badge @status="info" @text={{concat "L " this.data.by_priority.low}} @hideIcon={{true}} @disableHumanize={{true}} @wrapperClass="text-[9px] px-1 py-0" />
                    </div>
                </div>
            </div>
        {{/if}}
    </div>
</div>
