<script>
  import Sparkline from "./Sparkline.svelte";

  let { label = "", value = "", sub = "", sparkValues = [], sparkColor = undefined } = $props();
</script>

<div class="tile panel">
  <span class="label-caps">{label}</span>
  <span class="value mono">{value}</span>
  {#if sub}<span class="sub">{sub}</span>{/if}
  {#if sparkValues.length > 0}
    <div class="spark">
      <Sparkline values={sparkValues} color={sparkColor ?? "var(--signal)"} />
    </div>
  {/if}
</div>

<style>
  .tile { display: flex; flex-direction: column; gap: 5px; padding: 15px 17px; transition: border-color .15s ease, box-shadow .15s ease; }
  .tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow-8); }
  .value { font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
  .sub { font-size: 12px; color: var(--muted); }
  .spark { height: 28px; margin-top: 4px; }
</style>
