{% extends "base.html" %}

{% block content %}
<div class="columns">
    <div class="column is-4">
        <div class="box">
            <h1 class="title">{{ user.username }}</h1>
            <h2 class="subtitle">User Details</h2>
            <table class="table is-fullwidth">
                <tbody>
                    <tr>
                        <th>ID</th>
                        <td>{{ user.id }}</td>
                    </tr>
                    <tr>
                        <th>Discord ID</th>
                        <td>{{ user.discord_id }}</td>
                    </tr>
                    <tr>
                        <th>Minecraft UUID</th>
                        <td>{{ user.minecraft_uuid or 'Not Linked' }}</td>
                    </tr>
                    <tr>
                        <th>Minecraft Username</th>
                        <td>{{ user.minecraft_username or 'Not Linked' }}</td>
                    </tr>
                    <tr>
                        <th>Registered</th>
                        <td>{{ user.created_at.strftime('%Y-%m-%d %H:%M') if user.created_at else 'Unknown' }}</td>
                    </tr>
                    <tr>
                        <th>Admin Status</th>
                        <td>
                            <span class="tag is-{{ 'danger' if user.is_admin else 'light' }}">
                                {{ 'Admin' if user.is_admin else 'User' }}
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>
            <a href="{{ url_for('admin.user_search') }}" class="button is-light is-fullwidth">Back to Search</a>
        </div>
    </div>

    <div class="column is-8">
        <div class="box">
            <h2 class="subtitle">Relevant Tickets</h2>
            <table class="table is-fullwidth is-hoverable">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Title</th>
                        <th>Status</th>
                        <th>Date</th>
                    </tr>
                </thead>
                <tbody>
                    {% for ticket in tickets %}
                    <tr>
                        <td>{{ ticket.id }}</td>
                        <td><a href="{{ url_for('main.ticket_detail', ticket_id=ticket.id) }}"><strong>{{ ticket.title
                                    }}</strong></a></td>
                        <td><span class="tag is-{{ 'success' if ticket.status == 'CLOSED' else 'warning' }}">{{
                                ticket.status }}</span></td>
                        <td>{{ ticket.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
                    </tr>
                    {% else %}
                    <tr>
                        <td colspan="4">No relevant tickets found.</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}