{% extends "layouts/base.html" %}
{% load i18n %}

{% block extrastyle %}
<style>
  .clan-name-container {
    display: flex;
    align-items: center;
    gap: 6px; /* Espaço entre o grupo de crests e o nome */
  }

  .crest-group {
    display: flex;
    align-items: center;
    width: 26px;
    gap: 0px; /* Espaço entre as duas imagens */
  }

  .top-clan-crest {
    width: auto;
    height: 14px;
    margin: 0;
  }
</style>
{% endblock %}

{% block content %}
<div class="container mt-5">
  <div class="card shadow-lg p-4">
    <h2 class="text-center mb-4">{% trans "Todos os Heróis Olimpíada" %}</h2>

    {% if heroes %}
    <div class="table-responsive-md">
      <table class="table table-striped">
        <thead>
          <tr>
            <th>#</th>
            <th>{% trans "Jogador" %}</th>
            <th class="d-none d-md-table-cell">{% trans "Clan" %}</th>
            <th class="d-none d-md-table-cell">{% trans "Aliança" %}</th>
            <th>{% trans "Classe" %}</th>
            <th>{% trans "Contagem de Jogos" %}</th>
          </tr>
        </thead>
        <tbody>
          {% for hero in heroes %}
          <tr>
            <td>{{ forloop.counter }}</td>
            <td>{{ hero.char_name|default:"-" }}</td>
            <td><div class="clan-name-container">
              <div class="crest-group">
                {% if clan.ally_crest_image_base64 %}
                  <img src="data:image/png;base64,{{ hero.ally_crest_image_base64 }}" alt="Crest da Aliança" class="top-clan-crest">
                {% endif %}
                <img src="data:image/png;base64,{{ hero.clan_crest_image_base64 }}" alt="Crest do Clã" class="top-clan-crest">
              </div>
              {{ hero.clan_name|default:"-" }}
            </div></td>
            <td class="d-none d-md-table-cell">{{ hero.ally_name|default:"-" }}</td>
            <td>{{ hero.base }}</td>
            <td>{{ hero.count }}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
    {% else %}
    <div class="alert alert-warning text-center">
      {% trans "Nenhum dado encontrado." %}
    </div>
    {% endif %}
  </div>
</div>
{% endblock %}
