@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>

@functions {
	private string GetFontStack()
	{
		return "font-family:initial,Arial,Helvetica Neue,Helvetica,sans-serif;";
	}

	private string GetTableReset()
	{
		return "border:0;margin:0;outline:0;padding:0;";
	}
}

@{
	string backgroundColor = $"background-color:{Model.ColorScheme?.BackgroundColor?.Hex ?? string.Empty};";
	string foregroundColor = $"color:{Model.ColorScheme?.ForegroundColor?.Hex ?? string.Empty};";
	string borders = Model.Item.GetRawValueString("Borders", "none");
	string borderThicknes = Model.Item.GetRawValueString("BorderThicknes", "0") + "px";
	string borderClass = string.Empty;

	switch (borders)
	{
		case "top":
			borderClass = $"border-top:{borderThicknes} solid;";
			break;
		case "bottom":
			borderClass = $"border-bottom:{borderThicknes} solid;";
			break;
		case "top-bottom":
			borderClass = $"border-top:{borderThicknes} solid;border-bottom:{borderThicknes} solid;border-left:0;border-right:0;";
			break;
		case "all":
			borderClass = $"border:{borderThicknes} solid;";
			break;
	}

	string padding = Model.Item.GetRawValueString("Padding", "0");
	string align = Model.Item.GetRawValueString("Align", "left");
	string text = Model.Item.GetString("Text", string.Empty);
	string lineHeight = "line-height:" + (16 * Dynamicweb.Core.Converter.ToDouble(Model.Item.GetRawValueString("LineHeight", "1.5"))).ToString() + "px;";
}

<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace:0pt;mso-table-rspace:0pt;mso-line-height-rule:exactly;@GetTableReset()color:inherit;width:100%;">
	<tbody>
		<tr style="@GetTableReset()">
			<td style="word-wrap:anywhere;mso-line-height-rule:exactly;mso-table-lspace:0pt;mso-table-rspace:0pt;@GetTableReset()@GetFontStack()text-align:@align;@(backgroundColor)@(foregroundColor)@(lineHeight)word-break:break-word;padding:@(padding)px;@(borderClass)" width="100%">
				@text
				<!--[if mso]><br/><![endif]-->
			</td>
		</tr>
	</tbody>
</table>
