/* ========================================================================
   HorusFinder Searchbar — Unified Responsive
   ======================================================================== */

:root {
  --hf-active-color: #3b82f6;
  --hf-active-color-hover: #2563eb;
  --hf-color-bg: #f9f9f9;
  --hf-color-border: #ccc;
  --hf-color-text: #333;
  --hf-color-muted: #888;
  --hf-color-surface: #ffffff;
  --hf-color-surface-alt: #f0f0f0;
  --hf-color-danger: #dc2626;
  --hf-color-input-bg: #fafafa;
  /* Z-index hierarchy */
  --hf-z-overlay: 9999;
  --hf-z-searchbar: 10000;
  --hf-z-results: 10001;
  --hf-z-sidebar: 10002;
}

/* SVG icons inherit color from parent */
.hf-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ---- Desktop (default) ---- */

#hf-searchbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 45px;
}

#hf-buttons {
  display: flex;
  gap: 10px;
}

#hf-searchbar .input-group {
  display: flex;
  flex: 1;
  align-items: center;
  height: 100%;
  background: var(--hf-color-input-bg);
  overflow: hidden;
  position: relative;
  padding-left: 50px;
  box-shadow: 0 0 6px color-mix(in srgb, var(--hf-active-color) 80%, transparent);
  border: 1px solid var(--hf-active-color);
}

#hf-searchbar .input-group img.input-group-icon {
  position: absolute;
  left: 10px;
  height: 30px;
  width: auto;
  pointer-events: none;
  filter: contrast(0) brightness(1.7);
}

#hf-searchbar .input-group input {
  flex: 1;
  height: 100%;
  border: none;
  padding: 0 10px;
  font-size: 14px;
  outline: none;
  box-shadow: none;
  margin-right: 5px;
  background: transparent;
}

#hf-searchbar .input-group input:focus-visible {
  outline: none;
}

/* Hide native browser clear/cancel button on type="search" inputs.
   We render our own styled cross-icon button. */
#hf-searchbar .input-group input::-webkit-search-cancel-button,
#hf-searchbar .input-group input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
#hf-searchbar .input-group input::-ms-clear,
#hf-searchbar .input-group input::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

#hf-searchbar .input-group button {
  color: var(--hf-color-surface);
  height: 35px;
  width: 35px;
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  left: -4px;
}

#hf-searchbar .input-group .search-icon {
  background-color: var(--hf-active-color);
}

#hf-searchbar .input-group .cross-icon {
  display: none;
  background-color: var(--hf-active-color);
}

/* Index toggle buttons */
#hf-buttons .hf-index-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  padding: 5px;
  line-height: 16px;
  border: 1px solid var(--hf-color-surface-alt);
  cursor: pointer;
  transition: background-color 0.3s, box-shadow 0.3s, opacity 0.3s;
  flex: 1;
  height: 45px;
  width: 100px;
  box-sizing: border-box;
  opacity: 0.5;
  background-color: var(--hf-idx-color, var(--hf-active-color));
  color: var(--hf-color-surface);
}

#hf-buttons .hf-index-button.active {
  opacity: 1 !important;
  box-shadow: 0 0 6px currentColor !important;
}

#hf-buttons .hf-index-button:hover {
  background-color: var(--hf-idx-color-hover, var(--hf-active-color-hover));
}

#hf-buttons .button-image {
  height: 23px;
  width: auto;
  margin-right: 10px;
  display: inline-block;
  vertical-align: middle;
  filter: brightness(0) invert(1);
}

/* Chevron arrow on tab buttons (visible on mobile only) */
#hf-buttons .button-arrow {
  display: none;
}

/* Mobile-only elements: hidden on desktop */
.hf-inline-trigger {
  display: none !important;
}

/* ========================================================================
   Recent Searches Dropdown
   ======================================================================== */

.hf-recent-searches {
  padding: 10px;
  width: 100%;
}

.hf-recent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--hf-color-border);
}

.hf-recent-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--hf-color-text);
}

.hf-recent-clear {
  font-size: 12px;
  color: var(--hf-color-muted);
  cursor: pointer;
}

.hf-recent-clear:hover {
  color: var(--hf-active-color);
}

.hf-recent-item {
  padding: 8px 6px;
  font-size: 13px;
  color: var(--hf-color-text);
  cursor: pointer;
  border-radius: 3px;
}

.hf-recent-item:hover {
  background-color: var(--hf-color-surface-alt);
}

.hf-recent-icon {
  margin-right: 6px;
  font-size: 12px;
}

/* ========================================================================
   Trending Searches
   ======================================================================== */

.hf-trending-searches {
  padding: 10px;
  width: 100%;
}

.hf-trending-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--hf-color-border);
}

.hf-trending-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--hf-color-text);
}

.hf-trending-item {
  padding: 8px 6px;
  font-size: 13px;
  color: var(--hf-color-text);
  cursor: pointer;
  border-radius: 3px;
}

.hf-trending-item:hover {
  background-color: var(--hf-color-surface-alt);
}

.hf-trending-icon {
  margin-right: 6px;
  font-size: 12px;
}

/* ========================================================================
   Keyword Suggestions Dropdown
   ======================================================================== */

.hf-suggestions-container {
  width: 100%;
  background: var(--hf-color-surface);
  border-bottom: 1px solid var(--hf-color-border);
  padding: 4px 0;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.hf-suggestion-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--hf-color-text);
  cursor: pointer;
}

.hf-suggestion-item:hover {
  background-color: var(--hf-color-surface-alt);
}

.hf-suggestion-keyword {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hf-suggestion-keyword strong {
  font-weight: 700;
}

/* Suggestion count badge — hidden by design.
   The MySQL keyword count doesn't match the OpenSearch multi-field +
   synonym result count, so showing it would mislead users. Pattern
   follows Google/Amazon/eBay which never show counts in suggestions. */
.hf-suggestion-count {
  display: none;
}

/* ========================================================================
   Powered By Logo
   ======================================================================== */

.hf-powered-by {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
  border-top: 1px solid var(--hf-color-border);
  opacity: 0.4;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.hf-powered-by:hover {
  opacity: 0.8;
}

.hf-powered-by a {
  text-decoration: none;
  color: var(--hf-color-muted);
  font-size: 11px;
}

.hf-powered-by a strong {
  font-weight: 700;
}

/* ========================================================================
   Mobile / Tablet portrait (<=991.98px) — fullscreen overlay
   Matches warehouse theme breakpoint where #desktop-header is hidden.
   ======================================================================== */

@media (max-width: 991.98px) {
  /* Scroll lock when overlay is open */
  body.hf-mobile-open {
    overflow: hidden;
  }

  /* Fullscreen overlay container — hidden by default */
  #hf-searchbar {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;          /* fallback */
    height: 100dvh;         /* iOS Safari 15.4+ */
    max-height: 100dvh;
    background-color: var(--hf-color-surface);
    z-index: var(--hf-z-searchbar);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
    padding: 10px;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-12px);
    transition: visibility 0s linear 0.2s, opacity 0.2s ease, transform 0.2s ease;
  }

  /* Open state */
  body.hf-mobile-open #hf-searchbar {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    transition: visibility 0s linear 0s, opacity 0.2s ease, transform 0.2s ease;
  }

  /* Inline trigger (fallback: themes other than warehouse) */
  .hf-inline-trigger {
    display: none;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: currentColor;
    padding: 0;
  }

  body.hf-theme-inline .hf-inline-trigger {
    display: inline-flex !important;
  }

  .hf-inline-trigger:focus-visible {
    outline: 2px solid var(--hf-active-color);
    outline-offset: 2px;
  }

  /* Index tabs row */
  #hf-searchbar > #hf-buttons {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
    margin: 0;
    box-sizing: border-box;
    flex-shrink: 0;
  }

  #hf-buttons .hf-index-button {
    flex: 1;
    max-width: 48%;
    height: 45px;
  }

  /* Show chevron-down on mobile tabs (matches prod .button-arrow) */
  #hf-buttons .button-arrow {
    display: inline-flex;
    margin-left: auto;
    align-items: center;
    justify-content: center;
  }

  /* Hide tabs row entirely when only one index */
  #hf-searchbar:not([data-enable-hoc]) > #hf-buttons {
    display: none;
  }

  /* Single-index padding compensation (prod parity) */
  #hf-searchbar:not([data-enable-hoc]) {
    padding-top: 30px;
    padding-bottom: 30px;
  }

  /* Input group: colored border + box-shadow matching active tab.
     Override desktop `flex: 1; height: 100%` which would make the input
     grow vertically to fill the column container. */
  #hf-searchbar > .input-group {
    flex: 0 0 auto;
    height: 50px;
    margin: 0;
    padding: 0 5px 0 50px;
    box-sizing: border-box;
    border: 1px solid var(--hf-active-color);
    box-shadow: 0 0 6px color-mix(in srgb, var(--hf-active-color) 80%, transparent);
  }

  #hf-searchbar .input-group input {
    font-size: 16px;       /* prevent iOS zoom on focus */
  }

  #hf-searchbar .input-group input:focus-visible {
    outline: none;
  }

  #hf-searchbar .input-group button {
    max-height: 35px;
    height: 100%;
    left: 0;
  }

  /* ----------------------------------------------------------------------
     Keyword suggestions — horizontal scrollable chips (mobile only).
     Desktop keeps the vertical grid list. On mobile, a 45px-tall strip
     of pill chips replaces the ~300px vertical list so the product grid
     gets back most of the viewport.
     ---------------------------------------------------------------------- */
  .hf-suggestions-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    grid-template-columns: none;        /* cancel desktop grid */
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;              /* Firefox */
  }
  .hf-suggestions-container::-webkit-scrollbar {
    display: none;                      /* Chrome/Safari */
  }

  .hf-suggestion-item {
    flex-shrink: 0;
    scroll-snap-align: start;
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border: 1px solid var(--hf-active-color);
    background: color-mix(in srgb, var(--hf-active-color) 8%, transparent);
    color: var(--hf-color-text);
    border-radius: 999px;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease;
  }

  .hf-suggestion-item:hover,
  .hf-suggestion-item:focus-visible {
    background: color-mix(in srgb, var(--hf-active-color) 18%, transparent);
  }

  .hf-suggestion-keyword {
    flex: 0 0 auto;                     /* cancel desktop flex: 1 */
    overflow: visible;                  /* chip doesn't ellipsis */
  }
}

/* ========================================================================
   Small desktop intermediate (992-1024px) — collapse tab labels
   ======================================================================== */

@media (min-width: 992px) and (max-width: 1024px) {
  #hf-buttons .hf-index-button span {
    display: none;
  }

  #hf-buttons .button-image {
    margin-right: 0;
  }

  #hf-buttons .hf-index-button {
    width: 50px;
    justify-content: center;
  }
}

/* ========================================================================
   Focus-visible on interactive elements
   ======================================================================== */

.hf-index-button:focus-visible,
.search-icon:focus-visible,
.cross-icon:focus-visible,
.hf-suggestion-item:focus-visible,
.hf-recent-item:focus-visible {
  outline: 2px solid var(--hf-active-color);
  outline-offset: -2px;
}

/* ========================================================================
   No Results / Search Error states
   ======================================================================== */

.no-results,
.search-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  font-size: 14px;
}

.no-results {
  color: var(--hf-color-muted, #888);
}

.search-error {
  color: var(--hf-color-danger, #dc2626);
}

/* ========================================================================
   Skeleton Loading Placeholders
   ======================================================================== */

.hf-skeleton-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 250px;
  max-width: 250px;
  padding: 0.8em;
  box-sizing: border-box;
}

.hf-skeleton-image {
  width: 100%;
  height: 120px;
  margin-bottom: 15px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--hf-color-surface-alt) 25%, #e8e8e8 50%, var(--hf-color-surface-alt) 75%);
  background-size: 200% 100%;
  animation: hf-shimmer 1.5s infinite ease-in-out;
}

.hf-skeleton-title {
  width: 80%;
  height: 14px;
  margin-bottom: 8px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--hf-color-surface-alt) 25%, #e8e8e8 50%, var(--hf-color-surface-alt) 75%);
  background-size: 200% 100%;
  animation: hf-shimmer 1.5s infinite ease-in-out;
}

.hf-skeleton-title-short {
  width: 55%;
}

.hf-skeleton-price {
  width: 40%;
  height: 15px;
  margin-top: auto;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--hf-color-surface-alt) 25%, #e8e8e8 50%, var(--hf-color-surface-alt) 75%);
  background-size: 200% 100%;
  animation: hf-shimmer 1.5s infinite ease-in-out;
}

@keyframes hf-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========================================================================
   Lazy Image Fade-In
   ======================================================================== */

.search-result-image-wrapper {
  background-color: var(--hf-color-surface-alt);
}

.search-result-image {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.search-result-image.hf-loaded {
  opacity: 1;
}

/* ========================================================================
   Query Highlight
   ======================================================================== */

.search-result-title mark {
  background: color-mix(in srgb, var(--hf-active-color) 20%, transparent);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* ========================================================================
   Keyboard Navigation — Active Suggestion
   ======================================================================== */

.hf-suggestion-item.hf-suggestion-active {
  background-color: color-mix(in srgb, var(--hf-active-color) 12%, transparent);
  outline: 2px solid var(--hf-active-color);
  outline-offset: -2px;
}

/* ========================================================================
   Did You Mean Banner
   ======================================================================== */

.hf-did-you-mean {
  grid-column: 1 / -1;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--hf-color-muted);
  border-bottom: 1px solid var(--hf-color-border);
}

.hf-dym-link {
  color: var(--hf-active-color);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.hf-dym-link:hover {
  text-decoration: underline;
}

/* ========================================================================
   Price Range Slider
   ======================================================================== */

#price-container {
}

.hf-price-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--hf-color-text);
  text-align: center;
  margin-bottom: 6px;
}

.hf-price-slider {
  position: relative;
  height: 28px;
}

/* Visible track drawn once via pseudo-element */
.hf-price-slider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: var(--hf-color-surface-alt);
}

.hf-price-slider input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  pointer-events: none;
  z-index: 2;
}


.hf-price-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: transparent;
}

.hf-price-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--hf-active-color);
  border: 2px solid var(--hf-color-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  margin-top: -7px;
  cursor: pointer;
  pointer-events: auto;
}

.hf-price-slider input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: transparent;
}

.hf-price-slider input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--hf-active-color);
  border: 2px solid var(--hf-color-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  cursor: pointer;
  pointer-events: auto;
}

/* ========================================================================
   Manufacturer Chips
   ======================================================================== */

#manufacturer-container {
}

.hf-manufacturer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hf-manufacturer-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid var(--hf-color-border);
  border-radius: 999px;
  background: var(--hf-color-surface);
  color: var(--hf-color-text);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.hf-manufacturer-chip:hover {
  background: var(--hf-color-surface-alt);
  border-color: var(--hf-active-color);
}

.hf-manufacturer-chip.hf-chip-active {
  background: color-mix(in srgb, var(--hf-active-color) 15%, transparent);
  border-color: var(--hf-active-color);
  color: var(--hf-active-color);
  font-weight: 600;
}

/* ========================================================================
   Federated Search (grouped multi-index results)
   ======================================================================== */

.hf-federated-section {
  display: contents;
}

.hf-federated-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-left: 3px solid var(--hf-active-color);
  background: var(--hf-color-surface-alt);
  margin-bottom: 4px;
}

.hf-federated-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--hf-color-text);
}

.hf-federated-count {
  font-size: 12px;
  color: var(--hf-color-muted);
  font-weight: 500;
}

.hf-federated-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  padding: 0 4px 8px;
}

.hf-federated-see-all {
  grid-column: 1 / -1;
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--hf-active-color);
  background: transparent;
  border: 1px solid var(--hf-active-color);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.15s;
  margin-bottom: 12px;
}

.hf-federated-see-all:hover {
  background: color-mix(in srgb, var(--hf-active-color) 8%, transparent);
}

/* ========================================================================
   Reduced Motion
   ======================================================================== */

@media (prefers-reduced-motion: reduce) {
  #hf-searchbar, #hf-searchbar *, #hf-searchbar *::before, #hf-searchbar *::after,
  .hf-inline-trigger, .hf-powered-by {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .hf-skeleton-image,
  .hf-skeleton-title,
  .hf-skeleton-price {
    animation: none !important;
    background: var(--hf-color-surface-alt) !important;
  }

  .search-result-image {
    transition: none !important;
    opacity: 1 !important;
  }
}
