export function getSupabaseUrl(): string | null {
  const explicitUrl = process.env.NEXT_PUBLIC_SUPABASE_URL?.trim();
  if (explicitUrl) return explicitUrl.replace(/\/$/, "");

  const projectId = process.env.SUPABASE_PROJECT_ID?.trim();
  return projectId ? `https://${projectId}.supabase.co` : null;
}

export function getSupabaseAnonKey(): string | null {
  return (
    process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY?.trim() ||
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY?.trim() ||
    null
  );
}

export function isSupabaseConfigured(): boolean {
  return Boolean(getSupabaseUrl() && getSupabaseAnonKey());
}
