You’re using $post->ID
which is undefined. Try $_GET['post']
instead:
// Get Categories
if ( is_admin() && isset($_GET['post']) ) {
$cats = wp_get_post_categories( (int)$_GET['post'], array( 'fields' => 'all' ) );
$cats = wp_list_pluck( $cats, 'slug' );
foreach ( $cats as $cat ) {
$classes .= ' category-' . $cat;
}
}