{% 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."|urlize }}</p>
                </div>
                {% if service.external_links %}
                    <div class="row mt-3">
                        <div class="col-12">
                            <h6 class="mb-3">{% translate "External Links" %}</h6>
                            <div class="d-flex flex-wrap gap-2">
                                {% for link in service.external_links %}
                                    {% include "includes/external_link.html" %}
                                {% endfor %}
                            </div>
                        </div>
                    </div>
                {% endif %}
            </div>
        </div>
        <div class="row match-height card-grid">
            {% for offering in visible_offerings %}
                <div class="col-6 col-lg-3 col-md-4">
                    <div class="card">
                        <div class="card-header card-header-with-logo">
                            {% if offering.provider.logo %}
                                <img src="{{ offering.provider.logo.url }}"
                                     alt="{{ offering.provider.name }}">
                            {% endif %}
                            <div class="card-header-content">
                                <h4>{{ offering.provider.name }}</h4>
                            </div>
                        </div>
                        <div class="card-content">
                            <div class="card-body">
                                {% if offering.description %}
                                    <p class="card-text">{{ offering.description|urlize }}</p>
                                {% elif offering.provider.description %}
                                    <p class="card-text">{{ offering.provider.description|urlize }}</p>
                                {% endif %}
                            </div>
                        </div>
                        <div class="card-footer d-flex justify-content-between">
                            <span></span>
                            <a href="offering/{{ offering.pk }}/" class="btn btn-light-primary">{% translate "Create Instance" %}</a>
                        </div>
                    </div>
                </div>
            {% empty %}
                <div class="card">
                    <div class="card-body">
                        <p>{% translate "No offerings found." %}</p>
                    </div>
                </div>
            {% endfor %}
        </div>
    </section>
{% endblock content %}
