/* PGCO – product filters (templates/parts/product-filters.php)
 * One look everywhere: category sidebar, stabilizer / UPS landings, shop.
 * Mobile: bottom sheet with a sticky action bar. Desktop (≥992px): side drawer. */
:root {
  --pf-navy: #102653;
  --pf-red: #e52f3f;
  --pf-red-ink: #c92533;
  --pf-text: #1b2748;
  --pf-muted: #6b7a96;
  --pf-line: #e3e8f2;
  --pf-soft: #f4f6fb;
}

/* ---------- form ---------- */
.pf { display: flex; flex-direction: column; gap: 4px; font-family: "Vazirmatn", system-ui, sans-serif; color: var(--pf-text); }
.pf * { box-sizing: border-box; }
.pf-group { margin: 0; padding: 14px 0 16px; border: 0; border-bottom: 1px solid var(--pf-line); min-width: 0; }
.pf-group:first-of-type { padding-top: 4px; }
.pf-group__title {
  float: right; display: flex; align-items: center; gap: 8px; width: 100%; padding: 0; margin: 0 0 12px;
  font-size: 14px; font-weight: 800; color: var(--pf-navy);
}
.pf-group__title small { font-weight: 500; color: var(--pf-muted); font-size: 12px; }
.pf-group__badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: #fdecee; color: var(--pf-red-ink); font-size: 11.5px; font-weight: 800;
}

/* option chips */
.pf-options { clear: both; display: flex; flex-wrap: wrap; gap: 8px; }
.pf-chip {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px 7px 8px; border: 1px solid var(--pf-line); border-radius: 999px; background: #fff;
  font-size: 13px; font-weight: 600; color: var(--pf-text); cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.pf-chip input { position: absolute; opacity: 0; pointer-events: none; }
.pf-chip:hover { border-color: #c3cde0; box-shadow: 0 6px 14px -12px rgba(16, 38, 83, .5); }
.pf-chip:focus-within { outline: 2px solid var(--pf-navy); outline-offset: 2px; }
.pf-chip__count {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--pf-soft); color: var(--pf-muted); font-size: 11.5px; font-weight: 700;
  font-feature-settings: "tnum" 1;
}
.pf-chip.is-on { background: #edf2fc; border-color: #9fb2d6; color: var(--pf-navy); box-shadow: inset 0 0 0 1px #9fb2d6; }
.pf-chip.is-on .pf-chip__count { background: #fff; color: var(--pf-navy); }
.pf-chip.is-on::before {
  content: ""; width: 14px; height: 14px; flex: none; border-radius: 50%; background: var(--pf-navy)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.3l2.6 2.5L12 5.4' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.pf-chip.is-off { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* price */
.pf-price { clear: both; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pf-price__field {
  display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px;
  border: 1px solid var(--pf-line); border-radius: 12px; background: #fff;
}
.pf-price__field:focus-within { border-color: var(--pf-navy); box-shadow: 0 0 0 3px rgba(16, 38, 83, .08); }
.pf-price__field span { color: var(--pf-muted); font-size: 12.5px; flex: none; }
.pf-price__field input {
  width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; padding: 0;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--pf-text); direction: ltr; text-align: left;
}
.pf-price__field input::placeholder { color: #a9b3c6; font-weight: 500; }

/* actions */
.pf-actions { display: flex; align-items: center; gap: 10px; padding-top: 16px; }
.pf-apply {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px;
  border: 0; border-radius: 12px; background: var(--pf-red); color: #fff; font: inherit; font-size: 14.5px; font-weight: 800; cursor: pointer;
}
.pf-apply:hover { background: var(--pf-red-ink); }
.pf-reset { flex: none; padding: 0 6px; color: var(--pf-muted); font-size: 13px; font-weight: 700; text-decoration: none; }
.pf-reset:hover { color: var(--pf-red); }

/* active filter chips above the grid */
.pf-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.pf-active__chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: #eaf0fb; color: var(--pf-navy); font-size: 12.5px; font-weight: 700; text-decoration: none;
}
.pf-active__chip i { font-size: 11px; opacity: .7; }
.pf-active__chip:hover { background: #dbe5f7; }
.pf-active__clear { color: var(--pf-red); font-size: 12.5px; font-weight: 800; text-decoration: none; }

/* ---------- desktop sidebar on category pages ---------- */
@media (min-width: 992px) {
  .filters-desktop { padding: 20px 20px 18px !important; border-radius: 20px !important; top: 96px !important; box-shadow: 0 18px 40px -32px rgba(16, 38, 83, .45); }
  .filters-desktop .title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px !important; font-size: 17px !important; color: var(--pf-navy); }
  .filters-desktop .title::before { content: ""; width: 4px; height: 18px; border-radius: 99px; background: var(--pf-red); }
  .pg-shop:has(.filters-desktop) .filter-row .btn-filter { display: none !important; }   /* the sidebar is already on screen */
  .filters-desktop .pf-actions { padding-top: 14px; }
}

/* ---------- sheet (mobile) / drawer (desktop) ---------- */
.filter-modal { z-index: 10060 !important; background: rgba(10, 20, 45, .5) !important; backdrop-filter: blur(2px); }
.filter-modal .filter-sheet {
  display: flex; flex-direction: column; padding: 0 !important; background: #fff !important;
  border: 0 !important; border-radius: 22px 22px 0 0 !important; max-height: 88vh !important; overflow: hidden !important;
  box-shadow: 0 -20px 50px -20px rgba(10, 20, 45, .45);
}
.filter-modal .sheet-head {
  position: relative; flex: none; margin: 0 !important; padding: 22px 18px 12px; border-bottom: 1px solid var(--pf-line);
}
.filter-modal .sheet-head::before {
  content: ""; position: absolute; top: 8px; left: 50%; width: 42px; height: 4px; border-radius: 99px; background: #d6dce8; transform: translateX(-50%);
}
.filter-modal .sheet-title { font-size: 17px; font-weight: 900; color: var(--pf-navy); }
.filter-modal .btn-close { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--pf-line); background: var(--pf-soft); color: var(--pf-navy); cursor: pointer; }
.filter-modal .sheet-section { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 0; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }
.filter-modal .sheet-section > .pg-filter-content { flex: 1; display: flex; flex-direction: column; }
.filter-modal .pf { flex: 1; }
.filter-modal .pf-actions { margin-top: auto !important; }
.filter-modal .sheet-section > .sec-title { display: none; }
.filter-modal .pf-actions {
  position: sticky; bottom: 0; margin: 0 -18px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--pf-line); box-shadow: 0 -10px 24px -18px rgba(10, 20, 45, .35);
}

@media (min-width: 992px) {
  .filter-modal .filter-sheet {
    top: 0 !important; bottom: 0 !important; right: 0 !important; left: auto !important;
    width: 420px !important; max-width: 92vw !important; max-height: none !important; height: 100%;
    border-radius: 22px 0 0 22px !important; transform: translateX(105%) !important;
  }
  .filter-modal.active .filter-sheet { transform: translateX(0) !important; }
  .filter-modal .sheet-head { padding-top: 18px; }
  .filter-modal .sheet-head::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .filter-modal .filter-sheet, .pf-chip { transition: none !important; }
}

/* ---------- landing on the products after filtering (clear the sticky header) ---------- */
#stabilizer-products, #ups-products, #pf-results, #pg-grid { scroll-margin-top: 96px; }
.pf-anchor { height: 0; }
@media (min-width: 992px) { #stabilizer-products, #ups-products, #pf-results, #pg-grid { scroll-margin-top: 150px; } }

/* ---------- the "filters" button (landings + category pages) ---------- */
.btn-filter,
.stabilizer-products__filter,
.ups-products__filter {
  position: relative !important; display: inline-flex !important; align-items: center !important; justify-content: center; gap: 10px !important;
  min-width: 132px; height: 46px !important; min-height: 46px !important; padding: 0 18px !important;
  border: 1px solid #d5ddeb !important; border-radius: 14px !important; background: #fff !important; background-image: none !important;
  color: var(--pf-navy) !important; font: inherit; font-size: 14px !important; font-weight: 800 !important; cursor: pointer;
  box-shadow: 0 8px 20px -16px rgba(16, 38, 83, .55) !important; transform: none !important;
  transition: background .15s, border-color .15s, box-shadow .15s !important;
}
.btn-filter i,
.stabilizer-products__filter i,
.ups-products__filter i {
  display: inline !important; width: auto !important; height: auto !important; flex: none !important;
  background: none !important; border: 0 !important; box-shadow: none !important; color: var(--pf-navy) !important; font-size: 15px !important;
}
.btn-filter:hover, .btn-filter:focus-visible,
.stabilizer-products__filter:hover, .stabilizer-products__filter:focus-visible,
.ups-products__filter:hover, .ups-products__filter:focus-visible { background: var(--pf-soft) !important; border-color: #b9c6de !important; box-shadow: 0 10px 22px -16px rgba(16, 38, 83, .7) !important; }
.btn-filter:focus-visible { outline: 2px solid var(--pf-navy); outline-offset: 2px; }
.pf-btn-badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-inline-start: 2px;
  border-radius: 999px; background: #fdecee; color: var(--pf-red-ink); font-size: 12px; font-weight: 800; line-height: 1;
}

/* ---------- updating the grid in place (no page reload) ---------- */
#pg-grid { transition: opacity .2s ease; }
#pg-grid.pf-loading { opacity: .4; pointer-events: none; }
