{% extends 'users/base.html' %}

{% block title %}User Details: {{ user.get_full_name|default:user.email }}{% endblock %}

{% block card_content %}
<div class="row">
    <div class="col-md-6">
        <h4>Personal Information</h4>
        <table class="table table-bordered">
            <tr>
                <th>Name</th>
                <td>{{ user.get_full_name|default:"-" }}</td>
            </tr>
            <tr>
                <th>Email</th>
                <td>{{ user.email }}</td>
            </tr>
            <tr>
                <th>Role</th>
                <td>{{ user.role.name|default:"-" }}</td>
            </tr>
            <tr>
                <th>Department</th>
                <td>{{ user.department.name|default:"-" }}</td>
            </tr>
            <tr>
                <th>Status</th>
                <td>
                    <span class="badge {% if user.is_active %}bg-success{% else %}bg-danger{% endif %}">
                        {% if user.is_active %}Active{% else %}Inactive{% endif %}
                    </span>
                </td>
            </tr>
            <tr>
                <th>Last Login</th>
                <td>{{ user.last_login|default:"Never" }}</td>
            </tr>
            <tr>
                <th>Date Joined</th>
                <td>{{ user.date_joined }}</td>
            </tr>
        </table>
    </div>
    <div class="col-md-6">
        <h4>Permissions</h4>
        <table class="table table-bordered">
            <tr>
                <th>Is Staff</th>
                <td>{% if user.is_staff %}<i class="fas fa-check text-success"></i>{% else %}<i class="fas fa-times text-danger"></i>{% endif %}</td>
            </tr>
            <tr>
                <th>Is Superuser</th>
                <td>{% if user.is_superuser %}<i class="fas fa-check text-success"></i>{% else %}<i class="fas fa-times text-danger"></i>{% endif %}</td>
            </tr>
        </table>
    </div>
</div>
{% endblock %}

{% block card_footer %}
<div class="btn-group">
    <a href="{% url 'users:user_list' %}" class="btn btn-secondary">
        <i class="fas fa-arrow-left"></i> Back to List
    </a>
    <a href="{% url 'users:user_update' user.pk %}" class="btn btn-warning">
        <i class="fas fa-edit"></i> Edit User
    </a>
    {% if request.user.is_superuser %}
    <a href="{% url 'users:user_delete' user.pk %}" class="btn btn-danger"
       onclick="return confirm('Are you sure you want to delete this user?')">
        <i class="fas fa-trash"></i> Delete User
    </a>
    {% endif %}
</div>
{% endblock %}
