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

{% block title %}{{ project.name }} - PX360{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="mb-3">
        <a href="{% url 'projects:project_list' %}" class="btn btn-outline-secondary btn-sm">
            <i class="bi bi-arrow-left me-1"></i> Back to Projects
        </a>
    </div>

    <div class="row">
        <div class="col-lg-8">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">{{ project.name }}</h5>
                </div>
                <div class="card-body">
                    <p>{{ project.description }}</p>
                    
                    {% if project.outcome_description %}
                    <hr>
                    <h6>{% trans "Outcome:" %}</h6>
                    <p>{{ project.outcome_description }}</p>
                    {% endif %}
                    
                    {% if tasks %}
                    <hr>
                    <h6>{% trans "Tasks:" %}</h6>
                    <div class="list-group">
                        {% for task in tasks %}
                        <div class="list-group-item">
                            <div class="d-flex justify-content-between align-items-center">
                                <div>
                                    <strong>{{ task.title }}</strong>
                                    {% if task.assigned_to %}
                                    <br><small class="text-muted">Assigned to: {{ task.assigned_to.get_full_name }}</small>
                                    {% endif %}
                                </div>
                                <span class="badge bg-{{ task.status }}">{{ task.get_status_display }}</span>
                            </div>
                        </div>
                        {% endfor %}
                    </div>
                    {% endif %}
                </div>
            </div>
        </div>

        <div class="col-lg-4">
            <div class="card mb-3">
                <div class="card-header">
                    <h6 class="mb-0"><i class="bi bi-info-circle me-2"></i>{% trans "Project Info" %}</h6>
                </div>
                <div class="card-body">
                    <div class="mb-2">
                        <strong>Status:</strong><br>
                        <span class="badge bg-{{ project.status }}">{{ project.get_status_display }}</span>
                    </div>
                    <div class="mb-2">
                        <strong>Hospital:</strong><br>
                        {{ project.hospital.name }}
                    </div>
                    {% if project.department %}
                    <div class="mb-2">
                        <strong>Department:</strong><br>
                        {{ project.department.name }}
                    </div>
                    {% endif %}
                    {% if project.project_lead %}
                    <div class="mb-2">
                        <strong>Project Lead:</strong><br>
                        {{ project.project_lead.get_full_name }}
                    </div>
                    {% endif %}
                    {% if project.start_date %}
                    <div class="mb-2">
                        <strong>Start Date:</strong><br>
                        {{ project.start_date|date:"M d, Y" }}
                    </div>
                    {% endif %}
                    {% if project.target_completion_date %}
                    <div class="mb-0">
                        <strong>Target Date:</strong><br>
                        {{ project.target_completion_date|date:"M d, Y" }}
                    </div>
                    {% endif %}
                </div>
            </div>
            
            {% if project.related_actions.count > 0 %}
            <div class="card">
                <div class="card-header">
                    <h6 class="mb-0"><i class="bi bi-lightning me-2"></i>{% trans "Related Actions" %}</h6>
                </div>
                <div class="card-body">
                    <p class="mb-0">{{ project.related_actions.count }} linked actions</p>
                </div>
            </div>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}
