{% extends "admin/base_site.html" %}
{% load i18n static %}

{% block title %}{% trans "Confirm deletion" %}{% endblock %}

{% block extrastyle %}
  {{ block.super }}
  <style>
    .delete-confirmation-container {
      max-width: 600px;
      margin: 2rem auto;
      padding: 0 1.5rem;
    }

    .delete-confirmation-card {
      background-color: white;
      border: 2px solid #dc3545;
      border-radius: 0.5rem;
      padding: 2rem;
      box-shadow: 0 0.25rem 0.5rem rgba(220, 53, 69, 0.2);
    }

    .delete-icon {
      font-size: 3rem;
      color: #dc3545;
      text-align: center;
      margin-bottom: 1rem;
    }

    .delete-confirmation-card h2 {
      font-size: 1.5rem;
      font-weight: 700;
      color: #212529;
      text-align: center;
      margin-bottom: 1rem;
    }

    .delete-warning {
      background-color: #fff5f5;
      border-left: 4px solid #dc3545;
      padding: 1rem;
      border-radius: 0.375rem;
      margin-bottom: 1.5rem;
      color: #721c24;
    }

    .delete-warning strong {
      display: block;
      margin-bottom: 0.5rem;
    }

    .delete-warning ul {
      margin: 0;
      padding-left: 1.5rem;
    }

    .delete-warning li {
      margin-bottom: 0.5rem;
    }

    .object-list {
      background-color: #f8f9fa;
      border: 1px solid #dee2e6;
      border-radius: 0.375rem;
      padding: 1rem;
      margin-bottom: 1.5rem;
    }

    .object-list h3 {
      font-size: 0.95rem;
      font-weight: 700;
      color: #212529;
      margin: 0 0 1rem 0;
    }

    .object-list ul {
      list-style: none;
      padding: 0;
      margin: 0;
    }

    .object-list li {
      padding: 0.5rem;
      color: #495057;
      border-bottom: 1px solid #e9ecef;
    }

    .object-list li:last-child {
      border-bottom: none;
    }

    .object-list li:before {
      content: "✕ ";
      color: #dc3545;
      font-weight: bold;
      margin-right: 0.5rem;
    }

    .confirmation-form {
      margin-top: 2rem;
      padding-top: 1.5rem;
      border-top: 1px solid #dee2e6;
    }

    .form-actions {
      display: flex;
      gap: 1rem;
      justify-content: center;
    }

    .form-actions button,
    .form-actions a {
      padding: 0.75rem 1.5rem;
      font-weight: 600;
      font-size: 0.95rem;
      border: none;
      border-radius: 0.375rem;
      cursor: pointer;
      text-decoration: none;
      transition: all 0.2s ease;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
    }

    .form-actions .btn-danger {
      background-color: #dc3545;
      color: white;
    }

    .form-actions .btn-danger:hover {
      background-color: #c82333;
      transform: translateY(-1px);
      box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    }

    .form-actions .btn-secondary {
      background-color: #6c757d;
      color: white;
      text-decoration: none;
    }

    .form-actions .btn-secondary:hover {
      background-color: #5a6268;
      transform: translateY(-1px);
      box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    }

    .form-hidden {
      display: none;
    }
  </style>
{% endblock %}

{% block page_title %}
  {% trans "Confirm Deletion" %}
{% endblock %}

{% block content %}
<div class="delete-confirmation-container">
  <div class="delete-confirmation-card">
    <div class="delete-icon">
      <i class="bi bi-exclamation-triangle"></i>
    </div>

    <h2>{% trans "Confirm Deletion" %}</h2>

    {% if protected_objects %}
      <div class="delete-warning">
        <strong>{% trans "Cannot delete this object because other objects depend on it:" %}</strong>
        {% for related in protected_objects %}
          <div>
            <strong>{{ related.app_label }}.{{ related.model_name }}</strong>
            <ul>
              {% for obj in related.objects %}
                <li>{{ obj }}</li>
              {% endfor %}
            </ul>
          </div>
        {% endfor %}
      </div>

      <div class="form-actions">
        <a href="{{ back_url }}" class="btn-secondary">
          <i class="bi bi-arrow-left"></i> {% trans "Back" %}
        </a>
      </div>
    {% else %}
      <div class="delete-warning">
        <strong>{% trans "Are you sure?" %}</strong>
        <p>{% trans "This action cannot be undone. Please confirm that you want to delete the following object(s):" %}</p>
      </div>

      {% if deletion_count %}
        <div class="object-list">
          <h3>{% blocktranslate count counter=deletion_count %}{{ counter }} object{% plural %}{{ counter }} objects{% endblocktranslate %}</h3>
          <ul>
            {% for obj in deleted_objects %}
              <li>{{ obj }}</li>
            {% endfor %}
          </ul>
        </div>
      {% endif %}

      <form method="post" id="delete-form" class="confirmation-form">
        {% csrf_token %}
        <input type="hidden" name="post" value="yes">

        <div class="form-actions">
          <button type="submit" class="btn-danger" name="delete-confirm">
            <i class="bi bi-check-circle"></i> {% trans "Confirm Deletion" %}
          </button>
          <a href="{{ back_url }}" class="btn-secondary">
            <i class="bi bi-x-circle"></i> {% trans "Cancel" %}
          </a>
        </div>
      </form>
    {% endif %}
  </div>
</div>
{% endblock %}
