/* ========================================================================
   HorusFinder Filters / Left Column — Unified Responsive
   ======================================================================== */

/* ---- Desktop ---- */

#hf-results .hf-left-column {
  flex: 0 0 28%;
  max-width: 28%;
  padding: 15px;
  overflow-y: auto;
  max-height: inherit;       /* inherit parent's max-height so filters scroll */
  min-height: 0;
  box-sizing: border-box;
  background-color: var(--hf-color-bg, #f9f9f9);
  border-right: 1px solid var(--hf-color-border);
}

#hf-results .hf-left-column .search-context {
  flex-direction: column;
  margin-bottom: 1.5rem;
  font-size: 13px;
  color: var(--hf-color-text, #333);
}

#hf-results .hf-left-column .search-context h4 {
  margin-bottom: 5px;
  font-size: 16px;
  font-weight: bold;
}

#hf-results .hf-left-column .search-context .active-filter {
  display: flex;
  align-items: center;
  gap: 10px;
}

#hf-results .hf-left-column .search-context .active-filter .filter-icon {
  width: 35px;
  flex-shrink: 0;
}

#hf-results .hf-left-column .search-context .active-filter span {
  font-weight: bold;
  line-height: 1.2;
  white-space: normal;
  word-break: break-word;
  max-width: calc(100% - 45px);
}

#hf-results .hf-left-column h4 {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
}

/* Generic filter title — no border on title, border on container */
#hf-results .hf-left-column .hf-filter-title {
  color: var(--hf-active-color);
  padding-bottom: 5px;
}

#hf-results .hf-left-column .category-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

#hf-results .hf-left-column .hf-filter-row {
  cursor: pointer;
}

#hf-results .hf-left-column .hf-filter-row:hover {
  background-color: color-mix(in srgb, var(--hf-active-color) 5%, transparent);
  cursor: pointer;
  font-weight: 700;
  color: var(--hf-color-text, #333);
  font-size: 13px;
  line-height: 1.9rem;
  transition: transform 0.1s ease;
  transform: scale(1.02);
}

#hf-results .hf-left-column .hf-filter-row:focus-visible {
  outline: 2px solid var(--hf-active-color);
  outline-offset: -2px;
}

#hf-results .hf-left-column .hf-filter-row:hover .hf-filter-count {
  font-weight: 700;
  color: black;
}

#hf-results .hf-left-column .hf-filter-name {
  line-height: 1.9rem;
  padding-left: 5px;
  font-size: 13px;
}

#hf-results .hf-left-column .availability-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

/* All filter containers — border at the bottom of the section */
#hf-results .hf-left-column #categories-container,
#hf-results .hf-left-column #availability-container,
#hf-results .hf-left-column #price-container,
#hf-results .hf-left-column #manufacturer-container {
  margin-bottom: 1.5rem;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--hf-color-border);
}

#hf-results .hf-left-column .hf-filter-count {
  color: var(--hf-color-muted);
  padding-right: 5px;
  font-size: 12px;
  text-align: right;
}

/* Active filter — generic (color driven by CSS var) */
#hf-results .hf-left-column .hf-filter-active {
  background-color: var(--hf-active-color);
  color: var(--hf-color-surface, #fff);
  font-weight: 700;
}

#hf-results .hf-left-column .hf-filter-row.hf-filter-active:hover {
  background-color: var(--hf-active-color-hover, var(--hf-active-color));
  color: var(--hf-color-surface, #fff);
}

#hf-results .hf-left-column .hf-filter-row.hf-filter-active .hf-filter-count {
  color: var(--hf-color-surface);
  font-weight: 700;
}

/* Alternate index container */
#hf-results #alternate-index-container {
  cursor: pointer;
  align-items: center;
  justify-content: flex-start;
  padding: 8px;
  gap: 10px;
  opacity: 1;
  margin-top: 15px;
  margin-bottom: 18px;
}

#hf-results .alternate-index-invisible {
  display: none;
}

#hf-results .alternate-index-visible {
  display: flex;
}

#hf-results #alternate-index-container .alternate-icon {
  height: 30px;
  width: 30px;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

#hf-results #alternate-index-container span {
  font-size: 13px;
  color: var(--hf-color-surface);
  font-weight: 600;
  line-height: 1.5;
}

#hf-results .hf-left-column .close-sidebar-icon {
  display: none;
}

/* ========================================================================
   Filters / Left Column — Mobile / Tablet portrait (<=991.98px)
   ======================================================================== */

@media (max-width: 991.98px) {
  /* Shadow overlay for mobile filter sidebar */
  .shadow-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--hf-z-overlay, 9000);
    display: none;
    transition: opacity 0.3s ease-in-out;
  }

  #hf-results .hf-left-column.active ~ .shadow-overlay {
    display: block;
  }

  /* Mobile sidebar layout */
  #hf-results .hf-left-column {
    position: fixed;
    top: 0;
    right: -100%;
    height: 100%;
    width: min(85%, 320px);
    max-width: 100%;
    flex: none;
    background: var(--hf-color-surface, #fff);
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.3);
    transition: right 0.3s ease-in-out;
    z-index: var(--hf-z-sidebar, 9003);
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow-y: auto;
    box-sizing: border-box;
  }

  #hf-results .hf-left-column.active {
    right: 0;
  }

  /* Close sidebar buttons visible on mobile */
  #hf-results .hf-left-column .search-context .active-filter {
    justify-content: space-between;
    width: 100%;
  }

  #hf-results .hf-left-column .search-context .active-filter span {
    margin-right: auto;
    text-align: left;
  }

  #hf-results .hf-left-column .search-context .active-filter button {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    padding: 0;
    box-sizing: border-box;
  }

  #hf-results .hf-left-column .search-context .active-filter button svg {
    color: var(--hf-color-surface);
  }

  #hf-results .hf-left-column .search-context .active-filter .close-sidebar-icon {
    display: flex;
  }

  /* Alternate index ordering on mobile */
  #hf-results #alternate-index-container {
    order: -1;
  }

  #hf-results #categories-container {
    order: 0;
  }

  #hf-results #availability-container {
    order: 1;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  #hf-results .hf-left-column *, #hf-results .hf-left-column *::before, #hf-results .hf-left-column *::after,
  .shadow-overlay {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
