.searchlib-block {
  div.facets {
    i.icon.dropdown {
      margin-right: 0px;
      float: left;
    }

    div.content.active {
      padding-top: 0px;
    }
  }

  .match-select {
    margin-left: 1em;
    font-size: 70%;
  }

  .boolean-facet {
    .toggle {
      label {
        color: @deepBlue !important;

        &:before {
          box-shadow: 0px 0px 0px 2px @sf-medium-gray2 !important;
        }

        &:after {
          background: @white;
        }
      }

      &.checked {
        label {
          &:before {
            background-color: @secondaryColor !important;
            box-shadow: 0px 0px 0px 2px @secondaryColor !important;
          }
        }
      }
    }
  }

  .secondary-facets {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
  }
}

.ui.segment.facetslist-wrapper {
  padding: 0em;
  border: 0px;
  margin: 0em;
  box-shadow: none;
}

.histogram-facet {
  padding: 20px;
  background: @white;

  .text-input {
    display: flex;
    width: 100%;
    justify-content: space-between;

    .ui.input {
      input {
        max-width: 6em;
        border: 1px solid @sf-medium-gray;
        font-size: 14px;
        outline: none;
      }
    }
  }

  .tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted @darkerGray;
    margin-left: 22px;
  }

  .tooltip .tooltiptext {
    position: absolute;
    z-index: 1;
    bottom: 150%;
    left: 50%;
    width: 100px;
    padding: 5px 0;
    border-radius: 6px;
    margin-left: -60px;
    background-color: @darkerGray;
    color: @mediumLightWhite;
    opacity: 0.8;
    text-align: center;

    &:after {
      position: absolute;
      top: 100%;
      left: 50%;
      border-width: 5px;
      border-style: solid;
      border-color: @darkerGray transparent transparent transparent;
      margin-left: -5px;
      content: '';
    }
  }
}

.facets-wrapper {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  margin: 1em 0;
}

.searchlib-multiterm-facet,
.searchlib-fixedrange-facet {
  .toggleSort {
    display: flex;

    div.toggle-label {
      overflow: hidden;
      max-width: 7em;
    }
  }

  .sui-facet-search {
    display: flex;

    i.icon {
      padding: 6px 0;
    }
  }

  .sui-facet-search__text-input {
    border: 0px;
    font-size: 80%;
  }

  .sui-multi-checkbox-facet {
    overflow: auto;
    max-height: 100%;
    padding: 0 0.6em;
  }
}

.facets {
  margin-top: 1em;

  .accordion.ui {
    padding: 0.4em 0em;
    border-bottom: 1px solid @sf-medium-gray;

    &:hover {
      background-color: @lighterGray;
    }

    .content {
      padding-bottom: 0.5em !important;
      background-color: @white;
    }

    .title {
      white-space: nowrap;
    }

    .sui-facet__title {
      display: none;
    }
  }
}

.sui-multi-checkbox-facet.facet-term-controls {
  border-top: 1px solid @sf-medium-gray;
  border-bottom: 1px solid @sf-medium-gray;
  margin: 0px;
}

.sui-facet + .sui-facet {
  margin-top: 32px;
}

.sui-sorting + .sui-facet {
  margin-top: 32px;
}

.sui-facet__title {
  padding: 0;
  color: @blueGray;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sui-multi-checkbox-facet {
  margin: 8px 0;
  color: @darkGray;
  font-size: 13px;
}

.sui-multi-checkbox-facet__option-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.sui-multi-checkbox-facet__option-input-wrapper {
  display: flex;
  max-width: 15em;
  flex: 1;
}

.sui-multi-checkbox-facet__checkbox {
  margin-right: 8px;
  cursor: pointer;
}

.sui-multi-checkbox-facet__option-count {
  margin-left: 24px;
  color: @midLighterGray;
  font-size: 0.85em;
}

.sui-facet-view-more {
  display: block;
  padding: unset;
  border: unset;
  background: unset;
  color: @brightBlue;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  line-height: inherit;
  text-align: left;
}

.sui-facet-view-more:hover,
.sui-facet-view-more:focus {
  background-color: @lightWhite;
  outline: 4px solid @lightWhite;
}

.sui-facet-search {
  margin: 6px 0px 0px 0px;
}

.sui-facet-search__text-input {
  width: 100%;
  height: 100%;
  padding: 6px;
  border: 1px solid @sf-medium-gray;
  border-radius: 4px;
  margin: 0;
  font-family: inherit;
  outline: none;
}

.sui-facet-search {
  margin: 0px;

  i.icon.search {
    position: relative !important;
    top: 2px;
    left: 7px;
  }
}

.ui.dimmer.facet-dimmer {
  padding: 10px;
  background-color: @dimmedDarkBlueGray;

  > div.content {
    overflow: auto;
    min-width: 80vw;
    max-width: 100%;
    max-height: 97vh;
    padding: 20px;
    background-color: @sf-light-gray2;
    box-shadow:
      1px 3px 3px 0px @darkBlueGray,
      1px 3px 15px 2px @darkBlueGray;
  }

  button.show-filters {
    border-radius: 2px;
    margin-top: 30px;
    margin-right: 0px;
    background: @sf-light-gray !important;
    color: @secondaryColor !important;
    float: right;
    font-size: 12px;
  }

  .filter-list-item {
    max-width: 100%;

    .ui.labels {
      text-align: left;
    }

    .ui.label {
      display: inline-flex;
    }

    .facet-option-icon {
      display: inline;
      max-height: 12px !important;
      margin-right: 0.5em;
      background: @white;
      -webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */
      filter: grayscale(100%);
    }
  }

  .card {
    width: 80% !important;
    border: none;
    border-radius: 3px;
    margin: 3px 0px 3px 10%;
    box-shadow: none;

    &:hover {
      box-shadow: none !important;
    }

    div.content {
      padding: 0.5em;

      div.header {
        padding: 0px;
        margin: 0px;
        color: @sf-dark-gray;
        font-size: 16px !important;
        font-weight: 400 !important;

        span.text {
          display: block;
          overflow: hidden;
          max-width: calc(100% - 35px);
          float: left;
          text-overflow: ellipsis;
          white-space: nowrap;
        }

        span.clear-filters {
          button {
            padding: 3px;
            background: @sf-light-gray !important;
            color: @secondaryColor;
            float: right;
            font-size: 10px;
          }
        }
      }
    }

    div.filter.description {
      display: flex;

      div.ui.label {
        padding: 5px;
        margin-top: 4px;
        margin-bottom: 0px;
        background: @white;
        font-size: 12px;

        span.text {
          min-height: 13px !important;
        }
      }
    }

    &.active {
      background: @white;

      div.label {
        max-width: 100%;
        background: @sf-light-gray !important;
        color: @secondaryColor;
        font-weight: 600;

        span.text {
          display: block;
          overflow: hidden;
          max-width: calc(100% - 14px);
          float: left;
          text-overflow: hidden;
          white-space: nowrap;
        }
      }
    }
  }
}

.ui.modal.facet {
  img.facet-option-icon {
    display: inline;
    margin-right: 0.5em;
    background: @white;
    -webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */
    filter: grayscale(100%);
  }

  > .header {
    padding: 1em 1.5em;
  }

  .content {
    padding: 2em;
  }

  .content .searchlib-multiterm-facet.facet-sources {
    img.facet-option-icon {
      display: block;
      height: 28px;
      background: @white;
      -webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */
      filter: grayscale(100%);
    }
  }

  fieldset.sui-facet.searchlib-fixedrange-facet {
    padding: 20px;

    legend.sui-facet__title {
      position: relative;
      top: 15px;
      left: 12px;
      color: @sf-dark-gray;
      font-size: 14px;
      text-transform: initial;
    }
  }

  div.scrolling.content {
    max-height: 60vh;
  }

  div.scrolling.content > div {
    width: 100% !important;
  }

  div.by-groups {
    .group-heading.first {
      margin-top: 0px;
    }

    .group-heading {
      display: flex;
      align-items: center;
      margin-top: 1.5em;
      margin-bottom: 1em;
      --text-divider-gap: 0.5em;
    }

    .group-heading::after {
      height: 1px;
      flex-grow: 1;
      margin-left: var(--text-divider-gap);
      background-color: @sf-light-gray;
      content: '';
    }
  }

  div.header {
    border-bottom: 1px solid @midGray;
    background-color: initial;

    .facet-title {
      color: @lightBlack;

      h3 {
        font-size: calc(10px + 4 * ((100vw - 320px) / 680));
        font-weight: 600;
      }
    }

    .multitermlist__facet__header_bottom {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
    }

    .multitermlist__facet__header {
      .search {
        display: flex;
        align-items: center;
        margin-top: 1em;
      }

      input.multitermlist__search__text-input {
        width: 40%;
        padding: 0.2em;
        border: 1px solid @sf-medium-gray;
        border-radius: 5px;
        margin-right: 1em;
        margin-bottom: 0.2em;
        font-size: 80%;
      }

      span.label {
        color: @deepBlue;
        font-size: 16px;
        font-weight: 400;
      }

      div.order-controls {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        margin-left: auto;

        div.toggle-label {
          cursor: pointer;
        }

        div.toggleSort {
          padding-left: 0.3em;

          div.toggle-label {
            border-radius: 8px;
            margin-left: 10px;
            background: @white;
            color: @deepBlue;
            font-size: 16px;
            font-weight: 400;

            i.icon {
              margin-left: 3px;
            }

            &.active {
              color: @secondaryColor;
              font-weight: 700;
            }
          }
        }
      }

      div.ui.toggle.checkbox {
        padding-left: 0.5em;
        color: @sf-dark-gray !important;
        font-size: 14px;

        label {
          padding-left: 2.5rem;
          color: @sf-dark-gray !important;

          &:before {
            position: absolute;
            top: 5px;
            width: 1.6rem;
            height: 0.8rem !important;
            background: @mediumDarkerGray !important;
            box-shadow: 0px 0px 0px 2px @mediumDarkerGray !important;
          }

          &:after {
            position: absolute;
            top: 5px;
            width: 0.8rem !important;
            height: 0.8rem !important;
            background: @white;
          }
        }

        &.checked {
          label {
            &:before {
              background-color: @secondaryColor !important;
              box-shadow: 0px 0px 0px 2px @secondaryColor !important;
            }

            &:after {
              left: 1.3rem !important;
            }
          }
        }
      }
    }
  }

  .ui.card.term.active-term {
    width: auto !important;
    min-width: auto;
    margin: 5px 1.5em 5px 0 !important;

    .header,
    span.count {
      color: @secondaryColor;
      font-weight: 700;
    }
  }

  .ui.card.term {
    min-width: 100px;
    margin-top: 2em;

    &.disabled {
      .header,
      span.count {
        color: @midDarkerGray;
      }
    }

    .header {
      border: none;
      color: @deepBlue;
      font-size: 16px;
      font-weight: 400;
    }

    .content {
      flex-grow: initial;
      padding: 0;
      padding-bottom: 0.5em;
    }

    &.active {
      .header,
      span.count {
        color: @primaryColor;
        font-weight: 700;
      }

      &:hover {
        background: transparent !important;
      }
    }

    &:hover {
      border: none;
      background: transparent !important;
      box-shadow: none;
    }

    .title {
      margin-right: 5px;
    }

    .count {
      color: @deepBlue;
      font-size: 16px;
      font-weight: 400;
    }
  }

  div.actions {
    a.clear-filters {
      margin-left: auto;
      color: @secondaryColor;
      font-size: 12px;
    }
  }
}

.sui-facet {
  padding: 0;
  border: 0;
  margin: 0;
}

@media only screen and (max-width: 1080px) {
  div.facets {
    div.toggleSort {
      display: initial;

      select.match-select {
        margin-bottom: 3px;
        margin-left: 0px;
      }
    }
  }
}

@media screen and (max-width: 850px) and (min-width: 750px) {
  button.show-filters {
    padding: 0.5em !important;
  }
}
