<div class="gpu-grid">
@foreach($gpus as $gpu)
@php
    $used    = $gpu['mem_total'] - $gpu['mem_free'];
    $usedPct = $gpu['mem_total'] > 0 ? round($used / $gpu['mem_total'] * 100) : 0;
    $sel     = (string)$gpu['index'] === (string)$selectedDevice;
@endphp
<div class="gpu-card {{ $sel ? 'selected' : '' }}"
     data-index="{{ $gpu['index'] }}"
     onclick="selectGpuCard(this)">
    <div class="gpu-card-check">@if($sel)<i class="bi bi-check"></i>@endif</div>
    <div class="gpu-card-name">{{ $gpu['name'] }}</div>
    <div class="gpu-stat"><span>VRAM</span><span class="gpu-stat-val">{{ number_format($gpu['mem_total']) }} MB</span></div>
    <div class="gpu-stat"><span>Free</span><span class="gpu-stat-val">{{ number_format($gpu['mem_free']) }} MB</span></div>
    <div class="gpu-stat"><span>GPU Load</span><span class="gpu-stat-val">{{ $gpu['util'] }}%</span></div>
    <div class="gpu-stat"><span>Temp</span><span class="gpu-stat-val">{{ $gpu['temp'] }} °C</span></div>
    <div class="gpu-stat"><span>Driver</span><span class="gpu-stat-val">{{ $gpu['driver'] }}</span></div>
    <div class="mem-bar-wrap">
        <div class="mem-bar-track">
            <div class="mem-bar-fill" style="width:{{ $usedPct }}%"></div>
        </div>
    </div>
</div>
@endforeach
</div>
