<?php
/**
 * NFT (Nutrition Facts Table) partial.
 * Renders a Health Canada-style nutrition table per portion.
 *
 * @package RestaurantCosting
 * @var array<string, float> $nutrition
 * @var float                $portion_weight
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div class="rc-nft">
	<div class="rc-nft-header">Nutrition Facts</div>
	<div class="rc-nft-serving">Per <?php echo esc_html( (int) round( $portion_weight ) ); ?> g portion</div>

	<div class="rc-nft-row rc-nft-row-cal"><span class="rc-nft-label">Calories</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['calories'] ?? 0 ) ); ?></span></div>

	<div class="rc-nft-row"><span class="rc-nft-label">Fat (g)</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['fat_grams'] ?? 0 ) ); ?></span></div>
	<div class="rc-nft-row rc-nft-sub"><span class="rc-nft-label">Saturated (g)</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['saturated_fat_grams'] ?? 0 ) ); ?></span></div>
	<div class="rc-nft-row rc-nft-sub"><span class="rc-nft-label">Trans (g)</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['trans_fat_grams'] ?? 0 ) ); ?></span></div>

	<div class="rc-nft-divider"></div>

	<div class="rc-nft-row"><span class="rc-nft-label">Carbohydrate (g)</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['carb_grams'] ?? 0 ) ); ?></span></div>
	<div class="rc-nft-row rc-nft-sub"><span class="rc-nft-label">Fibre (g)</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['fiber_grams'] ?? 0 ) ); ?></span></div>
	<div class="rc-nft-row rc-nft-sub"><span class="rc-nft-label">Sugars (g)</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['sugar_grams'] ?? 0 ) ); ?></span></div>

	<div class="rc-nft-divider"></div>

	<div class="rc-nft-row"><span class="rc-nft-label">Cholesterol (mg)</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['cholesterol_mg'] ?? 0 ) ); ?></span></div>
	<div class="rc-nft-row"><span class="rc-nft-label">Protein (g)</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['protein_grams'] ?? 0 ) ); ?></span></div>
	<div class="rc-nft-row rc-nft-row-last"><span class="rc-nft-label">Sodium (mg)</span><span class="rc-nft-value"><?php echo esc_html( (string) ( $nutrition['sodium_mg'] ?? 0 ) ); ?></span></div>
</div>
