Get category id of next / prev post inside the_post_navigation

Here was my final solution:

$next_post = get_next_post();
if (!empty( $next_post )){
  $next_categories = get_the_terms($next_post->ID,'category');
  $next_cat_data = get_option('category_'.$next_categories[1]->term_id);
  if (isset($next_cat_data['hex'])){
    echo "<style>div.nav-next:hover{background-color:".$next_cat_data['hex'].";} div.nav-next:hover span.post-title, div.nav-next:hover span.meta-nav {color:#f8f7f4;}</style>";
  }
}
$previous_post = get_previous_post();
if (!empty( $previous_post )){
  $prev_categories = get_the_terms($previous_post->ID,'category');
  $prev_cat_data = get_option('category_'.$prev_categories[1]->term_id);
  if (isset($prev_cat_data['hex'])){
    echo "<style>div.nav-previous:hover{background-color:".$prev_cat_data['hex'].";} div.nav-previous:hover span.post-title, div.nav-previous:hover span.meta-nav {color:#f8f7f4;}</style>";
  }
}