/* ============================================================
   Stage 3.2 — Vitrina: cards, quick filters, product page, shop page.
   Loaded only when UI_V3_VITRINA is on (html.v3vit). Classes: v3c-
   (card), v3f- (filter bar), v3p- (product page extras).
   ============================================================ */
html.v3vit { --v3-good: #16A34A; --v3-mid: #D97706; --v3-low: #DC2626; --v3-top: 0px; }
html.v3vit.tg-mobile { --v3-top: calc(max(env(safe-area-inset-top, 0px), var(--s3-safe-top, 0px)) + var(--s3-content-top, 46px)); }
.v3-hidden { display: none !important; }

/* ---------------- card ---------------- */
html.v3vit .grid { gap: 10px; }
@media (min-width: 620px) { html.v3vit .grid { gap: 14px; } }
@media (min-width: 900px) { html.v3vit #grid.grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1180px) { html.v3vit #grid.grid { grid-template-columns: repeat(5, 1fr); } }
.v3c { background: var(--card); border: 1px solid var(--card-border); border-radius: 16px; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; min-width: 0; transition: transform .15s ease, box-shadow .15s ease; }
.v3c:active { transform: scale(.985); }
@media (hover: hover) { .v3c:hover { box-shadow: 0 6px 22px rgba(15,23,42,.08); } }
.v3c-photo { position: relative; aspect-ratio: 1 / 1; background: var(--chip); display: grid; place-items: center; overflow: hidden; }
.v3c-photo img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.v3c-ph { width: 30%; fill: none; stroke: var(--text-dim); stroke-width: 2; opacity: .55; }
.v3c-ph circle { fill: var(--text-dim); stroke: none; }
.v3c-soon { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text-dim); }
.v3c-badge { position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 999px; font: 700 11px/16px 'Manrope', sans-serif;
  background: var(--bg-elevated); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.v3c-badge.is-new { background: var(--accent); color: var(--btn-text); }
.v3c-badge.is-good { color: var(--v3-good); }
.v3c-badge.is-mid { color: var(--v3-mid); }
.v3c-badge.is-low { color: var(--v3-low); }
.v3c-heart { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--bg-elevated); color: var(--text-dim); display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.v3c-heart svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.v3c-heart.is-on { color: #E11D48; }
.v3c-heart.is-on svg { fill: currentColor; }
.v3c-body { padding: 10px 11px 11px; display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.v3c-title { font: 700 14px/18px 'Manrope', sans-serif; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.v3c-spec { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v3c-row { margin-top: auto; padding-top: 4px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.v3c-price { font: 800 16px/20px 'Manrope', sans-serif; color: var(--text); }
.v3c-meta { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- quick filter bar ---------------- */
.v3f { display: none; flex-direction: column; gap: 8px; max-width: 1180px; margin: 0 auto 12px; }
.v3f.is-open { display: flex; }
/* a little air between the header and the search box */
html.ui3 .search-bar { padding-top: 14px; }
.v3f-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 1px 20px; scroll-padding: 0 20px; }
@media (min-width: 900px) { .v3f-row { flex-wrap: wrap; overflow: visible; } }
.v3f-row::-webkit-scrollbar { display: none; }
.v3f-seg { display: inline-flex; flex: none; background: var(--chip); border-radius: 999px; padding: 3px; }
.v3f-seg button { border: 0; background: none; color: var(--text-dim); font: 700 13px 'Manrope', sans-serif; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.v3f-seg button.is-on { background: var(--bg-elevated); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.v3f-chip { flex: none; border: 1px solid var(--card-border); background: var(--card); color: var(--text); font: 600 13px 'Manrope', sans-serif;
  padding: 7px 13px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.v3f-chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--btn-text); }
html.v3vit .hero { display: none; }

/* ---------------- product page: full page ---------------- */
html.v3vit #overlay, html.v3vit #shopOverlay { background: var(--bg); backdrop-filter: none; padding: 0; align-items: stretch; justify-content: center; }
html.v3vit #overlay > .modal, html.v3vit #shopOverlay > .modal { max-width: 1240px; width: 100%; height: 100%; max-height: none; border-radius: 0;
  background: var(--bg); box-shadow: none; animation: v3in .2s ease; }
@keyframes v3in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* back button: a chevron on the left, under Telegram's band on phones */
html.v3vit #overlay .modal-close, html.v3vit #shopCloseBtn { position: fixed; top: calc(10px + var(--v3-top)); left: 12px; right: auto; width: 38px; height: 38px;
  font-size: 0; background: var(--bg-elevated); box-shadow: 0 1px 6px rgba(0,0,0,.14); z-index: 20; }
html.v3vit #overlay .modal-close::before, html.v3vit #shopCloseBtn::before { content: ''; width: 10px; height: 10px; border-left: 2.4px solid var(--text);
  border-bottom: 2.4px solid var(--text); transform: translateX(2px) rotate(45deg); }
/* Telegram's own Back button already closes the page there */
html.v3vit.tg-mobile #overlay .modal-close, html.v3vit.tg-mobile #shopCloseBtn { display: none; }

html.v3vit #overlay .carousel-wrapper { margin: 0; padding-top: var(--v3-top); background: var(--chip); }
html.v3vit #overlay .modal-carousel img { max-height: none; aspect-ratio: 1 / 1; object-fit: contain; padding: 0; }
/* no-photo placeholder on the product page, same look as the list card (.v3c-photo) */
.v3p-ph { position: relative; flex: 0 0 100%; width: 100%; aspect-ratio: 1 / 1; max-height: 300px; display: grid; place-items: center; scroll-snap-align: center; background: var(--chip); }
html.v3vit #overlay .v3p-ph { max-height: none; }
.v3p-ph .v3c-ph { width: min(30%, 150px); }
.v3p-ph .v3c-soon { bottom: 16px; font-size: 13px; }
html.v3vit #overlay .carousel-dots { position: absolute; bottom: 10px; left: 0; right: 0; margin: 0; }
html.v3vit #overlay .modal-body { padding: 16px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
html.v3vit .modal-title { font: 800 21px/26px 'Manrope', sans-serif; margin: 0; }
.v3p-sub { color: var(--text-dim); font-size: 13px; margin: 3px 0 0; }
html.v3vit .modal-head-row { align-items: flex-start; }
html.v3vit .modal-price { color: var(--text); font: 800 26px/32px 'Manrope', sans-serif; margin: 10px 0 2px; }
html.v3vit .modal-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--text-dim); font-size: 12px; margin-bottom: 14px; }
.v3p-bat { background: var(--card); border: 1px solid var(--card-border); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.v3p-bat-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.v3p-bat-top b { font: 800 15px 'Manrope', sans-serif; }
.v3p-bat-bar { height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.v3p-bat-bar i { display: block; height: 100%; border-radius: 99px; }
.v3p-bat.is-good b { color: var(--v3-good); } .v3p-bat.is-good i { background: var(--v3-good); }
.v3p-bat.is-mid b { color: var(--v3-mid); } .v3p-bat.is-mid i { background: var(--v3-mid); }
.v3p-bat.is-low b { color: var(--v3-low); } .v3p-bat.is-low i { background: var(--v3-low); }
html.v3vit .spec-item { border-radius: 14px; }
.v3p-sim { margin: 0 0 18px; }
.v3p-sim:empty { display: none; }
.v3p-sim-h { font: 800 15px 'Manrope', sans-serif; margin-bottom: 8px; }
.v3p-sim-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.v3p-sim-row::-webkit-scrollbar { display: none; }
.v3p-sim-row button { flex: none; text-align: left; border: 1px solid var(--card-border); background: var(--card); color: var(--text); border-radius: 12px;
  padding: 9px 12px; cursor: pointer; font-family: 'Manrope', sans-serif; display: flex; flex-direction: column; gap: 2px; min-width: 112px; }
.v3p-sim-row b { font-size: 13px; }
.v3p-sim-row span { font-size: 12px; color: var(--text-dim); }
/* bottom CTA bar */
html.v3vit #overlay .modal-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; flex-direction: row-reverse; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px));
  background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--card-border); }
html.v3vit #overlay .modal-actions .btn { flex: 1; margin: 0; min-height: 48px; border-radius: 14px; font: 700 15px 'Manrope', sans-serif; }
html.v3vit #overlay .btn-call { flex: 0 0 auto; padding: 0 16px; }

@media (min-width: 900px) {
  html.v3vit #overlay, html.v3vit #shopOverlay { top: var(--s3-head-h, 69px); }
  html.v3vit #overlay > .modal { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 32px; padding: 28px 24px 40px; align-content: start; }
  html.v3vit #overlay .carousel-wrapper { border-radius: 20px; overflow: hidden; position: sticky; top: 0; align-self: start; }
  html.v3vit #overlay .modal-body { padding: 0; }
  html.v3vit #overlay .modal-close { position: absolute; top: 36px; left: 36px; }
  html.v3vit #shopCloseBtn { position: absolute; top: 16px; left: auto; right: 16px; }
  html.v3vit #overlay .modal-actions { position: static; background: none; backdrop-filter: none; border: 0; padding: 0; margin-top: 4px; }
  html.v3vit .modal-title { font-size: 26px; line-height: 32px; }
  html.v3vit .modal-price { font-size: 30px; line-height: 36px; }
}

/* ---------------- shop page ---------------- */
html.v3vit #shopOverlay > .modal { max-width: 1000px; }
html.v3vit #shopModalBody { padding: 0 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
html.v3vit .shop-header { position: relative; padding: calc(64px + var(--v3-top)) 0 4px; text-align: left; display: grid; grid-template-columns: auto 1fr; grid-template-rows: 38px auto; column-gap: 14px; align-items: center; }
html.v3vit .shop-header::before { content: ''; position: absolute; left: -16px; right: -16px; top: 0; height: calc(102px + var(--v3-top));
  background: linear-gradient(135deg, var(--accent), var(--accent-dim)); z-index: 0; }
html.v3vit .shop-header > * { position: relative; z-index: 1; }
html.v3vit .shop-logo, html.v3vit .shop-logo-fallback { width: 76px; height: 76px; border-radius: 20px; border: 3px solid var(--bg); margin: 0; grid-row: span 2; object-fit: cover; }
html.v3vit .shop-name { font: 800 21px/26px 'Manrope', sans-serif; margin: 0; grid-column: 2; grid-row: 2; align-self: start; padding-top: 6px; }
html.v3vit .shop-desc { grid-column: 1 / -1; margin-top: 10px; color: var(--text-dim); font-size: 14px; }
html.v3vit .shop-stats-row { justify-content: flex-start; gap: 10px; margin: 14px 0 10px; }
html.v3vit .shop-stat { background: var(--card); border: 1px solid var(--card-border); border-radius: 14px; padding: 10px 16px; }
html.v3vit #shopListingsGrid.grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 620px) { html.v3vit #shopListingsGrid.grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) {
  html.v3vit #shopListingsGrid.grid { grid-template-columns: repeat(4, 1fr); }
  html.v3vit .shop-header::before { left: 0; right: 0; border-radius: 0 0 20px 20px; }
  html.v3vit .shop-header { padding-left: 20px; }
}
html.v3vit #shopListingsGrid .card { border-radius: 16px; }
html.v3vit #shopListingsGrid .card-photo { padding: 0; background: var(--chip); }
html.v3vit #shopListingsGrid .card-photo img { object-fit: cover; border-radius: 0; }

/* ---- "Yana yuklash" (replaces the page numbers) ---- */
html.v3vit #pagination.pagination { margin: 18px auto 34px; padding: 0 16px; }
.v3-more { width: 100%; max-width: 420px; height: 52px; border-radius: 16px; border: 1px solid var(--card-border); background: var(--card); color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 10px; font: 800 15px 'Manrope', sans-serif; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.v3-more small { font-size: 12.5px; font-weight: 700; color: var(--text-dim); }
.v3-more:active { transform: scale(.98); }
.v3-more:disabled { opacity: .7; cursor: default; }
@media (hover: hover) { .v3-more:hover { border-color: var(--accent); color: var(--accent); } }

/* ---- Stage 6: pinned listings ("Tavsiya") — option A: accent pill + accent border ---- */
.v3c.is-pin { border: 2px solid var(--accent); box-shadow: 0 6px 18px rgba(var(--accent-rgb), .18); }
.v3c-pin { position: absolute; left: 8px; bottom: 8px; z-index: 2; height: 24px; padding: 0 9px 0 7px; border-radius: 999px; background: var(--accent); color: var(--btn-text);
  display: inline-flex; align-items: center; gap: 4px; font: 800 11.5px/1 'Manrope', sans-serif; box-shadow: 0 2px 6px rgba(var(--accent-rgb), .35); pointer-events: none; }
.v3c-pin svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* product page — staff only */
.v3-pinbox { margin: 10px 0 2px; }
.v3-pinbox svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.v3-pin-add { width: 100%; height: 44px; border-radius: 12px; border: 1.5px dashed var(--accent); background: transparent; color: var(--accent);
  display: flex; align-items: center; justify-content: center; gap: 6px; font: 800 14px 'Manrope', sans-serif; cursor: pointer; }
.v3-pin-on { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(var(--accent-rgb), .1); border: 1px solid rgba(var(--accent-rgb), .3); }
.v3-pin-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--btn-text); display: grid; place-items: center; flex: none; }
.v3-pin-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.v3-pin-t b { font: 800 14px 'Manrope', sans-serif; color: var(--text); }
.v3-pin-t small { font-size: 12px; color: var(--text-dim); }
.v3-pin-off { height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(220,38,38,.35); background: rgba(220,38,38,.08); color: #DC2626;
  font: 800 13px 'Manrope', sans-serif; cursor: pointer; flex: none; }
.v3-pin-off:disabled, .v3-pinsheet-go:disabled { opacity: .6; }

.v3-pinsheet { position: fixed; inset: 0; z-index: 3000; }
.v3-pinsheet-bg { position: absolute; inset: 0; background: rgba(15,23,42,.45); opacity: 0; transition: opacity .2s; }
.v3-pinsheet-card { position: absolute; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto; background: var(--card); color: var(--text); border-radius: 22px 22px 0 0;
  padding: 12px 18px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 30px rgba(15,23,42,.18); transform: translateY(100%); transition: transform .22s cubic-bezier(.2,.8,.3,1); }
.v3-pinsheet.is-open .v3-pinsheet-bg { opacity: 1; }
.v3-pinsheet.is-open .v3-pinsheet-card { transform: none; }
.v3-pinsheet-grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--card-border); margin: 0 auto 14px; }
.v3-pinsheet-h { display: flex; align-items: center; gap: 8px; font: 800 18px 'Manrope', sans-serif; }
.v3-pinsheet-h svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.v3-pinsheet-card p { font-size: 13px; color: var(--text-dim); margin: 6px 0 14px; line-height: 1.45; }
.v3-pinsheet-l { font: 800 12px 'Manrope', sans-serif; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 8px; }
.v3-pinsheet-days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.v3-pinsheet-days button { height: 44px; border-radius: 12px; border: 1px solid var(--card-border); background: var(--card); color: var(--text); font: 800 14px 'Manrope', sans-serif; cursor: pointer; }
.v3-pinsheet-days button.is-on { border: 2px solid var(--accent); background: rgba(var(--accent-rgb), .1); color: var(--accent); }
.v3-pinsheet-go { width: 100%; margin-top: 14px; height: 50px; border: 0; border-radius: 14px; background: var(--accent); color: var(--btn-text); font: 800 15px 'Manrope', sans-serif; cursor: pointer; }
.v3-pinsheet-card small { display: block; margin-top: 10px; text-align: center; font-size: 12px; color: var(--text-dim); }
@media (min-width: 900px) { .v3-pinsheet-card { bottom: 50%; transform: translateY(50%) scale(.96); opacity: 0; border-radius: 22px; transition: transform .2s, opacity .2s; }
  .v3-pinsheet.is-open .v3-pinsheet-card { transform: translateY(50%); opacity: 1; } }
