jQuery(document).ready(function($) {
	let counter = $('#boxyfy-produkt-info-container .boxyfy-produkt-info-row').length;

	$('.boxyfy-add-row').on('click', function(e) {
		e.preventDefault();
		let newRow = `
			<div class="boxyfy-produkt-info-row">
				<label>Filtertitel:</label>
				<input type="text" name="tsprodukt_info[${counter}][name]" placeholder="z. B. Gewicht" />
				<label>Filterwert:</label>
				<input type="text" name="tsprodukt_info[${counter}][value]" placeholder="z. B. 4.89" />
				<label>Einheit:</label>
				<input type="text" class="boxyfy-einheit-input" name="tsprodukt_info[${counter}][unit]" placeholder="z. B. Gramm/g" />
				<button class="boxyfy-remove-row">Entfernen</button>
			</div>
		`;
		$('#boxyfy-produkt-info-container').append(newRow);
		counter++;
	});

	$(document).on('click', '.boxyfy-remove-row', function(e) {
		e.preventDefault();
		$(this).parent().remove();
	});
});
