/* AppShell — боковое меню + верхняя полоса заголовка */

:root {
	--app-shell-rail-w: 240px;
	--app-shell-rail-w-collapsed: 52px;
	--app-shell-header-h: 52px;
	--app-shell-content-pad-y: 12px;
}

html {
	height: 100%;
}

body {
	min-height: 100%;
}

body.has-app-shell {
	margin: 0;
}

.app-shell {
	display: flex;
	align-items: flex-start;
	min-height: 100vh;
	background: #f8fafc;
}

.app-shell-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
	z-index: 1035;
}

.app-shell-backdrop.show {
	display: block;
}

/* ── Rail ── */
.app-shell-rail {
	width: var(--app-shell-rail-w);
	flex-shrink: 0;
	position: sticky;
	top: 0;
	height: 100vh;
	background: #fff;
	border-right: 1px solid #dee2e6;
	box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.08);
	display: flex;
	flex-direction: column;
	transition: width 0.2s ease, transform 0.2s ease;
	z-index: 1040;
}

.app-shell.rail-collapsed .app-shell-rail {
	width: var(--app-shell-rail-w-collapsed);
}

.app-shell-brand {
	height: var(--app-shell-header-h);
	min-height: var(--app-shell-header-h);
	max-height: var(--app-shell-header-h);
	box-sizing: border-box;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 10px;
	border-bottom: 1px solid #dee2e6;
	flex-shrink: 0;
}

.app-shell-brand .app-shell-logo {
	height: 28px;
	width: auto;
	flex-shrink: 0;
}

.app-shell-brand .app-shell-brand-text {
	font-weight: 600;
	font-size: 0.95rem;
	color: #212529;
	white-space: nowrap;
	overflow: hidden;
	flex: 1;
	min-width: 0;
}

.app-shell-menu-btn {
	width: 36px;
	height: 36px;
	flex-shrink: 0;
	border: 0;
	border-radius: 0.375rem;
	background: transparent;
	color: #212529;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	margin-left: auto;
}

.app-shell-menu-btn:hover {
	background: #f1f3f5;
}

.app-shell.rail-collapsed .app-shell-brand {
	justify-content: center;
	padding: 0;
}

.app-shell.rail-collapsed .app-shell-brand .app-shell-logo,
.app-shell.rail-collapsed .app-shell-brand .app-shell-brand-text {
	display: none;
}

.app-shell.rail-collapsed .app-shell-brand .app-shell-menu-btn {
	margin-left: 0;
}

.app-shell-nav {
	flex: 1;
	padding: 8px;
	overflow-y: auto;
	overflow-x: hidden;
}

.app-shell-section {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #6c757d;
	padding: 10px 10px 4px;
	white-space: nowrap;
	overflow: hidden;
}

.app-shell.rail-collapsed .app-shell-section {
	font-size: 0;
	height: 8px;
	padding: 6px 0;
}

.app-shell.rail-collapsed .app-shell-section::after {
	content: "";
	display: block;
	width: 18px;
	height: 1px;
	background: #dee2e6;
	margin: 0 auto;
}

.app-shell-link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0.5rem 0.65rem;
	margin-bottom: 2px;
	border-radius: 0.375rem;
	color: #212529;
	text-decoration: none;
	font-size: 0.9rem;
	white-space: nowrap;
	overflow: hidden;
	position: relative;
}

.app-shell-link:hover {
	background: #f8f9fa;
	color: #0d6efd;
}

.app-shell-link.active {
	background: #e7f1ff;
	color: #0d6efd;
	font-weight: 500;
}

.app-shell-link .app-shell-ico {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0.85;
}

.app-shell-link .app-shell-ico svg {
	width: 16px;
	height: 16px;
}

.app-shell.rail-collapsed .app-shell-link {
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	margin-left: auto;
	margin-right: auto;
}

.app-shell.rail-collapsed .app-shell-link .app-shell-label {
	display: none;
}

.app-shell.rail-collapsed .app-shell-link[data-tip]:hover::after {
	content: attr(data-tip);
	position: absolute;
	left: calc(100% + 8px);
	top: 50%;
	transform: translateY(-50%);
	background: #212529;
	color: #fff;
	font-size: 12px;
	font-weight: 400;
	padding: 4px 8px;
	border-radius: 0.25rem;
	white-space: nowrap;
	z-index: 50;
	pointer-events: none;
}

.app-shell-footer {
	border-top: 1px solid #dee2e6;
	padding: 10px 12px;
	flex-shrink: 0;
	min-height: 52px;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 2px;
	overflow: hidden;
}

.app-shell-user-name {
	font-size: 0.875rem;
	font-weight: 600;
	color: #212529;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.app-shell-user-role {
	font-size: 0.75rem;
	color: #6c757d;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.app-shell.rail-collapsed .app-shell-footer {
	padding: 8px 4px;
	align-items: center;
}

.app-shell.rail-collapsed .app-shell-user-name,
.app-shell.rail-collapsed .app-shell-user-role {
	display: none;
}

.app-shell.rail-collapsed .app-shell-footer::after {
	content: attr(data-initials);
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: #e7f1ff;
	color: #0d6efd;
	font-size: 0.7rem;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* ── Main ── */
.app-shell-main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.app-shell-topbar {
	height: var(--app-shell-header-h);
	min-height: var(--app-shell-header-h);
	max-height: var(--app-shell-header-h);
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	background: #fff;
	border-bottom: 1px solid #dee2e6;
	padding: 0 16px;
	flex-shrink: 0;
	position: sticky;
	top: 0;
	z-index: 1020;
}

.app-shell-topbar-left {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.app-shell-page-title {
	margin: 0;
	font-size: 1.15rem;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.app-shell-topbar .app-shell-menu-btn.mobile-only {
	display: none;
}

.app-shell-content {
	flex: 1;
	min-width: 0;
	padding-top: var(--app-shell-content-pad-y);
	padding-bottom: var(--app-shell-content-pad-y);
}

/* Auth: скрываем меню и topbar, пропускаем фоновое фото body.auth-page */
body.auth-page .app-shell-rail,
body.auth-page .app-shell-topbar,
body.auth-page .app-shell-backdrop {
	display: none !important;
}

body.auth-page .app-shell {
	display: block;
	background: transparent;
}

body.auth-page .app-shell-main {
	min-height: 100vh;
	width: 100%;
	background: transparent;
}

body.auth-page .app-shell-content {
	padding-top: 0;
	padding-bottom: 0;
	background: transparent;
}

/* Mobile */
@media (max-width: 767.98px) {
	.app-shell-rail {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		height: 100%;
		height: 100dvh;
		width: min(280px, 86vw) !important;
		transform: translateX(-105%);
		box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
	}

	.app-shell.mobile-open .app-shell-rail {
		transform: translateX(0);
	}

	.app-shell.rail-collapsed .app-shell-rail {
		width: min(280px, 86vw) !important;
	}

	.app-shell.rail-collapsed .app-shell-brand {
		justify-content: flex-start;
		padding: 0 10px;
	}

	.app-shell.rail-collapsed .app-shell-brand .app-shell-logo,
	.app-shell.rail-collapsed .app-shell-brand .app-shell-brand-text {
		display: unset;
	}

	.app-shell.rail-collapsed .app-shell-brand .app-shell-menu-btn {
		display: none;
	}

	.app-shell.rail-collapsed .app-shell-link {
		justify-content: flex-start;
		width: auto;
		height: auto;
		padding: 0.5rem 0.65rem;
		margin-left: 0;
		margin-right: 0;
	}

	.app-shell.rail-collapsed .app-shell-link .app-shell-label {
		display: inline;
	}

	.app-shell.rail-collapsed .app-shell-link[data-tip]:hover::after {
		display: none;
	}

	.app-shell.rail-collapsed .app-shell-section {
		font-size: 0.7rem;
		height: auto;
		padding: 10px 10px 4px;
	}

	.app-shell.rail-collapsed .app-shell-section::after {
		display: none;
	}

	.app-shell.rail-collapsed .app-shell-footer {
		display: flex;
		padding: 10px 12px;
		align-items: stretch;
	}

	.app-shell.rail-collapsed .app-shell-user-name,
	.app-shell.rail-collapsed .app-shell-user-role {
		display: block;
	}

	.app-shell.rail-collapsed .app-shell-footer::after {
		display: none;
	}

	.app-shell-brand .app-shell-menu-btn {
		display: none;
	}

	.app-shell-topbar .app-shell-menu-btn.mobile-only {
		display: inline-flex;
	}

	.app-shell-topbar {
		padding: 0 12px;
	}
}
