/* Algolia search results page (Phase 2) - SearchResults.aspx.
   Plain CSS (valid SCSS) so the .scss and compiled .css stay identical.
   Styles the hand-built container + the InstantSearch.js widgets (ais-* classes). */
/* ---- Foundation overrides ----
   This page is full-width and renders its own controls, so neutralise the Foundation base styles
   that otherwise leak in: .row max-width (62.5rem), button margin/font, select width:100%, and the
   form input/label margins. Scoped selectors (.algolia-search-page <el>) outrank Foundation's bare
   element rules, and only set properties our component rules don't, so they don't clobber styling. */
.algolia-search-page .row {
  max-width: 100%;
  margin: 0;
}

.algolia-search-page button {
  margin: 0;
  font-family: inherit;
  line-height: normal;
}

.algolia-search-page select {
  width: auto;
  height: auto;
  margin: 0;
}

.algolia-search-page input {
  margin: 0;
  height: auto;
}

.algolia-search-page label {
  margin: 0;
  font-size: inherit;
}

.algolia-search-page ul {
  margin: 0;
}

.algolia-search-page {
  padding: 0;
  margin-bottom: -80px;
}

.algolia-search-page .breadcrumb {
  padding: 16px 0;
  font-size: 12px;
}

.algolia-search-page .breadcrumb a {
  color: #6b7280;
  text-decoration: none;
}

.as-layout {
  display: flex;
}

/* Foundation's .row clearfix (:before/:after) would otherwise become stray flex items. */
.algolia-search-page .as-layout:before,
.algolia-search-page .as-layout:after {
  content: none;
}

/* ---------------- Filters ---------------- */
.as-filters {
  font-size: 13px;
  padding: 20px 20px 24px 20px;
  border-right: 1px solid #e5e7eb;
  background: white;
  flex-basis: 280px;
  flex-grow: 0;
  flex-shrink: 0;
}

.as-filters-inner {
  top: 16px;
  overflow-y: auto;
}

.as-filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  color: rgb(17, 17, 17);
}

/* active filter count badge beside the "Filters" title */
.as-filter-count {
  display: inline-block;
  min-width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 10px;
  background: #00889d;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  letter-spacing: 0;
  vertical-align: middle;
}

.ais-ClearRefinements-button {
  padding: 0;
  background: transparent !important;
  color: rgb(0, 136, 157) !important;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 2px;
  border: none !important;
  font-weight: bold;
}
.ais-ClearRefinements-button:disabled {
  display: none;
}

.as-section {
  border-bottom: 1px solid #f3f4f6;
  padding: 10px 0;
}

.as-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none !important;
  border: none;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1d1d1b !important;
  cursor: pointer;
}

.as-section-head .fa {
  transition: transform 0.15s ease;
  font-size: 16px;
}

.as-section.open > .as-section-head .fa {
  transform: rotate(180deg);
}

.as-section-body {
  display: none;
  padding-top: 8px;
}

.as-section.open > .as-section-body {
  display: block;
}

/* toggles section has no head - always visible. Sits in a light grey rounded panel per design. */
.as-section.as-toggles {
  display: block;
  background: #F9FAFB;
  border-radius: 10px;
  padding: 6px 16px;
  margin-bottom: 12px;
}

.as-toggle {
  padding: 4px 0;
}

/* iOS-style switches for the boolean toggle filters (In Stock / Next Day / Offers / Trade Only).
   The native checkbox InstantSearch renders is restyled into a pill switch sat to the right of
   the label, so the four toggles read as on/off switches per the design. */
.as-section.as-toggles .ais-ToggleRefinement-label {
  justify-content: space-between;
  padding: 2px 0;
}

/* Blue van icon on the "Stocked Item" toggle label. */
.as-toggle .as-toggle-icon {
  height: 12px;
  margin-right: 4px;
  vertical-align: middle;
}

.as-toggle .ais-ToggleRefinement-checkbox {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 20px;
  margin: 0;
  border: none;
  border-radius: 12px;
  background: #d1d5db;
  cursor: pointer;
  transition: background 0.2s ease;
  order: 2;
}

.as-toggle .ais-ToggleRefinement-checkbox:after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
  order: 1;
}

.as-toggle .ais-ToggleRefinement-checkbox:checked {
  background: #00889d;
}

.as-toggle .ais-ToggleRefinement-checkbox:checked:after {
  transform: translateX(18px);
}

/* InstantSearch list widgets */
.as-section .ais-RefinementList-list,
.as-section .ais-NumericMenu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.as-section .ais-RefinementList-item,
.as-section .ais-NumericMenu-item {
  margin: 4px 0;
}

.as-section .ais-RefinementList-label,
.as-section .ais-NumericMenu-label,
.as-section .ais-ToggleRefinement-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #374151;
}

/* Custom styled checkboxes for the value-list facets (Category / Brand / Type / Ranges):
   a square box that fills teal with a tick when refined, replacing the native control. */
.as-section .ais-RefinementList-checkbox,
.as-section .ais-NumericMenu-radio {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 2px solid #d1d5db;
  background: #ffffff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.as-section .ais-RefinementList-checkbox:checked,
.as-section .ais-NumericMenu-radio:checked {
  background: #00889d;
  border-color: #00889d;
}

/* appearance:none removes the native focus ring, so restore a visible one for keyboard users. */
.as-section .ais-RefinementList-checkbox:focus-visible,
.as-section .ais-NumericMenu-radio:focus-visible {
  outline: 2px solid #00889d;
  outline-offset: 2px;
}

.as-section .ais-RefinementList-checkbox:checked:after,
.as-section .ais-NumericMenu-radio:checked:after {
  content: "";
  position: absolute;
  top: 0px;
  left: 4px;
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.as-section .ais-RefinementList-count {
  margin-left: auto;
  border-radius: 10px;
  padding: 1px 0;
  font-size: 11px;
  color: #6b7280;
}

.as-section .ais-RefinementList-showMore {
  margin-top: 8px;
  background: none;
  border: none;
  color: #00889d;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

/* Hide "+ more" when there's nothing more to show (InstantSearch keeps it but marks it disabled). */
.as-section .ais-RefinementList-showMore[disabled],
.as-section .ais-RefinementList-showMore--disabled {
  display: none;
}

/* range input (min/max) */
.as-range-input {
  margin-top: 10px;
}

/* Stack min / "to" / max / Update vertically so each is full-width and legible, rather than
   cramming three controls onto one row. */
.as-range-input .ais-RangeInput-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.as-range-input .ais-RangeInput-label {
  display: block;
  width: 100%;
}

.as-range-input .ais-RangeInput-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  font-size: 13px;
}

/* Design stacks Min then Max with no "to" between them. */
.as-range-input .ais-RangeInput-separator {
  display: none;
}

.as-range-input .ais-RangeInput-submit {
  width: 100%;
  background: #00889d;
  color: #fff;
  border: none;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.as-range-input .ais-RangeInput-submit:hover {
  background: #006b7d;
}

/* finish blocks */
.as-finish-blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.as-finish-block {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
}

.as-finish-block.active {
  background: #00889d;
  border-color: #00889d;
  color: #ffffff;
}

/* ---------------- Results ---------------- */
.as-results {
  flex-basis: calc(100% - 280px);
  flex-grow: 0;
  flex-shrink: 0;
  background: #F5F5F5;
  padding: 24px 24px 80px 24px;
}

.as-results-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 0 16px;
}

.as-stats {
  font-size: 13px;
  color: #6b7280;
}

.as-sort .ais-SortBy-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 34px 8px 10px;
  border: 1px solid #e5e7eb;
  font-size: 13px;
  cursor: pointer;
  background-color: #fff !important;
  /* Custom chevron (matches the fa-angle section toggles) in place of the native select arrow. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px 14px;
}
.as-sort .ais-SortBy-select:hover {
  background-color: #fff;
}

.as-current-refinements {
  display: none !important;
  margin-bottom: 12px;
}

.as-current-refinements .ais-CurrentRefinements-item {
  display: inline-flex;
  align-items: center;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 4px 8px;
  margin: 0 6px 6px 0;
  font-size: 12px;
}

/* hits grid */
.as-hits .ais-Hits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.as-hits .ais-Hits-item {
  padding: 0;
  border: none;
  box-shadow: none;
  background: #F9FAFB;
}

.as-card {
  border: 1px solid #f3f4f6;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.as-card-img {
  display: block;
  text-align: center;
  padding: 20px;
}

.as-card-img img {
  width: auto;
  margin: 0 auto;
}

.as-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  background: #ffffff;
}

.as-card-brand {
  font-size: 11px;
  color: rgb(107, 114, 128);
  font-weight: 500;
  margin-bottom: 8px;
}

.as-card-name {
  font-size: 12px;
  font-weight: 600;
  color: rgb(55, 65, 81) !important;
  line-height: 1.4;
  margin-bottom: 8px;
}

.as-card-sku {
  font-size: 10px;
  color: rgb(156, 163, 175);
  font-family: monospace;
  margin-bottom: auto;
}

.as-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.as-badge {
  flex-basis: 100%;
}

.as-badge.as-instock {
  font-size: 10px;
  font-weight: 700;
  color: rgb(22, 163, 74);
  display: flex;
  align-items: center;
  gap: 4px;
}

.as-badge.as-outofstock {
  font-size: 10px;
  font-weight: 700;
  color: rgb(220, 38, 38);
  display: flex;
  align-items: center;
  gap: 4px;
}

.as-badge.as-nextday {
  font-size: 9px;
  font-weight: 900;
  color: rgb(241, 135, 0);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.as-badge.as-nextday img {
  height: 12px;
  margin-right: 4px;
}

.as-card-price-title {
  font-size: 10px;
  color: rgb(107, 114, 128);
  margin-top: 12px;
  margin-bottom: 4px;
}

.as-card-price {
  font-size: 18px;
  font-weight: 900;
  color: rgb(17, 17, 17);
  margin-bottom: 16px;
}

.as-card-actions {
  display: flex;
  gap: 8px;
}

.as-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgb(200, 200, 200);
  background: rgb(230, 230, 230);
  color: rgb(64, 64, 64);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  flex: 1 1 0%;
  cursor: pointer;
  transition: 0.15s;
}
.as-action:hover {
  border: 1px solid rgb(200, 200, 200);
  background: rgb(230, 230, 230);
  color: rgb(64, 64, 64);
}

.as-action.as-add-quote {
  border: 1px solid rgb(0, 136, 157);
  background: rgb(0, 136, 157);
  color: rgb(255, 255, 255);
}

.as-action.as-add-basket {
  border: 1px solid #FFCC00;
  background: #FFCC00;
  color: rgb(17, 17, 17);
}

.as-action.as-compare {
  border: 1px solid rgb(229, 0, 64);
  background: #ffffff;
  color: rgb(229, 0, 64);
}

.as-noresults {
  padding: 64px 20px;
  text-align: center;
}

.as-noresults-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 16px;
}

.as-noresults-title {
  font-size: 20px;
  font-weight: 800;
  color: #111;
  margin-bottom: 8px;
}

.as-noresults-text {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 20px;
}

.as-noresults-clear {
  background: #00889d;
  color: #fff;
  border: none;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.as-noresults-clear:hover {
  background: #006b7d;
}

/* pagination */
.as-pagination {
  margin-top: 28px;
}

.as-pagination .ais-Pagination-list {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 0;
  margin: 0;
}

.as-pagination .ais-Pagination-link {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  color: #374151;
  text-decoration: none;
  font-size: 13px;
}

.as-pagination .ais-Pagination-item--selected .ais-Pagination-link {
  background: #00889d;
  border-color: #00889d;
  color: #ffffff;
}

/* ---------------- Responsive ----------------
   Mobile-only chrome (drawer toggle, overlay, drawer title bar, close button) is hidden on desktop
   and revealed in the small-screen media query below; desktop layout is otherwise untouched. */
.as-filters-toggle,
.as-filters-overlay,
.as-filters-mobile-bar,
.as-filters-close {
  display: none;
}

@media (max-width: 1280px) {
  .as-hits .ais-Hits-list {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 1024px) {
  .as-hits .ais-Hits-list {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 768px) {
  /* Results span the full width; the filter sidebar becomes an off-canvas drawer. */
  .as-results {
    flex-basis: 100%;
    padding: 16px;
  }
  .as-filters {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1001;
    width: 86%;
    max-width: 340px;
    height: 100%;
    flex-basis: auto;
    border-right: none;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .as-filters.open {
    transform: translateX(0);
  }
  .as-filters-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease;
  }
  .as-filters-overlay.open {
    opacity: 1;
    visibility: visible;
  }
  body.as-filters-lock {
    overflow: hidden;
  }
  /* "Filters" button on the results top bar */
  .as-filters-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    color: #1d1d1b;
    cursor: pointer;
  }
  /* Drawer title bar + close button */
  .as-filters-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #111;
  }
  .as-filters-close {
    display: block;
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0 4px;
  }
  /* Cards become a single-column horizontal list (image left, details right). */
  .as-hits .ais-Hits-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .as-card {
    flex-direction: row;
    align-items: stretch;
  }
  .as-card-img {
    flex: 0 0 96px;
    width: 96px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .as-card-img img {
    max-width: 100%;
    max-height: 88px;
  }
  .as-card-body {
    flex: 1;
    min-width: 0;
  }
  .as-card-name {
    height: auto;
    -webkit-line-clamp: 2;
  }
}
