{% extends "base.html" %}
{% from "_macros.html" import modal %}
{% block extra_head %}
<link rel="stylesheet" href="/static/css/feed.css">
<link rel="stylesheet" href="/static/css/post.css">
<link rel="stylesheet" href="/static/css/bugs.css">
{% endblock %}
{% block content %}
<div class="bugs-layout">
<div class="bugs-header">
<h1>Bug Reports</h1>
{% if user %}
<button type="button" class="btn btn-primary btn-sm" data-modal="create-bug-modal"><span class="icon">&#x1F41B;</span> Report Bug</button>
{% endif %}
</div>
<div class="bugs-list">
{% for item in bugs %}
<div class="bug-card">
<div class="bug-card-header">
{% set _user = item.author %}{% set _size = 24 %}{% set _size_class = "sm" %}{% include "_avatar_link.html" %}
<span class="bug-title">{{ item.bug['title'] }}</span>
<span class="bug-status {{ item.bug['status'] }}">{{ item.bug['status'] }}</span>
</div>
<div class="bug-desc">{{ item.bug['description'][:300] }}</div>
<div class="bug-meta">{{ item.author['username'] if item.author else 'Unknown' }} &middot; {{ item.time_ago }}</div>
{% set b_attachments = item.get('attachments', []) %}
{% if b_attachments %}
{% with attachments=b_attachments %}
{% include "_attachment_display.html" %}
{% endwith %}
{% endif %}
{% with target_uid=item.bug['uid'], target_type="bug", comments=item.comments %}
{% include "_comment_section.html" %}
{% endwith %}
</div>
{% else %}
<div class="empty-state">No bug reports yet.</div>
{% endfor %}
</div>
</div>
{% if user %}
{% call modal('create-bug-modal', 'Report a Bug') %}
<form method="POST" action="/bugs/create">
<div class="auth-field auth-field-gap">
<label for="bug-title">Title</label>
<input type="text" id="bug-title" name="title" required maxlength="200" placeholder="Brief description of the issue">
</div>
<div class="auth-field auth-field-gap">
<label for="bug-description">Description</label>
<textarea id="bug-description" name="description" required maxlength="5000" placeholder="Detailed steps to reproduce..." class="min-h-120" data-mention></textarea>
</div>
{% include "_attachment_form.html" %}
<div class="modal-footer">
<button type="button" class="modal-close btn btn-secondary">Cancel</button>
<button type="submit" class="btn btn-primary"><span class="icon">&#x1F4E4;</span> Submit Report</button>
</div>
</form>
{% endcall %}
{% endif %}
{% endblock %}