.search-listpage-icon {
  font-size: 16px;
  color: $gray-400;
}

.search-listpage-clear {
  position: absolute;
  right: 8px;
  display: none;
  width: 22px;
  height: 22px;
  padding: 8px;
  font-size: 0.6em;
  color: $gray-300;
}

.search-typeahead {
  position: relative;
  width: 100%;

  .search-clear {
    position: absolute;
    top: 5px;
    right: 4px;
    z-index: 3;
    width: 24px;
    height: 24px;
    padding: 0;
    color: $gray-400;
  }

  .rbt-menu {
    max-height: none !important;
    margin-top: 3px;

    li a span {
      .page-path {
        display: inline;
        padding: 0 4px;
        color: inherit;
      }

      .page-list-meta {
        font-size: 0.9em;
        color: $gray-400;

        > span {
          margin-right: 0.3rem;
        }
      }
    }
  }
}

// input styles
.grw-global-search {
  .search-clear {
    top: 3px;
    right: 26px;
  }

  .dropdown-toggle {
    min-width: 95px;
    padding-left: 1.5rem;
    border-top-left-radius: 40px;
    border-bottom-left-radius: 40px;
  }

  .search-typeahead {
    // corner radius
    border-top-right-radius: 40px;
    border-bottom-right-radius: 40px;
    .rbt-input-main {
      padding-right: 58px;
      // corner radius
      border-top-right-radius: 40px;
      border-bottom-right-radius: 40px;
    }
    .rbt-menu {
      @extend .dropdown-menu-right;
      @extend .dropdown-menu-md-left;
      @include media-breakpoint-down(sm) {
        left: auto !important;
        width: 90vw;
      }
    }
  }

  // using react-bootstrap-typeahead
  // see: https://github.com/ericgio/react-bootstrap-typeahead
  .rbt-input.form-control {
    height: 30px;
    .rbt-input-wrapper {
      margin-left: 8px;
    }
  }

  .form-group:not(.has-error) {
    .rbt-input.form-control {
      border: none;
    }
  }

  .btn-group-submit-search {
    position: absolute;
    top: 0;
    right: 0;

    z-index: 3;

    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
  }
}

// layout
.grw-global-search-top {
  // centering on navbar
  top: $grw-navbar-height / 2;
  left: 50vw;
  z-index: $zindex-fixed + 1;
  transform: translate(-50%, -50%);

  .rbt-input.form-control {
    width: 200px;
    transition: 0.3s ease-out;

    // focus
    &.focus {
      width: 300px;
    }

    @include media-breakpoint-up(md) {
      width: 300px;
    }
    @include media-breakpoint-up(lg) {
      // focus
      &.focus {
        width: 400px;
      }
    }
    @include media-breakpoint-up(xl) {
      width: 350px;
      // focus
      &.focus {
        width: 450px;
      }
    }
  }
  .search-typeahead {
    border-radius: 0 25px 25px 0;
  }
}

.search-result {
  .search-result-list {
    position: sticky;
    top: 64px;
    height: 100vh;
    overflow-y: scroll;

    .nav.nav-pills {
      > li {
        > a {
          height: 123px;
          padding: 2px 8px;
          word-break: break-all;
          border-radius: 0;

          &:hover {
            color: inherit;
            text-decoration: none;
          }
          &.active {
            padding-right: 5px;
            border-left: solid 3px transparent;
          }
          > * {
            margin-right: 3px;
          }
        }
      }
    }

    .search-result-meta {
      margin-bottom: 10px;
      font-weight: bold;
    }

    .search-result-list-delete-checkbox {
      margin: 0 10px 0 0;
      vertical-align: middle;
    }
  }

  .search-result-content {
    padding-bottom: 36px;

    .search-result-page {
      padding-top: 64px;
      // adjust for anchor links by the height of fixed .search-page-input
      margin-top: -64px;

      > h2 {
        margin-right: 10px;
        font-size: 22px;
        line-height: 1em;
      }

      &:first-child > h2 {
        margin-top: 0;
      }

      .wiki {
        padding: 16px;
        font-size: 13px;
        border: solid 1px $gray-300;
      }
    }
  }
}

// 2021/9/22 TODO: Remove after moving to SearchResult
.search-page-input {
  position: sticky;
  top: 15px;
  // placed at front-most
  z-index: 15;

  margin-bottom: 15px;

  .input-group-btn .btn {
    height: 34px;
    padding: 0px 10px;
  }
}

// support for your search
.grw-search-table {
  caption {
    display: table-header-group;
  }
}

@include media-breakpoint-down(sm) {
  .grw-search-table {
    th {
      text-align: right;
    }

    td {
      overflow-wrap: anywhere;
      white-space: normal !important;
    }

    @include media-breakpoint-down(xs) {
      th,
      td {
        display: block;
      }

      th {
        text-align: left;
      }

      td {
        padding-top: 0 !important;
        border-top: none !important;
      }
    }
  }
}
