{% extends 'base.html' %}
{% block content %}
<div class="container mt-5">
  <!-- Action Buttons -->
  {% comment %} <div class="d-flex justify-content-end mb-3 gap-2">
    <form method="post" action="{% url 'update_official_status' official.id %}">
      {% csrf_token %}
      <input type="hidden" name="action" value="Approved" />
      <button type="submit" class="btn btn-success">Approve</button>
    </form>

    <form method="post" action="{% url 'update_official_status' official.id %}">
      {% csrf_token %}
      <input type="hidden" name="action" value="Rejected" />
      <button type="submit" class="btn btn-danger">Reject</button>
    </form>

    
  </div> {% endcomment %}


  <div class="card shadow-sm">
    <div class="card-header bg-dark text-white">
      <h4 class="mb-0">Official Details</h4>
    </div>
    <div class="card-body">
      <div class="row g-3">
        <div class="col-md-6"><strong>Name:</strong> {{ official.name }}</div>
        <div class="col-md-6"><strong>Designation:</strong> {{ official.designation }}</div>
        <div class="col-md-6"><strong>Sex:</strong> {{ official.sex }}</div>
        <div class="col-md-6">
          <strong>Status:</strong>
          <span class="badge 
            {% if official.status == 'Approved' %}bg-success
            {% elif official.status == 'Rejected' %}bg-danger
            {% else %}bg-secondary{% endif %}">
            {{ official.status }}
          </span>
        </div>
        <div class="col-md-6"><strong>Club:</strong> {{ official.club.name }}</div>
        <div class="col-md-6"><strong>Coach:</strong> {{ official.is_coach|yesno:"Yes,No" }}</div>

        {% if official.is_coach %}
        <div class="col-md-6"><strong>Certificate:</strong> {{ official.coaching_certificate_obtained }}</div>
        <div class="col-md-6"><strong>Year:</strong> {{ official.certificate_year }}</div>
        <div class="col-md-6">
          <strong>Upload:</strong>
          {% if official.certificate_upload %}
            <a href="{{ official.certificate_upload.url }}" target="_blank">Download</a>
          {% else %}
            <span class="text-muted">Not uploaded</span>
          {% endif %}
        </div>
        {% endif %}

        <div class="col-md-6">
          <strong>Passport Photo:</strong><br />
          <img src="{{ official.passport_photo.url }}" class="img-thumbnail mt-2" width="150" />
        </div>
      </div>
    </div>

 
    <div class="card-footer text-end">
      {% comment %} {% if official.status != 'Approved'  or official.status == 'Rejected' %}
      <a href="{% url 'update_official_status' official.id %}" class="btn btn-primary">Update Status</a>
      {% else %} {% endcomment %}
     
      {% comment %} <a href="{% url 'official_delete' official.id %}" class="btn btn-danger">Delete</a> {% endcomment %}
      <a href="{% url 'club_official_list' %}" class="btn btn-secondary">Back</a>
      {% comment %} {% endif %} {% endcomment %}
    </div>
  </div>
</div>
{% endblock %}
