/*
 * Backpack - Skyscanner's Design System
 *
 * Copyright 2016-2021 Skyscanner Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@import '~bpk-mixins/index';

.bpk-autosuggest {
  &__container--open {
    position: relative;
  }

  &__suggestions-container {
    display: none;

    &--open {
      position: absolute;
      top: 100%;
      display: block;
      z-index: $bpk-zindex-autosuggest;
      width: 100%;
      margin-top: $bpk-spacing-sm;

      &::before {
        position: absolute;
        bottom: 100%;
        left: 50%;
        content: ' ';
        display: block;
        margin-bottom: -$bpk-one-pixel-rem;
        margin-left: -($bpk-spacing-sm + $bpk-one-pixel-rem);
        border: ($bpk-spacing-sm + $bpk-one-pixel-rem) solid transparent;
        border-bottom-color: $bpk-color-sky-gray-tint-06;
        pointer-events: none;
      }

      &::after {
        position: absolute;
        bottom: 100%;
        left: 50%;
        content: ' ';
        display: block;
        margin-bottom: -$bpk-one-pixel-rem;
        margin-left: -$bpk-spacing-sm;
        border: $bpk-spacing-sm solid transparent;
        border-bottom-color: $bpk-autosuggest-list-background-color;
        pointer-events: none;
      }
    }
  }

  &__suggestions-list {
    min-width: fit-content;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: hidden;

    @include bpk-layer;
  }

  &__suggestion-item {
    cursor: pointer;

    @include bpk-text;
    @include bpk-text--base;

    &:not(:last-child) {
      @include bpk-border-bottom-sm($bpk-color-sky-gray-tint-06);
    }

    &:active {
      background-color: $bpk-autosuggest-list-item-active-background-color;
    }

    &--highlighted {
      background-color: $bpk-autosuggest-list-item-highlighted-background-color;
    }
  }

  &__suggestion {
    display: table;
    width: 100%;
    padding: $bpk-spacing-sm $bpk-spacing-md;

    &--indent {
      padding-left: $bpk-spacing-lg;
    }

    &-icon {
      display: table-cell;
      margin-right: $bpk-spacing-xs;
      vertical-align: top;
      fill: $bpk-color-sky-gray-tint-02;

      @include bpk-rtl {
        margin-right: 0;
        margin-left: $bpk-spacing-xs;
      }
    }

    &-inner {
      display: table-cell;
      width: 100%;
      vertical-align: top;
    }

    &-value {
      display: block;
      width: 100%;
    }

    &-sub-heading {
      display: table-cell;
      width: 100%;
      vertical-align: top;

      @include bpk-text;
      @include bpk-text--xs;
    }

    &-tertiary-label {
      display: table-cell;
      vertical-align: top;
      word-break: keep-all;

      @include bpk-text;
      @include bpk-text--xs;
    }
  }
}
