/*
 * stat: one measured number with its label, for report pages (alunos ativos, aulas concluídas).
 * Goes inside a .card__body or a .stat-grid. The number is tabular so columns of stats line up;
 * the delta names its direction in text (the arrow icon is decoration).
 * Markup: <div class="stat"><span class="stat__label">Alunos ativos</span>
 *           <span class="stat__value">1.284</span>
 *           <span class="stat__delta stat__delta--up"><svg…>+12% em 30 dias</span></div>
 */
@layer components {
  .stat-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  }

  .stat {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-inline-size: 0;
  }

  .stat__label {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
  }

  .stat__value {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-none);
    font-variant-numeric: tabular-nums;
  }

  .stat__unit {
    margin-inline-start: var(--space-1);
    color: var(--color-text-muted);
    font-size: var(--text-base);
    font-weight: var(--weight-regular);
  }

  .stat__delta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--color-text-muted);
    font-size: var(--text-sm);

    & svg {
      inline-size: 1em;
      block-size: 1em;
    }
  }

  .stat__delta--up {
    color: var(--color-success);
  }

  .stat__delta--down {
    color: var(--color-danger);
  }

  /* Loading: the value becomes a static bar, the label stays readable. */
  .stat[aria-busy="true"] .stat__value {
    inline-size: 5ch;
    block-size: var(--text-2xl);
    border-radius: var(--radius-sm);
    background: var(--color-border);
    color: transparent;
  }
}
