/* جستجوی هوشمند — صفحه محصولات */

.products-search-wrap {
  position: relative;
  max-width: 520px;
  margin: 0 auto 12px;
  z-index: 50;
}

.products-search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  min-height: 48px;
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line, #dfe8e2);
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(26, 31, 28, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.products-search-wrap.is-open .products-search-field,
.products-search-field:focus-within {
  border-color: var(--brand, #81B061);
  box-shadow: 0 6px 22px rgba(129, 176, 97, 0.12);
}

.products-search-icon {
  flex-shrink: 0;
  color: var(--brand, #81B061);
  display: flex;
}

.products-search-input {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text, #1a1f1c);
  min-width: 0;
}

.products-search-input::placeholder {
  color: var(--text-muted, #5c6560);
  opacity: 0.85;
}

.products-search-input:focus {
  outline: none;
}

/* فقط دکمهٔ سفارشی — ضربدر پیش‌فرض مرورگر روی type=search */
.products-search-input::-webkit-search-cancel-button,
.products-search-input::-webkit-search-decoration,
.products-search-input::-webkit-search-results-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.products-search-input::-ms-clear {
  display: none;
  width: 0;
  height: 0;
}

.products-search-clear {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-alt, #f0f4f1);
  color: var(--text-muted, #5c6560);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.products-search-clear:hover {
  background: var(--line, #dfe8e2);
  color: var(--text, #1a1f1c);
}

.products-search-suggest {
  left: 0;
  right: 0;
  min-width: 100%;
}

.products-search-hint {
  font-size: 0.8rem;
  color: var(--text-muted, #5c6560);
  margin: 0 0 6px;
}

.products-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line, #dfe8e2);
}

.products-toolbar-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #5c6560);
  flex: 0 0 auto;
}

.products-sort {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.products-sort-pill {
  display: inline-block;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #5c6560);
  text-decoration: none;
  background: var(--bg-alt, #f4f7f5);
  border: 1px solid var(--line, #dfe8e2);
  border-radius: 999px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.products-sort-pill:hover {
  border-color: var(--brand, #81B061);
  color: var(--brand, #81B061);
}

.products-sort-pill.active {
  background: var(--brand);
  border-color: var(--brand, #81B061);
  color: #fff;
}

.products-sort-pill.active[href*="sort=deli"] {
  background: var(--brand);
  border-color: #719552;
}

.products-filter-chips {
  display: none;
}

.product-card-rating {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--brand, #81B061);
}

.product-card-rating small {
  font-weight: 500;
  color: var(--text-muted, #5c6560);
}

.pdp-rating--store .pdp-rating-count a {
  color: var(--brand, #81B061);
  font-weight: 600;
  text-decoration: none;
}

/* هدر فشرده — فاصله کم تا گرید */
.products-page .products-header.products-header--compact {
  margin-bottom: 12px;
}

.products-header--compact .products-tagline {
  margin-bottom: 10px;
}

.products-category-seo {
  margin: 10px 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-soft, #f4f7f5);
  border: 1px solid var(--border-subtle, #e2ebe6);
  text-align: right;
}

.products-category-seo__title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 700;
}

.products-category-seo__body {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-muted, #4a5c52);
}

.products-category-seo__body a {
  color: var(--brand-green, #2d8a5c);
  font-weight: 600;
}

.products-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 20px 24px;
  align-items: start;
}

.products-layout-main {
  min-width: 0;
}

.products-sidebar {
  position: sticky;
  top: calc(var(--header-h, 88px) + 12px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.products-sidebar-card {
  padding: 14px 16px;
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line, #dfe8e2);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(26, 31, 28, 0.04);
}

.products-sidebar-icon {
  display: inline-flex;
  color: var(--brand, #81B061);
  margin-bottom: 6px;
}

.products-sidebar-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text, #1a1f1c);
}

.products-sidebar-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--text-muted, #5c6560);
}

.products-sidebar-link--solo {
  margin: 0;
}

.products-sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text, #1a1f1c);
  text-decoration: none;
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line, #dfe8e2);
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s;
}

.products-sidebar-link:hover {
  border-color: var(--brand, #81B061);
  background: rgba(129, 176, 97, 0.05);
  color: var(--brand, #81B061);
}

.products-sidebar-deli {
  padding: 4px 0 0;
}

.products-sidebar-deli .deli--compact {
  max-width: 100%;
}

.products-grid-empty {
  grid-column: 1 / -1;
}

.products-chef-picks-title {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.products-chef-picks-lead {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--text-muted, #5c6560);
}

.products-chef-picks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.products-chef-pick-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(129, 176, 97, 0.08), rgba(129, 176, 97, 0.02));
  border: 1px solid rgba(129, 176, 97, 0.2);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.products-chef-pick-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(129, 176, 97, 0.12);
}

.products-chef-pick-name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
}

.products-chef-pick-price {
  font-size: 0.82rem;
  color: var(--brand, #81B061);
  font-weight: 700;
}

.product-card-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 4px 0 0;
}

.product-card-meta {
  font-size: 0.68rem;
  color: var(--text-muted, #5c6560);
  line-height: 1.35;
  direction: rtl;
  unicode-bidi: isolate;
}

.product-card-badge {
  font-size: 0.64rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(129, 176, 97, 0.12);
  color: var(--brand, #81B061);
}

.product-card-badge--organic {
  background: rgba(76, 140, 74, 0.15);
}

/* کارت محصول — گرید فروشگاه و سایر صفحات لیست */
:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line, #dfe8e2);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card:hover {
  border-color: color-mix(in srgb, var(--brand, #81B061) 38%, var(--line, #dfe8e2));
  box-shadow: 0 10px 26px rgba(26, 31, 28, 0.08);
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-link {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  text-decoration: none;
  color: inherit;
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-img {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: linear-gradient(145deg, #f4f9f5 0%, #eef4ef 100%);
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card:hover .product-card-img img {
  transform: scale(1.04);
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-body {
  padding: 11px 12px 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-title {
  font-size: clamp(0.8rem, 2.4vw, 0.92rem);
  font-weight: 700;
  line-height: 1.45;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text, #1a1f1c);
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-excerpt {
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--text-muted, #5c6560);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 12px;
  margin-top: auto;
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-foot-link {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-price {
  display: block;
  font-size: clamp(0.78rem, 2.3vw, 0.9rem);
  font-weight: 800;
  color: var(--brand, #81B061);
  line-height: 1.3;
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-cta {
  display: block;
  margin-top: 1px;
  font-size: 0.65rem;
  color: var(--text-muted, #5c6560);
  transition: color 0.2s ease;
}

:is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card:hover .product-card-cta {
  color: var(--brand, #81B061);
}

.product-card-add {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brand, #81B061);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(129, 176, 97, 0.32);
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.product-card-add-icon {
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1;
  margin-top: -1px;
}

.product-card-add:hover {
  background: var(--brand-hover, #719552);
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(129, 176, 97, 0.38);
}

.product-card-add:active {
  transform: scale(0.95);
}

.product-card-img.cart-add-pulse img {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .product-card-add:hover,
  .product-card-add:active {
    transform: none;
  }

  :is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card:hover .product-card-img img {
    transform: none;
  }
}

.product-card--out {
  opacity: 0.92;
}

.product-card--out .product-card-title {
  color: #5c6560;
}

.badge-out {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  z-index: 2;
  background: rgba(185, 28, 28, 0.92);
  color: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.products-grid.is-search-loading {
  opacity: 0.72;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.products-grid-loader {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 28px 0 8px;
}

/* اسکرول بی‌نهایت — صفحه‌بندی سئو برای کراولر؛ با JS اسکرول سریع */
html.js-products-scroll .products-page .seo-pagination {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* اسکرول بی‌نهایت — اسپینر نرم */
.products-page .load-more-trigger {
  grid-column: 1 / -1;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0 24px;
}

.products-page .load-more-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--line, #dfe8e2);
  border-top-color: var(--brand, #81B061);
  border-radius: 50%;
  animation: products-spin 0.75s cubic-bezier(0.45, 0.05, 0.35, 0.95) infinite;
  opacity: 0.35;
  transition: opacity 0.25s ease;
}

.products-page .load-more-trigger.loading .load-more-spinner {
  opacity: 1;
}

@keyframes products-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 960px) {
  .products-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .products-layout-main {
    order: 1;
  }

  .products-sidebar {
    position: static;
    order: 2;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
  }

  .products-sidebar-deli {
    grid-column: 1 / -1;
  }

  .products-sidebar-link--solo {
    grid-column: span 1;
  }
}

/* دسکتاپ — فیلتر همیشه باز، بدون دکمه جمع‌شونده */
@media (min-width: 769px) {
  .products-filter-panel {
    display: block;
  }

  .products-filter-toggle {
    display: none;
  }

  .products-filter-panel > .products-toolbar {
    display: flex;
  }
}

@media (max-width: 768px) {
  .page-products .products-page {
    padding: 10px clamp(1.125rem, 5vw, 1.5rem) 28px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .page-products #main > .container:first-child {
    padding-inline: clamp(1.125rem, 5vw, 1.5rem);
  }

  .products-page .products-header.products-header--compact {
    margin-bottom: 8px;
    text-align: right;
  }

  .products-page--searching .products-header h1,
  .products-page--searching .products-tagline,
  .products-page--searching .products-season-banner {
    display: none;
  }

  .products-header h1 {
    font-size: 1.15rem;
    margin-bottom: 2px;
  }

  .products-header--compact .products-tagline {
    margin-bottom: 6px;
    font-size: 0.8rem;
  }

  .products-search-wrap {
    max-width: 100%;
    margin: 0 0 6px;
  }

  .products-search-field {
    min-height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(26, 31, 28, 0.05);
  }

  .products-search-hint {
    margin: 0 0 4px;
    font-size: 0.78rem;
    text-align: right;
  }

  .products-categories {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    margin-top: 6px;
    margin-bottom: 2px;
    padding-bottom: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .products-categories::-webkit-scrollbar {
    display: none;
  }

  .category-pill {
    flex-shrink: 0;
    padding: 5px 12px;
    font-size: 0.75rem;
    border-radius: 999px;
  }

  .products-filter-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 0 2px;
  }

  .products-filter-chips .products-toolbar-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted, #5c6560);
    margin-inline-end: 2px;
  }

  .products-filter-panel {
    margin-top: 6px;
    border: 1px solid var(--line, #dfe8e2);
    border-radius: 12px;
    background: var(--surface-strong, #fff);
    overflow: hidden;
  }

  .products-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text, #1a1f1c);
    cursor: pointer;
    list-style: none;
    user-select: none;
  }

  .products-filter-toggle::-webkit-details-marker {
    display: none;
  }

  .products-filter-toggle-icon {
    display: inline-flex;
    color: var(--text-muted, #5c6560);
    transition: transform 0.2s ease;
  }

  .products-filter-panel[open] .products-filter-toggle-icon {
    transform: rotate(-90deg);
  }

  .products-filter-panel > .products-toolbar {
    margin: 0;
    padding: 0 12px 12px;
    border-top: 1px solid var(--line, #dfe8e2);
    border-bottom: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .products-toolbar-label {
    font-size: 0.72rem;
    margin-top: 4px;
  }

  .products-sort {
    justify-content: flex-start;
    gap: 5px;
  }

  .products-sort-pill {
    padding: 4px 10px;
    font-size: 0.72rem;
  }

  .products-page--searching .products-sidebar {
    display: none;
  }

  .products-layout {
    gap: 10px;
  }
}

@media (max-width: 640px) {
  .products-search-input {
    font-size: 0.88rem;
  }

  :is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  :is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-body {
    padding: 8px 9px 0;
  }

  :is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-foot {
    padding: 6px 9px 9px;
    gap: 6px;
  }

  :is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-excerpt {
    -webkit-line-clamp: 1;
    font-size: 0.66rem;
  }

  :is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-meta-row {
    gap: 3px 5px;
  }

  :is(.products-page, .page-sale, .page-organic, .page-home, .page-diet, .page-product-detail, .page-seo-landing) .product-card-cta {
    display: none;
  }

  .product-card-add {
    width: 36px;
    height: 36px;
  }

  .product-card-add-icon {
    font-size: 1.15rem;
  }
}
