{% extends "base.html" %}

{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
    <h1 class="h2">Dettaglio Cliente</h1>
    <div>
        <a href="{% url 'client_update' client.pk %}" class="btn btn-secondary">Modifica</a>
        <a href="{% url 'client_delete' client.pk %}" class="btn btn-danger">Elimina</a>
    </div>
</div>

<div class="card mb-4">
    <div class="card-header">
        <h3>{{ client.name }}</h3>
    </div>
    <div class="card-body">
        <p><strong>Email:</strong> {{ client.email }}</p>
        <p><strong>Telefono:</strong> {{ client.phone }}</p>
        <p><strong>Indirizzo:</strong> {{ client.address }}</p>
        <p><strong>Password di sistema:</strong> <code>{{ client.system_password }}</code></p>
        <p><strong>Data Creazione:</strong> {{ client.created_at|date:"d/m/Y H:i" }}</p>
    </div>
</div>

<div class="card">
    <div class="card-header">
        <h4>Attività del Cliente</h4>
    </div>
    <div class="card-body">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>Titolo</th>
                    <th>Stato</th>
                    <th>Data</th>
                    <th>Azioni</th>
                </tr>
            </thead>
            <tbody>
                {% for activity in activities %}
                <tr>
                    <td>{{ activity.title }}</td>
                    <td><span class="badge bg-secondary">{{ activity.get_status_display }}</span></td>
                    <td>{{ activity.activity_date|date:"d/m/Y" }}</td>
                    <td>
                        <a href="{% url 'activity_detail' activity.pk %}" class="btn btn-sm btn-info">Dettagli</a>
                    </td>
                </tr>
                {% empty %}
                <tr>
                    <td colspan="4" class="text-center">Nessuna attività trovata per questo cliente.</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="card-footer text-muted">
        <a href="{% url 'client_list' %}" class="btn btn-light">Torna alla lista</a>
    </div>
</div>
{% endblock %}
