/* ==========================================================================
	1. ПЕРЕМЕННЫЕ И ТЕМЫ
	========================================================================== */

:root {
	/* Цвета фона */
	--bg-primary: #f5f5f5;
	--bg-secondary: #ffffff;
	--body-bg: #f5f5f5; /* Alias for public page compatibility */
	--card-bg: #ffffff; /* Specific for public page cards */
	--hover-bg: #f9f9f9;

	/* Текст */
	--text-color: #333333;
	--text-secondary: #666666;

	/* Границы и тени */
	--border-color: #e0e0e0;
	--border-radius: 8px;
	--shadow-color: rgba(0, 0, 0, 0.1);
	--shadow-hover: rgba(0, 0, 0, 0.15);

	/* Цвета акцентов */
	--primary-color: #a8d5a8; /* Green from Login */
	--admin-primary: #667eea; /* Blue-Purple from Admin */
	--success-color: #a8d5a8;
	--danger-color: #dc3545; /* Unified red */
	--warning-color: #ffd93d;

	/* Заголовок */
	--header-bg: #262626;
	--header-text: #ffffff;

	/* Тумблер темы */
	--toggle-bg: #ccc;
	--toggle-active: #60a5fa;

	/* Иконки */
	--icon-fill: #ffffff;

	/* Переходы */
	--transition-base: all 0.2s ease;
}

[data-theme="dark"] {
	/* Цвета фона */
	--bg-primary: #1a1a1a;
	--bg-secondary: #2d2d2d;
	--body-bg: #121212; /* Public page dark bg */
	--card-bg: #1e1e1e; /* Public page dark card (darker than admin) */
	--hover-bg: rgba(255, 255, 255, 0.05);

	/* Текст */
	--text-color: #e0e0e0;
	--text-secondary: #a0a0a0;

	/* Границы и тени */
	--border-color: #444444;
	--shadow-color: rgba(0, 0, 0, 0.3);
	--shadow-hover: rgba(0, 0, 0, 0.4);

	/* Заголовок */
	--header-bg: #1a1a1a;

	/* Тумблер темы */
	--toggle-bg: #555555;
	--toggle-active: #60a5fa;
}

/* ==========================================================================
	2. БАЗОВЫЕ СТИЛИ
	========================================================================== */

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	background: var(--bg-primary);
	color: var(--text-color);
	line-height: 1.6;
	min-height: 100vh;
	transition: background-color 0.3s ease, color 0.3s ease;
}

/* Public page uses specific body background variable */
body.public-page {
	background-color: var(--body-bg);
}

a {
	color: inherit;
	text-decoration: none;
}

.container {
	max-width: 1200px;
	margin: 0 auto;
	padding: 20px;
	width: 100%;
}

.footer {
	padding: 24px 20px;
	text-align: center;
	position: relative;
}

.footer::before {
	content: "";
	position: absolute;
	top: -2px;
	left: 20%;
	right: 20%;
	height: 2px;
	background: linear-gradient(90deg, transparent, var(--border-color), transparent);
}

.footer-content {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	color: var(--text-secondary);
	font-weight: 500;
	opacity: 0.7;
}

/* ==========================================================================
	3. ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ (УНИФИЦИРОВАННЫЙ)
	========================================================================== */

.controls-bar {
	position: fixed;
	top: 20px;
	right: 20px;
	display: flex;
	align-items: center;
	gap: 16px;
	background: var(--bg-secondary);
	padding: 12px 20px;
	border-radius: 12px;
	border: 1px solid var(--border-color);
	box-shadow: 0 4px 16px var(--shadow-color);
	z-index: 100;
	flex-wrap: wrap;
}

.controls-wrapper {
	display: flex;
	align-items: center;
	gap: 20px;
}

.info-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	color: var(--text-color);
}

.theme-toggle-container {
	display: flex;
	align-items: center;
	gap: 8px;
}

.theme-toggle {
	position: relative;
	display: inline-block;
	width: 60px;
	height: 28px;
}

.theme-toggle input {
	opacity: 0;
	width: 0;
	height: 0;
}

.slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: var(--toggle-bg);
	border-radius: 34px;
	transition: 0.3s;
}

.slider:before {
	position: absolute;
	content: "";
	height: 20px;
	width: 20px;
	left: 4px;
	bottom: 4px;
	background-color: white;
	border-radius: 50%;
	transition: 0.3s;
	background-repeat: no-repeat;
	background-position: center;
	background-size: 12px 12px;
	background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 3V5M12 19V21M5 12H3M21 12H19M17.8 6.2L16.4 7.6M7.6 16.4L6.2 17.8M17.8 17.8L16.4 16.4M7.6 7.6L6.2 6.2" stroke="%23999" stroke-width="2" stroke-linecap="round"/><circle cx="12" cy="12" r="4.5" fill="%23999" stroke="%23999" stroke-width="1"/></svg>');
}

input:checked + .slider {
	background-color: var(--toggle-active);
}

input:checked + .slider:before {
	transform: translateX(32px);
	background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%234a90e2"><path d="M12 3a9 9 0 109 9c0-.46-.04-.92-.1-1.36a5.389 5.389 0 01-4.4 2.26 5.403 5.403 0 01-3.14-9.8c-.44-.06-.9-.1-1.36-.1z"/></svg>');
}

/* Theme icons */
.theme-options {
	 display: flex;
	 align-items: center;
}

.theme-icon {
	 margin: 0 8px;
	 cursor: pointer;
	 opacity: 0.5;
	 transition: opacity 0.3s;
	 width: 18px;
	 height: 18px;
	 fill: var(--icon-fill);
}

.theme-icon.active {
	 opacity: 1;
}

.theme-icon svg {
	 width: 100%;
	 height: 100%;
}

.auto-icon {
	 margin-left: 10px;
}

/* ==========================================================================
	4. ЗАГОЛОВОК И НАВИГАЦИЯ
	========================================================================== */

header {
	background-color: var(--header-bg);
	color: var(--header-text);
	box-shadow: 0 2px 5px var(--shadow-color);
	position: sticky;
	top: 0;
	z-index: 100;
}

.studio-container {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.header-content {
	display: flex;
	justify-content: space-between;
	align-items: center;
	height: 48px;
	padding: 0 20px;
	max-width: 1320px;
	margin: 0 auto;
	width: 100%;
}

.top-logo {
	display: flex;
	align-items: center;
	height: 100%;
	gap: 15px;
	text-decoration: none;
}

.top-logo img {
	max-height: 23px;
	width: auto;
	vertical-align: middle;
}

.user-info {
	font-size: 12px;
	color: var(--header-text);
	text-decoration: none;
}

.user-info:hover {
	text-decoration: none;
}

/* Hamburger Menu */
.hamburger-button {
	width: 20px;
	height: 16px;
	position: relative;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}

.hamburger-line {
	display: block;
	width: 100%;
	height: 2px;
	background-color: var(--header-text);
	border-radius: 1px;
	transition: all 0.3s ease;
}

.hamburger-button.active .hamburger-line:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
	transform-origin: center;
}

.hamburger-button.active .hamburger-line:nth-child(2) {
	opacity: 0;
}

.hamburger-button.active .hamburger-line:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
	transform-origin: center;
}

.nav-menu {
	position: fixed;
	top: 48px;
	right: -300px;
	width: 300px;
	max-width: 80%;
	height: calc(100vh - 48px);
	background-color: var(--header-bg);
	box-shadow: -2px 0 5px var(--shadow-color);
	transition: right 0.3s ease, background-color 0.3s ease;
	z-index: 100;
	overflow-y: auto;
	padding: 20px 0;
}

.nav-menu.active {
	right: 0;
}

.nav-menu-items {
	list-style: none;
	padding: 0;
	margin: 0;
	width: 100%;
}

.nav-menu-items li {
	padding: 0;
	margin: 0;
	width: 100%;
}

.nav-menu-items li a {
	display: flex;
	align-items: center;
	padding: 15px 20px;
	color: var(--header-text);
	text-decoration: none;
	transition: background-color 0.3s ease;
}

.nav-menu-items li a:hover {
	background-color: rgba(255, 255, 255, 0.1);
}

.nav-menu-items li a img {
	width: 24px;
	height: 24px;
	margin-right: 15px;
	object-fit: contain;
}

.menu-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.5);
	z-index: 99;
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active {
	visibility: visible;
	opacity: 1;
}

.menu-separator {
	border-top: 1px solid rgba(255, 255, 255, 0.1);
	margin-top: 10px;
	padding-top: 10px;
}

/* ==========================================================================
	5. ПУБЛИЧНАЯ СТРАНИЦА (PUBLIC.HTML)
	========================================================================== */

main {
	flex: 1;
	padding: 20px;
	max-width: 1320px;
	margin: 0 auto;
	width: 100%;
}

.greeting-block {
	margin-top: 20px;
}

.greeting-modules-block {
	display: flex;
	flex-direction: column;
	align-items: center;
}

/* Большие карточки */
.feature-card {
	background-color: var(--card-bg);
	border-radius: var(--border-radius);
	padding: 20px;
	margin-bottom: 30px;
	box-shadow: 0 2px 5px var(--shadow-color);
	max-width: 700px;
	width: 100%;
	position: relative;
	transition: var(--transition-base);
	border: 1px solid var(--border-color);
}

.feature-card-link {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
	display: block;
	border-radius: var(--border-radius);
	text-decoration: none;
}

.feature-card-link:hover {
	background-color: var(--hover-bg);
}

.feature-card-content {
	display: flex;
	align-items: center;
	position: relative;
	z-index: 2;
	pointer-events: none;
}

.feature-card-image {
	margin-right: 20px;
}

.feature-card-image img {
	width: 200px;
	height: 200px;
	object-fit: contain;
	transition: var(--transition-base);
}

.feature-card:hover .feature-card-image img {
	transform: scale(1.03);
}

.feature-card-text {
	color: var(--text-color);
}

.feature-card-text .title {
	font-size: 24px;
	font-weight: bold;
	color: var(--text-color);
	margin-bottom: 10px;
	display: block;
	text-align: center;
}

.feature-card-text .description {
	display: block;
	color: var(--text-secondary);
	line-height: 1.6;
	text-align: left;
}

/* Маленькие карточки */
.products-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 20px;
	max-width: 100%;
	width: 100%;
}

.product {
	background-color: var(--card-bg);
	border-radius: var(--border-radius);
	padding: 20px;
	text-align: center;
	text-decoration: none;
	color: var(--text-color);
	transition: var(--transition-base);
	display: flex;
	flex-direction: column;
	align-items: center;
	box-shadow: 0 2px 5px var(--shadow-color);
	border: 1px solid var(--border-color);
	position: relative;
	overflow: hidden;
}

.product::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 4px;
	background: linear-gradient(90deg, #60a5fa, #3b82f6);
	opacity: 0;
	transition: var(--transition-base);
}

.product:hover {
	transform: translateY(-5px);
	box-shadow: 0 5px 15px var(--shadow-hover);
}

.product:hover::before {
	opacity: 1;
}

.product img {
	width: 100px;
	height: 100px;
	margin-bottom: 15px;
	object-fit: contain;
	transition: var(--transition-base);
}

.product:hover img {
	transform: scale(1.1);
}

.product .title {
	font-weight: bold;
	font-size: 16px;
}

.product .description {
	font-size: 12px;
	color: var(--text-secondary);
	margin-top: 8px;
	line-height: 1.4;
}

/* ==========================================================================
	6. ЛОГИН СТРАНИЦЫ
	========================================================================== */

.login-container {
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: 100vh;
	padding: 20px;
}

.card {
	background: var(--bg-secondary);
	border-radius: 12px;
	padding: 24px;
	margin-bottom: 24px;
	box-shadow: 0 1px 3px var(--shadow-color);
	border: 1px solid var(--border-color);
}

.login-card {
	width: 100%;
	max-width: 400px;
}

.login-card h3 {
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--text-color);
	margin-bottom: 20px;
	padding-bottom: 12px;
	border-bottom: 2px solid var(--border-color);
}

.form-group {
	margin-bottom: 20px;
}

.form-group label {
	display: block;
	font-weight: 500;
	color: var(--text-color);
	margin-bottom: 6px;
	font-size: 14px;
}

.label-optional {
	color: var(--text-secondary);
	font-weight: normal;
	font-size: 12px;
}

.form-group input,
input[type="text"],
input[type="password"],
input[type="file"],
textarea {
	width: 100%;
	padding: 12px 16px;
	border: 1px solid var(--border-color);
	border-radius: 8px;
	font-size: 14px;
	transition: all 0.2s ease;
	background: var(--bg-primary);
	color: var(--text-color);
	font-family: inherit;
}

.form-group input:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="file"]:focus,
textarea:focus {
	outline: none;
	border-color: var(--primary-color);
	box-shadow: 0 0 0 3px rgba(168, 213, 168, 0.1);
}

textarea {
	resize: vertical;
	min-height: 80px;
}

.btn,
.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 20px;
	border: none;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
}

.btn-primary {
	background: var(--primary-color);
	color: #333;
	width: 100%;
}

.btn-primary:hover {
	filter: brightness(0.9);
}

.button {
	background: var(--admin-primary); /* Use specific admin blue color */
	color: white;
}

.button:hover {
	filter: brightness(0.9);
}

.button.danger {
	background: var(--danger-color);
}

.button.danger:hover {
	background: #c82333;
}

.btn-secondary {
	background: var(--text-secondary);
	color: white;
}

.btn-secondary:hover {
	filter: brightness(0.9);
}

.button.small,
.btn-small {
	padding: 6px 12px;
	font-size: 12px;
}

.admin-link,
.back-link {
	text-align: center;
	margin-top: 20px;
	padding-top: 20px;
	border-top: 1px solid var(--border-color);
}

.admin-link a,
.back-link a {
	color: var(--text-color);
	text-decoration: none;
	font-size: 14px;
	position: relative;
	display: inline-block;
}

.admin-link a::after,
.back-link a::after {
	content: '';
	position: absolute;
	width: 100%;
	height: 1px;
	bottom: -2px;
	left: 0;
	background-color: var(--text-color);
	transform: scaleX(0);
	transform-origin: bottom right;
	transition: transform 0.3s ease;
}

.admin-link a:hover::after,
.back-link a:hover::after {
	transform: scaleX(1);
	transform-origin: bottom left;
}

/* ==========================================================================
	7. АДМИН ПАНЕЛЬ
	========================================================================== */

body.admin-page {
	padding-top: 80px;
}

.header {
	margin-bottom: 30px;
	text-align: center;
}

.header h1 {
	font-size: 1.8rem;
	font-weight: 600;
	color: var(--text-color);
	margin-bottom: 0;
	display: inline-flex;
	align-items: center;
	gap: 12px;
}

/* Хлебные крошки (Breadcrumbs) */
.breadcrumb {
	padding: 10px 0;
	font-size: 15px;
}

.breadcrumb a {
	color: #31a2e6;
	text-decoration: none;
}

.breadcrumb a:hover {
	text-decoration: underline;
}

.section {
	background: var(--bg-secondary);
	border-radius: 8px;
	padding: 30px;
	margin-bottom: 30px;
	box-shadow: 0 2px 10px var(--shadow-color);
	border: 1px solid var(--border-color);
}

.section h2 {
	font-size: 20px;
	margin-bottom: 20px;
	padding-bottom: 10px;
	border-bottom: 2px solid var(--border-color);
	color: var(--text-color);
}

.hint {
	color: var(--text-secondary);
	font-size: 12px;
	margin-bottom: 20px;
}

.settings-preview {
	width: 80px;
	height: 80px;
	border-radius: 4px;
	background: var(--bg-primary);
	border: 1px solid var(--border-color);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.settings-preview img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.settings-controls {
	display: flex;
	align-items: center;
}

.file-preview {
	margin-top: 5px;
	color: var(--text-secondary);
}

/* Списки элементов */
.items-list {
	display: grid;
	gap: 15px;
}

.item {
	border: 1px solid var(--border-color);
	border-radius: 4px;
	padding: 15px;
	display: flex;
	gap: 15px;
	background: var(--hover-bg);
	transition: all 0.2s ease;
	cursor: move;
}

.item:hover {
	box-shadow: 0 4px 12px var(--shadow-color);
}

.item-image {
	width: 100px;
	height: 100px;
	flex-shrink: 0;
	border-radius: 4px;
	background: var(--bg-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	border: 1px solid var(--border-color);
}

.item-image img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.item-content {
	flex: 1;
}

.item-title {
	font-weight: 600;
	font-size: 16px;
	margin-bottom: 5px;
	color: var(--text-color);
}

.item-description {
	font-size: 13px;
	color: var(--text-secondary);
	margin-bottom: 8px;
	line-height: 1.4;
}

.item-url {
	font-size: 12px;
	color: #667eea;
	word-break: break-all;
	margin-bottom: 10px;
}

.item-actions {
	display: flex;
	gap: 10px;
}

.empty-message {
	text-align: center;
	padding: 40px 20px;
	color: var(--text-secondary);
	font-style: italic;
}

/* ==========================================================================
	8. МОДАЛЬНЫЕ ОКНА
	========================================================================== */

.modal {
	display: none;
	position: fixed;
	z-index: 1000;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.4);
}

.modal.active {
	display: flex;
	align-items: center;
	justify-content: center;
}

.modal-content {
	background-color: var(--bg-secondary);
	padding: 30px;
	border-radius: 8px;
	width: 90%;
	max-width: 500px;
	box-shadow: 0 4px 20px var(--shadow-color);
	max-height: 90vh;
	overflow-y: auto;
	border: 1px solid var(--border-color);
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
}

.modal-header h2 {
	margin: 0;
	border: none;
	padding: 0;
	font-size: 20px;
	color: var(--text-color);
}

.close {
	font-size: 28px;
	font-weight: bold;
	color: #aaa;
	cursor: pointer;
	border: none;
	background: none;
}

.close:hover {
	color: var(--text-color);
}

.form-actions {
	display: flex;
	gap: 10px;
	justify-content: flex-end;
	margin-top: 20px;
}

/* ==========================================================================
	9. АДАПТИВНОСТЬ
	========================================================================== */

@media (max-width: 768px) {
	body.admin-page {
		padding-top: 0px;
	}

	.theme-toggle-container {
		margin-right: 15px;
	}

	.products-grid {
		grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
		gap: 15px;
	}

	.feature-card {
		padding: 15px;
	}

	.feature-card-content {
		flex-direction: column;
	}

	.feature-card-image {
		margin-right: 0;
		margin-bottom: 15px;
	}

	.feature-card-text .title {
		text-align: center;
	}

	.product {
		padding: 15px;
	}

	.product img {
		width: 80px;
		height: 80px;
	}

	.product .title {
		font-size: 14px;
	}

	.modal-content {
		width: 95%;
		max-height: 95vh;
	}

	.item {
		flex-direction: column;
	}

	.item-image {
		width: 100%;
		height: 120px;
	}

	.controls-bar {
		position: static;
		justify-content: center;
		margin-bottom: 20px;
		border-radius: 0;
		top: 0;
		right: 0;
		left: 0;
	}

	.page-header {
		min-height: auto;
		padding-top: 20px;
	}

	.breadcrumb {
		position: static;
		transform: none;
		margin-bottom: 10px;
	}
}

@media (max-width: 480px) {
	.products-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* ==========================================================================
	10. УТИЛИТЫ
	========================================================================== */

.clearfix::after {
	content: "";
	display: table;
	clear: both;
}
