{% import 'macro/accordion.html' as accordion with context %}
{% import 'macro/badge.html' as badge %}
{% import 'macro/card.html' as card %}

<div class="card mb-3 flex-fill {% if solo %}card-solo{% endif %}">
  {{ card.header(item, item.fields.name, solo=solo, identifier=item.fields.part, icon='shapes-line') }}
  {{ card.image(item, solo=solo, last=last, caption=item.fields.name, alt=item.fields.image_id, medium=true) }}
  <div class="card-body border-bottom-0 {% if not solo %}p-1{% endif %}">
    {% if not solo %}
      {{ badge.color(item) }}
      {{ badge.print(item) }}
    {% endif %}
    {{ badge.total_sets(sets_using | length, solo=solo, last=last) }}
    {{ badge.total_minifigures(minifigures_using | length, solo=solo, last=last) }}
    {{ badge.total_quantity(item.fields.total_quantity, solo=solo, last=last) }}
    {{ badge.total_spare(item.fields.total_spare, solo=solo, last=last) }}
    {{ badge.total_missing(item.fields.total_missing, solo=solo, last=last) }}
    {{ badge.total_damaged(item.fields.total_damaged, solo=solo, last=last) }}
    {% if not last %}
      {{ badge.rebrickable(item, solo=solo, last=last) }}
      {{ badge.bricklink(item, solo=solo, last=last) }}
    {% endif %}
  </div>
  {% if solo %}
    <div class="accordion accordion-flush border-top" id="part-details">
      {{ accordion.cards(sets_using, 'Sets using this part', 'sets-using-inventory', 'part-details', 'set/card.html', icon='hashtag') }}
      {{ accordion.cards(sets_missing, 'Sets missing this part', 'sets-missing-inventory', 'part-details', 'set/card.html', icon='question-line') }}
      {{ accordion.cards(sets_damaged, 'Sets with this part damaged', 'sets-damaged-inventory', 'part-details', 'set/card.html', icon='error-warning-line') }}
      {{ accordion.cards(minifigures_using, 'Minifigures using this part', 'minifigures-using-inventory', 'part-details', 'minifigure/card.html', icon='group-line') }}
      {{ accordion.cards(minifigures_missing, 'Minifigures missing this part', 'minifigures-missing-inventory', 'part-details', 'minifigure/card.html', icon='question-line') }}
      {{ accordion.cards(minifigures_damaged, 'Minifigures with this part damaged', 'minifigures-damaged-inventory', 'part-details', 'minifigure/card.html', icon='error-warning-line') }}
      {{ accordion.cards(different_color, 'Same part with a different color', 'different-color', 'part-details', 'part/card.html', icon='palette-line') }}
      {{ accordion.cards(similar_prints, 'Prints using the same base', 'similar-prints', 'part-details', 'part/card.html', icon='paint-brush-line') }}
    </div>
    <div class="card-footer"></div>
  {% endif %}
</div>
