/**
 * Local Product Search — autocomplete dropdown + results page styles.
 *
 * Targets:
 *   .wrd-product-search        — search form wrapper
 *   .wrd-product-search__input — search input
 *   .wrd-ps-dropdown           — autocomplete suggestion dropdown
 *   .wrd-ps-*                  — search results page components
 */

/* ── Search form wrapper ──────────────────────────────────────────────────── */
.wrd-product-search {
  position: relative;
}

.wrd-product-search__input {
  /* inherits existing .form-control styles */
}

/* Minimal header/page-head treatment — closer to the old search feel */
.page-head .search-form .wrd-product-search {
  display: block;
}

.page-head .search-form .wrd-product-search:before {
  content: "\f002";
  font-family: FontAwesome;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  pointer-events: none;
}

.page-head .search-form .wrd-product-search__input {
  width: 100%;
  height: 42px;
  padding: 10px 36px 10px 0;
  border: 0;
  border-bottom: 2px solid #d75917;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

.page-head .search-form .wrd-product-search__input::-webkit-input-placeholder {
  color: rgba(255, 255, 255, 0.78);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 700;
}

.page-head .search-form .wrd-product-search__input::-moz-placeholder {
  color: rgba(255, 255, 255, 0.78);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 700;
}

.page-head .search-form .wrd-product-search__input:-ms-input-placeholder {
  color: rgba(255, 255, 255, 0.78);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 700;
}

.page-head .search-form .wrd-product-search__input::placeholder {
  color: rgba(255, 255, 255, 0.78);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 700;
}

.page-head .search-form .wrd-product-search__input:hover {
  border-bottom-color: #e56a2a;
}

.page-head .search-form .wrd-product-search__input:focus {
  border-color: #d75917;
  box-shadow: none;
  background: transparent;
  color: #fff;
}

.page-head .search-form .wrd-ps-dropdown {
  margin-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 6px;
}

.page-head .wrd-ps-header-search .wrd-product-search:before {
  left: 18px;
  right: auto;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.4);
}

@media screen and (max-width: 991px) {
  .page-head .search-form .wrd-product-search__input {
    text-align: left;
    padding-left: 0;
  }

  .page-head .search-form .wrd-product-search:before {
    right: 0;
  }
}

/* ── Autocomplete dropdown ─────────────────────────────────────────────────── */
.wrd-ps-dropdown {
  position: absolute;
  z-index: 9999;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.13), 0 1px 4px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
}

.wrd-ps-dropdown-options {
  overflow-y: auto;
  max-height: 340px;
}

.wrd-ps-suggestion {
  display: flex;
  align-items: center;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.12s ease, padding-left 0.12s ease;
}

.wrd-ps-suggestion:last-child {
  border-bottom: none;
}

.wrd-ps-suggestion:hover,
.wrd-ps-suggestion--highlight {
  background: #f4f7fb;
  padding-left: 18px;
}

.wrd-ps-suggestion--highlight {
  outline: 2px solid #5b9dd9;
  outline-offset: -2px;
}

.wrd-ps-suggestion-img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 4px;
  margin-right: 14px;
  background: #f8f8f8;
  flex-shrink: 0;
}

.wrd-ps-suggestion-text {
  flex: 1;
  min-width: 0;
}

.wrd-ps-suggestion-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #222;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wrd-ps-suggestion-sku {
  display: block;
  font-size: 12px;
  color: #888;
  margin-top: 2px;
  font-weight: 400;
}

/* ── Autocomplete category section ─────────────────────────────────────────── */
.wrd-ps-categories {
  padding: 10px 16px 12px;
  border-top: 1px solid #eee;
  background: #fafbfc;
}

.wrd-ps-categories-label {
  font-size: 11px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.wrd-ps-category-link {
  display: block;
  padding: 4px 0;
  font-size: 13px;
  color: #337ab7;
  text-decoration: none;
}

.wrd-ps-category-link:hover {
  color: #23527c;
  text-decoration: underline;
}

.wrd-ps-view-all {
  display: block;
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #337ab7;
  background: #fafbfc;
  border-top: 1px solid #eee;
  text-decoration: none;
  transition: background 0.12s ease;
  border-radius: 0 0 6px 6px;
}

.wrd-ps-view-all:hover {
  background: #f0f4f8;
  text-decoration: none;
  color: #23527c;
}

/* ── Search results page ──────────────────────────────────────────────────── */

.page-head.article-header {
  margin-bottom: 0;
}

/* Dedicated search input — larger on search page */
.wrd-ps-header-search {
  padding: 14px 0 14px;
}

.page-head .wrd-ps-header-search .search-form {
  margin-top: 0 !important;
  margin-bottom: 0;
}

.page-head .wrd-ps-header-search .wrd-product-search__input {
  height: 52px;
  font-size: 18px;
  text-align: left;
  padding: 12px 44px 12px 48px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.page-head .wrd-ps-header-search .wrd-product-search:before {
  left: 18px;
  right: auto;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.4);
}

/* ── Results toolbar: summary left, filter chips right (flex row) ────────── */
.wrd-ps-results-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 20px;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.wrd-ps-results-toolbar:empty {
  display: none;
}

/* Filter drawer — now lives inside the toolbar; remove dark panel styling */
#wrd-ps-results-refinements.wrd-ps-filter-drawer {
  display: inline-flex;
  width: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 0;
}

/* Ensure the drawer sits in the toolbar row */
#wrd-ps-results-refinements {
  margin-top: 0;
}

.wrd-ps-filter-drawer .wrd-ps-chip-label {
  color: #888;
}

.wrd-ps-filter-drawer .wrd-ps-chip {
  /* inherit default light chip styles below */
}

.wrd-ps-filter-drawer .wrd-ps-chip:hover {
  /* inherit default light chip hover */
}

.wrd-ps-filter-drawer .wrd-ps-chip--active {
  /* inherit default active style */
}

.wrd-ps-filter-drawer .wrd-ps-chip--active:hover {
  /* inherit default active hover */
}

/* ── Refinement chips (R3-R4) ─────────────────────────────────────────────── */
.wrd-ps-results-refinements {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0;
}

.wrd-ps-results-refinements::-webkit-scrollbar {
  display: none;
}

.wrd-ps-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #666;
  background: #fff;
  border: 1px solid #d5d8dd;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease,
    box-shadow 0.12s ease;
  white-space: nowrap;
  line-height: 1.4;
}

.wrd-ps-chip:hover {
  border-color: #b0b5bd;
  color: #333;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.wrd-ps-chip:focus {
  outline: 2px solid #5b9dd9;
  outline-offset: 1px;
}

.wrd-ps-chip--active {
  color: #fff;
  background: #d75917;
  border-color: #d75917;
}

.wrd-ps-chip--active:hover {
  color: #fff;
  background: #b84a14;
  border-color: #b84a14;
}

/* ── Chip label (shared) ──────────────────────────────────────────────────── */
.wrd-ps-chip-label {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px 4px 0;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  line-height: 1.4;
}

/* ── Family parts anchor (FPF) ────────────────────────────────────────────── */
.wrd-ps-family-anchor {
  margin: 0 0 16px;
}

.wrd-ps-family-anchor-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #d75917;
  background: #fdf6f2;
  border: 1px solid #f0d8c8;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.12s ease;
}

.wrd-ps-family-anchor-link:hover {
  background: #fcf0e8;
  text-decoration: none;
  color: #b84a14;
}

/* ── Active summary line (R5) ──────────────────────────────────────────────── */
.wrd-ps-results-summary {
  font-size: 13px;
  color: #888;
  margin: 0;
  font-style: italic;
}

/* ── Results-page category row ─────────────────────────────────────────────── */
.wrd-ps-results-categories {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.wrd-ps-results-categories-label {
  font-size: 12px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
  white-space: nowrap;
}

.wrd-ps-results-category-chip {
  display: inline-block;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #337ab7;
  background: #f0f4f8;
  border: 1px solid #d9e2ec;
  border-radius: 3px;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.wrd-ps-results-category-chip:hover {
  background: #d9e8f5;
  border-color: #b0cbe0;
  text-decoration: none;
  color: #23527c;
}

.wrd-ps-results-grid {
  /* Uses existing Bootstrap .row for grid columns */
}

/* ── Result card overrides (inside theme .product-single.card) ─────────────── */
.wrd-ps-results-grid .product-single.card {
  display: block;
  margin-bottom: 20px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.wrd-ps-results-grid .product-single.card:hover {
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.wrd-ps-results-grid .product-single h2 {
  font-size: 16px;
  margin: 0 0 4px;
  color: #222;
  line-height: 1.3;
}

.wrd-ps-results-grid .product-single .item-number {
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
}

.wrd-ps-results-grid .product-single .product-image .inside {
  text-align: center;
}

.wrd-ps-results-grid .product-single .product-image img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.wrd-ps-results-grid .product-single .description {
  font-size: 13px;
  color: #777;
  margin-top: 6px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wrd-ps-results-grid .product-single .product-category {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 3px;
  margin-top: 6px;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.5;
}

/* Phase V4: Variant availability note on result cards */
.wrd-ps-results-grid .product-single .wrd-ps-variant-note {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
  font-style: italic;
}

.wrd-ps-results-empty {
  text-align: center;
  padding: 48px 20px;
  color: #888;
}

.wrd-ps-results-empty h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: #555;
}

.wrd-ps-results-load-more-wrap {
  text-align: center;
  padding: 20px 0 40px;
}

/* ── Loading state ────────────────────────────────────────────────────────── */
.wrd-ps-loading-msg {
  text-align: center;
  padding: 40px 20px;
  color: #888;
  font-size: 16px;
}

.wrd-ps-loading-msg .fa-spinner {
  margin-right: 8px;
}

.wrd-ps-loading .wrd-ps-results-grid {
  opacity: 0.5;
  pointer-events: none;
}

/* ── No-JS fallback — hidden immediately when JS activates ─────────────────── */
.wrd-ps-fallback {
  /* Shown for no-JS users; hidden by JS on init */
}

/* When JS hasn't yet loaded the index, prevent empty grid from taking space */
#wrd-ps-results-grid:empty {
  display: none;
}

/* Hide the results-count paragraph when empty */
#wrd-ps-results-count:empty {
  display: none;
}

/* ── Mobile refinements ───────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .wrd-ps-dropdown {
    position: fixed;
    top: auto !important;
    bottom: 0;
    left: 0 !important;
    right: 0;
    width: 100% !important;
    max-height: 55vh;
    border-radius: 12px 12px 0 0;
    border: 1px solid #ddd;
    border-bottom: none;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
  }

  .wrd-ps-dropdown-options {
    overflow-y: auto;
  }

  .wrd-ps-suggestion {
    padding: 14px 16px;
  }

  .wrd-ps-results-grid .product-single .product-image img {
    max-height: 100px;
  }

  .wrd-ps-results-grid .product-single h2 {
    font-size: 14px;
  }

  .wrd-ps-results-grid .product-single .item-number {
    font-size: 12px;
  }

  .wrd-ps-results-toolbar {
    margin-bottom: 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .wrd-ps-header-search {
    padding: 6px 0 8px;
  }

  .page-head .wrd-ps-header-search .wrd-product-search__input {
    height: 46px;
    font-size: 16px;
    padding-left: 40px;
    padding-right: 36px;
  }

  .page-head .wrd-ps-header-search .wrd-product-search:before {
    left: 12px;
    font-size: 16px;
  }

  .wrd-ps-filter-drawer {
    padding: 0;
    border-radius: 0;
    margin-bottom: 0;
  }

  .wrd-ps-filter-drawer .wrd-ps-chip {
    font-size: 11px;
    padding: 3px 10px;
  }

  .wrd-ps-header-refinements .wrd-ps-chip {
    font-size: 11px;
    padding: 3px 10px;
  }
}
