/* ==========================================================================
 * Макет: header, sidebar, main, footer (из /front/)
 * ========================================================================== */

/* --- App Layout --- */
.app-layout {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--color-bg);
}

/* --- Header (как /front/ desktop-header) --- */
.desktop-header {
	width: 100%;
	height: var(--header-height);
	padding: 0 var(--space-xl);
	background: var(--color-surface);
	border-bottom: 1px solid var(--color-border);
	display: flex;
	align-items: center;
	gap: var(--space-md);
	position: sticky;
	top: 0;
	z-index: 100;
}

/* Бренд в шапке: логотип + «РТТ Статистика» */
.header-brand {
	flex-shrink: 0;
	min-width: 0;
}
.header-brand-link {
	display: inline-flex;
	align-items: center;
	gap: var(--space-md);
	text-decoration: none;
	color: inherit;
	transition: opacity 0.15s ease;
}
.header-brand-link:hover {
	text-decoration: none;
	opacity: 0.88;
}
.header-logo {
	display: block;
	width: auto;
	height: 32px;
	max-width: 140px;
	max-height: 32px;
	object-fit: contain;
	flex-shrink: 0;
}
.header-brand-text {
	display: flex;
	align-items: baseline;
	flex-wrap: nowrap;
	gap: 0.35em;
	padding-left: var(--space-md);
	border-left: 1px solid var(--color-border);
	font-family: var(--font-body);
	font-size: 1.25rem;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.02em;
	white-space: nowrap;
}
.header-brand-accent {
	color: var(--color-primary);
	font-weight: 700;
}
.header-brand-name {
	color: var(--color-text);
	font-weight: 500;
}

/* --- Sidebar toggle (бургер) --- */
.sidebar-toggle {
	display: none;
	background: none;
	border: none;
	color: var(--color-text);
	cursor: pointer;
	padding: var(--space-sm);
	border-radius: var(--radius-md);
}
.sidebar-toggle:hover {
	background: var(--color-bg);
}
.sidebar-toggle svg {
	display: block;
	width: 20px;
	height: 20px;
}

/* --- Кнопка калькулятора рейтингов --- */
.header-calc-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	color: var(--color-text-muted);
	cursor: pointer;
	padding: var(--space-sm);
	border-radius: var(--radius-md);
	transition: color 0.15s, background 0.15s;
}
.header-calc-btn:hover {
	color: var(--color-primary);
	background: var(--color-bg);
}
.header-calc-btn svg {
	display: block;
	width: 20px;
	height: 20px;
}

/* --- Приветствие --- */
.greeting-text {
	font-size: var(--font-size-sm);
	color: var(--color-text);
	white-space: nowrap;
}

/* --- Player Selector (как UserMenu в /front/) --- */
.player-selector {
	position: relative;
	margin-left: auto;
	flex-shrink: 0;
}
.player-selector-native {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
.player-selector-trigger {
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: var(--space-sm);
	padding: var(--space-xs) var(--space-sm);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
	background: var(--color-surface);
	font: inherit;
	color: var(--color-text);
	max-width: min(320px, 45vw);
	transition: background 0.15s, border-color 0.15s;
}
.player-selector-trigger:hover {
	background: var(--color-bg);
	border-color: var(--color-primary);
}
.player-selector-avatar-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	line-height: 0;
}
.player-selector-name {
	font-size: var(--font-size-sm);
	font-weight: 500;
	color: var(--color-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
	flex: 1;
	text-align: left;
}
.player-selector-chevron {
	flex-shrink: 0;
	color: var(--color-text-muted);
}
.player-selector-avatar {
	width: 42px;
	height: 42px;
	border-radius: var(--radius-round);
	object-fit: cover;
	border: 2px solid var(--color-border);
}
.player-selector-avatar.placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--color-primary);
	color: #fff;
	font-size: var(--font-size-md);
	font-weight: 600;
}
.player-selector-dropdown {
	position: absolute;
	top: 100%;
	right: 0;
	width: 380px;
	max-width: 90vw;
	background: #f9fafe;
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-card);
	z-index: 400;
	margin-top: var(--space-sm);
	overflow: hidden;
}
.player-selector-list {
	max-height: 400px;
	overflow-y: auto;
}
.player-selector-list-item {
	display: flex;
	align-items: center;
	padding: var(--space-md) var(--space-lg);
	border-bottom: 1px solid var(--color-border-light);
	cursor: pointer;
	transition: background 0.15s;
}
.player-selector-list-item:hover {
	background: var(--color-sidebar-active);
}
.player-selector-list-item.active {
	background: var(--color-sidebar-active);
}
.player-selector-list-item img {
	width: 40px;
	height: 40px;
	border-radius: var(--radius-round);
	object-fit: cover;
	margin-right: var(--space-md);
	flex-shrink: 0;
}
.player-selector-list-item .avatar-placeholder {
	width: 40px;
	height: 40px;
	border-radius: var(--radius-round);
	background: var(--color-primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: var(--font-size-sm);
	font-weight: 600;
	margin-right: var(--space-md);
	flex-shrink: 0;
}
.player-selector-list-item-content {
	flex: 1;
	min-width: 0;
}
.player-selector-list-item-name {
	font-weight: 500;
	color: var(--color-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.player-selector-list-item-role {
	font-size: var(--font-size-xs);
	color: var(--color-text-muted);
}
.player-selector-logout {
	display: block;
	width: 100%;
	padding: var(--space-md) var(--space-lg);
	text-align: left;
	color: var(--color-danger);
	background: var(--color-surface);
	border: none;
	border-top: 1px solid var(--color-border-light);
	font-size: var(--font-size-sm);
	font-weight: 500;
	cursor: pointer;
	transition: background 0.15s;
}
.player-selector-logout:hover {
	background: rgba(251, 62, 124, 0.06);
}

/* --- App Body (sidebar + main) --- */
.app-body {
	display: flex;
	flex: 1;
	min-height: 0;
}

/* --- Sidebar --- */
.app-sidebar {
	flex: 0 0 var(--sidebar-width);
	width: var(--sidebar-width);
	background: var(--color-sidebar-bg);
	border-right: 1px solid var(--color-border);
	overflow-y: auto;
	height: calc(100vh - var(--header-height));
	position: sticky;
	top: var(--header-height);
}
.sidebar-nav {
	padding: var(--space-lg) 0;
}
.sidebar-section {
	padding: 0 var(--space-lg);
	margin-bottom: var(--space-lg);
}
.sidebar-section-title {
	font-family: var(--font-nav);
	font-weight: 300;
	font-size: 1.2rem;
	text-transform: uppercase;
	color: var(--color-text-muted);
	padding: var(--space-sm) 0;
	margin-bottom: var(--space-sm);
}
.sidebar-link {
	display: flex;
	align-items: center;
	padding: var(--space-sm) var(--space-md);
	border-radius: var(--radius-md);
	color: var(--color-text);
	font-size: var(--font-size-sm);
	text-decoration: none;
	transition: background 0.15s, color 0.15s;
	margin-bottom: 2px;
}
.sidebar-link:hover {
	background: var(--color-sidebar-active);
	text-decoration: none;
}
.sidebar-link.active,
.sidebar-link.sidebar-link-active {
	background: var(--color-sidebar-active);
	color: var(--color-primary);
	font-weight: 500;
}
/* Кнопка «Выход» в сайдбаре */
button.sidebar-link {
	width: calc(100% - var(--space-lg) * 2);
	margin-left: var(--space-lg);
	margin-right: var(--space-lg);
	border: none;
	background: none;
	font: inherit;
	cursor: pointer;
}
button.sidebar-link:hover {
	text-decoration: none;
}
.sidebar-link-icon {
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-right: var(--space-sm);
	flex-shrink: 0;
	color: var(--color-text-muted);
}
.sidebar-link.active .sidebar-link-icon,
.sidebar-link.sidebar-link-active .sidebar-link-icon {
	color: var(--color-primary);
}
.sidebar-link-icon svg {
	width: 16px;
	height: 16px;
}
.sidebar-divider {
	height: 1px;
	background: var(--color-border-light);
	margin: var(--space-md) var(--space-lg);
}

/* --- Sidebar Overlay (mobile) --- */
.sidebar-overlay {
	display: none;
	position: fixed;
	top: var(--header-height);
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0,0,0,0.3);
	z-index: 150;
}
.sidebar-overlay.open {
	display: block;
}

/* --- Main Content --- */
.app-content {
	flex: 1;
	overflow-y: auto;
	min-height: calc(100vh - var(--header-height));
}
.app-content .content-wrapper {
	max-width: var(--container-max);
	margin: 0 auto;
	padding: var(--space-xl);
}

/* --- Мобильная версия (<1024px) --- */
@media (max-width: 1023px) {
	.desktop-header {
		padding: 0 var(--space-md);
	}
	.sidebar-toggle {
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.app-sidebar {
		position: fixed;
		top: var(--header-height);
		left: 0;
		width: 280px;
		height: calc(100vh - var(--header-height));
		z-index: 200;
		transform: translateX(-100%);
		transition: transform 0.3s ease;
		border-right: 1px solid var(--color-border);
		box-shadow: var(--shadow-card);
	}
	.app-sidebar.open {
		transform: translateX(0);
	}
	.app-content {
		margin-left: 0;
		width: 100%;
	}
}

@media (max-width: 759px) {
	.desktop-header {
		padding: 0 var(--space-sm);
	}
	.header-brand-text {
		font-size: 1.0625rem;
		padding-left: var(--space-sm);
		gap: 0.25em;
	}
	.header-brand-name {
		display: none;
	}
	.header-logo {
		height: 28px;
		max-width: 100px;
	}
	.app-content .content-wrapper {
		padding: var(--space-md);
	}
	.player-selector-dropdown {
		width: 300px;
	}
	.player-selector-name {
		display: none;
	}
	.player-selector-trigger {
		padding: var(--space-xs);
		border: none;
		max-width: none;
	}
}
