<script lang="ts">
  import { notifiche } from '#lib/notifiche.svelte.js';
  import Icona from './Icona.svelte';

  const stile = { ok: 'bg-green-800', errore: 'bg-red-700', info: 'bg-slate-800' } as const;
</script>

<div class="pointer-events-none fixed inset-x-0 bottom-[max(1rem,env(safe-area-inset-bottom))] z-50 flex flex-col items-center gap-2 px-4" aria-live="polite">
  {#each notifiche as n (n.id)}
    <div class="pointer-events-auto flex max-w-md items-center gap-2 rounded-xl px-4 py-3 text-sm font-medium text-white shadow-lg {stile[n.tono]}">
      <Icona nome={n.tono === 'ok' ? 'spunta' : n.tono === 'errore' ? 'errore' : 'info'} classe="size-5 shrink-0" />
      {n.testo}
    </div>
  {/each}
</div>
