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

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

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

<div class="card">
  <div class="term-head">
    <span class="term-head-name">~/audio/albums/new</span>
  </div>
  <div class="card-body">
    <form method="post" action="/admin/audio/albums/create" enctype="multipart/form-data" class="space-y-2">
      <div class="form-control">
        <label class="label"><span class="label-text t-green">{{ t(key="album-title-label", lang=lang | default(value='sk')) }}</span></label>
        <input type="text" name="title" required class="input input-bordered w-full">
      </div>

      <div class="form-control">
        <label class="label"><span class="label-text t-green">{{ t(key="artist", lang=lang | default(value='sk')) }}</span></label>
        <input type="text" name="artist" class="input input-bordered w-full">
      </div>

      <div class="form-control">
        <label class="label"><span class="label-text t-green">{{ t(key="release-date", lang=lang | default(value='sk')) }}</span></label>
        <input type="date" name="release_date" class="input input-bordered w-full">
      </div>

      <div class="form-control">
        <label class="label"><span class="label-text t-green">{{ t(key="cover-image", lang=lang | default(value='sk')) }}</span></label>
        <input type="file" name="cover" accept="image/png,image/jpeg,image/webp,image/gif" class="file-input file-input-bordered w-full">
        <p class="term-help">{{ t(key="cover-help", lang=lang | default(value='sk')) }}</p>
      </div>

      <div class="form-control">
        <label class="label"><span class="label-text t-green">{{ t(key="description", lang=lang | default(value='sk')) }}</span></label>
        <textarea name="description" rows="5" class="textarea textarea-bordered w-full"></textarea>
      </div>

      <div class="term-formdiv"></div>

      <div class="form-control">
        <label class="label"><span class="label-text t-green">{{ t(key="songs-in-album", lang=lang | default(value='sk')) }}</span></label>
        {% if available_tracks | length > 0 %}
        <div class="term-picklist">
          {% for song in available_tracks %}
          <label class="term-pick">
            <input type="checkbox" name="track_ids" value="{{ song.id }}" class="checkbox checkbox-sm">
            <span class="min-w-0 flex-1 font-medium">{{ song.title }}</span>
            {% if song.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 %}
          </label>
          {% endfor %}
        </div>
        <p class="term-help">{{ t(key="free-songs-help", lang=lang | default(value='sk')) }}</p>
        {% else %}
        <div class="term-picklist">
          <div class="term-pick">
            <span class="term-help" style="margin:0">
              {{ t(key="no-free-songs", lang=lang | default(value='sk')) }}
              <a href="/admin/audio/tracks/upload" class="t-blue">{{ t(key="upload-song-first", lang=lang | default(value='sk')) }}</a>,
              {{ t(key="create-empty-add-later", lang=lang | default(value='sk')) }}
            </span>
          </div>
        </div>
        {% endif %}
      </div>

      <label class="label cursor-pointer justify-start gap-2">
        <input type="checkbox" name="published" class="checkbox checkbox-sm">
        <span class="label-text">{{ t(key="publish-album-now", lang=lang | default(value='sk')) }}</span>
      </label>

      <div class="flex flex-wrap gap-2 pt-2">
        <button type="submit" class="btn btn-primary btn-sm">{{ t(key="create-album", lang=lang | default(value='sk')) }}</button>
        <a href="/admin/audio/albums" class="btn btn-ghost btn-sm">{{ t(key="cancel", lang=lang | default(value='sk')) }}</a>
      </div>
    </form>
  </div>
</div>
{% endblock content %}
