{% extends "frontend/base.html" %}
{% load i18n %}
{% load static %}
{% block html_title %}
    {% block page_title %}
        {{ service.name }}
    {% endblock page_title %}
{% endblock html_title %}
{% block content %}
    <section class="section">
        <div class="card">
            <div class="card-header d-flex align-items-center">
                {% if service.logo %}
                    <img src="{{ service.logo.url }}"
                         alt="{{ service.name }}"
                         class="me-3"
                         style="max-width: 48px;
                                max-height: 48px">
                {% endif %}
                <div class="d-flex flex-column">
                    <h4 class="mb-0">{{ service.name }}</h4>
                    <small class="text-muted">{{ service.category }}</small>
                </div>
            </div>
            <div class="card-body">
                <div class="row">
                    <p>{{ service.description|default:"No description available." }}</p>
                </div>
            </div>
        </div>
        {% for offering in service.offerings.all %}
            <div class="card col-6 col-lg-3 col-md-4">
                <div class="card-header d-flex align-items-center">
                    {% if offering.provider.logo %}
                        <img src="{{ offering.provider.logo.url }}"
                             alt="{{ offering.provider.name }}"
                             class="me-3"
                             style="max-width: 48px;
                                    max-height: 48px">
                    {% endif %}
                    <div class="d-flex flex-column">
                        <h4 class="mb-0">{{ offering.provider.name }}</h4>
                    </div>
                </div>
                <div class="card-body">
                    {% if offering.description %}
                        <p class="card-text">{{ offering.description }}</p>
                    {% elif offering.provider.description %}
                        <p class="card-text">{{ offering.provider.description }}</p>
                    {% endif %}
                </div>
                <div class="card-footer d-flex justify-content-between">
                    <span></span>
                    <a href="offering/{{ offering.pk }}/" class="btn btn-light-primary">{% translate "Read More" %}</a>
                </div>
            </div>
        {% empty %}
            <div class="card">
                <div class="card-body">
                    <p>{% translate "No offerings found." %}</p>
                </div>
            </div>
        {% endfor %}
    </section>
{% endblock content %}
