export function trialDaysRemaining(trialEndsAt: Date | null, now: Date = new Date()): number {
  if (!trialEndsAt) return 0;
  const ms = trialEndsAt.getTime() - now.getTime();
  if (ms <= 0) return 0;
  return Math.ceil(ms / (24 * 60 * 60 * 1000));
}

export function formatPlanBadge(
  planNombre: string | null,
  status: string,
  trialEndsAt: Date | null,
  now: Date = new Date()
): string {
  const plan = planNombre ? `Plan ${planNombre}` : 'Sin plan';
  if (status === 'trial') {
    return `${plan} · trial, ${trialDaysRemaining(trialEndsAt, now)} días restantes`;
  }
  return `${plan} · ${status}`;
}
