{% extends "base.html" %}
{% load static %}

{% block title %}{{ title }}{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h1 class="h3 mb-0">{{ title }}</h1>
                <a href="{% url 'source_detail' source.slug %}" class="btn btn-outline-secondary">
                    <i class="fas fa-arrow-left"></i> Back to Source
                </a>
            </div>

            <div class="row">
                <div class="col-md-8">
                    <div class="card">
                        <div class="card-body">
                            <div class="alert alert-warning d-flex align-items-center">
                                <i class="fas fa-exclamation-triangle fa-2x me-3"></i>
                                <div>
                                    <strong>Warning:</strong> This action cannot be undone.
                                    Deleting this source will also remove all associated integration logs and API credentials.
                                </div>
                            </div>

                            <div class="mb-4">
                                <h5>Source to be deleted:</h5>
                                <div class="card bg-light">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col-md-6">
                                                <strong>Name:</strong><br>
                                                {{ source.name }}
                                            </div>
                                            <div class="col-md-6">
                                                <strong>Type:</strong><br>
                                                <span class="badge bg-info">{{ source.get_source_type_display }}</span>
                                            </div>
                                        </div>
                                        {% if source.description %}
                                            <hr>
                                            <div>
                                                <strong>Description:</strong><br>
                                                {{ source.description|linebreaks }}
                                            </div>
                                        {% endif %}
                                        <hr>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <strong>Created:</strong><br>
                                                {{ source.created_at|date:"M d, Y H:i" }}
                                            </div>
                                            <div class="col-md-6">
                                                <strong>Total API Calls:</strong><br>
                                                {{ source.integration_logs.count }}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <form method="post" class="d-inline">
                                {% csrf_token %}
                                <div class="d-flex justify-content-between">
                                    <a href="{{ cancel_url }}" class="btn btn-outline-secondary">
                                        <i class="fas fa-times"></i> Cancel
                                    </a>
                                    <button type="submit" class="btn btn-danger">
                                        <i class="fas fa-trash"></i> Delete Source
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

                <div class="col-md-4">
                    <div class="card">
                        <div class="card-header">
                            <h6 class="mb-0">Impact Summary</h6>
                        </div>
                        <div class="card-body">
                            <div class="mb-3">
                                <label class="form-label text-muted">Integration Logs</label>
                                <div class="h5 mb-0 text-danger">
                                    {{ source.integration_logs.count }} will be deleted
                                </div>
                            </div>
                            <div class="mb-3">
                                <label class="form-label text-muted">API Credentials</label>
                                <div class="h5 mb-0 text-danger">
                                    API Key & Secret will be permanently lost
                                </div>
                            </div>
                            <div class="mb-3">
                                <label class="form-label text-muted">Active Integrations</label>
                                <div class="h5 mb-0 text-warning">
                                    Any systems using this API will lose access
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
