{% extends '@Contao/frontend_module/_base.html.twig' %}
{% import "@ContaoCore/Image/Studio/_macros.html.twig" as studio %}

{% block content %}
    {% if groups is not defined or groups is empty %}
        <p class="alert alert-secondary">{{ 'MSC.re_empty'|trans({}, 'contao_default') }}</p>
    {% else %}
        {% for group in groups %}
            {% block group %}
                {% if data.vr_re_grouped is defined and data.vr_re_grouped == '1' %}
                    <h3>{{ group.label }}</h3>
                {% endif %}
                <div class="assetList">
                    {% for item in group.items %}
                        {% block item %}
                            <div class="asset re_asset_card">
                                {% if item.teaserFigure %}
                                    {{- studio.figure(item.teaserFigure, { attr: { class: ('image_container media') }}) -}}
                                {% endif %}

                                <div class="details">
                                    <ul>
                                        <li>
                                            <span class="label">Adresse:</span>
                                            {% if item.address is not empty %}{{ item.address }}<br>{% endif %}
                                            {% if item.postal is not empty and item.city is not empty %}{{ item.postal }} {{ item.city }}<br>{% endif %}
                                        </li>
                                        {% if item.livingSpace > 0 %}
                                            <li>
                                                <span class="label">Wohnfläche:</span>
                                                {{ item.livingSpace|number_format(2, ',', '') }} m²
                                            </li>
                                        {% endif %}
                                        <li>
                                            <span class="label">Kaltmiete:</span>
                                            {% if item.coldRent is not empty %}{{ item.coldRent|number_format(2, ',', '') }} €{% endif %}
                                        </li>
                                    </ul>
                                    {% if item.detailsUrl %}
                                        <p class="details-link"><a class="link" href="{{ item.detailsUrl }}">{{ 'MSC.more'|trans({}, 'contao_default') }}</a></p>
                                    {% endif %}
                                </div>
                            </div>
                        {% endblock %}
                    {% endfor %}
                </div>
            {% endblock %}
        {% endfor %}
    {% endif %}
{% endblock %}
