@php
  $haAllergeni = ($piatto->elencoAllergeni?->isNotEmpty() ?? false)
    || (is_iterable($piatto->allergeni ?? null) && count($piatto->allergeni) > 0);
@endphp

<div class="col">
  <div
    class="cassa-piatto-card cassa-piatto-card--compact card border shadow-sm h-100"
    tabindex="0"
    role="button"
    data-piatto-id="{{ $piatto->id }}"
    data-piatto-nome="{{ $piatto->nome }}"
    data-piatto-prezzo="{{ $piatto->prezzo }}"
    data-cucina-id="{{ $cucina->id ?? '' }}"
    aria-label="Aggiungi {{ $piatto->nome }} al carrello"
    aria-pressed="false"
  >
    <div class="cassa-piatto-body card-body d-flex flex-column">
      <div class="d-flex justify-content-between align-items-start gap-2 mb-2">
        <div class="cassa-piatto-title">{{ $piatto->nome }}</div>
        <span class="cassa-piatto-add-icon" aria-hidden="true"><i class="bx bx-plus"></i></span>
      </div>

      <div class="mt-auto">
        @if($haAllergeni)
          <span class="cassa-piatto-allergeni-badge mb-1">
            <i class="bx bx-error-circle me-1"></i>! Allergeni
          </span>
        @endif
        <span class="cassa-piatto-price">{{ number_format((float) $piatto->prezzo, 2, ',', '.') }} €</span>
      </div>
    </div>
  </div>
</div>