/* ─────────────────────────────────────────────────────────────────────────────
   catalog_v2.css — JIT Order Platform v49
   MTM + RTW Catalog page card redesign. Scope: .catalog-page-v49
   Same visual card language as .factories-page-v49 (factories_v2.css).
   RTW swatches + badges are in the page inline <style> (product_catalog.html).
   Zero important overrides. No CDN. No brand color.
   ───────────────────────────────────────────────────────────────────────────── */

.catalog-page-v49 {
  --cv-panel:   var(--panel, #fff);
  --cv-sec:     var(--section-bg, #faf9f6);
  --cv-line:    var(--line, #e9e7e0);
  --cv-text:    var(--text, #1a1a1a);
  --cv-muted:   var(--muted, #7c7a73);
}

/* ── Legacy reset (same problem as factories: global legacy_overrides.css
   imposes fixed 320px heights on .jit-product-* classes) ────────────────── */
.catalog-page-v49 .jit-product-card,
.catalog-page-v49 .jit-product-media,
.catalog-page-v49 .main-photo-wrap,
.catalog-page-v49 .jit-product-main-photo,
.catalog-page-v49 .main-photo,
.catalog-page-v49 .jit-product-thumb,
.catalog-page-v49 .sub-photo {
  height: auto;
  min-height: 0;
  max-height: none;
  border-radius: 0;
}

/* ── Grid ──────────────────────────────────────────────────────────────────── */
.catalog-page-v49 .products-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 20px;
  row-gap: 25px;
}

/* ── Product card ──────────────────────────────────────────────────────────── */
.catalog-page-v49 .product-card {
  background: var(--cv-panel);
  border: 1px solid var(--cv-line);
  border-radius: 12px;
  overflow: visible;       /* allows desc-tooltip to float above neighbours */
  position: relative;
  cursor: pointer;
  /* v3.8.67: transform добавлен, чтобы подъём .jit-product-card:hover был плавным
     (иначе этот transition перекрывал theme_v2 и анимация transform пропадала). */
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.16s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  width: auto;
  max-width: none;
  padding: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.catalog-page-v49 .product-card:hover {
  border-color: var(--cv-muted);
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  z-index: 2;              /* lift above siblings so tooltip isn't clipped */
}
.catalog-page-v49 .product-card.inactive-card { opacity: 0.5; }

/* ── Main photo — inset (6px), 3:4 portrait ───────────────────────────────── */
.catalog-page-v49 .main-photo-wrap {
  padding: 6px 6px 0;
  display: block;
  grid-template-rows: none;
  gap: 0;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
}
.catalog-page-v49 .main-photo {
  position: relative;
  width: 100%;
  padding-top: 133%;
  overflow: hidden;
  border-radius: 8px;
  background: var(--cv-sec);
  height: auto;
  min-height: 0;
  max-height: none;
  display: block;
}
.catalog-page-v49 .main-photo img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.catalog-page-v49 .main-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--cv-muted);
}
.catalog-page-v49 .main-photo-empty span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Additional photos — 4-col square grid (product angles) ───────────────── */
.catalog-page-v49 .sub-photos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  padding: 6px;
  width: 100%;
  box-sizing: border-box;
}
.catalog-page-v49 .sub-photo {
  position: relative;
  overflow: hidden;
  background: var(--cv-sec);
  border-radius: 8px;
  border: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
  display: block;
  width: 100%;
  min-height: 0;
  max-height: none;
}
.catalog-page-v49 .sub-photo::before {
  content: '';
  display: block;
  padding-top: 100%;
}
.catalog-page-v49 .sub-photo.active { box-shadow: inset 0 0 0 2px var(--cv-text); }
.catalog-page-v49 .sub-photo img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Product info ──────────────────────────────────────────────────────────── */
/* fix: the card inherits align-items:center (from legacy .jit-product-card), which
   shrank .product-info/.product-footer to content width and centered them — pushing
   the text to the right. Stretch them so the text sits flush on the left. */
.catalog-page-v49 .product-card { align-items: stretch; }
.catalog-page-v49 .product-info {
  padding: 4px 10px 0 6px;   /* left 6px → aligned with the photo's left edge */
  flex: 1;
  text-align: left;
}
.catalog-page-v49 .product-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--cv-text);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.catalog-page-v49 .product-cat {
  font-size: 10px;
  color: var(--cv-muted);
  margin-bottom: 3px;
}
.catalog-page-v49 .product-price {
  font-size: 12px;
  font-weight: 500;
  color: var(--cv-text);
}

/* ── Floating tooltip for description AND composition ─────────────────────── */
.catalog-page-v49 .product-desc-wrap {
  position: relative;
  display: inline-block;
  margin-top: 2px;
}
.catalog-page-v49 .product-desc-link {
  font-size: 10px;
  color: var(--cv-muted);
  cursor: pointer;
  border-bottom: 1px dashed var(--cv-line);
  display: inline-block;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  padding: 0;
  text-decoration: none;
}
.catalog-page-v49 .product-desc-link:hover { color: var(--cv-text); }
.catalog-page-v49 .desc-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  width: 220px;
  background: var(--cv-panel);
  border: 1px solid var(--cv-line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--cv-text);
  line-height: 1.5;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.catalog-page-v49 .product-desc-wrap:hover .desc-tooltip { display: block; }

/* ── Footer ────────────────────────────────────────────────────────────────── */
.catalog-page-v49 .product-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  margin-top: 6px;
  border-top: 1px solid var(--cv-line);
}
.catalog-page-v49 .btn-order {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 8px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  text-transform: none;
  transition: background 0.12s;
  display: inline-block;
}
.catalog-page-v49 .btn-order:hover { background: #333; color: #fff; }
.catalog-page-v49 .act-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--cv-line);
  border-radius: 8px; /* v3.8.49: канон иконочной кнопки 28/r8 */
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--cv-muted);
  font-size: 12px;
  flex-shrink: 0;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.catalog-page-v49 .act-btn:hover { background: var(--cv-sec); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .catalog-page-v49 .products-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .catalog-page-v49 .products-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .catalog-page-v49 .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── RTW interactive card: color → size → stock → quantity (catalog_rtw.js) ──
   Maps the spec's --color-* tokens to this file's theme aliases (--cv-*). */
.product-card .rtw-buy { margin-top: 4px; }
.product-card .rtw-row-label {
  font-size: 9px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase;
  color: var(--cv-muted); margin: 6px 0 5px; display: flex; align-items: center; gap: 4px;
}
.product-card .rtw-color-name {
  font-size: 10px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--cv-text);
}
.product-card .rtw-colors { display: flex; gap: 5px; flex-wrap: wrap; }
.product-card .rtw-swatch2 {
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 1.5px solid transparent; flex-shrink: 0; transition: border-color .15s;
}
.product-card .rtw-swatch2:not(.out):hover { border-color: var(--cv-muted); }
.product-card .rtw-swatch2.active { border-color: #1a1a1a; box-shadow: 0 0 0 2px #fff inset; }
.product-card .rtw-swatch2.out { opacity: .3; cursor: not-allowed; }

.product-card .rtw-sizes { display: flex; gap: 4px; flex-wrap: wrap; }
.product-card .rtw-size-btn {
  padding: 3px 8px; border: 0.5px solid var(--cv-line); border-radius: 8px;
  font-size: 10px; font-weight: 500; color: var(--cv-muted);
  background: var(--cv-panel); cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.product-card .rtw-size-btn:not(.out):not(.active):not(:disabled):hover {
  border-color: var(--cv-muted); background: var(--cv-sec);
}
.product-card .rtw-size-btn.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.product-card .rtw-size-btn.out { opacity: .35; cursor: not-allowed; text-decoration: line-through; }

/* ── v3.7 compact RTW layout: desc/comp in name row (tooltip down) ── */
.product-card .name-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 1px;
}
.product-card .desc-links { display: flex; gap: 8px; flex-shrink: 0; margin-top: 1px; }
.product-card .desc-wrap { position: relative; }
.product-card .desc-link {
  font-size: 10px; color: var(--cv-muted); cursor: pointer;
  border-bottom: 0.5px dashed var(--cv-line); white-space: nowrap; display: inline-block;
}
/* opens DOWN; right:0 so it doesn't run off the card's right edge. Inherits the rest
   (display:none, bg, border, padding, font…) from the base .desc-tooltip rule. */
.product-card .desc-tooltip--down {
  top: calc(100% + 6px); bottom: auto; right: 0; left: auto;
  width: 200px; box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.product-card .desc-wrap:hover .desc-tooltip--down { display: block; }

/* ── Stock pill badge in the price row ── */
.product-card .price-stock-row {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.product-card .stock-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px;
  border-radius: 100px; font-size: 10px; font-weight: 500; white-space: nowrap;
}
.product-card .stock-badge--idle { background: var(--cv-sec); color: var(--cv-muted); border: 0.5px solid var(--cv-line); }
.product-card .stock-badge--in  { background: #FAFAFA; color: #3b6d11; border: 0.5px solid #c8e6b0; }
.product-card .stock-badge--low { background: #FFFFFF; color: #ba7517; border: 0.5px solid #f0d9a0; }
.product-card .stock-badge--out { background: #fdf0f0; color: #CC2200; border: 0.5px solid #f0c0c0; }
.product-card .stock-badge .stock-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ── Quantity stepper (shown only after color + size) ── */
.product-card .qty-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.product-card .qty-label { font-size: 9px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; color: var(--cv-muted); }
.product-card .qty-ctrl { display: flex; align-items: center; border: 0.5px solid var(--cv-line); border-radius: 8px; overflow: hidden; }
.product-card .qty-btn {
  width: 24px; height: 24px; border: none; background: transparent; font-size: 14px; cursor: pointer;
  color: var(--cv-text); display: flex; align-items: center; justify-content: center; line-height: 1;
}
.product-card .qty-btn:hover { background: var(--cv-sec); }
.product-card .qty-val {
  width: 32px; text-align: center; font-size: 12px; font-weight: 500; color: var(--cv-text);
  border: none; border-left: 0.5px solid var(--cv-line); border-right: 0.5px solid var(--cv-line);
  background: var(--cv-panel); height: 24px; padding: 0;
}
.product-card .qty-val::-webkit-inner-spin-button,
.product-card .qty-val::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.product-card .rtw-order-btn:disabled { background: #E8E8E8; color: #fff; cursor: not-allowed; }

/* v3.7: bidirectional dimming — the other axis fades options it can't combine with;
   '.dim' stays clickable (switching the selection), '.out' is globally empty/disabled. */
.product-card .rtw-swatch2.dim { opacity: .3; }
.product-card .rtw-size-btn.dim { opacity: .45; text-decoration: none; cursor: pointer; }
/* compact quantity stepper (smaller number, lower height) */
.product-card .qty-btn { width: 20px; height: 20px; font-size: 12px; }
.product-card .qty-val { width: 28px; height: 20px; font-size: 11px; }
