/* فرم جستجو و فیلتر صفحه‌ی محصولات */
.pf {
  display: grid;
  gap: 14px;
  margin: 8px 0 18px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
}

/* جستجو: آیکون ابتدای خط، دکمه‌ی «جستجو» انتهای خط */
.pf-search {
  position: relative;
  display: flex;
  align-items: center;
}

.pf-search-icon {
  position: absolute;
  inset-inline-start: 16px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  pointer-events: none;
}

.pf-search-input {
  width: 100%;
  height: 50px;
  padding-inline: 46px 104px;
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.pf-search-input::placeholder {
  color: var(--text-muted);
}

.pf-search-input:focus {
  outline: none;
  background: var(--bg-card);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

/* ضربدر پیش‌فرض مرورگر برای input[type=search] */
.pf-search-input::-webkit-search-cancel-button {
  margin-inline-end: 4px;
  cursor: pointer;
}

.pf-search-btn {
  position: absolute;
  inset-inline-end: 6px;
  height: 38px;
  padding: 0 18px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.pf-search-btn:hover {
  background: var(--accent-dim);
}

.pf-search-btn:active {
  transform: scale(0.97);
}

/* ردیف فیلترها: سه ستون روی دسکتاپ، دو ستون روی موبایل (مرتب‌سازی تمام‌عرض) */
.pf-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.pf-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.pf-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.pf-select {
  width: 100%;
  height: 46px;
  padding-block: 0;
  padding-inline: 14px 40px;
  font: inherit;
  color: var(--text-primary);
  background-color: var(--bg-input);
  /* فلش سفارشی سمت انتهای خط (چپ در راست‌به‌چپ) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

[dir="ltr"] .pf-select {
  background-position: right 14px center;
}

.pf-select:hover {
  border-color: color-mix(in oklch, var(--text-primary) 25%, var(--border));
}

.pf-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

@media (max-width: 620px) {
  .pf {
    padding: 12px;
  }
  .pf-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pf-field:last-child {
    grid-column: 1 / -1;
  }
  .pf-search-btn {
    padding: 0 14px;
  }
  .pf-search-input {
    padding-inline: 44px 88px;
  }
}

/* تعداد نتایج + فیلترهای فعال */
.pf-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 16px;
}

.pf-meta .result-count {
  margin: 0;
  font-weight: 600;
}

.pf-active {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pf-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 12px;
  font-size: 0.8125rem;
  color: var(--accent);
  background: color-mix(in oklch, var(--accent) 10%, transparent);
  border-radius: 99px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.pf-tag:hover {
  background: color-mix(in oklch, var(--accent) 18%, transparent);
}

.pf-tag > span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--accent) 14%, transparent);
}

.pf-clear {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pf-clear:hover {
  color: var(--text-primary);
}

/* صفحه‌بندی */
.pager {
  align-items: center;
}

.pager a {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  text-decoration: none;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pager a:hover {
  background: var(--bg-input);
}

.pager a[aria-current="page"] {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
}

.pager .pager-nav {
  padding: 0 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ==========================================================================
   سوییچ نمای شبکه / لیست (Liquid Glass segmented control)
   ========================================================================== */
.view-switch {
  display: inline-flex;
  gap: 2px;
  margin-inline-start: auto;
  padding: 3px;
  border: 1px solid var(--lg-border);
  border-radius: 999px;
  background: var(--lg-fill);
}

.view-switch a {
  display: grid;
  place-items: center;
  width: 38px;
  height: 32px;
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background-color 0.25s var(--lg-spring), color 0.25s var(--lg-spring), box-shadow 0.25s var(--lg-spring);
}

.view-switch a:hover { color: var(--text-primary); }
.view-switch a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.view-switch a.on {
  color: var(--accent);
  background: var(--lg-lens-bg);
  box-shadow: var(--lg-lens-shadow);
}

/* نمای لیستی: هر محصول یک ردیف؛ آیکون و عنوان کنار هم، قیمت و دکمه‌ها در انتها */
html body .grid-products.list-view { grid-template-columns: 1fr !important; gap: 10px; max-width: none; }

html body .grid-products.list-view .product-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "top foot" "badges foot" "desc foot";
  align-items: center;
  column-gap: 24px;
  row-gap: 6px;
  padding: 14px 18px;
  height: 100%;
}

html body .grid-products.list-view .pc-top { grid-area: top; }
html body .grid-products.list-view .badges { grid-area: badges; margin: 0; }
html body .grid-products.list-view .pc-desc { grid-area: desc; margin: 0; -webkit-line-clamp: 1; line-clamp: 1; }
html body .grid-products.list-view .pc-foot {
  grid-area: foot;
  display: grid;
  justify-items: end;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}
html body .grid-products.list-view .pc-icon { width: 64px; height: 64px; }
html body .grid-products.list-view .pc-icon svg { width: 34px; height: 34px; }

@media (max-width: 620px) {
  html body .grid-products.list-view .product-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "top" "foot";
    padding: 12px 14px;
  }
  html body .grid-products.list-view .badges,
  html body .grid-products.list-view .pc-desc { display: none; }
  html body .grid-products.list-view .pc-foot { grid-auto-flow: column; justify-content: space-between; align-items: center; justify-items: stretch; }
}

@media (prefers-reduced-motion: reduce) { .view-switch a { transition: none; } }
