<!-- Empty State -->
{% if spools|length == 0 or not spools %}
<div class="alert alert-info text-center" role="alert">
  No spools available to tag at the moment.
</div>
{% else %}

<!-- Spool List -->
<div class="list-group">
  {% for spool in spools %}
  <!-- Individual Spool Item -->
  {% if action_fill %}<a href="{{ url_for('fill', spool_id=spool.id, ams=ams_id, tray=tray_id) }}"
     class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">{% endif %}
  {% if action_assign %}<a href="{{ url_for('write_tag', spool_id=spool.id) }}"
     class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">{% endif %}
    <!-- Left: Filament Color Badge -->
    <div class="me-3">
        <span class="badge d-inline-block"
              style="background-color: #{{ spool.filament.color_hex }}; width: 20px; height: 50px;">
        </span>
    </div>

    <!-- Middle: Filament Details -->
    <div class="flex-grow-1">
      <!-- Vendor Name and Material (Row 1) -->
      <h6 class="mb-0">{{ spool.filament.vendor.name }} - {{ spool.filament.material }}</h6>
      <!-- Filament Name (Row 2) -->
      <small class="text-muted">{{ spool.filament.name }}</small>
    </div>

    {% if action_fill %}
    <span class="badge bg-primary rounded-pill">
                <i class="bi bi-plus-circle"></i> Fill
            </span>
    {% endif %}
    {% if action_assign %}
    <!-- Action Icon -->
    {% if spool.extra.get("tag") or spool.extra.get("tag") == "\"\"" %}
    <span class="badge bg-secondary rounded-pill">
                <i class="bi bi-plus-circle"></i> Reassign
            </span>
    {% else %}
    <span class="badge bg-primary rounded-pill">
                <i class="bi bi-plus-circle"></i> Assign
            </span>
    {% endif %}
    {% endif %}
  {% if action_fill or action_assign %}</a>{% endif %}
  {% endfor %}
</div>
{% endif %}
