@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
@using Dynamicweb.Ecommerce.ProductCatalog
@using System.Collections.Generic

@{
	var groups = GetViewParameter("Groups") as List<FieldGroupViewModel>;
	bool hideGroupHeaders = GetViewParameterBoolean("HideGroupHeaders");
	bool hideTitle = GetViewParameterBoolean("HideTitle");
	string size = GetViewParameterString("Size");

	string title = Model.Item.GetString("Title");
	bool hideLabels = Model.Item.GetBoolean("HideFieldLabels");
	string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "display-4");
	string gapCss = size == "full" ? " gap-4" : " gap-2";

	if (!hideTitle)
	{
		<h2 class="g-col-12 @titleFontSize">@title</h2>
	}

	foreach (var group in groups)
	{

		if (!hideGroupHeaders)
		{
			<div class="g-col-12">
				<h3>@group.Name</h3>
			</div>
		}

		<div class="g-col-12">
			<div class="grid @(gapCss)">
				@foreach (var field in group.Fields)
				{
					<dl class="grid g-col-6 g-col-lg-4 gap-1">
						@if (!hideLabels)
						{
							<dt class="g-col-12 g-col-lg-4">@(field.Name)</dt>
							<dd class="g-col-12 g-col-lg-8 mb-0 text-break">@RenderPartial("Components/Specifications/Shared/FieldValue.cshtml", field)</dd>
						}
						else
						{
							<dd class="g-col-12 mb-0 text-break">@RenderPartial("Components/Specifications/Shared/FieldValue.cshtml", field)</dd>
						}
					</dl>
				}
			</div>
		</div>
	}
}
