{* Title *}
{if $theme->name}
{$meta_title = "Тема {$theme->name}" scope=root}
{else}
{$meta_title = "Тема не указана" scope=root}
{/if}

{* Container *}
<div class="container-fluid">

	{* Head *}
	<div class="nk-block-head nk-block-head-sm">
		<div class="nk-block-between">

			{* Title *}
			<div class="nk-block-head-content">
				<h3 class="nk-block-title page-title">
					{if $theme->name}
					Текущая тема - {$theme->name}
					{else}
					Установите тему магазина
					{/if}
				</h3>
				<div class="nk-block-des text-soft">
					<p>Управление темами магазина.</p>
				</div>
			</div>

			{* Buttons *}
			<div class="nk-block-head-content">
    			<div class="toggle-wrap nk-block-tools-toggle">

    				{* Mobile toogle btn *}
    				<a href="#" class="btn btn-icon btn-trigger toggle-expand mr-n1" data-target="pageMenu">
    					<em class="icon ti ti-menu"></em>
    				</a>

    				{* Add btn *}
    				<div class="toggle-expand-content" data-content="pageMenu">
    					<ul class="nk-block-tools g-3">
    						<li>
    							<a href="#" class="btn btn-secondary js-clone-theme">
    								<em class="icon ti ti-copy"></em>
    								<span>Создать копию темы</span>
    							</a>
    						</li>
    					</ul>
    				</div>
    			</div>
    		</div>

		</div>
	</div>

	{* Error *}
	{if $message_error}
	<div class="pb-2">
		<div class="alert alert-fill alert-danger alert-icon">
			<em class="icon ti ti-circle-x"></em>
			{if $message_error == 'permissions'}Установите права на запись для папки {$themes_dir}
			{elseif $message_error == 'name_exists'}Тема с таким именем уже существует
			{else}{$message_error}{/if}.
		</div>
	</div>
	{/if}

	{* Main block *}
	<div class="nk-block">

		{* Form *}
    	<form class="js-theme" method="post" enctype="multipart/form-data">

    		{* Inputs *}
    		<input type="hidden" name="action">
    		<input type="hidden" name="theme">

    		{* Themes *}
			<div class="row">

				{foreach $themes as $t}
				<div class="col-lg-3 mb-2 js-item-theme" data-theme="{$t->name|escape}">
					<div class="card card-bordered">
						<div class="h-100 theme-block">
							<img src="{$root_dir}../design/{$t->name}/preview.png" class="card-img-top" alt="{$t->name|escape}">
						</div>
						<div class="card-inner">
							<h5 class="card-title js-theme-name">{$t->name|escape|truncate:16:'...'}</h5>
							<div class="between-center flex-wrap">

								{* Left side *}
								<div>
									{if $theme->name == $t->name}
									<div class="btn btn-secondary">
										<em class="icon ti ti-circle-check"></em>
										<span>Активна</span>
									</div>
									{else}
									<a href="#" class="btn btn-light js-set-main-theme">Выбрать</a>
									{/if}
								</div>

								{* Right side *}
								<div>
									{* Rename *}
									<div class="btn btn-icon btn-light js-theme-edit" data-toggle="tooltip" data-placement="top" title="Переименовать">
										<em class="icon ti ti-pencil"></em>
									</div>

									{if $theme->name != $t->name}
									{* Delete *}
									<div class="btn btn-icon btn-danger js-theme-delete" data-toggle="tooltip" data-placement="top" title="Удалить">
										<em class="icon ti ti-trash"></em>
									</div>
									{/if}
								</div>

							</div>
						</div>
					</div>
				</div>
				{/foreach}
			</div>
			<div class="row g-3">
				<div class="col-lg-7 offset-lg-5">
					<div class="form-group mt-2">
						<button type="submit" class="btn btn-success">Сохранить</button>
					</div>
				</div>
			</div>
		</form>
	</div>

</div>
