{% extends "base.html" %}

{% block title %}User: {{ user.email }} - Admin - {{ config.APP_NAME }}{% endblock %}

{% block content %}
<main class="container">
  <header style="display: flex; justify-content: space-between; align-items: center;">
    <h1>{{ user.email }}</h1>
    <a href="{{ url_for('admin.users') }}" role="button" class="secondary outline">← Users</a>
  </header>
  
  <div class="grid">
    <!-- User Info -->
    <article>
      <header><h3>User Info</h3></header>
      <dl>
        <dt>ID</dt>
        <dd>{{ user.id }}</dd>
        
        <dt>Email</dt>
        <dd>{{ user.email }}</dd>
        
        <dt>Name</dt>
        <dd>{{ user.name or '-' }}</dd>
        
        <dt>Created</dt>
        <dd>{{ user.created_at }}</dd>
        
        <dt>Last Login</dt>
        <dd>{{ user.last_login_at or 'Never' }}</dd>
      </dl>
    </article>
    
    <!-- Subscription -->
    <article>
      <header><h3>Subscription</h3></header>
      <dl>
        <dt>Plan</dt>
        <dd>
          {% if user.plan %}
          <mark>{{ user.plan }}</mark>
          {% else %}
          free
          {% endif %}
        </dd>
        
        <dt>Status</dt>
        <dd>{{ user.sub_status or 'N/A' }}</dd>
        
        {% if user.stripe_customer_id %}
        <dt>Stripe Customer</dt>
        <dd>
          <a href="https://dashboard.stripe.com/customers/{{ user.stripe_customer_id }}" target="_blank">
            {{ user.stripe_customer_id }}
          </a>
        </dd>
        {% endif %}
      </dl>
    </article>
  </div>
  
  <!-- Actions -->
  <article>
    <header><h3>Actions</h3></header>
    <div style="display: flex; gap: 1rem;">
      <form method="post" action="{{ url_for('admin.impersonate', user_id=user.id) }}">
        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
        <button type="submit" class="secondary">Impersonate User</button>
      </form>
    </div>
  </article>
</main>
{% endblock %}
