/**
 * AshesWP Search V3 — canonical Search CSS owner.
 */

.asheswp-search-form,
.asheswp-live-search {
  position: relative;
}

.asheswp-search-results {
  position: absolute;
  z-index: 10050;
  inset-block-start: calc(100% + 8px);
  inset-inline: 0;
  max-height: min(70vh, 590px);
  overflow: auto;
  padding: 12px;
  background: var(--asheswp-surface, #fff);
  color: var(--asheswp-ink, #242427);
  border: 1px solid var(--asheswp-line, #e7e7ea);
  border-radius: 16px;
  box-shadow: var(--asheswp-shadow, 0 18px 50px rgba(31, 31, 35, 0.12));
  text-align: right;
  direction: rtl;
}

.asheswp-search-results[hidden] {
  display: none !important;
}

.asheswp-header__search .asheswp-search-results {
  z-index: 130;
}

.asheswp-search-results__message {
  margin: 0;
  padding: 12px 8px;
  text-align: center;
  color: var(--asheswp-muted, #74747a);
}

.asheswp-search-results__error {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px;
}

.asheswp-search-results__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.asheswp-search-results__retry {
  appearance: none;
  border: 1px solid var(--asheswp-line, #e7e7ea);
  background: var(--asheswp-surface-soft, #f7f8fa);
  color: var(--asheswp-ink, #242427);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}

.asheswp-search-result__match {
  display: block;
  margin-block-start: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--asheswp-muted, #74747a);
}

.asheswp-search-result__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.asheswp-search-result__stock {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  max-width: 42%;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #e8f6ee;
  color: #147a45;
}

.asheswp-search-result__stock[data-stock="outofstock"] {
  background: #f6e8ea;
  color: #a1283a;
}

.asheswp-search-result__stock[data-stock="onbackorder"] {
  background: #fff4e5;
  color: #9a5b00;
}

.asheswp-search-result__entity {
  display: block;
  margin-block-start: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--asheswp-muted, #74747a);
}

.asheswp-search-results__dym {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--asheswp-surface-soft, #f7f8fa);
  color: var(--asheswp-ink, #242427);
  text-align: right;
  cursor: pointer;
  font: inherit;
}

.asheswp-search-results__dym:hover,
.asheswp-search-results__dym:focus-visible {
  outline: none;
  box-shadow: var(--asheswp-focus, 0 0 0 3px rgba(255, 106, 47, 0.18));
}

.asheswp-search-results__categories,
.asheswp-search-results__recent {
  padding: 5px 6px 12px;
  border-bottom: 1px solid var(--asheswp-line, #e7e7ea);
}

.asheswp-search-results__categories strong,
.asheswp-search-results__recent strong {
  display: block;
  margin-bottom: 8px;
  color: var(--asheswp-muted, #74747a);
  font-size: 12px;
  font-weight: 700;
}

.asheswp-search-results__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.asheswp-search-chip,
.asheswp-search-recent {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  background: var(--asheswp-surface-soft, #f7f8fa);
  border: 0;
  border-radius: 9px;
  color: var(--asheswp-ink, #242427);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.asheswp-search-chip small {
  color: var(--asheswp-muted, #74747a);
}

.asheswp-search-results__products {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding-top: 10px;
  min-width: 0;
}

.asheswp-search-result {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  padding: 8px;
  border-radius: 12px;
  color: var(--asheswp-ink, #242427);
  text-decoration: none;
  overflow: hidden;
}

.asheswp-search-result:hover,
.asheswp-search-result.is-active,
.asheswp-search-chip.is-active,
.asheswp-search-recent.is-active {
  background: var(--asheswp-surface-soft, #f7f8fa);
  outline: 2px solid color-mix(in srgb, var(--asheswp-color-primary, #ff7239) 45%, transparent);
}

.asheswp-search-result img {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  object-fit: contain;
  background: #fff;
  border-radius: 9px;
}

.asheswp-search-result__body {
  display: grid;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.asheswp-search-result__title {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
}

.asheswp-search-result__meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--asheswp-muted, #74747a);
  font-size: 11px;
}

.asheswp-search-result__price {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--asheswp-color-primary, #ff7239);
  font-size: 12px;
}

.asheswp-search-result__price[data-state="inquiry"],
.asheswp-search-result__price[data-state="unavailable"] {
  color: var(--asheswp-muted, #74747a);
}

.asheswp-search-results__more {
  display: block;
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--asheswp-color-primary, #ff7239);
  color: #fff !important;
  text-align: center;
  text-decoration: none;
}

.asheswp-live-search__control {
  display: flex;
  position: relative;
  min-width: 0;
  max-inline-size: 100%;
}

.asheswp-live-search__control input {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding-inline: 16px 50px;
  border: 1px solid var(--asheswp-line, #e7e7ea);
  border-radius: 12px;
  background: var(--asheswp-surface, #fff);
  color: var(--asheswp-ink, #242427);
}

.asheswp-live-search__control button {
  position: absolute;
  inset-inline-end: 0;
  inset-block: 0;
  width: 50px;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--asheswp-color-primary, #ff7239);
}

.asheswp-search-results__recent {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.asheswp-search-recent {
  width: 100%;
  min-height: 44px;
  justify-content: flex-start;
}

/* Mobile popup: full-screen workspace results panel */
@media (max-width: 767.98px) {
  .search-pup-up .asheswp-search-results {
    position: relative;
    inset: auto;
    max-height: none;
  }

  .asheswp-search-results__products {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===== Overlay search sheet (header + footer search buttons) ===== */
.search-pup-up {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: none;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  overflow: hidden;
  color: var(--asheswp-ink, #242427);
  background: rgba(20, 22, 26, 0.48);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.search-pup-up.popup-search-active,
.search-pup-up:not([hidden]) {
  display: flex;
}

.search-pup-up[hidden] {
  display: none !important;
}

.search-pup-up__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.search-pup-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: 100dvh;
  margin: 0;
  padding: max(10px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}

.search-pup-inner > * {
  pointer-events: auto;
}

.asheswp-search-overlay {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--asheswp-surface, #fff);
  border: 1px solid var(--asheswp-line, #e7e7ea);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(31, 31, 35, 0.16);
}

.asheswp-search-overlay__bar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--asheswp-line, #e7e7ea);
}

.asheswp-search-overlay__title {
  margin: 0;
  color: var(--asheswp-ink, #242427);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.asheswp-search-overlay__close {
  display: inline-flex;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--asheswp-line, #e7e7ea);
  border-radius: 12px;
  background: #f7f8fa;
  color: var(--asheswp-ink, #242427);
  cursor: pointer;
}

.asheswp-search-overlay__close:hover,
.asheswp-search-overlay__close:focus-visible {
  border-color: #ffd6c6;
  background: #fff4ef;
  color: var(--asheswp-color-primary, #ff7239);
}

.asheswp-search-overlay__close i {
  font-size: 16px;
  line-height: 1;
}

.asheswp-search-overlay__body,
.search-pup-up .form-wrap {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 12px 14px 16px !important;
}

.search-pup-up .asheswp-live-search {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.search-pup-up .asheswp-live-search__control {
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--asheswp-line, #e7e7ea);
  border-radius: 14px;
  background: #f7f8fa;
}

.search-pup-up .asheswp-live-search__control:focus-within {
  border-color: var(--asheswp-color-primary, #ff7239);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 114, 57, 0.18);
}

.search-pup-up #fast-search-input,
.search-pup-up .asheswp-search-input {
  width: 100%;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px;
  padding-block: 0 !important;
  padding-inline: 14px 48px !important;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  color: var(--asheswp-ink, #242427);
  font-size: 16px !important;
  line-height: 1.4;
  text-align: right;
}

.search-pup-up #fast-search-input::placeholder,
.search-pup-up .asheswp-search-input::placeholder {
  color: var(--asheswp-muted, #74747a);
}

.search-pup-up .asheswp-live-search__control button {
  width: 48px;
  color: #fff;
  background: var(--asheswp-color-primary, #ff7239);
}

.search-pup-up .asheswp-search-results {
  position: relative !important;
  inset: auto !important;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  margin-top: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #f7f8fa;
  border-radius: 14px;
  box-shadow: none;
}

.search-pup-up .asheswp-search-results[hidden] {
  display: none !important;
  flex: 0 0 auto;
}

.search-pup-up .asheswp-search-results__products {
  grid-template-columns: minmax(0, 1fr);
}

.search-pup-up .asheswp-search-result {
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.search-pup-up .asheswp-search-result img {
  width: 64px;
  height: 64px;
}

.search-pup-up .asheswp-search-result__title {
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-size: 13px;
}

body.asheswp-search-overlay-open {
  overflow: hidden;
}

body.asheswp-search-overlay-open .asheswp-mobile-nav {
  visibility: hidden;
  pointer-events: none;
}

@media (min-width: 768px) {
  .search-pup-inner {
    width: min(720px, 100%);
    height: min(820px, calc(100dvh - 48px));
    max-height: min(820px, calc(100dvh - 48px));
    margin-inline: auto;
    padding: max(24px, env(safe-area-inset-top, 0px)) 24px 24px;
  }

  .asheswp-search-overlay {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin-inline: 0;
  }

  .search-pup-up .asheswp-search-results__products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .search-pup-up {
    align-items: flex-start;
    justify-content: center;
    padding-top: 6vh;
  }

  .search-pup-inner {
    width: min(720px, calc(100% - 48px));
    height: min(780px, 82vh);
    max-height: min(780px, 82vh);
    padding: 0;
  }

  .asheswp-header__search .asheswp-search-results {
    max-height: min(70vh, 560px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .asheswp-search-results {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
