{% include 'overall_header.html' %}

<header class="iz-sectionhead">
	<h1 class="iz-sectionhead__title">
		{% if SEARCH_TITLE %}{{ SEARCH_TITLE }}{% else %}{{ SEARCH_MATCHES }}{% endif %}
		{% if SEARCH_WORDS %}&#58;&nbsp;<a class="iz-link" href="{{ U_SEARCH_WORDS }}">{{ SEARCH_WORDS }}</a>{% endif %}
	</h1>
</header>

{% if SEARCHED_QUERY %}
	<p class="iz-meta">{{ L_SEARCHED_QUERY }}{{ L_COLON }}&nbsp;<strong>{{ SEARCHED_QUERY }}</strong></p>
{% endif %}
{% if IGNORED_WORDS %}
	<p class="iz-meta">{{ L_IGNORED_TERMS }}{{ L_COLON }}&nbsp;<span class="iz-badge iz-badge--warning">{{ IGNORED_WORDS }}</span></p>
{% endif %}
{% if PHRASE_SEARCH_DISABLED %}
	<p class="iz-alert iz-alert--warning" role="note"><strong>{{ L_PHRASE_SEARCH_DISABLED }}</strong></p>
{% endif %}

{% if SEARCH_TOPIC %}
	<p class="iz-navback">
		<a class="iz-link" href="{{ U_SEARCH_TOPIC }}">{{ L_RETURN_TO }}{{ L_COLON }}&nbsp;{{ SEARCH_TOPIC }}</a>
	</p>
{% else %}
	<p class="iz-navback">
		<a class="iz-link" href="{{ U_SEARCH }}" title="{{ L_SEARCH_ADV }}">{{ L_GO_TO_SEARCH_ADV }}</a>
	</p>
{% endif %}

{% EVENT search_results_header_after %}

{% if pagination or SEARCH_MATCHES or TOTAL_MATCHES or PAGE_NUMBER %}
	<section class="iz-toolbar iz-toolbar--searchresults" aria-label="{{ L_SEARCH }}">
		<div class="iz-toolbar__left">
			{% if TOTAL_MATCHES > 0 %}
				<form method="post" action="{{ S_SEARCH_ACTION }}" class="iz-form iz-form--inline">
					<fieldset class="iz-fieldset">
						<label class="iz-label iz-visually-hidden" for="add_keywords">{{ L_SEARCH_IN_RESULTS }}</label>
						<div class="iz-inputgroup">
							<input type="text" class="iz-input" name="add_keywords" id="add_keywords" placeholder="{{ L_SEARCH_IN_RESULTS }}">
							<button class="iz-btn iz-btn--ghost" type="submit" value="{{ L_SEARCH }}">{{ L_SEARCH }}</button>
						</div>
					</fieldset>
				</form>
			{% endif %}
		</div>

		<div class="iz-toolbar__right">
			<div class="iz-paginationbar iz-only-desktop" aria-label="{{ L_PAGINATION }}">
				<span class="iz-badge">{{ SEARCH_MATCHES }}</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 %}
					{% if U_MARK_ALL_READ %}
						<li class="iz-pagination__item">
							<a class="iz-pagination__link mark-read" href="{{ U_MARK_ALL_READ }}">{{ L_MARK_ALL_READ }}</a>
						</li>
					{% endif %}
				</ul>
			</div>

			<div class="iz-only-mobile" aria-label="{{ L_PAGINATION }}">
				<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>
	</section>
{% endif %}

{% if S_SHOW_TOPICS %}

	{% if searchresults %}
		<section class="iz-card iz-card--searchresults">
			<header class="iz-card__header">
				<h2 class="iz-card__title">{{ L_TOPICS }}</h2>
			</header>

			<div class="iz-card__body">
				<div class="iz-tablewrap" role="region" aria-label="{{ L_TOPICS }}">
					<table class="iz-table iz-table--topics">
						<thead>
							<tr>
								<th scope="col">{{ L_TITLE }}</th>
								<th scope="col" class="iz-only-desktop">{{ L_TOPICS_POSTS_STATISTICS }}</th>
								<th scope="col" class="iz-only-desktop">{{ L_LAST_POST }}</th>
							</tr>
						</thead>
						<tbody>
							{% set VAR = {{ L_VIEW_TOPIC_LOCKED }} %}

							{% for searchresults in searchresults %}
								{% EVENT search_results_topic_before %}
								<tr id="topic-{{ searchresults.TOPIC_ID }}">
									<td>
										<div class="iz-topicrow">
											<div class="iz-topicrow__title">
												{% EVENT topiclist_row_prepend %}

												{% if searchresults.S_UNREAD_TOPIC and not S_IS_BOT %}
													<a class="iz-link" href="{{ searchresults.U_NEWEST_POST }}" title="{{ L_VIEW_FIRST_UNREAD }}">
														{{ L_VIEW_FIRST_UNREAD }}
													</a>
													<span class="iz-sep">•</span>
												{% endif %}

												<a class="iz-link iz-topicrow__link" href="{{ searchresults.U_VIEW_TOPIC }}">
													{% if searchresults.FORUM_TITLE %}[{{ searchresults.FORUM_TITLE }}]: {% endif %}{{ searchresults.TOPIC_TITLE }}
												</a>

												{% if searchresults.ATTACH_ICON_IMG %}
													<span class="iz-badge iz-badge--muted" title="{{ L_ATTACH_FORUM }}">{{ L_ATTACHMENTS }}</span>
												{% endif %}

												{% if searchresults.S_TOPIC_UNAPPROVED or searchresults.S_POSTS_UNAPPROVED %}
													<a class="iz-badge iz-badge--warning" href="{{ searchresults.U_MCP_QUEUE }}" title="{{ L_TOPICS_ROW_NOT_APPROVED }}">
														{{ L_TOPICS_ROW_NOT_APPROVED }}
													</a>
												{% endif %}
												{% if searchresults.S_TOPIC_DELETED %}
													<a class="iz-badge iz-badge--danger" href="{{ searchresults.U_MCP_QUEUE }}" title="{{ L_TOPIC_DELETED }}">
														{{ L_TOPIC_DELETED }}
													</a>
												{% endif %}
												{% if searchresults.S_TOPIC_REPORTED %}
													<a class="iz-badge iz-badge--danger" href="{{ searchresults.U_MCP_REPORT }}" title="{{ L_TOPICS_ROW_REPORTED }}">
														{{ L_TOPICS_ROW_REPORTED }}
													</a>
												{% endif %}

												{% EVENT topiclist_row_append %}
											</div>

											<div class="iz-topicrow__meta">
												{{ L_POST_BY_AUTHOR }}&nbsp;{{ searchresults.TOPIC_AUTHOR_FULL }}
												<small>&nbsp;&#45;&nbsp;<time datetime="{{ searchresults.FIRST_POST_TIME_RFC3339 }}">{{ searchresults.FIRST_POST_TIME }}</time></small>

												{% if not searchresults.S_TOPIC_GLOBAL %}
													<small>&nbsp;&#45;&nbsp;{{ L_IN }}{{ L_COLON }}&nbsp;<a class="iz-link" href="{{ searchresults.U_VIEW_FORUM }}">{{ searchresults.FORUM_TITLE }}</a></small>
												{% else %}
													<small>&nbsp;&#40;{{ L_GLOBAL }}&#41;</small>
												{% endif %}
											</div>

											{% if searchresults.pagination %}
												<nav class="iz-topicrow__pages iz-only-desktop" aria-label="{{ L_PAGINATION }}">
													<ul class="iz-pagination__list iz-pagination__list--compact">
														{% for pagination in pagination %}
															{% if searchresults.pagination.S_IS_PREV %}
															{% elseif searchresults.pagination.S_IS_CURRENT %}
																<li class="iz-pagination__item is-current"><span class="iz-pagination__link">{{ searchresults.pagination.PAGE_NUMBER }}</span></li>
															{% elseif searchresults.pagination.S_IS_ELLIPSIS %}
																<li class="iz-pagination__item is-ellipsis"><span class="iz-pagination__link">{{ L_ELLIPSIS }}</span></li>
															{% elseif searchresults.pagination.S_IS_NEXT %}
															{% else %}
																<li class="iz-pagination__item"><a class="iz-pagination__link" href="{{ searchresults.pagination.PAGE_URL }}">{{ searchresults.pagination.PAGE_NUMBER }}</a></li>
															{% endif %}
														{% endfor %}
													</ul>
												</nav>
											{% endif %}
										</div>
									</td>

									<td class="iz-only-desktop">
										<div class="iz-stats">
											<div>{{ searchresults.TOPIC_REPLIES }}&nbsp;{{ L_REPLIES }}</div>
											<div>{{ searchresults.TOPIC_VIEWS }}&nbsp;{{ L_VIEWS }}</div>
										</div>
									</td>

									<td class="iz-only-desktop">
										<div class="iz-lastpost">
											<div>{{ L_POST_BY_AUTHOR }}&nbsp;{{ searchresults.LAST_POST_AUTHOR_FULL }}</div>
											<div>
												{% if not S_IS_BOT %}
													<a class="iz-link" title="{{ L_FORUMLIST_LASTPOST }}" href="{{ searchresults.U_LAST_POST }}">{{ L_FORUMLIST_LASTPOST }}</a>
													<span class="iz-sep">•</span>
												{% endif %}
												<small><time datetime="{{ searchresults.LAST_POST_TIME_RFC3339 }}">{{ searchresults.LAST_POST_TIME }}</time></small>
											</div>
										</div>
									</td>
								</tr>
								{% EVENT search_results_topic_after %}
							{% endfor %}
						</tbody>
					</table>
				</div>
			</div>
		</section>

	{% else %}
		<div class="iz-alert iz-alert--info" role="status">
			<strong>{{ L_INFO_BOX }}</strong>&nbsp;{{ L_NO_SEARCH_RESULTS }}
		</div>
	{% endif %}

{% else %}

	<div class="iz-stack iz-stack--searchposts">
		{% for searchresults in searchresults %}
			{% EVENT search_results_post_before %}

			<article class="iz-card iz-card--searchpost">
				<div class="iz-card__body">

					{% if searchresults.S_POST_PRIVATE %}
						<p class="iz-meta">
							{{ L_PRIVATE_BY }}&nbsp;{{ searchresults.POST_AUTHOR_FULL }}&nbsp;&#166;&nbsp;{{ searchresults.POST_DATE }}
						</p>
						<div class="iz-prose">
							<p><strong>{{ L_PRIVATE_POST_NO_CONTENT }}</strong></p>
						</div>

					{% else %}

						{% if searchresults.S_IGNORE_POST %}
							<div class="iz-alert iz-alert--muted" role="note">
								{{ searchresults.L_IGNORE_POST }}
							</div>
						{% else %}
							<h2 class="iz-h4">
								<a class="iz-link" href="{{ searchresults.U_VIEW_POST }}">{{ searchresults.POST_SUBJECT }}</a>
							</h2>

							{% EVENT search_results_postprofile_before %}
							<p class="iz-meta">
								{{ L_POST_BY_AUTHOR }}&nbsp;{{ searchresults.POST_AUTHOR_FULL }}&nbsp;&#166;&nbsp;{{ searchresults.POST_DATE }}&nbsp;&#166;
								{% if searchresults.FORUM_TITLE %}
									{{ L_FORUM }}{{ L_COLON }}&nbsp;<a class="iz-link" href="{{ searchresults.U_VIEW_FORUM }}">{{ searchresults.FORUM_TITLE }}</a>&nbsp;&#166;&nbsp;
									{{ L_TOPIC }}{{ L_COLON }}&nbsp;<a class="iz-link" href="{{ searchresults.U_VIEW_TOPIC }}">{% if searchresults.FORUM_TITLE %}[{{ searchresults.FORUM_TITLE }}]: {% endif %}{{ searchresults.TOPIC_TITLE }}</a>&nbsp;&#166;
								{% else %}
									{{ L_GLOBAL }}{{ L_COLON }}&nbsp;<a class="iz-link" href="{{ searchresults.U_VIEW_TOPIC }}">{% if searchresults.FORUM_TITLE %}[{{ searchresults.FORUM_TITLE }}]: {% endif %}{{ searchresults.TOPIC_TITLE }}</a>&nbsp;&#166;
								{% endif %}
								{{ L_REPLIES }}{{ L_COLON }}&nbsp;<strong>{{ searchresults.TOPIC_REPLIES }}</strong>&nbsp;&#166;&nbsp;{{ L_VIEWS }}{{ L_COLON }}&nbsp;<strong>{{ searchresults.TOPIC_VIEWS }}</strong>
							</p>
							{% EVENT search_results_postprofile_after %}

							<div class="iz-prose">
								{{ searchresults.MESSAGE }}
							</div>
						{% endif %}

						{% if not searchresults.S_IGNORE_POST %}
							<p class="iz-actions iz-actions--end">
								<a class="iz-btn iz-btn--ghost iz-btn--sm" href="{{ searchresults.U_VIEW_POST }}">{{ L_JUMP_TO_POST }}</a>
							</p>
						{% endif %}

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

			{% EVENT search_results_post_after %}
		<!-- BEGINELSE -->
			<div class="iz-alert iz-alert--info" role="status">
				<strong>{{ L_INFO_BOX }}</strong>&nbsp;{{ L_NO_SEARCH_RESULTS }}
			</div>
		{% endfor %}
	</div>

{% endif %}

<section class="iz-layout iz-layout--two">
	<div class="iz-layout__main">

		{% if pagination or .searchresults or PAGE_NUMBER or S_SELECT_SORT_KEY or S_SELECT_SORT_DAYS %}
			<div class="iz-toolbar iz-toolbar--bottom" aria-label="{{ L_PAGINATION }}">

				{% if searchresults and (S_SELECT_SORT_DAYS or S_SELECT_SORT_KEY) %}
					<details class="iz-disclosure iz-toolbar__options">
						<summary class="iz-btn iz-btn--ghost iz-btn--sm">{{ L_OPTIONS }}</summary>
						<form method="post" action="{{ S_SEARCH_ACTION }}" class="iz-form iz-form--inline">
							{% include 'display_options.html' %}
						</form>
					</details>
				{% endif %}

				<div class="iz-paginationbar iz-only-desktop">
					<span class="iz-badge">{{ SEARCH_MATCHES }}</span>
					<ul class="iz-pagination__list iz-pagination__list--compact">
						{% if pagination %}
							{% include 'pagination.html' %}
						{% else %}
							<li class="iz-pagination__item is-current"><span class="iz-pagination__link">{{ PAGE_NUMBER }}</span></li>
						{% endif %}
						{% if U_MARK_ALL_READ %}
							<li class="iz-pagination__item"><a class="iz-pagination__link mark-read" href="{{ U_MARK_ALL_READ }}">{{ L_MARK_ALL_READ }}</a></li>
						{% endif %}
					</ul>
				</div>

				<div class="iz-only-mobile">
					<ul class="iz-pagination__list iz-pagination__list--compact">
						{% 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>
		{% endif %}

	</div>

	<aside class="iz-layout__aside">
		{% include 'jumpbox_options.html' %}
	</aside>
</section>

{% include 'jump_links.html' %}

{% include 'overall_footer.html' %}
