$search_width: 240px !default;

@mixin clearBorders($exception-side: "", $exception-value: "") {
  $border-sides: top, right, bottom, left;

  @each $border-side in $border-sides {
    @if $border-side == $exception-side {
      border-#{$exception-side}: $exception-value;
    } @else {
      border-#{$border-side}: none;
    }
  }
}

@mixin search() {
  @include loopingProgressBar(".esri-search--searching");

  .esri-search {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    justify-content: center;
    width: $search_width;
    overflow: visible;

    .esri-widget--button {
      box-shadow: none;
    }

    .esri-icon-notice-triangle {
      margin-inline-end: 5px;
      vertical-align: text-bottom;
      line-height: 16px;
      font-size: 16px;
    }

    .esri-widget__loader {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: $button-height;
    }

    .esri-widget__loader-text {
      margin: 0 $side-spacing--third;
    }
  }

  .esri-search__container,
  .esri-search__input-container,
  .esri-search__form {
    display: flex;
    flex-flow: row nowrap;
  }

  .esri-search__container {
    position: relative;
    flex: 1 0 100%;
    align-items: stretch;

    .esri-search__input,
    .esri-widget--button {
      z-index: 0;
    }

    .esri-search__input:focus,
    .esri-widget--button:focus {
      z-index: 1;
    }
  }

  .esri-search__input-container {
    flex: 2 0;
    align-items: stretch;
  }

  .esri-search__form {
    flex: 1 0;
    align-items: stretch;
    margin: 0;
    padding: 0;
  }

  .esri-search__input {
    display: block;
    margin: 0;
    border: none;
    box-shadow: none;
    width: 100%;
  }

  .esri-search__input::-ms-clear {
    display: none;
  }

  .esri-search__input::placeholder {
    opacity: 1;
    color: $font-color--placeholder;
  }

  .esri-search__submit-button,
  .esri-search__sources-button {
    display: flex;
    align-self: flex-end;
    cursor: pointer;
  }

  .esri-search__submit-button {
    @include clearBorders(left, solid 1px $border-color);
  }

  .esri-search__sources-button {
    @include clearBorders(right, solid 1px $border-color);
  }

  .esri-search__sources-button--up {
    display: none;
  }

  .esri-search__clear-button {
    @include clearBorders();

    display: flex;
    align-self: flex-end;
  }

  .esri-search__source-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .esri-search__suggestions-menu {
    @include icomoonIconSelector() {
      vertical-align: middle;
    }
  }

  .esri-search__suggestions-menu .esri-menu__header:first-child,
  .esri-search__suggestions-menu ul:first-child {
    border: none;
  }

  .esri-search--show-suggestions .esri-search__suggestions-menu,
  .esri-search--sources .esri-search__sources-menu {
    visibility: visible;
    max-height: 300px;
    overflow: auto;
    animation: esri-fade-in 250ms ease-out;
  }

  .esri-search__source--active {
    background-color: $background-color--active;
  }

  .esri-search--warning .esri-search__warning-menu {
    transition: opacity 125ms ease-in-out;
    visibility: visible;
    opacity: 1;
    max-height: inherit;
  }

  .esri-search--multiple-sources .esri-search__input {
    border-left: 0;
  }

  .esri-search__warning-menu {
    opacity: 0;
    z-index: 1;
    font-size: 14px;
  }

  .esri-search__warning-body {
    padding: 0.8em 1em;
  }

  .esri-search__warning-header {
    margin-bottom: 5px;
    font-weight: $font-weight--bold;
  }

  .esri-ui-bottom-left,
  .esri-ui-bottom-right {
    .esri-search__sources-button--up {
      display: flex;
    }

    .esri-search__sources-button--down {
      display: none;
    }
  }

  .esri-view-width-less-than-small .esri-search__input {
    font-size: 16px;
  }

  [dir="rtl"] {
    .esri-search__submit-button {
      border-right: solid 1px $border-color;
      border-left: none;
    }

    .esri-search__sources-button {
      border-right: none;
      border-left: solid 1px $border-color;
    }

    .esri-search__container::after {
      animation: looping-progresss-bar-ani $looping-progress-bar-params reverse;
    }
  }
}

@if $include_Search == true {
  @include search();
}
