{% extends 'pxy_dashboard/partials/base.html' %}
{% load static %}

{% block title %}Polisplexity Portal{% endblock title %}

{% block content %}
<div class="container-fluid">
    <div class="row justify-content-center">
        <div class="col-12 text-center mb-4">
            <h2 class="mt-3">Welcome to Polisplexity</h2>
            <p class="text-muted">Select one of the available options</p>
        </div>
    </div>

    {% for category, items in grouped_menu_items.items %}
        {% if not forloop.first %}
        <div class="row mt-4">
            <div class="col-12">
                <hr class="border-secondary">
            </div>
        </div>
        {% endif %}

        <div class="row mb-4">
            <div class="col-12">
                <h4 class="text-primary">{{ category.name }}</h4>
                <p class="text-muted">{{ category.description }}</p>
            </div>
        </div>

        <div class="row">
            {% for menu_item in items %}
            <div class="col-sm-6 col-lg-3">
                <div class="card d-block">
                    {% if menu_item.image %}
                        <img class="card-img-top" src="{{ menu_item.image.url }}" alt="{{ menu_item.title }}">
                    {% elif menu_item.icon %}
                        <div class="card-header text-center bg-light-subtle">
                            <span class="material-symbols-rounded display-4 text-primary">{{ menu_item.icon }}</span>
                        </div>
                    {% endif %}
                    <div class="card-body">
                        <h5 class="card-title">{{ menu_item.title }}</h5>
                        <p class="card-text">{{ menu_item.description }}</p>
                        <a href="{{ menu_item.url }}" class="btn btn-sm btn-primary stretched-link">{{ menu_item.url_text }}</a>
                    </div>
                </div>
            </div>
            {% endfor %}
        </div>
    {% endfor %}
</div>
{% endblock content %}
