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

{% block title %}Call Interaction - PX360{% endblock %}

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

    <div class="row">
        <div class="col-lg-8">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">{% trans "Call Interaction Details" %}</h5>
                </div>
                <div class="card-body">
                    <div class="mb-3">
                        <strong>Subject:</strong><br>
                        {{ interaction.subject }}
                    </div>
                    
                    {% if interaction.notes %}
                    <div class="mb-3">
                        <strong>Notes:</strong><br>
                        <p>{{ interaction.notes }}</p>
                    </div>
                    {% endif %}
                    
                    {% if interaction.resolution_notes %}
                    <div class="mb-3">
                        <strong>Resolution:</strong><br>
                        <div class="alert alert-success">
                            {{ interaction.resolution_notes }}
                        </div>
                    </div>
                    {% endif %}
                    
                    <div class="row">
                        <div class="col-md-6">
                            <strong>Call Type:</strong><br>
                            <span class="badge bg-info">{{ interaction.get_call_type_display }}</span>
                        </div>
                        <div class="col-md-6">
                            <strong>Resolved:</strong><br>
                            {% if interaction.resolved %}
                            <span class="badge bg-success">Yes</span>
                            {% else %}
                            <span class="badge bg-warning">No</span>
                            {% endif %}
                        </div>
                    </div>
                </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-star me-2"></i>{% trans "Rating" %}</h6>
                </div>
                <div class="card-body text-center">
                    {% if interaction.satisfaction_rating %}
                    <h1 class="mb-2 {% if interaction.is_low_rating %}text-danger{% else %}text-success{% endif %}">
                        {{ interaction.satisfaction_rating }}/5
                    </h1>
                    {% if interaction.is_low_rating %}
                    <span class="badge bg-danger">Low Rating</span>
                    {% endif %}
                    {% else %}
                    <p class="text-muted">No rating provided</p>
                    {% endif %}
                </div>
            </div>
            
            <div class="card mb-3">
                <div class="card-header">
                    <h6 class="mb-0"><i class="bi bi-clock me-2"></i>{% trans "Call Metrics" %}</h6>
                </div>
                <div class="card-body">
                    {% if interaction.wait_time_seconds %}
                    <div class="mb-2">
                        <strong>Wait Time:</strong><br>
                        {{ interaction.wait_time_seconds }} seconds
                    </div>
                    {% endif %}
                    
                    {% if interaction.call_duration_seconds %}
                    <div class="mb-2">
                        <strong>Duration:</strong><br>
                        {{ interaction.call_duration_seconds }} seconds
                    </div>
                    {% endif %}
                    
                    <div class="mb-0">
                        <strong>Started:</strong><br>
                        {{ interaction.call_started_at|date:"M d, Y H:i" }}
                    </div>
                </div>
            </div>
            
            <div class="card">
                <div class="card-header">
                    <h6 class="mb-0"><i class="bi bi-person me-2"></i>{% trans "Caller Info" %}</h6>
                </div>
                <div class="card-body">
                    {% if interaction.patient %}
                    <div class="mb-2">
                        <strong>Patient:</strong><br>
                        {{ interaction.patient.get_full_name }}
                    </div>
                    <div class="mb-0">
                        <strong>MRN:</strong><br>
                        {{ interaction.patient.mrn }}
                    </div>
                    {% else %}
                    <div class="mb-2">
                        <strong>Name:</strong><br>
                        {{ interaction.caller_name }}
                    </div>
                    <div class="mb-0">
                        <strong>Phone:</strong><br>
                        {{ interaction.caller_phone }}
                    </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
