{% extends "layouts/base.html" %}
{% load i18n static %}

{% block title %}{% trans "Appreciation Details" %} - {% endblock %}

{% block content %}
<div class="container-fluid py-4">
    <!-- Breadcrumb -->
    <nav aria-label="breadcrumb" class="mb-4">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="{% url 'appreciation:appreciation_list' %}">{% trans "Appreciation" %}</a></li>
            <li class="breadcrumb-item active" aria-current="page">{% trans "Details" %}</li>
        </ol>
    </nav>

    <!-- Appreciation Details Card -->
    <div class="row">
        <div class="col-lg-8">
            <div class="card shadow-sm mb-4">
                <div class="card-body">
                    <!-- Category Badge -->
                    <div class="d-flex justify-content-between align-items-start mb-3">
                        <div>
                            {% if appreciation.category %}
                                <span class="badge bg-primary fs-6 mb-2">
                                    <i class="{{ appreciation.category.icon|default:'fa-heart' }} me-2"></i>
                                    {{ appreciation.category.name_en }}
                                </span>
                            {% endif %}
                            <h2 class="h4 mb-1">{{ appreciation.message_en }}</h2>
                            {% if appreciation.message_ar %}
                                <p class="text-muted mb-0" dir="rtl">{{ appreciation.message_ar }}</p>
                            {% endif %}
                        </div>
                        <span class="badge bg-{% if appreciation.status == 'acknowledged' %}success{% else %}primary{% endif %}">
                            {{ appreciation.get_status_display }}
                        </span>
                    </div>

                    <hr>

                    <!-- Sender and Recipient Info -->
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <h6 class="text-muted mb-2">{% trans "From" %}</h6>
                            {% if appreciation.is_anonymous %}
                                <p class="mb-0">
                                    <i class="bi-person-secret text-muted me-2"></i>
                                    {% trans "Anonymous" %}
                                </p>
                            {% else %}
                                <p class="mb-0">
                                    <i class="bi-person text-primary me-2"></i>
                                    {{ appreciation.sender.get_full_name }}
                                </p>
                            {% endif %}
                        </div>
                        <div class="col-md-6">
                            <h6 class="text-muted mb-2">{% trans "To" %}</h6>
                            <p class="mb-0">
                                <i class="bi-person text-success me-2"></i>
                                {{ appreciation.recipient_name }}
                            </p>
                        </div>
                    </div>

                    <!-- Additional Details -->
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <h6 class="text-muted mb-2">{% trans "Sent At" %}</h6>
                            <p class="mb-0">
                                <i class="bi-clock text-info me-2"></i>
                                {{ appreciation.sent_at|date:"F j, Y, g:i A" }}
                            </p>
                        </div>
                        <div class="col-md-6">
                            <h6 class="text-muted mb-2">{% trans "Visibility" %}</h6>
                            <p class="mb-0">
                                <i class="bi-eye text-warning me-2"></i>
                                {{ appreciation.get_visibility_display }}
                            </p>
                        </div>
                    </div>

                    {% if appreciation.acknowledged_at %}
                        <div class="alert alert-success">
                            <i class="bi-check-circle me-2"></i>
                            {% trans "Acknowledged on" %} {{ appreciation.acknowledged_at|date:"F j, Y, g:i A" }}
                        </div>
                    {% endif %}

                    <!-- Actions -->
                    <div class="d-flex gap-2 mt-4">
                        {% if is_recipient and appreciation.status == 'sent' %}
                            <form method="post" action="{% url 'appreciation:appreciation_acknowledge' appreciation.id %}" class="d-inline">
                                {% csrf_token %}
                                <button type="submit" class="btn btn-success">
                                    <i class="bi-check me-2"></i>
                                    {% trans "Acknowledge" %}
                                </button>
                            </form>
                        {% endif %}
                        <a href="{% url 'appreciation:appreciation_list' %}" class="btn btn-outline-secondary">
                            <i class="bi-arrow-left me-2"></i>
                            {% trans "Back to List" %}
                        </a>
                    </div>
                </div>
            </div>

            <!-- Related Appreciations -->
            {% if related %}
                <div class="card shadow-sm">
                    <div class="card-header bg-light">
                        <h5 class="card-title mb-0">
                            <i class="bi-link me-2"></i>
                            {% trans "Related Appreciations" %}
                        </h5>
                    </div>
                    <div class="card-body">
                        <div class="list-group list-group-flush">
                            {% for rel in related %}
                                <a href="{% url 'appreciation:appreciation_detail' rel.id %}" class="list-group-item list-group-item-action">
                                    <div class="d-flex w-100 justify-content-between">
                                        <h6 class="mb-1">{{ rel.message_en|truncatewords:10 }}</h6>
                                        <small class="text-muted">{{ rel.sent_at|date:"M d, Y" }}</small>
                                    </div>
                                    <p class="mb-1 small text-muted">
                                        <i class="bi-person me-1"></i>
                                        {{ rel.sender.get_full_name }}
                                    </p>
                                </a>
                            {% endfor %}
                        </div>
                    </div>
                </div>
            {% endif %}
        </div>

        <!-- Sidebar -->
        <div class="col-lg-4">
            <!-- Quick Stats -->
            <div class="card shadow-sm mb-4">
                <div class="card-header bg-light">
                    <h6 class="card-title mb-0">{% trans "Quick Info" %}</h6>
                </div>
                <div class="card-body">
                    <ul class="list-unstyled mb-0">
                        <li class="mb-2">
                            <i class="bi-building text-muted me-2"></i>
                            <strong>{% trans "Hospital:" %}</strong> {{ appreciation.hospital.name }}
                        </li>
                        {% if appreciation.department %}
                            <li class="mb-2">
                                <i class="bi-diagram-3 text-muted me-2"></i>
                                <strong>{% trans "Department:" %}</strong> {{ appreciation.department.name }}
                            </li>
                        {% endif %}
                        <li>
                            <i class="bi bi-card-badge text-muted me-2"></i>
                            <strong>{% trans "ID:" %}</strong> #{{ appreciation.id }}
                        </li>
                    </ul>
                </div>
            </div>

            <!-- Actions -->
            <div class="card shadow-sm">
                <div class="card-header bg-light">
                    <h6 class="card-title mb-0">{% trans "Actions" %}</h6>
                </div>
                <div class="card-body">
                    <div class="d-grid gap-2">
                        <a href="{% url 'appreciation:appreciation_send' %}" class="btn btn-primary">
                            <i class="bi-send me-2"></i>
                            {% trans "Send Appreciation" %}
                        </a>
                        <a href="{% url 'appreciation:leaderboard_view' %}" class="btn btn-info">
                            <i class="bi-trophy me-2"></i>
                            {% trans "View Leaderboard" %}
                        </a>
                        <a href="{% url 'appreciation:my_badges_view' %}" class="btn btn-warning">
                            <i class="bi-award me-2"></i>
                            {% trans "My Badges" %}
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
{{ block.super }}
<script>
// Add any appreciation detail-specific JavaScript here
</script>
{% endblock %}
