@php
  /**
   * Contratto $statistiche (controller — da implementare):
   *
   * 'operazioni' => ['oggi' => int, 'totali' => int],
   * 'contanti'  => ['oggi' => ['count' => int, 'importo' => float], 'totali' => [...]],
   * 'digitali'  => ['oggi' => ['count' => int, 'importo' => float], 'totali' => [...]],
   */
  $stats = $statistiche ?? [];
  $operazioni = $stats['operazioni'] ?? [];
  $contanti = $stats['contanti'] ?? [];
  $digitali = $stats['digitali'] ?? [];

  $fmtEuro = fn ($val) => number_format((float) ($val ?? 0), 2, ',', '.') . ' €';
  $fmtCount = fn ($val) => number_format((int) ($val ?? 0), 0, ',', '.');
@endphp

<div class="row">
  <div class="col-12 mb-6">
    <div class="card">
      <div class="card-body py-4">
        <div class="row g-4 g-lg-0 align-items-stretch">

          {{-- Operazioni --}}
          <div class="col-sm-6 col-lg-4">
            <div class="d-flex h-100 justify-content-between align-items-center px-lg-3 border-lg-end">
              <div>
                <div class="d-flex align-items-center gap-2 mb-2">
                  <span class="avatar avatar-sm">
                    <span class="avatar-initial rounded bg-label-secondary">
                      <i class="bx bx-receipt"></i>
                    </span>
                  </span>
                  <span class="fw-medium">Operazioni</span>
                </div>
                <p class="mb-1 small text-muted">Pagamenti registrati</p>
                <p class="mb-0 fs-4 fw-semibold lh-sm">
                  <span>{{ $fmtCount($operazioni['oggi'] ?? null) }}</span>
                  <span class="text-muted fw-normal mx-1">/</span>
                  <span class="text-body-secondary fw-normal">{{ $fmtCount($operazioni['totali'] ?? null) }}</span>
                </p>
                <p class="mb-0 mt-1 small text-muted">oggi / totali</p>
              </div>
            </div>
          </div>

          {{-- Contanti --}}
          <div class="col-sm-6 col-lg-4">
            <div class="d-flex h-100 justify-content-between align-items-center px-lg-3 border-lg-end">
              <div>
                <div class="d-flex align-items-center gap-2 mb-2">
                  <span class="avatar avatar-sm">
                    <span class="avatar-initial rounded bg-label-success">
                      <i class="bx bx-money text-success"></i>
                    </span>
                  </span>
                  <span class="fw-medium">Contanti</span>
                </div>
                <p class="mb-1 small text-muted">Importo incassato</p>
                <p class="mb-0 fs-4 fw-semibold lh-sm text-success">
                  <span>{{ $fmtEuro($contanti['oggi']['importo'] ?? null) }}</span>
                  <span class="text-muted fw-normal mx-1">/</span>
                  <span class="text-body-secondary fw-normal">{{ $fmtEuro($contanti['totali']['importo'] ?? null) }}</span>
                </p>
                <p class="mb-0 mt-2 small">
                  <span class="text-muted">N°</span>
                  <span class="fw-medium">{{ $fmtCount($contanti['oggi']['count'] ?? null) }}</span>
                  <span class="text-muted mx-1">/</span>
                  <span class="text-body-secondary">{{ $fmtCount($contanti['totali']['count'] ?? null) }}</span>
                  <span class="text-muted ms-1">pagamenti</span>
                </p>
              </div>
            </div>
          </div>

          {{-- Digitali --}}
          <div class="col-sm-12 col-lg-4">
            <div class="d-flex h-100 justify-content-between align-items-center px-lg-3">
              <div>
                <div class="d-flex align-items-center gap-2 mb-2">
                  <span class="avatar avatar-sm">
                    <span class="avatar-initial rounded bg-label-info">
                      <i class="bx bx-credit-card text-info"></i>
                    </span>
                  </span>
                  <span class="fw-medium">Digitali</span>
                </div>
                <p class="mb-1 small text-muted">Importo incassato</p>
                <p class="mb-0 fs-4 fw-semibold lh-sm text-info">
                  <span>{{ $fmtEuro($digitali['oggi']['importo'] ?? null) }}</span>
                  <span class="text-muted fw-normal mx-1">/</span>
                  <span class="text-body-secondary fw-normal">{{ $fmtEuro($digitali['totali']['importo'] ?? null) }}</span>
                </p>
                <p class="mb-0 mt-2 small">
                  <span class="text-muted">N°</span>
                  <span class="fw-medium">{{ $fmtCount($digitali['oggi']['count'] ?? null) }}</span>
                  <span class="text-muted mx-1">/</span>
                  <span class="text-body-secondary">{{ $fmtCount($digitali['totali']['count'] ?? null) }}</span>
                  <span class="text-muted ms-1">pagamenti</span>
                </p>
              </div>
            </div>
          </div>

        </div>
      </div>
    </div>
  </div>
</div>
