/* Помощник подбора («ИИ-помощник») — кнопка в верхней панели и окно чата.
   Дизайн bruleur: заливки вместо рамок, радиусы 6 / 8 / 12, Inter, только токены из main.css.
   Тень — только у самого окна (всплывающий слой). Образцы — design/index.html, вкладка «Каркас и меню». */

/* ---------- Кнопка-запускалка в верхней панели ---------- */
/* Одна кнопка на десктоп и телефон: подпись меняет media-запрос. Ставит её assistant.js: в нижнюю строку шапки, после поиска. */
.bpa-launch {
	display: inline-flex; align-items: center; gap: 8px; flex: none;
	height: 44px; padding: 0 16px 0 12px; border: 0; border-radius: var(--radius-md);
	background: var(--surface-2); color: var(--ink); white-space: nowrap; cursor: pointer;
	font: 600 13px/1 var(--font-sans); letter-spacing: .005em;
	transition: background .15s ease; -webkit-tap-highlight-color: transparent;
}
.bpa-launch[hidden] { display: none; }
.bpa-launch:hover, .bpa-launch[aria-expanded="true"] { background: var(--surface-3); }
.bpa-launch__icon { display: grid; place-items: center; width: 20px; height: 20px; color: var(--brand); }   /* бренд-оранж, как пламя логотипа */
.bpa-launch__icon svg { width: 18px; height: 18px; }
.bpa-launch__short { display: none; }
/* Десктоп: поиск, кнопка, корзина — три колонки вместо двух равных. Поиск остаётся главным (1fr), корзина у правого края
   в половинной ячейке: bp.js считает миниатюры по ширине её ячейки, поэтому кнопка не может стоять внутри неё. */
.browser-bar__row--bottom.has-assist { grid-template-columns: minmax(0, 1fr) auto minmax(150px, .5fr); }
@media (min-width: 961px) and (max-width: 1180px) {   /* узкий десктоп: только значок, чтобы поиск не терял ширину */
	.bpa-launch { width: 44px; padding: 0; justify-content: center; }
	.bpa-launch__label { display: none; }
}
@media (max-width: 960px) {
	.bpa-launch { height: 40px; padding: 0 12px 0 10px; border-radius: var(--radius-sm); }
	.bpa-launch__long { display: none; }
	.bpa-launch__short { display: inline; }
}
@media (max-width: 359px) {      /* совсем узкий экран: только значок, имя остаётся в aria-label */
	.bpa-launch { padding: 0 10px; }
	.bpa-launch__label { display: none; }
}

/* ---------- Окно ---------- */
/* Десктоп: плавающая панель справа. Фон страницы не затемняем, клик по странице окно не закрывает. */
.bpa {
	position: fixed; right: var(--gap); top: var(--gap); bottom: var(--gap); z-index: 55;
	display: flex; flex-direction: column; width: 460px; max-width: calc(100vw - var(--gap) * 2);
	background: var(--surface); color: var(--ink); border-radius: var(--radius-lg); overflow: hidden;
	box-shadow: 0 12px 40px rgba(15, 17, 22, .16);
	font-family: var(--font-sans);
	opacity: 0; transform: translateX(16px); pointer-events: none;
	transition: opacity .2s ease, transform .26s cubic-bezier(.2, .8, .2, 1);
}
.bpa[hidden] { display: none; }
.bpa.is-open { opacity: 1; transform: none; pointer-events: auto; }

.bpa__head { flex: none; display: flex; align-items: center; gap: 12px; padding: 16px 12px 12px 18px; }
.bpa__mark { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--surface-2); color: var(--brand); }
.bpa__mark svg { width: 20px; height: 20px; }
.bpa__title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bpa__title b { font-size: 15px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.bpa__title span { font-size: 12px; line-height: 1.35; color: var(--muted); }
.bpa__wipe {
	flex: none; height: 36px; padding: 0 12px; border: 0; border-radius: var(--radius-sm);
	background: none; color: var(--muted); font: 500 13px/1 var(--font-sans); cursor: pointer;
	transition: background .15s ease, color .15s ease;
}
.bpa__wipe[hidden] { display: none; }
.bpa__wipe:hover { background: var(--surface-2); color: var(--ink); }
.bpa__close {
	flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-md);
	background: none; color: var(--muted); cursor: pointer; transition: background .15s ease, color .15s ease;
}
.bpa__close:hover { background: var(--surface-2); color: var(--ink); }
.bpa__close svg { width: 18px; height: 18px; }

/* Лента: прокручивается только она. Реплики, карточки, плитки и чипсы идут друг за другом. */
.bpa__log {
	position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
	display: flex; flex-direction: column; gap: 10px; padding: 8px 18px 16px;
}
.bpa__log > * { flex: none; }

.bpa-msg {
	margin: 0; max-width: 88%; padding: 10px 14px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere;
}
.bpa-msg--user { align-self: flex-end; background: var(--ink); color: var(--dark-ink); border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg); }
.bpa-msg--bot { align-self: flex-start; background: var(--surface-2); color: var(--ink); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px; }
.bpa-msg--error { background: var(--badge-red-bg); color: var(--badge-red-fg); }

/* Ожидание ответа — три точки */
.bpa-msg--wait { display: inline-flex; align-items: center; gap: 5px; padding: 14px 16px; }
.bpa-msg--wait i { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); animation: bpa-dot 1.1s ease-in-out infinite; }
.bpa-msg--wait i:nth-child(2) { animation-delay: .16s; }
.bpa-msg--wait i:nth-child(3) { animation-delay: .32s; }
@keyframes bpa-dot { 0%, 70%, 100% { opacity: .35; transform: none; } 35% { opacity: 1; transform: translateY(-3px); } }

/* Карточки товара: та же карточка, что в сетке каталога, но лёжа — фото 3:4 слева, остальное справа */
.bpa-cards-wrap { max-width: 100%; }
.bpa-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bpa-card {
	display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; padding: 10px;
	background: var(--surface-2); border-radius: var(--radius-md);
}
.bpa-card__media {
	display: block; width: 72px; aspect-ratio: 3 / 4; overflow: hidden; border-radius: var(--radius-sm);
	background: var(--surface); align-self: start;
}
.bpa-card__media img { width: 100%; height: 100%; object-fit: contain; display: block; }
.bpa-card__media .bpa-card__art { padding: 8px; mix-blend-mode: multiply; }
.bpa-card__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bpa-card__sku { font-size: 10px; font-weight: 500; line-height: 1.2; letter-spacing: .02em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bpa-card__name {
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
	font-size: 13px; font-weight: 500; line-height: 1.3; letter-spacing: -.005em; color: var(--ink-2);
}
.bpa-card__name:hover { color: var(--ink); text-decoration: underline; }
.bpa-card__why { font-size: 11px; line-height: 1.35; color: var(--muted); }
.bpa-card__bottom { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 8px; margin-top: auto; padding-top: 4px; }
/* На серой подложке карточки счётчик и кнопка «подробнее» — белые, иначе сливаются с ней */
.bpa-card .shop-card__qty, .bpa-card .shop-card__add--detail { background: var(--surface); }
.bpa-card .shop-card__add--detail:hover { background: var(--surface-3); }

/* Плитки разделов: рисунок 40×40, имя, счётчик. Белые плитки сливаются с заливкой через multiply. */
.bpa-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.bpa-tiles a, .bpa-tiles button {
	display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 56px; padding: 8px 10px 8px 8px;
	border: 0; border-radius: var(--radius-md); background: var(--surface-2); color: var(--ink);
	font: inherit; text-align: left; cursor: pointer; transition: background .15s ease;
}
.bpa-tiles a:hover, .bpa-tiles button:hover { background: var(--surface-3); }
.bpa-tiles img { flex: none; width: 40px; height: 40px; object-fit: contain; border-radius: var(--radius-sm); mix-blend-mode: multiply; }
.bpa-tiles span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bpa-tiles b { font-size: 12.5px; font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; }
.bpa-tiles s { text-decoration: none; font-size: 11px; line-height: 1; color: var(--muted); }

/* Чипсы: кнопка продолжает разговор здесь же («+»), ссылка уводит в каталог («→») */
.bpa-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bpa-chips a, .bpa-chips button {
	display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 0; border-radius: var(--radius-sm);
	background: var(--surface-2); color: var(--ink); font: 500 13px/1.2 var(--font-sans); text-align: left; cursor: pointer;
	transition: background .15s ease;
}
.bpa-chips a:hover, .bpa-chips button:hover { background: var(--surface-3); }
.bpa-chips button::before { content: "+"; color: var(--muted); font-weight: 600; }
.bpa-chips a::after { content: "→"; color: var(--muted); }
.bpa-chips s { text-decoration: none; color: var(--muted); font-weight: 400; }

/* Поле ввода */
.bpa__form { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 18px 18px; }
.bpa__input {
	flex: 1 1 auto; min-width: 0; height: 48px; padding: 0 14px; border: 0; border-radius: var(--radius-md);
	background: var(--surface-2); color: var(--ink); font: 400 14px/1.4 var(--font-sans);
	-webkit-appearance: none; appearance: none;
}
.bpa__input::placeholder { color: var(--muted); }
.bpa__input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--ink); }
.bpa__send {
	flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-sm);
	background: var(--ink); color: var(--dark-ink); cursor: pointer; transition: background .15s ease;
}
.bpa__send:hover { background: var(--ink-hover); }
.bpa__send:disabled { opacity: .5; cursor: not-allowed; }
.bpa__send svg { width: 18px; height: 18px; }

/* Образец в макете: окно лежит в потоке, а не поверх страницы */
.bpa--static {
	position: static; width: 100%; max-width: 460px; height: 640px; opacity: 1; transform: none; pointer-events: auto;
}

/* ---------- Телефон: шторка во весь экран ---------- */
/* Высоту и верх ставит assistant.js по видимой части экрана (visualViewport): иначе при открытой клавиатуре строка ввода уезжает под неё. */
@media (max-width: 960px) {
	body.assist-open { overflow: hidden; }
	.bpa {
		left: 0; right: 0; top: var(--vvt, 0px); bottom: auto; width: auto; max-width: none; height: var(--vvh, 100%);
		z-index: 70; border-radius: 0; box-shadow: none; transform: translateY(24px);
	}
	.bpa__head { min-height: 56px; padding: 8px 8px 8px 14px; }
	.bpa__mark { width: 36px; height: 36px; }
	.bpa__title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.bpa__log { padding: 8px 14px 14px; }
	.bpa-msg { max-width: 92%; }
	.bpa__form { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
	.bpa__input { font-size: 16px; }   /* iPhone увеличивает страницу при вводе в поле мельче 16 px */
	.bpa__send { width: 44px; height: 44px; }
	.bpa__close, .bpa__wipe { min-height: 44px; }
	.bpa__close { width: 44px; height: 44px; }
	.bpa-chips a, .bpa-chips button { min-height: 40px; }
	.bpa--static { height: 640px; transform: none; border-radius: var(--radius-lg); box-shadow: 0 12px 40px rgba(15, 17, 22, .16); }
}
/* Тесно (клавиатура в ландшафте): подпись окна уступает место ленте */
.bpa.is-tight .bpa__title span { display: none; }
.bpa.is-tight .bpa__head { padding-top: 6px; padding-bottom: 6px; min-height: 48px; }
.bpa.is-tight .bpa__form { padding-top: 6px; padding-bottom: 8px; }
.bpa.is-tight .bpa__input { height: 40px; }

@media (prefers-reduced-motion: reduce) {
	.bpa, .bpa-launch { transition: none; }
	.bpa-msg--wait i { animation: none; opacity: .6; }
}

/* Плашка cookie не должна лезть под окно помощника: на десктопе окно стоит справа (460px + отступы), плашку сдвигаем левее */
@media (min-width: 961px) {
	body:has(.bpa.is-open) .bpf-cc { right: calc(460px + var(--gap) * 2); margin-left: 16px; }
}
