@import 'moda-themes/themes';
@import '~shared/constants/breakpoints';

.search-bar-container {
  display: inline-block;
  width: 100%;

  &.search-bar-container--white {
    .search-bar-input-wrapper {
      border: 1px solid color('cashmere');
    }
  }

  &.search-bar-container--light-grey {
    .search-bar-input-wrapper {
      .search-bar-input {
        background-color: color('light-grey');

        &::placeholder {
          color: color('cement');
        }
      }
    }
  }

  .search-bar-input-wrapper {
    position: relative;

    .search-icon {
      display: block;
      position: absolute;
      top: 7px;
      left: 18px;
      height: 18px;
      width: 18px;
      color: color('black');
    }

    .exit-icon {
      position: absolute;
      top: 9px;
      right: 15px;
      font-size: 10px;
      line-height: 1;
      color: color('black');
      cursor: pointer;
    }

    .search-bar-input {
      box-sizing: border-box;
      border: none;
      width: 100%;
      height: 33px;
      padding: 0 48px;
      font-family: font-family('sans');
      font-size: 13px;
      line-height: 1.15;
      color: color('black');

      &.search-bar-input--placeholder-center {
        &::placeholder {
          text-align: center;
        }
      }

      &::placeholder {
        color: color('nokia');
        letter-spacing: normal;
      }

      &:focus {
        outline: 0;
      }
    }
  }

  .search-bar-results {
    position: relative;
    margin-top: -1px;
    border: 1px solid color('cashmere');
    border-top: none;
    padding: 20px;
    background-color: white;

    .divider {
      position: absolute;
      top: 0;
      left: 14px;
      right: 14px;
      border-top: 1px solid color('nokia');
    }

    .search-bar-results-section {
      margin-bottom: 24px;

      &:last-child {
        margin-bottom: 0;
      }

      .search-bar-section-title {
        font-family: font-family('sans');
        font-size: 12px;
        color: color('cement');
        margin-bottom: 8px;
        text-transform: uppercase;
      }

      .search-bar-section-results {
        display: flex;
        flex-direction: column;

        .search-bar-result-container {
          &:last-child {
            margin-bottom: 0;
          }

          &:hover > *, &:active > * {
            text-decoration: underline;
          }

          .search-bar-result {
            display: inline-block;
            border-bottom: 1px solid transparent;
            line-height: 2;
            font-family: font-family('sans');
            font-size: 12px;
            color: color('black');

            &.search-bar-result--selected {
              text-decoration: underline;
            }

            em {
              font-family: font-family('sans');
            }
          }
        }
      }
    }

    .search-bar-no-results {
      font-family: font-family('sans');
      font-size: 12px;
      line-height: 1.67;
      color: color('nokia');
    }
  }
}

@media screen and (max-width: $small) {
  .search-bar-container {
    display: block;
    width: auto;

    &.search-bar-container--white {
      .search-bar-input-wrapper {
        border: 1px solid color('black');
      }
    }

    &.search-bar-container--light-grey {
      .search-bar-input-wrapper {
        .search-icon {
          top: 8px;
        }

        .exit-icon {
          top: 9px;
        }

        .search-bar-input {
          height: 35px;
          font-size: font-size('md');
        }
      }

      .search-bar-results {
        margin: 10px 0;
      }
    }

    .search-bar-input-wrapper {
      margin: 5px 15px;

      .search-icon {
        height: 20px;
        width: 20px;
        top: 15px;
        left: 12px;
      }

      .exit-icon {
        top: 16px;

        &:after {
          content: '';
          display: block;
          position: absolute;
          top: calc(50% - 15px);
          left: calc(50% - 15px);
          width: 30px;
          height: 30px;
        }
      }

      .search-bar-input {
        height: 48px;
        padding: 0 40px;
        font-size: 16px;
      }
    }

    .search-bar-results {
      height: 500px;
      margin: 20px 0;
      overflow: auto;
      padding: 0;
      border: none;

      .divider {
        display: none;
      }

      .search-bar-results-section {
        margin: 0;

        .search-bar-section-title {
          padding: 15px 20px;
          background-color: color('noise');
          font-family: font-family('sans');
          font-size: 14px;
          color: color('black');
          text-transform: capitalize;
        }

        .search-bar-section-results {
          .search-bar-result-container {
            margin: 0 20px;
            padding: 15px 0;
            display: block;

            &:not(:last-child) {
              border-bottom: 1px solid color('noise');
            }

            .search-bar-result {
              font-size: 14px;
            }
          }
        }
      }

      .search-bar-no-results {
        margin: 0 20px;
        font-size: 14px;
        color: color('black');
      }
    }

    &--in-results-mode {
      .search-bar__input-overlay {
        display: none;
      }
    }
  }

  .search-bar__input-overlay {
    position: absolute;
    height: 100%;
    width: 100%;
    opacity: 0;
    cursor: pointer;
  }
}
