/* Algolia InstantSearch Custom Styles - Using Theme's Checkbox Structure */

/* Refinement List & Hierarchical Menu - Remove Algolia defaults, use theme styling */
.ais-RefinementList {
  font-size: 14px;
}

[candidates-filter] .input-wrapper.input-checkbox,
[candidates-filter] label {
  margin: 0 !important;
  padding: 0 !important;
}

[candidates-filter] .input-text .input-wrap {
  width: unset !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
}

[class*="showMore"] {
  background: transparent !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  color: #000 !important;
  padding: 0 !important;
  text-decoration: underline !important;
  border: 0 !important;
  box-shadow: none !important;
  margin-top: 15px !important;
  letter-spacing: normal !important;
}

/* Ensure input-wrapper is positioned for count badge */
.ais-RefinementList-item .input-wrapper,
.ais-HierarchicalMenu-item .input-wrapper {
  position: relative !important;
  width: 100% !important;
}

/* Ensure .input-wrap[type=checkbox] gets theme styling */
.ais-RefinementList-item .input-wrap[type="checkbox"],
.ais-HierarchicalMenu-item .input-wrap[type="checkbox"] {
  width: auto !important;
  float: left !important;
  border: 0 !important;
  background: none !important;
  display: flex !important;
  align-items: center !important;
  position: relative !important;
}

/* Hide the actual checkbox input */
.ais-RefinementList-item .input-wrap[type="checkbox"] input,
.ais-HierarchicalMenu-item .input-wrap[type="checkbox"] input {
  visibility: hidden !important;
  width: calc(var(--checkboxSize, 30px) + 2px) !important;
  height: var(--checkboxSize, 30px) !important;
  position: relative !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Style the toggler label (visual checkbox) */
.ais-RefinementList-item .input-wrap[type="checkbox"] [toggler],
.ais-HierarchicalMenu-item .input-wrap[type="checkbox"] [toggler] {
  width: var(--checkboxSize, 30px) !important;
  height: var(--checkboxSize, 30px) !important;
  cursor: pointer !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  background: rgba(0, 0, 0, 0) !important;
  border-radius: var(--checkboxBorderRadius, 5px) !important;
  border: var(--checkboxOutline, 2px solid #ddd) !important;
}

/* Checkmark (::after pseudo-element on toggler) */
.ais-RefinementList-item .input-wrap[type="checkbox"] [toggler]::after,
.ais-HierarchicalMenu-item .input-wrap[type="checkbox"] [toggler]::after {
  content: "" !important;
  width: 10px !important;
  height: 4px !important;
  position: absolute !important;
  top: 7px !important;
  left: 6px !important;
  border: 3px solid var(--checkboxCheckedArrowColor, #e5e7eb) !important;
  border-top: none !important;
  border-right: none !important;
  background: transparent !important;
  opacity: 0 !important;
  transform: rotate(-45deg) !important;
}

/* Hover state */
.ais-RefinementList-item .input-wrap[type="checkbox"] [toggler]:hover,
.ais-HierarchicalMenu-item .input-wrap[type="checkbox"] [toggler]:hover {
  background: rgba(0, 0, 0, 0.05) !important;
}

/* Checked state - dark background */
/* Use both :checked (immediate feedback) and --selected class (after Algolia updates) */
.ais-RefinementList-item--selected>div .input-wrap[type="checkbox"] [toggler],
.ais-RefinementList-item--selected>div:first-child .input-wrap[type="checkbox"] [toggler],
.ais-HierarchicalMenu-item--selected>div:first-child .input-wrap[type="checkbox"] [toggler],
.ais-HierarchicalMenu-item--selected>div:first-child .input-wrap[type="checkbox"] input:checked+[toggler] {
  background-color: var(--checkboxCheckedBGColor, #2d3748) !important;
  border: var(--checkboxCheckedOutline, 2px solid #ddd) !important;
}

.ais-RefinementList-item--selected>div:first-child .input-wrap[type="checkbox"] [toggler]::after,
.ais-RefinementList-item--selected>div:first-child .input-wrap[type="checkbox"] input:checked+[toggler]::after,
.ais-HierarchicalMenu-item--selected>div:first-child .input-wrap[type="checkbox"] [toggler]::after,
.ais-HierarchicalMenu-item--selected>div:first-child .input-wrap[type="checkbox"] input:checked+[toggler]::after {
  opacity: 1 !important;
  border-color: var(--checkboxCheckedArrowColor, #e5e7eb) !important;
}

/* For hierarchicalMenu, ONLY use :checked to avoid parent items showing as checked */
.ais-HierarchicalMenu-item .input-wrap[type="checkbox"] input:checked+[toggler] {
  background-color: var(--checkboxCheckedBGColor, #2d3748) !important;
  border: var(--checkboxCheckedOutline, 2px solid #ddd) !important;
}

.ais-HierarchicalMenu-item .input-wrap[type="checkbox"] input:checked+[toggler]::after {
  opacity: 1 !important;
  border-color: var(--checkboxCheckedArrowColor, #e5e7eb) !important;
}

/* Also support the --selected class for hierarchical BUT with deeper selector to avoid parent matches */
.ais-HierarchicalMenu-item--selected>div>div>.input-wrapper .input-wrap[type="checkbox"] [toggler] {
  background-color: var(--checkboxCheckedBGColor, #2d3748) !important;
  border: var(--checkboxCheckedOutline, 2px solid #ddd) !important;
}

.ais-HierarchicalMenu-item--selected>div>div>.input-wrapper .input-wrap[type="checkbox"] [toggler]::after {
  opacity: 1 !important;
  border-color: var(--checkboxCheckedArrowColor, #e5e7eb) !important;
}

/* Text label styling */
.ais-RefinementList-item .input-wrap[type="checkbox"] label:not([toggler]),
.ais-HierarchicalMenu-item .input-wrap[type="checkbox"] label:not([toggler]) {
  cursor: pointer !important;
  margin-left: 10px !important;
  flex: 1 !important;
}

/* Count badge positioning - inside input-wrapper */
.input-wrapper .ais-RefinementList-count,
.input-wrapper .ais-HierarchicalMenu-count {
  opacity: 0.4;
  font-size: 14px;
  color: var(--gray-600, #6b7280);
  font-weight: 400;
  position: absolute;
  right: 10px;
  top: 6px;
  pointer-events: none;
  z-index: 1;
}

/* Child lists (nested hierarchical) */
.ais-HierarchicalMenu-list--child {
  padding-left: 30px;
  margin-top: 10px;
}

/* Hits container */
.ais-Hits-item {
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

#hits {
  min-height: 200px;
}

/* Search Box within filters */
.ais-SearchBox {
  margin-bottom: 12px;
}

.ais-SearchBox-form {
  position: relative;
}

.ais-SearchBox-input {
  width: 100%;
  padding: 10px 35px 10px 12px;
  border: 1px solid var(--gray-300, #ddd);
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s ease;
  background: white;
}

.ais-SearchBox-input:focus {
  outline: none;
  border-color: var(--blue, #1976d2);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.ais-SearchBox-submit,
.ais-SearchBox-reset {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--gray-600, #666);
}

.ais-SearchBox-submit {
  display: none;
}

.ais-SearchBox-reset {
  display: none;
}

.ais-SearchBox-reset:not([hidden]) {
  display: block;
}

.ais-SearchBox-resetIcon {
  width: 12px;
  height: 12px;
}

/* Main search input at top of filters */
#algolia-search-input {
  width: 100%;
  padding: 12px 40px 12px 15px;
  border: 1px solid var(--gray-300, #ddd);
  border-radius: 4px;
  font-size: 16px;
  transition: border-color 0.2s ease;
}

#algolia-search-input:focus {
  outline: none;
  border-color: var(--blue, #1976d2);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

/* Show More button */
.ais-RefinementList-showMore,
.ais-HierarchicalMenu-showMore {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 8px 0 0 10px;
  font-size: 13px;
  text-decoration: none;
  font-weight: 400;
  transition: color 0.15s ease;
  margin-top: 8px;
  display: block;
}

.ais-RefinementList-showMore:hover,
.ais-HierarchicalMenu-showMore:hover {
  color: #666;
  text-decoration: underline;
}

/* Hide when disabled (no more items) */
.ais-RefinementList-showMore--disabled,
.ais-HierarchicalMenu-showMore--disabled {
  display: none !important;
}

/* Hide if only showing a few items and showMore isn't needed */
.ais-RefinementList:has(.ais-RefinementList-list:not(:has(li:nth-child(11)))) .ais-RefinementList-showMore {
  display: none !important;
}

.ais-HierarchicalMenu:has(.ais-HierarchicalMenu-list:not(:has(li:nth-child(11)))) .ais-HierarchicalMenu-showMore {
  display: none !important;
}

/* Search box within refinement lists */
.ais-RefinementList-searchBox {
  margin-bottom: 12px;
}

.ais-RefinementList-searchBox .ais-SearchBox-input {
  padding: 8px 30px 8px 10px;
  font-size: 13px;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
}

.ais-RefinementList-searchBox .ais-SearchBox-input:focus {
  border-color: #ccc;
  box-shadow: none;
}

/* Stats */
.ais-Stats {
  font-size: 16px;
  color: #333;
}

/* Pagination - Matching original theme design */
.ais-Pagination {
  margin: 20px 0;
  user-select: none;
}

.ais-Pagination-list {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 6px;
  justify-content: center;
  flex-wrap: nowrap;
  align-items: center;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
  color: #2d3748;
}

.ais-Pagination-item {
  display: inline-block;
  flex: 0 0 auto;
}

.ais-Pagination-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 99999px;
  text-decoration: none;
  color: #2d3748;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  transition: all 400ms cubic-bezier(0,0,0,1), opacity 600ms cubic-bezier(0,0,0,1), background 900ms cubic-bezier(0,0,0,1);
  cursor: pointer; 
}

.ais-Pagination-link:hover {
  border: 2px solid #FFC082 !important;
  opacity: 0.85;
  background: transparent !important;
}

.ais-Pagination-link:active {
  background-color: #f0e6d9;
  border-color: #f0e6d9;
  opacity: 1.0;
}

.ais-Pagination-item .ais-Pagination-link {
  border-radius: 100% !important;
  box-shadow: none !important;
}

.ais-Pagination-item--selected .ais-Pagination-link {
  background-color: #FFC082;
  border-color: transparent;
  color: white;
  opacity: 1.0;
  pointer-events: none;
}

.ais-Pagination-item--disabled .ais-Pagination-link {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  background: transparent !important;
  border-color: transparent !important;
}

.ais-Pagination-item--previousPage .ais-Pagination-link,
.ais-Pagination-item--nextPage .ais-Pagination-link {
  border-radius: 99999px;
}

.ais-Pagination-link i {
  position: relative;
  font-size: 16px;
  top: -1px;
  line-height: 1;
}

/* Hide numbers on mobile, keep prev/next */
@media (max-width: 768px) {
  .ais-Pagination-item:not(.ais-Pagination-item--previousPage):not(.ais-Pagination-item--nextPage) {
    display: none;
  }
  
  .ais-Pagination-item--previousPage,
  .ais-Pagination-item--nextPage {
    display: inline-block;
  }
}

/* Clear Refinements */
.ais-ClearRefinements {
  margin: 15px 0;
}

.ais-ClearRefinements-button {
  padding: 10px 20px;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.ais-ClearRefinements-button:hover {
  background: #d32f2f;
}

.ais-ClearRefinements-button--disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Loading state */
.ais-InfiniteHits--empty,
.ais-Hits--empty {
  padding: 40px 20px;
  text-align: center;
  color: #666;
}

/* Accordion integration */
[filter-accordion-content] {
  overflow: visible !important;
  padding-top: 12px !important;
}

[filter-accordion-content] .ais-RefinementList,
[filter-accordion-content] .ais-HierarchicalMenu {
  padding: 0;
  margin: 0;
}

[filter-accordion-content] .ais-RefinementList-list,
[filter-accordion-content] .ais-HierarchicalMenu-list {
  padding: 0;
  margin: 0;
}

/* Ensure col-xs-12 wrapper doesn't interfere */
[filter-accordion-content] .col-xs-12 {
  padding: 0;
  margin: 0;
}

[filter-accordion-content] .row.start-xs {
  margin: 0;
}

/* Tighter spacing in accordion */
[filter-accordion-content] .ais-RefinementList-item,
[filter-accordion-content] .ais-HierarchicalMenu-item {
  margin-bottom: 6px !important;
}

/* Scrollable refinement lists */
[filter-accordion-content][filter-type="checkbox"] {
  max-height: 50vh;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
}

/* Add fade at bottom of scrollable lists */
[filter-accordion][filter-type="checkbox"]:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 60px;
  z-index: 1;
  bottom: 0;
  left: 0;
  pointer-events: none;
  background-image: linear-gradient(to bottom, transparent, white 50%);
  opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
  .ais-Pagination-link {
    min-width: 36px;
    height: 36px;
    font-size: 14px;
  }

  #algolia-search-input {
    font-size: 16px !important;
    /* Prevent zoom on iOS */
  }
}

/* Custom highlight styles */
.ais-Highlight-highlighted,
mark.ais-Highlight {
  background-color: #fff9c4;
  color: inherit;
  font-style: normal;
  font-weight: 600;
}

/* Hide elements that have no facets */
.ais-RefinementList:empty {
  display: none;
}

/* Smooth transitions */
.ais-RefinementList-item,
.ais-Pagination-link {
  transition: all 0.2s ease;
}