/*
 * Страница корзины (макет Cart.dc.html). Разметка — template/checkout/ivanko_cart.twig и template/ivanko/cart/{row,summary}.twig,
 * логика — js/ivanko-cart-page.js. Токены и приёмы те же, что у оформления заказа (css/ivanko-checkout.css).
 * Все правила висят на корне #icp: blue.css и responsive.css темы грузятся ПОСЛЕ этого файла, и только id-специфичность
 * (1,x,x) надёжно их перебивает. Токены повторены на корне по той же причине.
 * blue.css прячет все svg правилом body svg { display: none } — у каждой иконки display задан явно.
 *
 * Брейкпоинты: >= 1200 строка в одну линию (44 | 72 | 1fr | 124 | 128 | 36), сводка 400; 1024-1199 компактная строка, сводка 360;
 * < 1024 одна колонка, сводка после списка; <= 767 липкий нижний бар (скрывается при фокусе в поле), зоны нажатия >= 44.
 */
#icp {
	--ink: #15181C;
	--muted: #454B53;
	--muted-2: #656B74;
	--off: #8A9099;
	--border: #E2E5E9;
	--border-input: #D5DAE0;
	--bg-subtle: #F3F5F7;
	--bg-panel: #F5F7F9;
	--brand: #1B6FB3;
	--brand-hover: #124F82;
	--cta: #FFB224;
	--cta-hover: #F5A00F;
	--ok: #1D9A55;
	--warn: #E59A00;
	--warn-text: #8A5300;
	--err: #C42B26;
	--err-tint: #FDECEC;
	--err-text: #9B1C1C;
	--icp-pad: 64px;
	--icp-selbar-top: calc(var(--ih-h, 60px) + 4px);

	font-family: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.4;
	color: var(--ink);
	text-align: left;
	-webkit-font-smoothing: antialiased;
}
#icp *, #icp *::before, #icp *::after { box-sizing: border-box; }
#icp [hidden] { display: none !important; }
#icp a { color: var(--brand); text-decoration: none; background: none; }
#icp a:hover { color: var(--brand-hover); text-decoration: underline; }
#icp button, #icp input { font-family: inherit; margin: 0; letter-spacing: normal; text-transform: none; }
#icp button { cursor: pointer; }
#icp h1, #icp h2, #icp p { margin: 0; padding: 0; text-transform: none; }
#icp svg { display: block; fill: currentColor; flex: none; }
#icp a:focus-visible, #icp button:focus-visible, #icp input:focus-visible {
	outline: 3px solid rgba(27, 111, 179, .45);
	outline-offset: 2px;
}

#icp .icp-wrap { max-width: 1440px; margin: 0 auto; padding: 20px var(--icp-pad) 80px; display: flex; flex-direction: column; gap: 16px; }
#icp .icp-crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--muted-2); }
#icp .icp-crumbs a { color: var(--muted-2); }
#icp .icp-crumbs a:hover { color: var(--brand); }
#icp .icp-sep { color: #B5BBC3; }
#icp .icp-h1 { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
#icp .icp-headline { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; }
#icp .icp-count { font-size: 16px; color: var(--muted-2); }

/* Ошибка сети: плашка вместо alert() */
#icp .icp-net { padding: 12px 14px; border-radius: 10px; background: var(--err-tint); color: var(--err-text); font-size: 14px; line-height: 1.45; }

#icp .icp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 32px; align-items: start; }
#icp .icp-list { min-width: 0; display: flex; flex-direction: column; }

/* Панель выбора: липкая под липкой шапкой */
#icp .icp-selbar { position: sticky; top: var(--icp-selbar-top); z-index: 6; background: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 52px; padding: 4px 0; border-bottom: 1px solid var(--border); }
#icp .icp-selall { display: flex; align-items: center; min-height: 44px; margin: 0; padding-right: 4px; cursor: pointer; font-size: 15px; font-weight: 600; }
#icp .icp-selall-box { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
#icp .icp-selall input, #icp .icp-chk input { width: 22px; height: 22px; margin: 0; accent-color: var(--brand); cursor: pointer; }
#icp .icp-selcount { font-size: 15px; color: var(--muted); }
#icp .icp-selcount-m { display: none; }
#icp .icp-grow { flex: 1; }
#icp .icp-delbtn { min-height: 44px; padding: 0 4px; border: 0; background: none; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--muted-2); }
#icp .icp-delbtn svg { width: 18px; height: 18px; }
#icp .icp-delbtn[disabled] { color: #C9CED4; cursor: default; }
#icp .icp-delask { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 14px; }
#icp .icp-delq { font-weight: 600; }
#icp .icp-delyes { height: 44px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--err-tint); color: var(--err); font-size: 14px; font-weight: 700; }
#icp .icp-delno { height: 44px; padding: 0 10px; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 500; }

/* Строка товара: широкая раскладка 44 | 72 | 1fr | 124 | 128 | 36 */
#icp .icp-rows { display: flex; flex-direction: column; }
#icp .icp-row { display: grid; grid-template-columns: 44px 72px minmax(0, 1fr) 124px 128px 36px; grid-template-areas: "chk photo info qty sum rm" "chk photo notes qty sum rm"; column-gap: 14px; row-gap: 2px; align-items: center; min-height: 96px; padding: 10px 0; border-bottom: 1px solid var(--border); }
#icp .icp-chk { grid-area: chk; width: 44px; height: 44px; margin: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
#icp .icp-photo { grid-area: photo; width: 72px; height: 72px; border-radius: 10px; background: var(--bg-panel); display: flex; align-items: center; justify-content: center; overflow: hidden; transition: opacity .15s; }
#icp .icp-photo img { display: block; width: 100%; height: 100%; object-fit: contain; }
#icp .icp-sil { width: 54px; height: 34px; color: #AFC0CE; fill: currentColor; }
#icp .icp-info { grid-area: info; align-self: end; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#icp .icp-notes { grid-area: notes; align-self: start; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
#icp .icp-notes:empty { display: none; }
#icp .icp-ctrl { display: contents; }
#icp .icp-qtywrap { grid-area: qty; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#icp .icp-sumcol { grid-area: sum; display: flex; flex-direction: column; align-items: flex-end; text-align: right; transition: opacity .2s; }
#icp .icp-rm { grid-area: rm; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; }
#icp .icp-rm svg { width: 20px; height: 20px; }
#icp .icp-rm:hover { background: var(--bg-subtle); color: var(--err); }

#icp .icp-name { font-size: 16px; font-weight: 600; line-height: 1.3; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; transition: opacity .15s; }
#icp .icp-name:hover { color: var(--brand); text-decoration: none; }
#icp .icp-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; overflow-wrap: anywhere; }
#icp .icp-code { font: 500 13px 'JetBrains Mono', ui-monospace, Consolas, monospace; color: var(--ink); }
#icp .icp-stock { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; line-height: 1.35; color: var(--muted); }
#icp .icp-dot { width: 8px; height: 8px; flex: none; margin-top: 5px; border-radius: 50%; background: #9AA2AC; }
#icp .icp-dot--ok { background: var(--ok); }
#icp .icp-dot--warn { background: var(--warn); }

#icp .icp-off { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted-2); }
#icp .icp-off svg { width: 16px; height: 16px; }
#icp .icp-err { display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; font-size: 13px; }
#icp .icp-err-t { display: flex; align-items: flex-start; gap: 4px; line-height: 1.35; color: var(--err); }
#icp .icp-err-t svg { width: 16px; height: 16px; margin-top: 1px; }
#icp .icp-err-act { display: flex; flex-wrap: wrap; gap: 0 14px; }
#icp .icp-lnk { min-height: 32px; padding: 0; border: 0; background: none; font-size: 13px; font-weight: 600; color: var(--brand); }
#icp .icp-lnk:hover { color: var(--brand-hover); text-decoration: underline; }

/* Счётчик − N + */
#icp .icp-qty { display: flex; align-items: center; height: 40px; border: 1.5px solid var(--border-input); border-radius: 10px; background: #fff; }
#icp .icp-qb { width: 36px; height: 100%; border: 0; background: none; font-size: 18px; line-height: 1; color: var(--ink); border-radius: 8px; }
#icp .icp-qb:hover:not([disabled]) { background: var(--bg-subtle); }
#icp .icp-qb[disabled] { color: #C9CED4; cursor: default; }
#icp .icp-qin { width: 40px; height: 100%; padding: 0; border: 0; background: none; box-shadow: none; text-align: center; font-size: 15px; font-weight: 600; color: var(--ink); outline: none; }
#icp .icp-atmax { font-size: 12px; color: var(--warn-text); text-align: center; }
#icp .icp-minmsg { font-size: 12px; line-height: 1.3; color: var(--err); text-align: center; }
#icp .icp-sumv { font-size: 18px; font-weight: 700; line-height: 1.25; }
#icp .icp-sumv.is-req { font-size: 15px; }
#icp .icp-unit { font-size: 13px; color: var(--muted-2); }

/* Снятая строка: фото, название и сумма приглушены; счётчик и «×» контрастные */
#icp .icp-row.is-off .icp-photo, #icp .icp-row.is-off .icp-name { opacity: .45; }
#icp .icp-row.is-off .icp-sumcol { opacity: .45; }
#icp .icp-row.is-off .icp-minmsg { color: var(--muted-2); }
#icp .icp-row.is-flash { animation: icp-flash 1.2s ease-out; }
@keyframes icp-flash { 0% { background: #FFF4DE; } 100% { background: transparent; } }

/* Строка-тост «Товар удалён · Вернуть» вместо удалённой на 6 с */
#icp .icp-toast, #icp .icp-etoast { display: none; align-items: center; gap: 12px; min-height: 56px; padding: 6px 8px 6px 14px; background: var(--bg-subtle); border-radius: 10px; font-size: 15px; }
#icp .icp-toast svg, #icp .icp-etoast svg { width: 20px; height: 20px; color: var(--muted-2); }
#icp .icp-etoast { display: flex; }
#icp .icp-toast-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#icp .icp-toast-t span { color: var(--muted); }
#icp .icp-undo { height: 44px; padding: 0 14px; border: 0; border-radius: 8px; background: none; font-size: 15px; font-weight: 700; color: var(--brand); }
#icp .icp-undo:hover { background: #E6EBF0; }
#icp .icp-row.is-pending { display: block; min-height: 0; padding: 8px 0; }
#icp .icp-row.is-pending > *:not(.icp-toast) { display: none; }
#icp .icp-row.is-pending > .icp-toast { display: flex; }

/* Сводка */
#icp .icp-sum { position: sticky; top: calc(var(--ih-h, 60px) + 20px); border: 1px solid var(--border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 14px; background: #fff; }
#icp .icp-sum-head { display: flex; flex-direction: column; gap: 4px; }
#icp .icp-sum-title { font-size: 20px; font-weight: 700; }
#icp .icp-heldline { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--muted-2); }
#icp .icp-heldline svg { width: 16px; height: 16px; }
#icp .icp-totals { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); transition: opacity .2s; }
#icp .icp-trows { display: flex; flex-direction: column; gap: 6px; }
#icp .icp-trow { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; color: var(--muted); }
#icp .icp-total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 4px; }
#icp .icp-total span { font-size: 17px; font-weight: 600; }
#icp .icp-total b { font-size: 24px; font-weight: 700; }
#icp .icp-hint { display: flex; align-items: flex-start; gap: 8px; padding: 12px 14px; border-radius: 10px; background: var(--bg-subtle); font-size: 15px; line-height: 1.4; color: var(--muted); }
#icp .icp-hint svg { width: 20px; height: 20px; }
#icp .icp-blocked { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--err); }
#icp .icp-blocked svg { width: 18px; height: 18px; }
#icp .icp-show { min-height: 32px; padding: 0; border: 0; background: none; font-size: 14px; font-weight: 600; color: var(--brand); text-decoration: underline; }
#icp .icp-cta { height: 56px; border: 0; border-radius: 10px; background: var(--cta); color: var(--ink); font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: center; text-align: center; text-decoration: none; transition: background-color .15s; }
#icp .icp-cta:hover { background: var(--cta-hover); color: var(--ink); text-decoration: none; }
#icp .icp-cta.is-off, #icp .icp-cta.is-off:hover { background: #E9ECEF; color: var(--muted-2); cursor: not-allowed; }
#icp .icp-continue { align-self: center; min-height: 40px; display: flex; align-items: center; font-size: 15px; font-weight: 600; }
#icp .icp-help { display: flex; gap: 12px; align-items: flex-start; padding-top: 14px; border-top: 1px solid var(--border); }
#icp .icp-help > svg { width: 22px; height: 22px; color: var(--brand); }
#icp .icp-help-t { display: flex; flex-direction: column; gap: 2px; font-size: 14px; color: var(--muted); line-height: 1.4; }
#icp .icp-help-ph { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; color: var(--ink); white-space: nowrap; }
#icp .icp-help-ph svg { display: none; width: 20px; height: 20px; }
#icp .icp-help-ph:hover { color: var(--ink); }
#icp .icp-help-sub { font-size: 13px; color: var(--muted-2); }

/* Пока идёт пересчёт, сереют только суммы */
#icp.is-calc .icp-sumcol, #icp.is-calc .icp-totals, #icp.is-calc .icp-bar-total { opacity: .35; }

/* Пустая корзина */
#icp .icp-emptybox { display: flex; flex-direction: column; gap: 12px; }
#icp .icp-empty { border: 1px solid var(--border); border-radius: 16px; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
#icp .icp-empty-ico { width: 80px; height: 80px; border-radius: 50%; background: var(--bg-subtle); color: var(--muted); display: flex; align-items: center; justify-content: center; }
#icp .icp-empty-ico svg { width: 40px; height: 40px; }
#icp .icp-empty-hint { font-size: 16px; color: var(--muted); }
#icp .icp-empty-act { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding-top: 4px; }
#icp .icp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 28px; border-radius: 10px; font-size: 17px; font-weight: 700; text-decoration: none; }
#icp .icp-btn:hover { text-decoration: none; }
#icp .icp-btn--cta { background: var(--cta); color: var(--ink); }
#icp .icp-btn--cta:hover { background: var(--cta-hover); color: var(--ink); }
#icp .icp-btn--out { border: 1.5px solid var(--border-input); background: #fff; color: var(--ink); padding: 0 22px; font-size: 16px; font-weight: 600; }
#icp .icp-btn--out:hover { border-color: #9AA2AC; color: var(--ink); }
#icp .icp-btn--out svg { width: 20px; height: 20px; }
#icp .icp-empty-ph { font-size: 14px; color: var(--muted); }
#icp .icp-empty-ph a { font-weight: 700; color: var(--ink); white-space: nowrap; }

/* Нижний бар (мобильный) */
#icp .icp-bar { display: none; }

/* 1024-1199: сводка 360, компактная строка */
@media (max-width: 1199px) {
	#icp { --icp-pad: 32px; }
	#icp .icp-grid { grid-template-columns: minmax(0, 1fr) 360px; }
	#icp .icp-row { grid-template-columns: 44px 72px minmax(0, 1fr) 36px; grid-template-areas: "chk photo info rm" ". notes notes notes" ". ctrl ctrl ctrl"; column-gap: 10px; row-gap: 0; align-items: start; padding: 12px 0; }
	#icp .icp-chk { margin-top: -6px; }
	#icp .icp-info { align-self: start; gap: 4px; }
	#icp .icp-name { font-size: 15px; }
	#icp .icp-meta { font-size: 12px; gap: 0 5px; }
	#icp .icp-code { font-size: 12px; }
	#icp .icp-rm { width: 44px; height: 44px; margin: -10px -8px 0 -8px; }
	#icp .icp-notes { gap: 0; }
	#icp .icp-off, #icp .icp-err { margin-top: 8px; }
	#icp .icp-err { flex-direction: column; align-items: flex-start; gap: 2px; }
	#icp .icp-lnk { min-height: 44px; font-size: 14px; }
	#icp .icp-ctrl { grid-area: ctrl; display: flex; align-items: flex-start; gap: 12px; margin-top: 8px; }
	#icp .icp-qtywrap { align-items: flex-start; }
	#icp .icp-qty { height: 44px; }
	#icp .icp-qb { width: 44px; }
	#icp .icp-qin { width: 36px; font-size: 16px; }
	#icp .icp-atmax, #icp .icp-minmsg { text-align: left; }
	#icp .icp-sumcol { flex: 1; min-width: 0; align-self: center; }
	#icp .icp-unit { font-size: 12px; }
}

/* < 1024: одна колонка, сводка после списка */
@media (max-width: 1023px) {
	#icp .icp-grid { display: flex; flex-direction: column; gap: 16px; }
	#icp .icp-sum { position: static; width: 100%; padding: 16px; gap: 12px; }
	#icp .icp-sum-title { font-size: 18px; }
	#icp .icp-total span { font-size: 16px; }
	#icp .icp-total b { font-size: 22px; }
	#icp .icp-continue { align-self: stretch; height: 48px; border: 1.5px solid var(--border-input); border-radius: 10px; justify-content: center; color: var(--ink); font-size: 16px; }
	#icp .icp-continue:hover { color: var(--ink); text-decoration: none; border-color: #9AA2AC; }
	#icp .icp-help { flex-direction: column; border-top: 0; padding-top: 0; }
	#icp .icp-help > svg { display: none; }
	#icp .icp-help-ph { height: 48px; justify-content: center; border: 1.5px solid var(--brand); border-radius: 10px; font-size: 16px; }
	#icp .icp-help-ph svg { display: block; }
	#icp .icp-help-t { width: 100%; }
	#icp .icp-help-sub { display: none; }
}

@media (max-width: 767px) {
	#icp { --icp-pad: 16px; --icp-selbar-top: 56px; }
	#icp .icp-wrap { padding-top: 14px; padding-bottom: 120px; }
	#icp .icp-h1 { font-size: 26px; }
	#icp .icp-selcount-d { display: none; }
	#icp .icp-selcount-m { display: inline; }
	#icp .icp-delbtn span { display: none; }
	#icp .icp-delbtn { width: 44px; justify-content: center; }
	#icp .icp-delbtn svg { width: 22px; height: 22px; }
	#icp .icp-row { grid-template-columns: 44px 64px minmax(0, 1fr) 36px; }
	#icp .icp-photo { width: 64px; height: 64px; }
	#icp .icp-sil { width: 48px; height: 30px; }
	#icp .icp-empty { padding: 32px 16px; }
	#icp .icp-sum > .icp-cta, #icp .icp-sum > .icp-blocked { display: none; }
	#icp .icp-bar { position: fixed; left: 0; right: 0; bottom: var(--cookie-h, 0px); z-index: 1040; display: flex; flex-direction: column; gap: 6px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(20, 30, 40, .08); }
	#icp .icp-bar-blocked button { min-height: 28px; padding: 0; border: 0; background: none; display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--err); text-align: left; }
	#icp .icp-bar-blocked svg { width: 16px; height: 16px; }
	#icp .icp-bar-blocked u { color: var(--brand); font-weight: 600; }
	#icp .icp-bar-row { display: flex; align-items: center; gap: 12px; }
	#icp .icp-bar-total { display: flex; flex-direction: column; line-height: 1.15; transition: opacity .2s; }
	#icp .icp-bar-total b { font-size: 20px; font-weight: 700; white-space: nowrap; }
	#icp .icp-bar-total span { font-size: 12px; color: var(--muted); }
	#icp .icp-bar-none { font-size: 15px; font-weight: 600; color: var(--muted); }
	#icp .icp-bar .icp-cta { flex: 1; height: 52px; font-size: 17px; }
	#icp.is-kb .icp-bar, #icp.is-empty .icp-bar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	#icp * { transition: none !important; animation: none !important; }
}
