/* Сетка шапки: одна строка, центральная колонка меню сжимается (не переносим иконки/профиль вниз) */
.header {
	position: relative;
	/* Выше типичного контента (.main, промо, z-index в личном кабинете), ниже cookie (999) и модалок авторизации */
	z-index: 500;
}

.header__top .header__row.row {
	flex-wrap: nowrap;
	align-items: center;
	justify-content: flex-start;
	min-width: 0;
}

.header__top .container {
	min-width: 0;
}

.header__top .header__row .header__col-navbar.col {
	flex: 1 1 auto;
	min-width: 0;
	width: auto;
	max-width: 100%;
}

/* Цепочка flex: иначе длинное меню не сжимается и выталкивает поиск/профиль за край */
.header__col-navbar .navbar,
.header__col-navbar .header__nav,
.header__col-navbar .header__menu {
	min-width: 0;
	max-width: 100%;
}

/*
 * Выпадающие подменю (.drop-menu в common.css) — position:absolute вниз от пункта.
 * 1) Нельзя задавать overflow-x: auto / overflow-y: hidden на .header__nav-list: при не-visible
 *    по одной оси вторая ось перестаёт быть «visible» и список получает scrollport — подменю
 *    обрезается по вертикали (видна только «пустая» полоска с тенью).
 * 2) Колонка меню в DOM раньше поиска/иконок: без z-index следующая колонка рисуется поверх
 *    области подменю — белый фон поиска визуально «съедает» пункты.
 */
.header__top .header__col-navbar {
	position: relative;
	z-index: 20;
}

.header__top .header__col-search {
	position: relative;
	z-index: 1;
}

.header__top .header__col-actions {
	position: relative;
	/* Выше .header__col-navbar (20): иначе выпадашки профиля/уведомлений рисуются под колонкой меню */
	z-index: 30;
}

/* Десктоп: пункты в одну линию; горизонтальный scroll у списка убран — см. комментарий выше */
@media (min-width: 992px) {
	.header__top .header__nav-list {
		flex-wrap: nowrap;
		min-width: 0;
	}

	.header__top .header__nav-list > .nav-item {
		flex-shrink: 0;
	}
}

.header__col-logo {
	flex: 0 0 auto;
}

.header__col-search {
	flex: 0 1 200px;
	min-width: 0;
	margin-left: auto;
}

.header__top .header__search {
	width: 100%;
	max-width: 200px;
	min-width: 120px;
	box-sizing: border-box;
}

.header__col-actions {
	flex: 0 0 auto;
	flex-shrink: 0;
}

/* media.css задаёт 25% / 0 — ломает сетку и обрезает бургер/меню */
@media (max-width: 991px) {
	.header__top .header__col-navbar {
		width: auto;
		flex: 0 0 auto;
		min-width: 0;
	}
}

/* Блок действий в шапке в стиле MEKA front: сравнение, избранное, уведомления, профиль */
:root {
	--hun-text: #1f1f1f;
	--hun-muted: #6d6d6d;
	--hun-border: #e6e6e6;
}

.header__actions--nav {
	display: flex;
	align-items: center;
	flex-wrap: nowrap;
	gap: 16px;
}

.header__actions--nav .nav__action {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
	color: var(--hun-text);
	min-width: 28px;
	min-height: 28px;
}

.header__actions--nav .nav__action img {
	height: 22px;
	width: 22px;
	display: block;
}

/* Совместимость со старым JS: класс нужен для клика, но без legacy-стиля из common.css */
.header__actions--nav .header__favorite {
	background: none;
	width: auto;
	height: auto;
	display: inline-flex;
}

.header__actions--nav .header__compare {
	background: none;
	width: auto;
	height: auto;
	margin-right: 0;
	display: inline-flex;
}

.header__actions--nav .nav__badge {
	position: absolute;
	top: -6px;
	right: -8px;
	min-width: 14px;
	height: 14px;
	padding: 0 3px;
	border-radius: 999px;
	background: #111111;
	color: #ffffff;
	font-size: 10px;
	line-height: 14px;
	text-align: center;
	font-weight: 600;
}

.nav__notify-menu,
.nav__user-menu {
	position: relative;
	display: inline-flex;
	align-items: center;
}

.nav__notify-toggle,
.nav__user-toggle {
	display: none !important;
}

.nav__notify-dropdown {
	position: absolute;
	right: -10px;
	top: calc(100% + 10px);
	background: #ffffff;
	border: 1px solid var(--hun-border);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
	width: 280px;
	display: none;
	flex-direction: column;
	z-index: 520;
}

.nav__notify-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 12px;
	font-size: 13px;
	border-bottom: 1px solid #efefef;
	position: relative;
}

.nav__notify-more-wrap {
	position: relative;
	display: flex;
	align-items: center;
}

.nav__notify-more-toggle {
	display: none !important;
}

.nav__notify-more {
	border: none;
	background: none;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	color: var(--hun-muted);
	padding: 0 4px;
}

.nav__notify-more-menu {
	position: absolute;
	right: 0;
	top: calc(100% + 6px);
	background: #ffffff;
	border: 1px solid #efefef;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
	padding: 6px;
	display: none;
	z-index: 530;
	min-width: 190px;
}

.nav__notify-more-menu button {
	width: 100%;
	border: none;
	background: none;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
	color: var(--hun-text);
	padding: 6px 8px;
	cursor: pointer;
	font-family: inherit;
}

.nav__notify-more-menu img {
	width: 14px;
	height: 14px;
	opacity: 0.7;
}

.nav__notify-more-toggle:checked + .nav__notify-more + .nav__notify-more-menu {
	display: block;
}

.nav__notify-sub {
	padding: 8px 12px;
	font-size: 11px;
	color: var(--hun-muted);
}

.nav__notify-list {
	list-style: none;
	padding: 0;
	margin: 0;
	max-height: 280px;
	overflow-y: auto;
}

.nav__notify-list li {
	position: relative;
	padding: 0;
	border-top: 1px solid #f1f1f1;
}

.nav__notify-item {
	width: 100%;
	border: none;
	background: none;
	text-align: left;
	padding: 10px 28px 10px 12px;
	cursor: pointer;
	display: block;
	font-family: inherit;
}

.nav__notify-text {
	font-size: 12px;
	color: var(--hun-text);
}

.nav__notify-date {
	font-size: 10px;
	color: var(--hun-muted);
	margin-top: 4px;
}

.nav__notify-dot {
	position: absolute;
	right: 10px;
	top: 18px;
	width: 6px;
	height: 6px;
	background: #8f8f8f;
	border-radius: 50%;
}

.nav__notify-toggle:checked + .nav__action + .nav__notify-dropdown {
	display: flex;
}

.nav__user {
	display: flex;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	color: var(--hun-text);
	cursor: pointer;
	max-width: 220px;
}

.nav__dropdown {
	position: absolute;
	right: 0;
	top: calc(100% + 10px);
	background: #ffffff;
	border: 1px solid var(--hun-border);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
	padding: 12px;
	min-width: 200px;
	display: none;
	flex-direction: column;
	gap: 10px;
	font-size: 13px;
	z-index: 520;
}

.nav__dropdown a {
	text-decoration: none !important;
	color: var(--hun-text);
}

.nav__dropdown a:hover {
	color: #3368c6;
}

.nav__dropdown-divider {
	height: 1px;
	background: #ececec;
	margin: 2px 0;
}

.nav__dropdown-logout {
	color: var(--hun-muted);
	display: flex;
	align-items: center;
	gap: 8px;
}

.nav__dropdown-logout img {
	width: 14px;
	height: 14px;
	opacity: 0.6;
}

.nav__user-toggle:checked + .nav__user + .nav__dropdown {
	display: flex;
}

.nav__avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: #d9d9d9;
	color: #1f1f1f;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 600;
	flex-shrink: 0;
	overflow: hidden;
}

.nav__avatar-initials {
	position: relative;
	z-index: 1;
}

.nav__avatar--image .nav__avatar-initials {
	opacity: 0;
}

.nav__avatar--image {
	position: relative;
	background: transparent;
	padding: 0;
}

.nav__avatar--image img {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: block;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	z-index: 2;
}

.nav__avatar-img {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: block;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	z-index: 2;
}

.nav__user-info {
	display: flex;
	flex-direction: column;
	line-height: 1.2;
	font-size: 12px;
	min-width: 0;
}

.nav__user-name {
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.nav__user-role {
	color: #5a6b8c;
	font-size: 11px;
	margin-top: 2px;
}

.notify-modal__overlay {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: rgba(0, 0, 0, 0.35);
	display: none;
	z-index: 100;
}

.notify-modal__overlay--open {
	display: block;
}

.notify-modal {
	position: fixed;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	background: #ffffff;
	border: 1px solid var(--hun-border);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
	padding: 24px 28px;
	width: 90vw;
	max-width: 520px;
	width: min(520px, 90vw);
	display: none;
	flex-direction: column;
	gap: 12px;
	z-index: 110;
	font-family: inherit;
}

.notify-modal--open {
	display: flex;
}

.notify-modal__title {
	margin: 0 0 6px;
	font-size: 16px;
	text-align: center;
}

.notify-modal__row {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
}

.notify-modal__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
}

.notify-modal__dot--yellow {
	background: #f3c54f;
}

.notify-modal__dot--purple {
	background: #7a5af8;
}

.notify-modal__meta {
	font-size: 11px;
	color: var(--hun-muted);
}

.notify-modal__button {
	margin-top: 8px;
	border: none;
	background: #2f2f2f;
	color: #ffffff;
	padding: 10px 12px;
	font-size: 12px;
	cursor: pointer;
	font-family: inherit;
}

.header__login-link {
	text-decoration: none !important;
	color: inherit;
	border: none;
	background: transparent;
	padding: 0;
	cursor: pointer;
	font: inherit;
}

.header__login-link:hover {
	opacity: 0.75;
}

.header__login-link img {
	display: block;
}

@media (max-width: 1012px) {
	.nav__user-info {
		display: none;
	}

	.nav__user {
		max-width: none;
	}
}

/* Как в макете MEKA: на узком экране — фиксированная нижняя панель (сравнение, избранное, уведомления/вход, профиль) */
@media (max-width: 980px) {
	body {
		padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
	}

	.header__top .header__col-actions {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 600;
		width: 100%;
		max-width: 100%;
		margin: 0;
		padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
		box-sizing: border-box;
		background: var(--page-bg, #ffffff);
		border-top: 1px solid var(--hun-border);
	}

	.header__actions--nav {
		width: 100%;
		justify-content: space-around;
		gap: 8px;
	}

	.header__col-actions .nav__notify-dropdown {
		top: auto;
		bottom: calc(100% + 10px);
		right: 0;
		left: auto;
		max-height: 55vh;
		max-height: min(320px, 55vh);
	}

	.header__col-actions .nav__dropdown {
		top: auto;
		bottom: calc(100% + 10px);
	}

	.header__col-actions .nav__notify-more-menu {
		top: auto;
		bottom: calc(100% + 6px);
	}
}

@media (max-width: 520px) {
	.header__top .header__col-actions {
		padding-left: 8px;
		padding-right: 8px;
	}
}


/*
 * п.28: шапка не «скачет».
 * Раньше поле поиска было flex: 0 1 200px и сжималось под ширину меню: после подгрузки шрифта (font-display: swap),
 * у пользователей с разной длиной имени, а у авторизованных и на 992–1920px меню заезжало под поиск.
 * Теперь ширина поиска фиксирована; где места нет — поиск свёрнут в иконку и раскрывается влево поверх меню
 * (место в строке не меняется: ширина 28px, при раскрытии width + отрицательный margin-left дают те же 28px).
 */
.header__col-search {
	flex: 0 0 auto;
}

.header__top .header__search {
	width: 200px;
	max-width: none;
	min-width: 0;
}

/* Свёрнутый поиск: гость на 992–1299px; авторизованный (имя, роль, колокольчик) — на всём десктопе */
@media (min-width: 992px) and (max-width: 1299px) {
	.header__top .header__search {
		width: 28px;
		border-bottom-color: transparent;
	}
	.header__top .header__search::before {
		pointer-events: none;
	}
	.header__top .header__search-input {
		cursor: pointer;
		background: transparent;
	}
	.header__top .header__search-input::placeholder {
		color: transparent;
	}
	.header__top .header__search:focus-within {
		width: 260px;
		margin-left: -232px;
		border-bottom-color: #18336C;
		/* белая подложка закрывает край пункта меню под раскрытым полем */
		box-shadow: -16px 0 0 #fff;
	}
	.header__top .header__search:focus-within .header__search-input {
		cursor: text;
		background: #fff;
	}
	.header__top .header__search:focus-within .header__search-input::placeholder {
		color: #9D9D9D;
	}
	.header__top .header__col-search:focus-within {
		z-index: 25;
	}
}

@media (min-width: 1300px) {
	.header--auth .header__top .header__search {
		width: 28px;
		border-bottom-color: transparent;
	}
	.header--auth .header__top .header__search::before {
		pointer-events: none;
	}
	.header--auth .header__top .header__search-input {
		cursor: pointer;
		background: transparent;
	}
	.header--auth .header__top .header__search-input::placeholder {
		color: transparent;
	}
	.header--auth .header__top .header__search:focus-within {
		width: 260px;
		margin-left: -232px;
		border-bottom-color: #18336C;
		box-shadow: -16px 0 0 #fff;
	}
	.header--auth .header__top .header__search:focus-within .header__search-input {
		cursor: text;
		background: #fff;
	}
	.header--auth .header__top .header__search:focus-within .header__search-input::placeholder {
		color: #9D9D9D;
	}
	.header--auth .header__top .header__col-search:focus-within {
		z-index: 25;
	}
}

@media (min-width: 992px) and (max-width: 1299px) {
	.header__top .nav-link {
		padding: 0 8px;
	}
	/* Имя и роль не помещаются рядом с меню — остаётся аватар, имя есть в выпадающем меню профиля */
	.header--auth .nav__user-info {
		display: none;
	}
}

/* media.css (≤1199px) раскладывает меню в несколько строк с отступами; на десктопе переноса нет (nowrap выше), отступы только раздвигают меню под поиск */
@media (min-width: 992px) and (max-width: 1199px) {
	.header__top .header__nav-list {
		gap: 0;
		padding: 0;
		justify-content: flex-start;
	}
	.header__top .header__nav-list > .nav-item {
		padding: 30px 0;
	}
	/* компактное меню: иначе у авторизованного (колокольчик, аватар) пункты заезжают под поиск */
	.header__top .nav-link {
		padding: 0 6px;
		font-size: 13px;
	}
	.header__top .nav-item.parent > .nav-link:after {
		display: none;
	}
}
