.shop-search-sort-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
}

/* Components: search input and interaction styles. */

.shop-search-brand-heading {
  margin: 0;
  font: inherit;
  line-height: 0;
  flex: 0 0 auto;
}

.shop-search-brand-logo {
  width: 74px;
  height: 34px;
  flex: 0 0 auto;
  display: block;
  text-decoration: none;
}

.shop-search-brand-logo picture,
.shop-search-brand-logo img {
  width: 100%;
  height: 100%;
}

.shop-search-brand-logo picture {
  display: block;
}

.shop-search-brand-logo img {
  object-fit: contain;
  display: block;
}

.shop-search-brand-logo-dark {
  display: none !important;
}

/* استایل‌های بهبود یافته برای فیلد جستجو */
.search-container {
  position: relative;
  flex: 1;
  min-width: 0;
  display: block;
}

#mobileCategoriesPage.mobile-categories-page {
  position: relative !important;
  left: 50% !important;
  right: auto !important;
  width: min(560px, calc(100vw - 24px)) !important;
  max-width: calc(100vw - 24px) !important;
  margin: 0 !important;
  padding: 18px 0 96px !important;
  transform: translateX(-50%) !important;
  box-sizing: border-box !important;
  overflow: visible;
}

#shop-section:has(#mobileCategoriesPage:not(.hidden))
  > .platform-shared-header {
  display: none;
}

.mobile-categories-header {
  margin: 8px 0 14px;
  position: relative;
  padding-right: 0;
  text-align: center;
}

.mobile-categories-header h2 {
  margin: 0 0 5px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-color);
}

.mobile-categories-header p {
  margin: 0;
  color: var(--gray);
  font-size: 0.86rem;
}

.mobile-categories-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  justify-items: center;
}

.mobile-category-sales,
.mobile-category-group {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(18px) saturate(155%);
  -webkit-backdrop-filter: blur(18px) saturate(155%);
  overflow: hidden;
}

.mobile-category-sales > summary,
.mobile-category-group > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  cursor: pointer;
  color: var(--text-color);
  list-style: none;
}

.mobile-category-sales > summary::-webkit-details-marker,
.mobile-category-group > summary::-webkit-details-marker {
  display: none;
}

.mobile-category-sales > summary i,
.mobile-category-group > summary i {
  color: currentColor;
}

.mobile-category-groups,
.mobile-category-children {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 12px;
}

.mobile-category-group {
  box-shadow: none;
  background: rgba(255, 255, 255, 0.44);
  border-radius: 14px;
}

.mobile-category-leaf {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--text-color);
  padding: 10px 11px;
  font-family: inherit;
  text-align: right;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-category-leaf:hover,
.mobile-category-leaf:focus-visible {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.32);
  background: rgba(220, 38, 38, 0.08);
  outline: none;
}

.mobile-category-card {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(18px) saturate(155%);
  -webkit-backdrop-filter: blur(18px) saturate(155%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  min-width: 0;
  font-family: inherit;
  text-align: right;
  cursor: pointer;
  color: var(--text-color);
}

.mobile-category-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
  flex: 0 0 auto;
}

.mobile-category-icon svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-category-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-category-copy strong {
  font-size: 0.98rem;
  font-weight: 500;
}

.mobile-category-copy small {
  color: var(--gray);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-category-more {
  color: #dc2626;
  font-size: 0.78rem;
  white-space: nowrap;
  flex: 0 0 auto;
}

@media (max-width: 380px) {
  #mobileCategoriesPage.mobile-categories-page {
    width: calc(100vw - 18px) !important;
    max-width: calc(100vw - 18px) !important;
    padding-top: 0 !important;
  }

  .mobile-category-card {
    gap: 10px;
    padding: 12px;
  }

  .mobile-category-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
  }

  .mobile-category-more {
    font-size: 0.72rem;
  }
}

@media (max-width: 340px) {
  .mobile-category-card {
    align-items: flex-start;
  }

  .mobile-category-more {
    align-self: center;
  }

  .mobile-category-copy small {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

@media (min-width: 640px) {
  #mobileCategoriesPage.mobile-categories-page {
    width: min(720px, calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px) !important;
  }
}

body.theme-dark .mobile-category-sales,
body.theme-dark .mobile-category-group,
body.theme-dark .mobile-category-leaf {
  background: rgba(31, 41, 55, 0.72);
  border-color: rgba(148, 163, 184, 0.22);
  color: #f8fafc;
}

body.theme-dark .mobile-categories-header h2,
body.theme-dark .mobile-category-sales > summary,
body.theme-dark .mobile-category-group > summary,
body.theme-dark .mobile-category-leaf {
  color: #f8fafc;
}

body.theme-dark .mobile-category-sales > summary i,
body.theme-dark .mobile-category-group > summary i,
body.theme-dark .mobile-category-leaf:hover,
body.theme-dark .mobile-category-leaf:focus-visible {
  color: #ff3b3b;
}

/* Mobile category browser: two-column RTL layout inspired by the reference. */
@media (max-width: 1023px) {
  #mobileCategoriesPage.mobile-categories-page {
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    max-width: 720px !important;
    margin-inline: auto !important;
    padding: 0 0 96px !important;
    transform: none !important;
  }

  .mobile-categories-header {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .mobile-categories-list {
    display: block;
    width: 100%;
    margin: 0;
  }

  .mobile-category-browser {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    width: 100%;
    min-height: calc(100dvh - 112px);
    direction: rtl;
    background: var(--light-gray);
    border: 0;
    border-radius: 0 0 14px 14px;
    box-shadow: none;
    overflow: hidden;
  }

  .mobile-category-sales-nav,
  .mobile-category-panel {
    direction: rtl;
    border: 0;
    border-radius: 0;
    overflow: hidden;
  }

  .mobile-category-sales-nav {
    position: relative;
    z-index: 1;
    align-self: stretch;
    flex: 0 0 clamp(90px, 30%, 124px);
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    background: var(--light-gray);
    box-shadow: none;
    overflow: hidden;
  }

  .mobile-category-sales-tab {
    position: relative;
    min-height: 112px;
    padding: 12px 5px;
    border: 0;
    border-bottom: 1px solid #eef0f3;
    border-radius: 0;
    background: transparent;
    color: #1f2937;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.6;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition:
      background-color 0.2s ease,
      color 0.2s ease;
    touch-action: manipulation;
  }

  .mobile-category-sales-tab:last-child {
    border-bottom-color: transparent;
  }

  .mobile-category-sales-tab.active {
    color: #dc2626;
    background-color: #ffffff;
    background-image: linear-gradient(#dc2626, #dc2626);
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 3px 42px;
    border-radius: 0;
    z-index: 1;
  }

  .mobile-category-sales-tab.active::before {
    content: none;
  }

  .mobile-category-sales-tab.active::after {
    content: none;
  }

  .mobile-category-sales-tab:focus-visible,
  .mobile-category-view-all:focus-visible,
  .mobile-category-group-toggle:focus-visible,
  .mobile-category-group-link:focus-visible,
  .mobile-category-leaf:focus-visible {
    outline: 2px solid rgba(220, 38, 38, 0.45);
    outline-offset: -2px;
  }

  .mobile-category-panel {
    align-self: stretch;
    flex: 1 1 0;
    min-width: 0;
    padding: 0;
    background: #ffffff;
    border-right: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .mobile-category-panel-header {
    min-height: 58px;
    padding-inline: 14px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: transparent;
    border-bottom: 1px solid #e9edf2;
  }

  .mobile-category-panel-header strong {
    color: #111827;
    font-size: 1rem;
    font-weight: 800;
    white-space: nowrap;
  }

  .mobile-category-view-all {
    min-height: 44px;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: #dc2626;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    white-space: nowrap;
    touch-action: manipulation;
  }

  .mobile-category-view-all svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
  }

  .mobile-category-groups {
    display: block;
    padding: 0;
    overflow: hidden;
    background: transparent;
    border-radius: 0;
  }

  .mobile-category-group,
  .mobile-category-group-link {
    width: 100%;
    margin: 0;
    border: 0;
    border-bottom: 1px solid #e9edf2;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow: hidden;
    color: #1f2937;
  }

  .mobile-category-group-toggle,
  .mobile-category-group-link {
    width: 100%;
    border: 0;
    background: transparent;
    min-height: 68px;
    padding: 8px 10px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 32px;
    align-items: center;
    gap: 8px;
    color: inherit;
    cursor: pointer;
    list-style: none;
    text-align: right;
    font-family: inherit;
    touch-action: manipulation;
  }

  .mobile-category-outline-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    color: #111827;
    background: #f8fafc;
    border: 1px solid #eef0f3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
  }

  .mobile-category-outline-icon.is-sales-icon {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: currentColor;
  }

  .mobile-category-outline-svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .is-sales-icon .mobile-category-outline-svg {
    width: 28px;
    height: 28px;
  }

  .mobile-category-group-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: 650;
  }

  .mobile-category-chevron {
    width: 22px;
    height: 22px;
    justify-self: end;
    fill: none;
    stroke: #64748b;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease;
  }

  .mobile-category-group.is-open .mobile-category-chevron {
    transform: rotate(180deg);
    color: #dc2626;
  }

  .mobile-category-children {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 42px 6px 0;
    animation: mobile-category-reveal 0.2s ease-out;
  }

  .mobile-category-children[hidden] {
    display: none;
  }

  .mobile-category-leaf {
    min-height: 46px;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    border-top: 1px solid #f0f2f5;
    border-radius: 0;
    background: transparent;
    color: #475569;
    font-family: inherit;
    font-size: 0.8rem;
    text-align: right;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition:
      color 0.18s ease,
      background-color 0.18s ease;
    touch-action: manipulation;
  }

  .mobile-category-leaf:hover,
  .mobile-category-leaf:active,
  .mobile-category-leaf:focus-visible {
    color: #dc2626;
    border-color: #f0f2f5;
    background: #fff7f7;
  }

  @keyframes mobile-category-reveal {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  body.theme-dark .mobile-category-browser {
    background: #0f172a;
    border-color: #283548;
    color: #f8fafc;
  }

  body.theme-dark .mobile-category-panel {
    background: #111827;
    border-color: #283548;
    color: #f8fafc;
  }

  body.theme-dark .mobile-category-sales-nav {
    background: #0f172a;
    color: #f8fafc;
  }

  body.theme-dark .mobile-category-sales-tab,
  body.theme-dark .mobile-category-group,
  body.theme-dark .mobile-category-group-link {
    color: #e5e7eb;
    border-color: #283548;
    background: transparent;
  }

  body.theme-dark .mobile-category-sales-tab.active {
    color: #f87171;
    background-color: #111827;
  }

  body.theme-dark .mobile-category-leaf:hover,
  body.theme-dark .mobile-category-leaf:active,
  body.theme-dark .mobile-category-leaf:focus-visible {
    color: #f87171;
    background: #26181d;
  }

  body.theme-dark .mobile-category-panel-header,
  body.theme-dark .mobile-category-groups,
  body.theme-dark .mobile-category-leaf {
    border-color: #283548;
  }

  body.theme-dark .mobile-category-panel-header,
  body.theme-dark .mobile-category-groups {
    background: transparent;
  }

  body.theme-dark .mobile-category-panel-header strong {
    color: #f8fafc;
  }

  body.theme-dark .mobile-category-view-all {
    color: #f87171;
  }

  body.theme-dark .mobile-category-outline-icon {
    color: #f8fafc;
    background: #1f2937;
    border-color: #334155;
  }

  body.theme-dark .mobile-category-outline-icon.is-sales-icon {
    color: currentColor;
    background: transparent;
    border-color: transparent;
  }

  body.theme-dark .mobile-category-leaf {
    color: #cbd5e1;
    background: transparent;
  }
}

@media (max-width: 360px) {
  .mobile-category-sales-tab {
    min-height: 102px;
    font-size: 0.72rem;
  }

  .mobile-category-group-toggle,
  .mobile-category-group-link {
    grid-template-columns: 38px minmax(0, 1fr) 26px;
    gap: 6px;
  }

  .mobile-category-outline-icon {
    width: 38px;
    height: 38px;
  }

  .mobile-category-panel-header strong {
    font-size: 0.92rem;
  }

  .mobile-category-view-all {
    font-size: 0.68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-category-sales-tab,
  .mobile-category-chevron,
  .mobile-category-leaf {
    transition: none;
  }

  .mobile-category-children {
    animation: none;
  }
}

.search-input {
  width: 100%;
  padding: 10px 35px 10px 116px;
  border-radius: 20px;
  border: none;
  background-color: rgba(245, 245, 245, 0.84);
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  display: block;
  position: relative;
  z-index: 1;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: #666;
  pointer-events: none; /* مهم: این باعث می‌شود کلیک از آیکون عبور کند */
  z-index: 2;
}

.clear-search-icon {
  position: absolute;
  left: 102px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  cursor: pointer;
  font-size: 14px;
  z-index: 2;
  pointer-events: auto; /* این آیکون باید کلیک را دریافت کند */
}

.clear-search-icon:hover {
  color: #f44336;
}

.search-suggestions-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  left: 0;
  z-index: 42;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(320px, 56vh);
  overflow-y: auto;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: linear-gradient(
    135deg,
    rgba(32, 32, 36, 0.82),
    rgba(18, 18, 22, 0.74)
  );
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.search-suggestion-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  text-align: right;
  cursor: pointer;
  transition:
    background-color 0.16s ease,
    color 0.16s ease;
}

.search-suggestion-item:hover,
.search-suggestion-item.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.search-suggestion-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.search-suggestion-icon svg {
  width: 15px;
  height: 15px;
}

.search-suggestion-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.search-suggestion-title,
.search-suggestion-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-suggestion-title {
  font-size: 13px;
  line-height: 1.8;
}

.search-suggestion-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.62);
}

.search-suggestions-empty {
  padding: 11px 12px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  text-align: center;
}

.shop-sort-container {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
  width: auto;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 10px;
  background: linear-gradient(
    135deg,
    rgba(32, 32, 36, 0.68),
    rgba(18, 18, 22, 0.58)
  );
  backdrop-filter: blur(20px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  padding: 0 8px;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  z-index: 3;
}

.shop-sort-icon {
  width: 14px;
  height: 14px;
  color: #ffffff;
  pointer-events: none;
  display: block;
}

.shop-sort-text {
  font-size: 12px;
  color: #374151;
  white-space: nowrap;
}

.shop-sort-trigger {
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.shop-sort-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 142px;
  z-index: 30;
  background: #ffffff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  padding: 6px;
}

.shop-sort-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: right;
  padding: 9px 10px;
  border-radius: 8px;
  color: #1f2937;
  cursor: pointer;
  font-size: 13px;
}

.shop-sort-item:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.shop-sort-item.active {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

@media (max-width: 420px) {
  .shop-search-sort-row {
    gap: 6px;
  }

  .shop-search-brand-logo {
    width: 58px;
    height: 30px;
  }
}

@media (min-width: 1024px) {
  .shop-search-sort-row {
    gap: 10px;
  }

  .search-container {
    flex: 1 1 0;
    max-width: none;
  }
}
