{% load static %}
<div class="card mx-auto benchcoach-lineup" style="max-width: 455px" id="benchcoach-lineup-{{ event_id }}">
  <form method="post" id="form-lineup-{{ event.data.id }}">
    {{ formset.management_form }}
    {% csrf_token %}
    <div class="border-bottom p-2">
      <h4 class="card-title text-nowrap">{{ event.data.formatted_title }}</h4>
      <h6 class="text-muted card-subtitle text-nowrap">{{ event.data.start_date|date:"D, F j, Y g:i A" }}</h6>

      <div class="row">
        <div class="col">
          <button class="btn btn-primary btn-sm py-0 m-1" onclick="importFromClipboard(this)" type="button"><i class="bi bi-arrow-90deg-down"></i></i><i class="bi bi-file-spreadsheet"></i>  </button>
        </div>
        <div class="col text-end d-inline">
          <div class="btn-group">
            <div class="dropdown">
              <button class="btn btn-secondary dropdown-toggle btn-sm py-0 m-1" type="button" id="dropdownMenuButton1"
                      data-bs-toggle="dropdown" aria-expanded="false">
                <i class="bi bi-share"></i> Export
              </button>
              <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
                <li>
                  <a class="dropdown-item" href="javascript:;"
                     onclick="copyEmailTable(this, '{{ event.data.start_date|date:"D, F j, Y g:i A" }}, {{ event.data.location_name }}, ({% if event.data.game_type == 'Away' %}@{% endif %}{{ event.data.opponent_name }})', '{% for form in formset %}{{ form.member.data.email_addresses.0 }},{% endfor %}')">
                    <i class="bi bi-envelope"></i> Generate Lineup Email
                  </a>
                </li>
                <li>
                  <a class="dropdown-item" onclick="sendToClipboard(this)">
                    <i class="bi bi-file-spreadsheet"></i> Sheet format to Clipboard
                  </a>
                </li>
              </ul>
            </div>
            <div>
              <button type="Submit"  class="btn btn-teamsnap btn-sm py-0 m-1" formaction="{% url 'teamsnap_submit_lineup' team_id=event.data.team_id event_id=event.data.id %}" form="form-lineup-{{ event.data.id }}" id="submit-lineup-teamsnap-{{ event.data.id }}">
                <i class="bi bi-arrow-right"></i>
                TeamSnap
              </button>
            </div>
            <div>
              {% if request.user.gamechanger_account %}
              <button type="Submit" class="btn btn-gamechanger btn-sm py-0 m-1 text-nowrap" formaction="{% url 'gamechanger_lineup_submit' %}" form="form-lineup-{{ event.data.id }}" id="submit-lineup-gamechanger-{{ event.data.id }}">
                <i class="bi bi-arrow-right"></i>
                GameChanger
              </button>
              {% endif %}
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="card-body p-0 m-0">
      <div>
        <div class="row m-0">
          <div class="col border-bottom bg-light">
            <i class="bi bi-clipboard-check me-1"></i><span class="text-uppercase fw-bold small">Starting Lineup</span>
          </div>
        </div>

        <div class = "row m-0">
          <div class="col border-bottom px-0">
            <div class="row mx-0 my-1 position-status">
              {% with 'P C 1B 2B 3B SS LF CF RF EH DH' as position_list %}
                {% for position in position_list.split %}
                  <div class="col fw-bold text-center small">
                    <span class="" id="position-status-{{ position }}">{{ position }}</span>
                  </div>
                {% endfor %}
              {% endwith %}
            </div>
          </div>
        </div>
        {% include 'lineup/widgets/lineup_table.html' with formset=formset_startinglineup table_id="benchcoach-startinglineup" %}
      </div>

      <div>
        <div class="row m-0">
          <div class="col border-bottom bg-light">
            <i class="bi bi-clipboard-minus me-1"></i><span class="text-uppercase fw-bold small">Starting (Positional Only)</span>

          </div>
        </div>

        {% include 'lineup/widgets/lineup_table.html' with formset=formset_startingpositionalonly table_id="benchcoach-startingpositionalonly" %}
      </div>

      <div>
        <div class="row m-0">
          <div class="col border-bottom bg-light">
            <i class="bi bi-clipboard me-1"></i><span class="text-uppercase fw-bold small">Bench</span>
          </div>
        </div>
      </div>
      {% include 'lineup/widgets/lineup_table.html' with formset=formset_bench table_id="benchcoach-bench" %}

      <div>
        <div class="row m-0">
          <div class="col border-bottom bg-light">
            <i class="bi bi-clipboard-x me-1"></i><span class="text-uppercase fw-bold small">Out</span>
          </div>
        </div>
      </div>
      {% include 'lineup/widgets/lineup_table.html' with formset=formset_out table_id="benchcoach-out" %}

    </div>
  </form>
</div>
