 <script>
var flagRequireReload = 0;
function ChangeOption(selectedOption) {
	document.getElementById('list').style.display = "none";
	{% if (status) %}document.getElementById('categories').style.display = "none";{% endif %}
	document.getElementById('uploadnew').style.display = "none";
	if(selectedOption == 'list') {
		if (flagRequireReload) {
			document.location.href = document.location.href;
		}
		document.getElementById('list').style.display = "";
		document.getElementById('entries').style.display = "";
	}
	{% if (status) %}if(selectedOption == 'categories') {
		document.getElementById('categories').style.display = "";
		document.getElementById('entries').style.display = "none";
	}{% endif %}
	if(selectedOption == 'uploadnew') {
		document.getElementById('uploadnew').style.display = "";
		document.getElementById('entries').style.display = "none";
	}
}
function setStatus(mode) {
 var st = document.getElementById('delform');
 st.subaction.value = mode;
}
</script>
<style>
	/* Simple Lightbox Styles */
	.lightbox-overlay {
		display: none;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, 0.85);
		z-index: 9999;
		cursor: pointer;
	}
	.lightbox-overlay.active {
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.lightbox-content {
		position: relative;
		max-width: 90%;
		max-height: 90vh;
		cursor: default;
	}
	.lightbox-content img {
		max-width: 100%;
		max-height: 90vh;
		display: block;
		box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
	}
	.lightbox-close {
		position: absolute;
		top: -40px;
		right: 0;
		color: white;
		font-size: 32px;
		font-weight: bold;
		background: none;
		border: none;
		cursor: pointer;
		padding: 5px 15px;
		opacity: 0.8;
		transition: opacity 0.3s;
	}
	.lightbox-close:hover {
		opacity: 1;
	}
	.lightbox-info {
		position: absolute;
		bottom: -40px;
		left: 0;
		right: 0;
		color: white;
		text-align: center;
		font-size: 14px;
	}
</style>
<div  class="comments-area" style=" margin-bottom: 30px;">
	<div class="row mb-2">
		<div class="col-sm-3 d-none d-md-block ">
			<h3>{{ lang['images_title'] }}</h3>
		</div>
		<!-- /.col -->
		<div class="col-sm-9">
			<ol class="breadcrumb float-sm-right">
				<li class="breadcrumb-item">
					<a href="{{ php_self }}">
						<i class="fa fa-home"></i>
					</a>
				</li>
				<li class="breadcrumb-item active" aria-current="page">{{ lang['images_title'] }}</li>
			</ol>
		</div>
		<!-- /.col -->
	</div>
	<!-- /.row -->
</div>
<div class="comments-area">
	<form action="{{ php_self }}" method="get" name="options_bar">
		<input type="hidden" name="mod" value="images"/>
		<input type="hidden" name="action" value="list"/>
		<input type="hidden" name="area" value="{{ area }}"/>
		<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr align="center">
				<td width="100%" class="contentNav" align="center" valign="top">
					<input type="button" onmousedown="javascript:ChangeOption('list')" value="{{ lang['list'] }}" class="navbutton"/>
					{% if (status) %}<input type="button" onmousedown="javascript:ChangeOption('categories')" value="{{ lang['categories'] }}" class="navbutton"/>
					{% endif %}
					<input type="button" onmousedown="javascript:ChangeOption('uploadnew')" value="{{ lang['uploadnew'] }}" class="navbutton"/>
				</td>
			</tr>
		</table>
					<table id="list" border="0" cellspacing="0" cellpadding="0" class="filterblock3">
							<td>
								<label><input type="checkbox" id="previewSwitch" {{ box_preview }}/>
									{{ lang['show_preview'] }}</label>
							</td>
							<td>
								<label>{{ lang['month'] }}</label>
								<select name="postdate">
									<option selected value="">-
										{{ lang['all'] }}
										-</option>
									{{ dateslist }}</select>
							</td>
							<td>
								<label>{{ lang['category'] }}</label>
								{{ dirlistcat }}</td>
							<td>
								{% if (status) %}
									<label>{{ lang['author'] }}</label>
									<select name="author">
										<option value="">-
											{{ lang['all'] }}
											-</option>
										{{ authorlist }}</select>
								{% endif %}
							</td>
							<td class="right">
								<label>{{ lang['per_page'] }}</label>
								<input style="text-align: center" name="npp" value="{{ npp }}" type="text" size="3"/>
								</td>
								</tr>
								<tr>
							<td colspan="5" class="right">
								<input type="submit" value="{{ lang['show'] }}" class="images_filterbutton"/>
								</td>
						</tr>
					</table>
	</form>
	<form action="{{ php_self }}?mod=images" method="post" name="imagedelete" id="delform">
		<input type="hidden" name="subaction" value=""/>
		<input type="hidden" name="area" value="{{ area }}"/>
		<table id="entries" border="0" cellspacing="0" cellpadding="0" class="content" align="center">
			<tr>
				<th colspan="3" width="80">{{ lang['header.insert']|default('Вставка') }}</th>
				<th class="preview-column">{{ lang['show_preview']|default('Превью') }}</th>
				<th>{{ lang['name']|default('Название') }}</th>
				<th colspan="2">{{ lang['header.view']|default('Вид') }}</th>
				<th colspan="2">{{ lang['size']|default('Размер') }}</th>
				<th>{{ lang['category']|default('Категория') }}</th>
				<th>{{ lang['author']|default('Автор') }}</th>
				<th>{{ lang['action']|default('Действия') }}</th>
				<th>
					<input class="check" type="checkbox" title="{{ lang['select_all'] }}" onclick="toggleAllImages(this)"/>
				</th>
			</tr>
			{% for entry in entries %}
				<!-- Табличный вид (скрыт по умолчанию) -->
				<tr class="entry-row">
					<td>
						<a href="#" data-toggle="tooltip" onclick="insertimage('[img=&quot;{{ images_url }}/{{ entry.folder }}/{{ entry.name|default(entry.file_name) }}&quot; border=&quot;0&quot; width=&quot;{{ entry.width }}&quot; height=&quot;{{ entry.height }}&quot; align=&quot;&quot;]{{ entry.name|default(entry.file_name) }} ({{ entry.size }})[/img]', ''); return false;" title="Полное изображение" data-bs-toggle="tooltip">
							<i class="fa fa-share-square-o"></i>
						</a>
					</td>
					<td>
						<a href="#" data-toggle="tooltip" onclick="insertimage('[url=&quot;{{ images_url }}/{{ entry.folder }}/{{ entry.name|default(entry.file_name) }}&quot; target=&quot;_blank&quot;][img=&quot;{{ images_url }}/{{ entry.folder }}/thumb/{{ entry.name|default(entry.file_name) }}&quot; border=&quot;0&quot; align=&quot;&quot;]{{ entry.name|default(entry.file_name) }} ({{ entry.size }})[/img][/url]', ''); return false;" title="Вставка превью с сылкой на полное изображение" data-bs-toggle="tooltip">
							<i class="fa fa-search-plus"></i>
						</a>
					</td>
					<td>
						<a href="#" data-toggle="tooltip" onclick="insertimage('[img=&quot;{{ images_url }}/{{ entry.folder }}/thumb/{{ entry.name|default(entry.file_name) }}&quot; border=&quot;0&quot; align=&quot;&quot;]{{ entry.name|default(entry.file_name) }}[/img]', ''); return false;" title="Вставка уменьшенного изображения" data-bs-toggle="tooltip">
							<i class="fa fa-search-minus"></i>
						</a>
					</td>
					<td class="preview-column"><img src="{{ images_url }}/{{ entry.folder }}/thumb/{{ entry.name|default(entry.file_name) }}" style="max-width: 100px; max-height: 100px;"></td>
					<td>{{ entry.file_name }}</td>
					<td>
						<a class="lightbox-trigger" href="{{ images_url }}/{{ entry.folder }}/{{ entry.name|default(entry.file_name) }}" data-lightbox-title="{{ entry.name|default(entry.file_name) }} ({{ entry.width }}x{{ entry.height }}, {{ entry.size }})" title="Полное изображение" data-bs-toggle="tooltip">
							<i class="fa fa-search-plus"></i>
						</a>
					</td>
					<td>
						<a class="lightbox-trigger" href="{{ images_url }}/{{ entry.folder }}/thumb/{{ entry.name|default(entry.file_name) }}" data-lightbox-title="{{ entry.name|default(entry.file_name) }} (preview)" title="Уменьшенное изображение" data-bs-toggle="tooltip">
							<i class="fa fa-search-minus"></i>
						</a>
					</td>
					<td>{{ entry.width }}x{{ entry.height }}</td>
					<td nowrap>{{ entry.size }}</td>
					<td>{{ entry.folder }}</td>
					<td>{{ entry.user }}</td>
					<td>
						<a href="{{ entry.edit_link }}" title="Редактировать" data-bs-toggle="tooltip">
							<i class="fa fa-pencil"></i>
						</a>
					</td>
					<td><input type="checkbox" name="files[]" value="{{ entry.id }}"/></td>
				</tr>
			{% endfor %}
			<tr>
				<td colspan="10" class="contentEdit">
					{% if (status) %}
						<div>{{ lang['move'] }}:
							{{ dirlist }}
							<input type="submit" class="button" onclick="setStatus('move');" value="OK"/></div>
					{% endif %}
				</td>
				<td colspan="3" class="contentEdit">
					{% if (status) %}
						<div><input type="submit" class="button" onclick="setStatus('delete');" value="{{ lang['delete'] }}"/></div>
					{% endif %}
				</td>
			</tr>
			<tr>
				<td colspan="13" class="contentEdit">{{ pagesss }}</td>
			</tr>
		</table>
	</form>
	{% if (status) %}
		<table id="categories" style="display: none;" border="0" cellspacing="0" cellpadding="0" class="content" align="center">
			<tr>
				<td width="50%" class="contentHead"><i class="fa fa-plus "></i> {{ lang['addnewcat'] }}</td>
				<td width="50%" class="contentHead"><i class="fa fa-plus "></i> {{ lang['delcat'] }}</td>
			</tr>
			<tr>
				<td width="50%" class="contentEntry1">
					<form action="{{ php_self }}?mod=images" method="post" name="newcat">
						<input type="hidden" name="subaction" value="newcat"/>
						<input type="hidden" name="area" value="{{ area }}"/>
						<input type="text" name="newfolder" size="30"/>&nbsp;
						<input type="submit" value="OK" class="button"/>
					</form>
				</td>
				<td width="50%" class="contentEntry1">
					<form action='{{ php_self }}?mod=images' method='post' name='delcat'>
						<input type="hidden" name="subaction" value="delcat"/>
						<input type="hidden" name="area" value="{{ area }}"/>
						{{ dirlist }}&nbsp;
						<input type="submit" value="OK" class="button"/>
					</form>
				</td>
			</tr>
		</table>
	{% endif %}
	<table id="uploadnew" style="display: none;" border="0" cellspacing="0" cellpadding="0" class="content">
		<tr>
			<td width="50%" valign="top" class="contentEntry1">
				<table border="0" cellspacing="0" cellpadding="0" class="content" align="center">
					<tr>
						<td class="contentHead"><i class="fa fa-upload "></i> {{ lang['upload_img'] }}</td>
					</tr>
					<tr>
						<td>
							<form id="uploadnew_form" action="{{ php_self }}?mod=images" method="post" enctype="multipart/form-data" name="sn">
								<input type="hidden" name="subaction" value="upload"/>
								<input type="hidden" name="area" value="{{ area }}"/>
								<br/>{{ dirlistS }}&nbsp;
								<span id="showRemoveAddButtoms">
									<input type="button" class="button" value='{{ lang['delone'] }}' onclick="RemoveImages();return false;"/>&nbsp;
									<input type="button" class="button" value='{{ lang['onemore'] }}' onclick="AddImages();return false;"/><br/><br/>
								</span>
								 <script language="javascript" type="text/javascript">
								function AddImages() {
									var tbl = document.getElementById('imageup');
									var lastRow = tbl.rows.length;
									var iteration = lastRow+1;
									var row = tbl.insertRow(lastRow);
									var cellRight = row.insertCell(0);
									cellRight.innerHTML = '<span>'+iteration+': <'+'/'+'span>';
									cellRight = row.insertCell(1);
									var el = document.createElement('input');
									el.setAttribute('type', 'file');
									el.setAttribute('name', 'userfile[' + iteration + ']');
									el.setAttribute('size', '60');
									el.setAttribute('value', iteration);
									cellRight.appendChild(el);
								}
								function RemoveImages() {
									var tbl = document.getElementById('imageup');
									var lastRow = tbl.rows.length;
									if (lastRow > 1){
										tbl.deleteRow(lastRow - 1);
									}
								}
								</script>
								<table id="imageup" class="upload">
									<tr id="row">
										<td>1:
										</td>
										<td><input type="file" size="60" id="fileUploadInput" name="userfile[0]"/></td>
									</tr>
								</table>
								<div class="list">
									<input type="checkbox" name="replace" value="1" id="flagReplace" class='check'/>
									<label for="flagReplace">{{ lang['do_replace'] }}</label><br/>
									<input type="checkbox" name="rand" value="1" id="flagRand" class='check'/>
									<label for="flagRand">{{ lang['do_rand'] }}</label><br/>
									<input type="checkbox" name="thumb" value="1" id="flagThumb" class='check' {{ thumb_mode }} {{ thumb_checked }}/>
									<label for="flagThumb">{{ lang['do_preview'] }}</label><br/>
									<input type="checkbox" name="shadow" value="1" id="flagShadow" class='check' {{ shadow_mode }} {{ shadow_checked }}/>
									<label for="flagShadow">{{ lang['do_shadow'] }}</label><br/>
									<input type="checkbox" name="stamp" value="1" id="flagStamp" class='check' {{ stamp_mode }} {{ stamp_checked }}/>
									<label for="flagStamp">{{ lang['do_wmimage'] }}</label>
								</div>
							</td>
						</td>
					</tr>
					<tr align="center">
						<td width="100%" class="contentEdit" align="center" valign="top">
							<input type="submit" value='{{ lang['upload'] }}' class="button"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</form>
</td>
<td width="50%" class="contentEntry1" valign="top">
	<form action="{{ php_self }}?mod=images" method="post" name="snup">
		<table border="0" cellspacing="0" cellpadding="0" class="content" align="center">
			<tr>
				<td class="contentHead"><i class="fa fa-upload "></i> {{ lang['upload_img_url'] }}</td>
			</tr>
			<tr>
				<td>
					<input type="hidden" name="subaction" value="uploadurl"/>
					<input type="hidden" name="area" value="{{ area }}"/>
					<br/>{{ dirlist }}&nbsp;
					<input type="button" class="button" value='{{ lang['delone'] }}' onclick="RemoveImages2();return false;"/>&nbsp;
					<input type="button" class="button" value='{{ lang['onemore'] }}' onclick="AddImages2();return false;"/><br/><br/>
					 <script language="javascript" type="text/javascript">
					function AddImages2() {
						var tbl = document.getElementById('imageup2');
						var lastRow = tbl.rows.length;
						var iteration = lastRow+1;
						var row = tbl.insertRow(lastRow);
						var cellRight = row.insertCell(0);
						cellRight.innerHTML = '<span">'+iteration+': <'+'/'+'span>';
						cellRight = row.insertCell(1);
						var el = document.createElement('input');
						el.setAttribute('type', 'text');
						el.setAttribute('name', 'userurl[' + iteration + ']');
						el.setAttribute('size', '60');
						cellRight.appendChild(el);
					}
					function RemoveImages2() {
						var tbl = document.getElementById('imageup2');
						var lastRow = tbl.rows.length;
						if (lastRow > 1){
							tbl.deleteRow(lastRow - 1);
						}
					}
					</script>
					<table id="imageup2" class="upload">
						<tr id="row">
							<td>1:
							</td>
							<td><input type="text" size="60" name="userurl[0]"/></td>
						</tr>
					</table>
					<div class="list">
						<input type="checkbox" name="replace" value='replace' id="replace2" class='check'/>
						<label for="replace2">{{ lang['do_replace'] }}</label><br/>
						<input type="checkbox" name="rand" value='rand' id="rand2" class='check'/>
						<label for="rand2">{{ lang['do_rand'] }}</label><br/>
						<input type="checkbox" name="thumb" value='thumb' id="thumb2" class='check' {{ thumb_mode }} {{ thumb_checked }}/>
						<label for="thumb2">{{ lang['do_preview'] }}</label><br/>
						<input type="checkbox" name="shadow" value='shadow' id="shadow2" class='check' {{ shadow_mode }} {{ shadow_checked }}/><label for="shadow2">{{ lang['do_shadow'] }}</label><br/>
						<input type="checkbox" name="stamp" value='stamp' id="stamp2" class='check' {{ stamp_mode }} {{ stamp_checked }}/><label for="stamp2">{{ lang['do_wmimage'] }}</label>
					</div>
				</td>
			</tr>
			<tr align="center">
				<td width="100%" class="contentEdit" align="center" valign="top">
					<input type="submit" value='{{ lang['upload'] }}' class="button"/>
				</td>
			</tr>
		</table>
	</form>
</td></tr></table></div>
<script type="text/javascript">
		// Функция для работы с cookie
		function setCookie(name, value, days) {
			let expires = '';
			if (days) {
				const date = new Date();
				date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
				expires = '; expires=' + date.toUTCString();
			}
			document.cookie = name + '=' + (value || '') + expires + '; path=/';
		}
		function getCookie(name) {
			const nameEQ = name + '=';
			const ca = document.cookie.split(';');
			for (let i = 0; i < ca.length; i++) {
				let c = ca[i];
				while (c.charAt(0) === ' ') c = c.substring(1, c.length);
				if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
			}
			return null;
		}
		// Переключатель превью
		document.addEventListener('DOMContentLoaded', function () {
			const previewSwitch = document.getElementById('previewSwitch');
			if (!previewSwitch) {
				return; // Элемент не найден
			}
			// Проверяем сохраненное значение превью
			const savedPreview = getCookie('img_preview');
			if (savedPreview === '0') {
				previewSwitch.checked = false;
				togglePreviewColumn(false);
			} else {
				previewSwitch.checked = true;
				togglePreviewColumn(true);
			}
			// Обработчик переключателя превью
			previewSwitch.addEventListener('change', function () {
				const showPreview = this.checked;
				setCookie('img_preview', showPreview ? '1' : '0', 365);
				togglePreviewColumn(showPreview);
			});
			function togglePreviewColumn(show) {
				const displayValue = show ? '' : 'none';
				document.querySelectorAll('.preview-column').forEach(col => {
					col.style.display = displayValue;
				});
			}
		});
	</script> <script type="text/javascript">
	function AddImages() {
	var tbl = document.getElementById('imageup');
	var lastRow = tbl.rows.length;
	var iteration = lastRow + 1;var row = tbl.insertRow(lastRow);
	var cellRight = row.insertCell(0);
	cellRight.innerHTML = '<span>' + iteration + ': </span>';
	cellRight = row.insertCell(1);
	var el = document.createElement('input');
	el.setAttribute('type', 'file');
	el.setAttribute('name', 'userfile[' + iteration + ']');
	el.setAttribute('size', '60');
	el.setAttribute('value', iteration);
	cellRight.appendChild(el);
	}
	function RemoveImages() {
	var tbl = document.getElementById('imageup');
	var lastRow = tbl.rows.length;
	if (lastRow > 1) {
	tbl.deleteRow(lastRow - 1);
	}
	}
	function AddImages2() {
	var tbl = document.getElementById('imageup2');
	var lastRow = tbl.rows.length;
	var iteration = lastRow + 1;
	var row = tbl.insertRow(lastRow);
	var cellRight = row.insertCell(0);
	cellRight.innerHTML = '<span>' + iteration + ': </span>';
	cellRight = row.insertCell(1);
	var el = document.createElement('input');
	el.setAttribute('type', 'text');
	el.setAttribute('name', 'userurl[' + iteration + ']');
	el.setAttribute('size', '60');
	el.setAttribute('class', 'form-control');
	cellRight.appendChild(el);
	}
	function RemoveImages2() {
	var tbl = document.getElementById('imageup2');
	var lastRow = tbl.rows.length;
	if (lastRow > 1) {
	tbl.deleteRow(lastRow - 1);
	}
	}
	</script> <script type="text/javascript">
		// Функция для выделения/снятия выделения всех изображений
		function toggleAllImages(masterCheckbox) {
			const isChecked = masterCheckbox.checked;
			const imageCheckboxes = document.querySelectorAll('input[name="files[]"]');
			imageCheckboxes.forEach(checkbox => {
				// Проверяем, что checkbox видим (его родитель не скрыт)
				if (checkbox.value && checkbox.offsetParent !== null) {
					checkbox.checked = isChecked;
				}
			});
		}
	</script> <script type="text/javascript">
			$(document).ready(function () {
	// Показ/скрытие селекта категории при выборе действия "Переместить"
	$('#delform').on('change input', function () {
		var form = this;
		if (form && form.elements && form.elements.subaction) {
			var show = (form.elements.subaction.value === 'move');
			if (form.elements.category) {
				$(form.elements.category).toggle(show);
			}
		}
	}).trigger('change');
	$('#uploadnew_form').on('submit', function (e) {
	e.preventDefault();
	$('#fileUploadInput').uploadifive('upload');
	});
	var fileCounter = 1;
	var uploader = $('#fileUploadInput').uploadifive({
	auto: false,
	uploadScript:'{{ admin_url }}/rpc.php?methodName=admin.files.upload',
	cancelImg:'{{ skins_url }}/images/up_cancel.png',
	folder: '',
	fileExt:'{{ listExt }}',
	fileDesc:'{{ descExt }}',
	sizeLimit:'{{ maxSize }}',
	multi: true,
	buttonText: 'Выбрать изображение ...',
	width: 200,
	onInit: function () {
	$('#showRemoveAddButtoms').hide();
	$('#flagThumb').prop('checked', true).prop('disabled', true).parent().hide();
	},
	onUpload: function (filesToUpload) {
	var formData = {
	ngAuthCookie:'{{ authcookie }}',
	uploadType: 'image',
	category: $('#uploadnew_form select[name="category"]').val() || $('#categorySelect').val() || '',
	rand: $('#flagRand').is(':checked') ? 1 : 0,
	replace: $('#flagReplace').is(':checked') ? 1 : 0,
	thumb: 1,
	stamp: $('#flagStamp').is(':checked') ? 1 : 0,
	forceRename: 1
	};
	$.each(this.fileQueue, function (index, file) {
	if (file.newName) {
	formData['newFilename_' + index] = file.newName;
	}
	});
	uploader.data('uploadifive').settings.formData = formData;
	},
	onAdd: function (file) {
	try {
	var originalName = file.name;
	var extension = originalName.split('.').pop().toLowerCase().substring(0, 4);
	var newName = (fileCounter++).toString().padStart(3, '0') + '.' + extension;
	if (newName.length > 22) {
	newName = newName.substring(0, 22);
	}
	file.newName = newName;
	file.name = newName;
	return true;
	} catch (e) {
	console.error('Error renaming file:', e);
	return true;
	}
	},
	onUploadComplete: function (fileObj, data) {
	try {
	var response = JSON.parse(data);
	fileObj.queueItem.find('.fileinfo').replaceWith(response.status ? '<div class="text-info">' + response.errorText + '</div>' : '<div class="text-danger">(' + response.errorCode + ') ' + response.errorText + ' ' + response.errorDescription + '</div>');
	} catch (e) {
	console.error('Error processing upload response:', e);
	}
	},
	onError: function (errorType, file) {
	console.error('Upload error:', errorType, file);
	},
	onQueueComplete: function () {
	// Перезагрузить страницу после завершения всех загрузок
	setTimeout(function() {
		document.location = document.location;
	}, 1000);
	}
	});
	});
	</script><!-- Simple Lightbox Modal --><div class="lightbox-overlay" id="imageLightbox"> <div class="lightbox-content"><button class="lightbox-close" id="lightboxClose">&times;</button><img id="lightboxImage" src="" alt=""><div class="lightbox-info" id="lightboxInfo"></div></div></div> <script type="text/javascript">
	// Simple Lightbox functionality
	(function() {
		const lightbox = document.getElementById('imageLightbox');
		const lightboxImg = document.getElementById('lightboxImage');
		const lightboxInfo = document.getElementById('lightboxInfo');
		const lightboxClose = document.getElementById('lightboxClose');
		if (!lightbox || !lightboxImg) return;
		// Open lightbox
		document.addEventListener('click', function(e) {
			const trigger = e.target.closest('.lightbox-trigger');
			if (trigger) {
				e.preventDefault();
				const imgSrc = trigger.getAttribute('href');
				const imgTitle = trigger.getAttribute('data-lightbox-title') || '';
				lightboxImg.src = imgSrc;
				lightboxInfo.textContent = imgTitle;
				lightbox.classList.add('active');
			}
		});
		// Close lightbox
		function closeLightbox() {
			lightbox.classList.remove('active');
			setTimeout(function() {
				lightboxImg.src = '';
			}, 300);
		}
		lightboxClose.addEventListener('click', function(e) {
			e.stopPropagation();
			closeLightbox();
		});
		lightbox.addEventListener('click', function(e) {
			if (e.target === lightbox) {
				closeLightbox();
			}
		});
		// Close on ESC key
		document.addEventListener('keydown', function(e) {
			if (e.key === 'Escape' && lightbox.classList.contains('active')) {
				closeLightbox();
			}
		});
	})();
	</script>
