{% extends 'base.html' %}
{% load static i18n %}

{% block title %}{{ title }} - ATS{% endblock %}

{% block content %}
<div class="container-fluid py-4">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header bg-warning text-white">
                    <h5 class="mb-0">
                        <i class="fas fa-exclamation-triangle me-2"></i>
                        {{ title }}
                    </h5>
                </div>
                <div class="card-body">
                    <div class="alert alert-warning" role="alert">
                        <i class="fas fa-info-circle me-2"></i>
                        {{ message }}
                    </div>

                    <div class="d-flex align-items-center mb-3">
                        <div class="me-3">
                            <strong>Agency:</strong> {{ access_link.assignment.agency.name }}
                        </div>
                        <div class="me-3">
                            <strong>Job:</strong> {{ access_link.assignment.job.title }}
                        </div>
                    </div>

                    <div class="d-flex align-items-center mb-3">
                        <div class="me-3">
                            <strong>Current Status:</strong>
                            <span class="badge bg-{{ 'success' if access_link.is_active else 'danger' }}">
                                {{ 'Active' if access_link.is_active else 'Inactive' }}
                            </span>
                        </div>
                    </div>

                    <div class="d-flex align-items-center mb-3">
                        <div class="me-3">
                            <strong>Expires:</strong> {{ access_link.expires_at|date:"Y-m-d H:i" }}
                        </div>
                    </div>

                    <div class="d-flex align-items-center mb-3">
                        <div class="me-3">
                            <strong>Access Count:</strong> {{ access_link.access_count }}
                        </div>
                    </div>

                    <div class="d-flex align-items-center mb-3">
                        <div class="me-3">
                            <strong>Last Accessed:</strong>
                            {% if access_link.last_accessed %}
                                {{ access_link.last_accessed|date:"Y-m-d H:i" }}
                            {% else %}
                                Never
                            {% endif %}
                        </div>
                    </div>

                    <form method="post" action="{% url request.resolver_match.url_name %}">
                        {% csrf_token %}
                        <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                            <a href="{{ cancel_url }}" class="btn btn-secondary">
                                <i class="fas fa-times me-2"></i>
                                Cancel
                            </a>
                            <button type="submit" class="btn btn-warning">
                                <i class="fas fa-{{ 'toggle-on' if title == 'Reactivate Access Link' else 'toggle-off' }} me-2"></i>
                                {{ title }}
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
