Get 1st parent category id from post

You need to use get_ancestors().

Assuming your post is only in one category, the following code should work (if it’s in multiple you’ll need to loop through each of the assigned categories to determine the various hierarchies).

$category = get_the_category();
$ancestors = get_ancestors( $category[0]->term_id, 'category' );
$direct_parent_id = $ancestors[0];

If you want to get the entire category hierarchy as an ordered array of IDs (which I like to have available) you’d do:

$category = get_the_category();
$hierarchy = array_reverse( get_ancestors( $category[0]->term_id, 'category' ) );
$hierarchy[] = $category[0]->term_id;