/**
 * Product Sorting widget — scoped styles only.
 */

.psrt-widget {
  --psrt-accent: #12b5a3;
  --psrt-text: #4b5160;
  --psrt-label: #8b90a0;
  --psrt-bg: #ffffff;
  --psrt-border: #e8eaef;
  --psrt-overlay: rgba(17, 18, 22, 0.45);
  --psrt-handle: #d8dbe3;
  --psrt-radius: 28px;
  --psrt-sheet-radius: 18px;
  --psrt-option-radius: 999px;
  --psrt-focus: #12b5a3;
  direction: rtl;
  font-family: inherit;
  color: var(--psrt-text);
}

.psrt-widget *,
.psrt-widget *::before,
.psrt-widget *::after {
  box-sizing: border-box;
}

.psrt-widget .psrt-svg {
  display: block;
  width: 1em;
  height: 1em;
}

.psrt-notice {
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
}

.psrt-fallback {
  display: none;
}

.psrt-widget:not(.is-ready) .psrt-fallback {
  display: none;
}

@media (max-width: 767px) {
  .psrt-widget:not(.is-ready) .psrt-fallback {
    display: block;
  }

  .psrt-widget:not(.is-ready) .psrt-mobile,
  .psrt-widget:not(.is-ready) .psrt-sheet,
  .psrt-widget:not(.is-ready) .psrt-overlay {
    display: none !important;
  }
}

.psrt-fallback select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--psrt-border);
  border-radius: 12px;
  padding: 8px 12px;
  background: var(--psrt-bg);
  color: inherit;
  font: inherit;
}

.psrt-desktop-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--psrt-bg);
  border-radius: var(--psrt-radius);
  padding: 10px 20px;
  box-shadow: 0 1px 3px rgba(28, 28, 30, 0.06);
  min-height: 56px;
}

.psrt-desktop-start {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.psrt-sort-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--psrt-label);
  flex: 0 0 auto;
  font-size: 18px;
}

.psrt-label {
  color: var(--psrt-label);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  line-height: 1.4;
}

.psrt-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.psrt-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--psrt-option-radius);
  border: 1px solid transparent;
  color: var(--psrt-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  white-space: nowrap;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.psrt-option:hover {
  color: #1c1c1e;
}

.psrt-option:focus-visible {
  outline: 2px solid var(--psrt-focus);
  outline-offset: 2px;
}

.psrt-option.is-active {
  color: var(--psrt-accent);
  border-color: var(--psrt-accent);
  background: transparent;
  font-weight: 500;
}

.psrt-count {
  margin: 0;
  color: var(--psrt-label);
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.psrt-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.psrt-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--psrt-border);
  background: var(--psrt-bg);
  color: var(--psrt-text);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}

.psrt-trigger:hover {
  border-color: #c9cdd6;
}

.psrt-trigger:focus-visible {
  outline: 2px solid var(--psrt-focus);
  outline-offset: 2px;
}

.psrt-trigger[aria-expanded="true"] .psrt-arrow {
  transform: rotate(180deg);
}

.psrt-arrow {
  display: inline-flex;
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.psrt-overlay {
  position: fixed;
  inset: 0;
  background: var(--psrt-overlay);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms cubic-bezier(0.22, 1, 0.36, 1);
}

.psrt-widget.is-open .psrt-overlay {
  opacity: 1;
  pointer-events: auto;
}

.psrt-sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 9999;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.psrt-sheet-panel {
  width: 100%;
  max-width: 560px;
  background: #ffffff;
  border-top-left-radius: var(--psrt-sheet-radius);
  border-top-right-radius: var(--psrt-sheet-radius);
  box-shadow: 0 -8px 32px rgba(17, 18, 22, 0.12);
  padding: 8px 0 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
}

.psrt-widget.is-open .psrt-sheet-panel {
  transform: translateY(0);
}

.psrt-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--psrt-handle);
  margin: 6px auto 8px;
}

.psrt-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 10px;
}

.psrt-sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1c1c1e;
  line-height: 1.3;
}

.psrt-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -8px;
  border: 0;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  border-radius: 10px;
}

.psrt-close:focus-visible {
  outline: 2px solid var(--psrt-focus);
  outline-offset: 2px;
}

.psrt-sheet-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.psrt-sheet-list li + li {
  border-top: 1px solid #f0f1f4;
}

.psrt-sheet-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 12px 20px;
  color: #1c1c1e;
  text-decoration: none;
  font-size: 15px;
  font-weight: 400;
}

.psrt-sheet-option:focus-visible {
  outline: 2px solid var(--psrt-focus);
  outline-offset: -2px;
}

.psrt-sheet-option.is-active {
  color: #1c1c1e;
  font-weight: 500;
}

.psrt-check {
  display: inline-flex;
  color: var(--psrt-accent);
  min-width: 18px;
  justify-content: center;
}

.psrt-sheet[hidden],
.psrt-overlay[hidden] {
  display: none !important;
}

.psrt-widget.is-open .psrt-sheet,
.psrt-widget.is-open .psrt-overlay {
  display: flex;
}

.psrt-widget.is-open .psrt-overlay {
  display: block;
}

body.psrt-lock {
  overflow: hidden;
}

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

@media (max-width: 767px) {
  .psrt-desktop {
    display: none;
  }

  .psrt-mobile {
    display: flex;
  }
}

@media (min-width: 768px) {
  .psrt-fallback {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .psrt-option,
  .psrt-overlay,
  .psrt-sheet-panel,
  .psrt-arrow {
    transition: none;
  }
}
