{% extends "website/base.html" %}
{% block content %}
<section class="section">
  <div class="card">
    <div class="card-title">
      <div class="icon">🎫</div>
      <div>
        <h1 class="h1" style="margin:0">Ticket {{ ticket.public_id }}</h1>
        <div class="small">Status: <strong>{{ ticket.get_status_display }}</strong></div>
      </div>
    </div>
    <div class="sep"></div>

    <div style="display:grid;gap:10px">
      {% for m in ticket.messages.all %}
        <div class="card soft card-tight" style="border-radius:14px">
          <div class="small" style="display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap">
            <strong>{{ m.sender|title }}</strong>
            <span>{{ m.created_at|date:"M d, Y H:i" }}</span>
          </div>
          <div style="margin-top:6px;white-space:pre-wrap">{{ m.message }}</div>
        </div>
      {% empty %}
        <p class="p">No messages yet.</p>
      {% endfor %}
    </div>

    <div class="sep"></div>

    <form method="post">
      {% csrf_token %}
      <label class="label">Add a message</label>
      <textarea name="message" placeholder="Type your message..." required></textarea>
      <div style="display:flex;gap:10px;flex-wrap:wrap;margin-top:12px">
        <button class="btn btn-primary" type="submit">Send</button>
        <a class="btn" href="/">Home</a>
      </div>
    </form>
  </div>
</section>
{% endblock %}
