@import "topcoder/tc-includes";

$border-color: #D8D8DB;
$active-icon-wrap-bg: #888894;

.SearchBar {
  background-color: $white;
  height: 40px;
  width: 100%;
  border: 1px solid $border-color;
  border-radius: 4px;
  position: relative;
  padding-left: 15px;
  padding-right: 46px;

  &.state-empty {
    .search-bar__clear {
      display: none;
    }
  }

  &.state-empty:before {
    content: "Search Topcoder for challenges, people or content";
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: $accent-gray;
    font-size: 15px;
    line-height: 20px;
    width: 75%;
    white-space: nowrap;
    overflow-x: hidden;
    text-overflow: ellipsis;

    @media screen and (max-width: 768px) {
      content: "Search Topcoder";
    }
  }

  &.state-focused:before,
  &.state-filled:before {
    content: "";
  }

  &.state-focused {
    border-color: $accent-gray;

    .search-typeahead-text {
      display: block;
    }

    .search-icon-wrap {
      cursor: pointer;
      background-color: $active-icon-wrap-bg;
    }

    .suggestions-panel {
      display: block;
    }
  }

  &.state-filled {
    border-color: $border-color;

    .search-typeahead-text {
      display: none;
    }

    .search-icon-wrap {
      cursor: pointer;
      background-color: $active-icon-wrap-bg;
    }

    .suggestions-panel {
      display: none;
    }
  }

  .search-bar__text,
  .search-typeahead-text {
    font-family: "Roboto", Arial, Helvetica, sans-serif;
    outline: 0px;
    border: 0px none;
    font-size: 17px;
    color: $accent-gray-dark;
    line-height: 20px;
    width: 90%;
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background-color: transparent;
    z-index: 20;
    padding-left: 0px;
  }

  .search-bar__text {

    &:hover,
    &:focus {
      border: none;
      box-shadow: none;
    }
  }

  .search-typeahead-text {
    color: $accent-gray;
    display: none;
    z-index: 10;
    left: 16.5px;
  }

  .search-bar__clear {
    position: absolute;
    top: 50%;
    right: 60px;
    transform: translateY(-50%);
    cursor: pointer;
    z-index: 30;
  }

  .search-icon-wrap {
    width: 46px;
    height: 40px;
    position: absolute;
    top: -1px;
    right: -1px;
    background-color: $gray-light;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;

    .search-bar__icon {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  }

  .suggestions-panel {
    display: none;
    position: absolute;
    top: 43px;
    left: 0;
    width: 100%;
    z-index: 1000;

    .loading-suggestions {
    }

    .SearchSuggestions {
      strong {
        font-weight: 600;
      }
    }
  }
}