/* Экран «Товары» (.pr-): каталог — строки на телефоне, таблица на ПК (как desktop/08 Битрикса);
   карточка товара, шторка создания, просмотр фото. Правила — docs/05-UI-KIT.md. */

:root {
  --pr-icon: #f5a623; /* значок каталога в шапке карточки, как в Битриксе */
  --pr-viewer-bg: #000000;
  --pr-viewer-text: #ffffff;
  --pr-viewer-btn: rgba(255, 255, 255, 0.14);
  --pr-viewer-danger: #ff7b76;
  --pr-on-success: #ffffff; /* текст на зелёной «Создать», как в Битриксе */
}

.pr-scroll { padding: 0 12px calc(var(--tabbar-h) + var(--safe-bottom) + 96px); }
.pr-search { position: relative; }
/* Свой ✕ уже есть — системный крестик поля поиска (Chrome, Safari) прячем, чтобы не было двух. */
.pr-search input::-webkit-search-cancel-button, .pr-search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.pr-search-x { width: 44px; height: 40px; margin-right: -10px; display: grid; place-items: center; color: var(--text-3); flex: none; }

/* Плашка бренда: «Бренд / YCapsule ⌄», справа число товаров — как плашка воронки в сделках */
.pr-plate { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 16px 8px 10px; margin: 2px 0 4px; background: var(--surface); border-radius: var(--radius); text-align: left; box-shadow: var(--shadow-card); transition: transform 100ms var(--ease-out); }
.pr-plate:active { transform: scale(0.99); }
.pr-plate-ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); color: var(--c, var(--accent)); }
.pr-plate-ic.brand { background: none; border-radius: 11px; }
.pr-plate-ic.brand .brand-icon, .pr-plate-ic.brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 19px; }
.pr-plate-k { display: block; font-size: 13px; color: var(--text-3); line-height: 1.2; }
.pr-plate-v { display: flex; align-items: center; gap: 4px; font-size: 17px; font-weight: 600; color: var(--text); line-height: 1.3; min-width: 0; }
.pr-plate-v > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-plate-v svg.ic { color: var(--text-3); }
.pr-plate-n { flex: none; text-align: right; font-size: 13px; color: var(--text-3); line-height: 1.2; }
.pr-plate-n b { display: block; font-size: 17px; font-weight: 600; color: var(--text); line-height: 1.3; }

/* Группы товаров чипами */
.pr-chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -12px; padding: 8px 12px 10px; scrollbar-width: none; }
.pr-chips::-webkit-scrollbar { display: none; }
.pr-chip { position: relative; flex: none; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); font-size: 15px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: transform 100ms var(--ease-out), background 120ms; }
.pr-chip::after { content: ''; position: absolute; inset: -4px -3px; } /* цель касания 44 px */
.pr-chip:active { transform: scale(0.97); }
.pr-chip .n { color: var(--text-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.pr-chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }
.pr-chip.on .n { color: var(--link); }

/* Список (телефон) */
.pr-group-h { display: flex; align-items: baseline; gap: 6px; padding: 14px 4px 6px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.pr-group-h .n { font-weight: 400; }
.pr-list { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); }
.pr-row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 10px 16px 10px 12px; color: var(--text); transition: background 120ms; }
.pr-row + .pr-row::before { content: ''; position: absolute; top: 0; left: 72px; right: 0; border-top: 0.5px solid var(--line); }
.pr-row:active { background: color-mix(in srgb, var(--text) 5%, transparent); }
.pr-row-main { flex: 1; min-width: 0; }
.pr-row-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 16px; line-height: 1.3; font-weight: 500; word-break: break-word; }
.pr-row-sub { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 13px; color: var(--text-3); min-width: 0; }
.pr-row-sub .t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-row-price { flex: none; max-width: 40%; font-size: 16px; font-weight: 600; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.pr-row-price.muted { font-size: 13px; font-weight: 400; color: var(--text-3); }
.pr-row.off .pr-row-name, .pr-row.off .pr-row-price { color: var(--text-3); }
.pr-row.off .pr-thumb, .pr-tr.off .pr-thumb { opacity: 0.5; }
.pr-badge { flex: none; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--line-2); color: var(--text-3); white-space: nowrap; font-weight: 400; }
.pr-badge.off { background: var(--surface-3); border-color: transparent; }

.pr-thumb { --s: 48px; position: relative; width: var(--s); height: var(--s); flex: none; border-radius: 10px; overflow: hidden; background: var(--surface-3); color: var(--text-4); display: grid; place-items: center; }
.pr-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Карточка товара */
.pr-card { padding-bottom: 8px; }
.pr-card .section { padding-bottom: 0; }
.pr-card .frow .fvalue .muted { color: var(--text-3); }
.pr-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(96px, 34%); border-bottom: 0.5px solid var(--line); }
.pr-pair:last-child { border-bottom: 0; }
.pr-pair > .frow { border-bottom: 0; }
.pr-pair > .frow + .frow { border-left: 0.5px solid var(--line); padding-left: 16px; }

.pr-photos { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.pr-ph-wrap { position: relative; flex: none; }
.pr-ph { display: block; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--surface-3); border: 0.5px solid var(--line); transition: transform 100ms var(--ease-out); }
.pr-ph:active { transform: scale(0.96); }
.pr-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pr-ph.miss { display: grid; place-items: center; color: var(--text-4); }
.pr-ph-x { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; background: var(--text-3); color: var(--surface); display: grid; place-items: center; border: 2px solid var(--surface); }
.pr-ph-x::after { content: ''; position: absolute; inset: -10px; } /* цель касания 44 px */
.pr-add { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 16px; color: var(--text-3); cursor: pointer; }
.pr-add.busy { pointer-events: none; }
.pr-add:active { opacity: 0.6; }
.pr-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pr-mini-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--primary); animation: spin 700ms linear infinite; flex: none; }

/* Шторка «Новый товар»: поля ввода прямо в строках */
.pr-create-form .frow { min-height: 64px; }
.pr-in { cursor: text; }
.pr-in input { display: block; width: 100%; min-width: 0; border: 0; outline: none; background: transparent; padding: 0; margin: 0; font-size: 17px; line-height: 1.35; color: var(--text); }
.pr-in input::placeholder { color: var(--text-4); }
.pr-in.bad .flabel { color: var(--danger-text); }
.pr-in-err { margin-top: 4px; font-size: 13px; color: var(--danger-text); }

/* Просмотр фото: поверх карточки, но под шторками (подтверждение удаления) */
.pr-viewer { position: fixed; inset: 0; z-index: 55; display: flex; flex-direction: column; background: var(--pr-viewer-bg); color: var(--pr-viewer-text); animation: fade-in 180ms var(--ease-out); }
.pr-viewer-top { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-top) + 4px) 8px 4px; flex: none; }
.pr-viewer .icon-btn { color: var(--pr-viewer-text); }
.pr-viewer-title { flex: 1; min-width: 0; text-align: center; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-viewer-gap { width: 44px; flex: none; }
.pr-viewer-img { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 16px; }
.pr-viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.pr-viewer-miss { display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 16px; opacity: 0.7; }
.pr-viewer-miss svg.ic { width: 44px; height: 44px; }
.pr-viewer-bar { flex: none; display: flex; justify-content: center; gap: 12px; padding: 10px 16px calc(var(--safe-bottom) + 16px); }
.pr-vbtn { position: relative; height: 44px; padding: 0 20px; border-radius: 22px; display: inline-flex; align-items: center; gap: 8px; background: var(--pr-viewer-btn); color: var(--pr-viewer-text); font-size: 16px; cursor: pointer; }
.pr-vbtn:active { opacity: 0.7; }
.pr-vbtn.danger { color: var(--pr-viewer-danger); }
.pr-vbtn.busy { pointer-events: none; opacity: 0.7; }

/* Десктоп: панель «бренд · поиск», таблица каталога */
.pr-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 0 2px; }
.pr-toolbar .searchbar { flex: 0 1 380px; margin: 0; background: var(--surface); border: 1px solid var(--line-2); }
.pr-create { background: var(--success); color: var(--pr-on-success); }
.pr-create:active { filter: brightness(0.95); }

.pr-table { background: var(--surface); border-radius: var(--radius); overflow: clip; }
.pr-tr { display: grid; grid-template-columns: 48px minmax(240px, 3fr) minmax(120px, 1.3fr) 64px 120px 96px minmax(110px, 1.2fr); align-items: center; gap: 14px; min-height: 60px; padding: 8px 20px; border-bottom: 0.5px solid var(--line); color: var(--text); font-size: 14px; }
.pr-tr:last-child { border-bottom: 0; }
.pr-th { min-height: 44px; position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--text-3); font-size: 13px; }
.pr-tr .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pr-tr .num.muted { font-size: 13px; }
.pr-td-name { min-width: 0; }
.pr-td-name .nm { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 500; word-break: break-word; }
.pr-td-name .bd { display: flex; gap: 6px; flex-wrap: wrap; }
.pr-td-name .bd:not(:empty) { margin-top: 3px; }
.pr-tr.off .nm { color: var(--text-3); }
.pr-foot { padding: 12px 4px 32px; font-size: 13px; color: var(--text-3); }

@media (hover: hover) and (pointer: fine) {
  .pr-row:hover, a.pr-tr:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
  .pr-plate:hover { background: color-mix(in srgb, var(--text) 2%, var(--surface)); }
  .pr-chip:hover { border-color: var(--text-4); }
  .pr-add:hover { color: var(--text-2); }
  .pr-ph:hover { border-color: var(--line-2); }
  .pr-vbtn:hover { filter: brightness(1.15); }
  .pr-create:hover { filter: brightness(1.05); }
}

@media (min-width: 1024px) {
  .pr-scroll { padding: 4px 24px 0; }
  .pr-chips { margin: 0; padding: 4px 0 12px; flex-wrap: wrap; }
  .pr-detail .detail-body { padding: 8px 12px 40px; }
  .pr-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; max-width: 1040px; }
  .pr-card .section { margin: 0; }
}
