@php
$piatto = $riga_ordine->piatto;
$accId = $riga_ordine->id;
@endphp

<div class="accordion-item card">
    <h2 class="accordion-header text-body d-flex flex-nowrap align-items-stretch" id="accordionPopoutIconHeader-{{ $accId }}">
        {{-- Stepper fuori da .accordion-button: non si possono annidare <button> dentro <button> --}}
        <div class="d-flex align-items-center justify-content-center flex-shrink-0 px-2 py-2 border-end"
             role="group"
             aria-label="Quantità">
            @include('punto_vendita.cassa._partials.carrello.cmd_carrello', [
                'cmd' => 'quantita',
                'piatto_id' => $piatto->id,
                'riga_ordine_id' => $riga_ordine->id,
            ])
        </div>
        <button type="button" class="accordion-button collapsed flex-grow-1 min-w-0" data-bs-toggle="collapse" data-bs-target="#accordionPopoutIcon-{{ $accId }}" aria-controls="accordionPopoutIcon-{{ $accId }}">
            <div class="row w-100 justify-content-between align-items-center gx-2">
                <div class="col min-w-0">
                    <i class="bx bx-dish me-2"></i>
                    <span class="text-truncate d-inline-block align-bottom" style="max-width: 100%;">{{ $piatto->nome }}</span>
                </div>
                <div class="col-auto text-end fw-semibold text-nowrap">
                    € {{ number_format($riga_ordine->prezzo, 2, ',', '.') }}
                </div>
            </div>
        </button>
    </h2>
    <div id="accordionPopoutIcon-{{ $accId }}" class="accordion-collapse collapse" aria-labelledby="accordionPopoutIconHeader-{{ $accId }}" data-bs-parent="#accordionPopoutIcon">
        <div class="accordion-body">
            <div class="mb-2">
                <strong>Descrizione:</strong> {{ $piatto->descrizione }}
            </div>
            @if($riga_ordine->note)
                <div class="mb-2">
                    <strong>Note:</strong> {{ $riga_ordine->note }}
                </div>
            @endif
            <div class="d-flex align-items-center">
                @include('punto_vendita.cassa._partials.carrello.cmd_carrello', [
                    'cmd' => 'elimina',
                    'piatto_id' => $piatto->id,
                    'riga_ordine_id' => $riga_ordine->id,
                ])
            </div>
        </div>
    </div>
</div>
