{% extends "admin/base.html" %}

{% block title %}{{ t(key="albums-title", lang=lang | default(value='sk')) }}{% endblock title %}
{% block crumb %}audio/albums{% endblock crumb %}

{% block content %}
<header class="term-cmd">
  <div>
    <h1 class="term-title">{{ t(key="albums-title", lang=lang | default(value='sk')) }}</h1>
    <p class="term-sub">{{ t(key="admin-albums-desc", lang=lang | default(value='sk')) }}</p>
  </div>
  <div class="term-cmd-actions">
    <a href="/admin/audio/albums/create" class="btn btn-primary btn-sm">{{ t(key="new-album", lang=lang | default(value='sk')) }}</a>
    <a href="/admin/audio/tracks" class="btn btn-outline btn-sm">{{ t(key="songs-title", lang=lang | default(value='sk')) }}</a>
  </div>
</header>

<div class="term-note">
  <p class="term-note-title">{{ t(key="admin-albums-before", lang=lang | default(value='sk')) }}</p>
  <div class="term-step">
    <span class="term-step-n">[1]</span>
    <span>{{ t(key="admin-albums-step-upload", lang=lang | default(value='sk')) }}</span>
  </div>
  <div class="term-step">
    <span class="term-step-n">[2]</span>
    <span>{{ t(key="admin-albums-step-create", lang=lang | default(value='sk')) }}</span>
  </div>
</div>

<div class="card">
  <div class="term-head">
    <span class="term-head-name">~/audio/albums/</span>
    <span class="term-head-meta term-tag is-purple">{{ albums | length }} {{ t(key="albums-title", lang=lang | default(value='sk')) }}</span>
  </div>
  <div class="card-body">
    {% if albums | length > 0 %}
      <div class="overflow-x-auto">
        <table class="table">
          <thead>
            <tr>
              <th>{{ t(key="album", lang=lang | default(value='sk')) }}</th>
              <th>{{ t(key="status", lang=lang | default(value='sk')) }}</th>
              <th>{{ t(key="songs-title", lang=lang | default(value='sk')) }}</th>
              <th class="text-right">{{ t(key="actions", lang=lang | default(value='sk')) }}</th>
            </tr>
          </thead>
          <tbody>
            {% for row in albums %}
            <tr>
              <td class="font-medium">{{ row.album.title }}</td>
              <td>
                {% if row.album.published %}
                <span class="term-tag is-green">{{ t(key="published", lang=lang | default(value='sk')) }}</span>
                {% else %}
                <span class="term-tag">{{ t(key="draft", lang=lang | default(value='sk')) }}</span>
                {% endif %}
              </td>
              <td>{{ row.track_count }}</td>
              <td>
                <div class="flex flex-wrap gap-2">
                  <a href="/admin/audio/albums/{{ row.album.id }}/tracks" class="btn btn-primary btn-sm">{{ t(key="open-edit", lang=lang | default(value='sk')) }}</a>
                  <a href="/audio/albums/{{ row.album.slug }}" class="btn btn-ghost btn-sm">{{ t(key="view", lang=lang | default(value='sk')) }}</a>
                </div>
              </td>
            </tr>
            {% endfor %}
          </tbody>
        </table>
      </div>
    {% else %}
      <div class="term-empty">
        <p class="font-medium">{{ t(key="admin-no-albums", lang=lang | default(value='sk')) }}</p>
        <p class="term-empty-cmd">{{ t(key="admin-create-album-empty", lang=lang | default(value='sk')) }}</p>
        <div class="pt-2">
          <a href="/admin/audio/albums/create" class="btn btn-primary btn-sm">{{ t(key="new-album", lang=lang | default(value='sk')) }}</a>
        </div>
      </div>
    {% endif %}
  </div>
</div>
{% endblock content %}
