{% include 'ucp_header.html' %}

<div class="tab-pane active">
	<form id="ucp" method="post" action="{{ S_UCP_ACTION }}"{{ S_FORM_ENCTYPE }} class="iz-form">
		<section class="iz-card iz-card--ucp">
			<header class="iz-card__header">
				<h2 class="iz-card__title">{{ L_TITLE }}</h2>
			</header>

			<div class="iz-card__body">
				<p class="iz-prose">{{ L_ATTACHMENTS_EXPLAIN }}</p>

				{% if attachrow %}
					<!-- Top pagination / count -->
					<div class="iz-toolbar iz-toolbar--ucp" aria-label="{{ L_PAGINATION }}">
						<div class="iz-toolbar__right">
							<div class="iz-paginationbar iz-only-desktop">
								<span class="iz-badge">{{ NUM_ATTACHMENTS }}</span>
								<ul class="iz-pagination__list">
									{% if pagination %}
										{% include 'pagination.html' %}
									{% else %}
										<li class="iz-pagination__item is-current"><span class="iz-pagination__link">{{ PAGE_NUMBER }}</span></li>
									{% endif %}
								</ul>
							</div>

							<div class="iz-only-mobile">
								<ul class="iz-pagination__list">
									{% if pagination %}
										{% include 'pagination_mobile.html' %}
									{% else %}
										<li class="iz-pagination__item is-current"><span class="iz-pagination__link">{{ PAGE_NUMBER }}</span></li>
									{% endif %}
								</ul>
							</div>
						</div>
					</div>

					<div class="iz-space iz-space--sm"></div>

					<!-- Attachments table -->
					<div class="iz-tablewrap" role="region" aria-label="{{ L_ATTACHMENTS }}">
						<table class="iz-table iz-table--attachments">
							<thead>
								<tr>
									<th scope="col">
										<a class="iz-link" href="{{ U_SORT_FILENAME }}">{{ L_FILENAME }}</a>
									</th>
									<th scope="col" class="iz-only-desktop">
										<a class="iz-link" href="{{ U_SORT_DOWNLOADS }}">{{ L_DOWNLOADS }}</a>
									</th>
									<th scope="col" class="iz-only-desktop">
										<a class="iz-link" href="{{ U_SORT_POST_TIME }}">{{ L_POST_TIME }}</a>
									</th>
									<th scope="col" class="iz-table__check">{{ L_MARK }}</th>
								</tr>
							</thead>
							<tbody>
								{% for attachrow in attachrow %}
									<tr>
										<td>
											<a class="iz-link" href="{{ attachrow.U_VIEW_ATTACHMENT }}">{{ attachrow.FILENAME }}</a>
											<span class="iz-meta">&nbsp;({{ attachrow.SIZE }})</span>

											<div class="iz-meta iz-meta--small">
												{% if attachrow.S_IN_MESSAGE %}
													{{ L_PM }}{{ L_COLON }}&nbsp;
												{% else %}
													{{ L_TOPIC }}{{ L_COLON }}&nbsp;
												{% endif %}
												<a class="iz-link" href="{{ attachrow.U_VIEW_TOPIC }}">{{ attachrow.TOPIC_TITLE }}</a>
											</div>
										</td>

										<td class="iz-only-desktop">{{ attachrow.DOWNLOAD_COUNT }}</td>

										<td class="iz-only-desktop">
											<small class="iz-meta iz-meta--small">{{ attachrow.POST_TIME }}</small>
										</td>

										<td class="iz-table__check">
											<div class="iz-choice iz-choice--check">
												<input
													type="checkbox"
													name="attachment[{{ attachrow.ATTACH_ID }}]"
													id="attachment-{{ attachrow.ATTACH_ID }}"
													value="1"
													{% if attachrow.S_LOCKED %} disabled{% endif %}
												>
												<label for="attachment-{{ attachrow.ATTACH_ID }}">
													<span class="iz-visually-hidden">{{ L_MARK }}</span>
												</label>
											</div>
										</td>
									</tr>
								{% endfor %}
							</tbody>
						</table>
					</div>

					<div class="iz-space iz-space--sm"></div>

					<!-- Actions + options -->
					<div class="iz-toolbar iz-toolbar--ucp-actions" aria-label="{{ L_OPTIONS }}">
						<div class="iz-toolbar__left">
							{% if S_ATTACHMENT_ROWS %}
								<div class="iz-actions">
									<button type="button" class="iz-btn iz-btn--ghost iz-btn--sm" onclick="marklist('ucp', 'attachment', true); return false;">
										{{ L_MARK_ALL }}
									</button>
									<button type="button" class="iz-btn iz-btn--ghost iz-btn--sm" onclick="marklist('ucp', 'attachment', false); return false;">
										{{ L_UNMARK_ALL }}
									</button>
									<button class="iz-btn iz-btn--danger iz-btn--sm" type="submit" name="delete" title="{{ L_DELETE_MARKED }}">
										{{ L_DELETE_MARKED }}
									</button>
								</div>

								{{ S_FORM_TOKEN }}
							{% endif %}
						</div>

						<div class="iz-toolbar__right">
							<div class="iz-paginationbar iz-only-desktop">
								<span class="iz-badge">{{ TOTAL_ATTACHMENTS }}&nbsp;{{ L_TITLE }}</span>
								<ul class="iz-pagination__list">
									{% if pagination %}
										{% include 'pagination.html' %}
									{% else %}
										<li class="iz-pagination__item is-current"><span class="iz-pagination__link">{{ PAGE_NUMBER }}</span></li>
									{% endif %}
								</ul>
							</div>

							<div class="iz-only-mobile">
								<ul class="iz-pagination__list">
									{% if pagination %}
										{% include 'pagination_mobile.html' %}
									{% else %}
										<li class="iz-pagination__item is-current"><span class="iz-pagination__link">{{ PAGE_NUMBER }}</span></li>
									{% endif %}
								</ul>
							</div>
						</div>
					</div>

					<div class="iz-space iz-space--sm"></div>

					<!-- Display options (kept as include, but without legacy collapse triggers) -->
					{% include 'display_options.html' %}
					{{ S_FORM_TOKEN }}

				{% else %}
					<div class="iz-alert iz-alert--info" role="status">
						{{ L_UCP_NO_ATTACHMENTS }}
					</div>
				{% endif %}

			</div>
		</section>
	</form>
</div>

{% include 'ucp_footer.html' %}
