// New Searchfield
//================================================== //

.inline.searchfield-wrapper:not(.toolbar-searchfield-wrapper) {
  > .icon:not(.icon-error) {
    top: 38px;
  }
}

.searchfield-wrapper {
  > .icon {
    &.close {
      top: 50%;
      transform: translateY(-50%);
    }
  }

  .btn-icon.close {
    top: 6px;
  }

  .go-button {
    height: 100%;
  }

  &.context .searchfield-category-button {
    border-right: 0;
  }

  .searchfield-category-button {
    height: 38px;

    &:hover {
      .category {
        color: $button-color-tertiary-hover-text-new;
      }
    }
  }

  &.context {
    > .searchfield {
      height: 38px;
    }
  }

  &.has-custom-button {
    .custom-button {
      position: absolute;
      top: 7px;
      left: 263px;
      width: 24px;
      min-width: 24px;
      min-height: 24px;
    }

    &.has-go-button .custom-button {
      left: 205px;
    }

    &.has-text.has-close-icon-button {
      .custom-button {
        left: 235px;
      }

      &.has-go-button .custom-button {
        left: 180px;
      }
    }
  }
}

.toolbar-searchfield-wrapper {
  // To correctly size the toolbar searchfield when it's not open, account for
  // missing text height.  The padding values should equal to `1px` taller on each side
  // than the standard input field padding.  The "closed" state also shifts the visual
  // location of the text/icon to better align it with other toolbar buttons.
  overflow: hidden;

  &:not(.is-open),
  &.non-collapsible {
    .searchfield {
      padding-top: 6px;

      @media only screen and (max-width: $breakpoint-phone-to-tablet) {
        height: 38px;
      }
    }
  }

  .btn-icon.close {
    align-items: center;
    justify-content: center;
    overflow: visible;
  }
}

.toolbar-searchfield-wrapper {
  &.searchfield-wrapper {
    &.non-collapsible {
      svg.icon:not(.close) {
        left: 8px;
      }

      .collapse-button .icon:not(.close) {
        transform: translateY(0);
      }
    }
  }
}

// Firefox needs some help
html.is-firefox {
  .searchfield-wrapper {
    height: 38px;

    &.toolbar-searchfield-wrapper {
      height: 38px;
      overflow: hidden;
    }

    .searchfield-category-button {
      height: inherit;
    }

    &.context {
      > .searchfield {
        color: $searchfield-header-icon-color;
        height: 38px;
      }
    }

    &.has-close-icon-button.has-text .btn-icon.close svg.close {
      top: -0.5px;
    }
  }

  .header.has-searchfield-xl .searchfield-wrapper {
    input {
      height: 48px;
    }

    > svg.icon:nth-child(1) {
      top: 53%;
    }
  }

  .toolbar-searchfield-wrapper {
    &:not(.is-open):not(.non-collapsible) {
      .searchfield {
        height: 38px;
        padding-bottom: 5px;
        padding-top: 7px;
      }
    }

    > .icon {
      &.close {
        top: 18px;
      }
    }

    &.is-open,
    &.non-collapsible {
      .searchfield {
        height: 38px;
        padding-bottom: 6px;
        padding-top: 6px;
      }
    }
  }
}

html.is-safari {
  .searchfield-wrapper {
    &.has-close-icon-button.has-text .btn-icon.close svg.close {
      top: -0.5px;
    }
  }
}

html[dir='rtl'] {
  .searchfield-wrapper {
    > .icon {
      &.close {
        left: 8px;
        right: auto;
      }
    }

    &.has-close-icon-button.has-text {
      .btn-icon.close {
        top: 7px;

        svg.close.icon {
          top: 1px;
        }
      }

      &.has-custom-button {
        .custom-button {
          right: calc(300px - 45%);
        }

        .searchfield {
          padding-left: 60px;
        }
      }
    }

    &.has-custom-button {
      .custom-button {
        top: 3px;
        right: calc(300px - 15%);
      }

      &.has-close-icon-button {
        .searchfield {
          padding-left: 34px;
          padding-right: 34px;
        }
      }

      &.has-go-button {
        .custom-button {
          right: calc(300px - 38%);
        }

        .btn-icon.close {
          right: calc(300px - 33%);
        }
      }
    }

    .searchfield-category-button {
      height: 38px;
    }

    &.has-categories button.close:not(.is-empty) {
      top: 0;
    }
  }

  &.is-firefox {
    .searchfield-wrapper {
      > .icon {
        &.close {
          top: 10px;
        }
      }
    }
  }
}
