/**
 * @license
 * Copyright 2024 The Model Explorer Authors. All Rights Reserved.
 *
 * 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.
 * ==============================================================================
 */

.container {
  position: relative;
  overflow: visible;
  background-color: white;
  border-radius: 99px;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 8px;

  .input-container {
    display: flex;
    align-items: center;
    width: 250px;

    mat-icon.search,
    mat-icon.clear {
      font-size: 20px;
      width: 20px;
      height: 20px;
      flex-shrink: 0;
    }

    mat-icon.clear {
      opacity: 0.6;
      cursor: pointer;

      &:hover {
        opacity: 0.9;
      }
    }

    input {
      height: 24px;
      border: none;
      outline: none;
      box-sizing: border-box;
      padding: 0 4px;
      font-size: 12px;
      flex-grow: 1;
      min-width: 0;
    }

    .btn-clear-container {
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .icon-container {
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      color: #999;
      opacity: 0.8;

      &:hover {
        opacity: 1;
      }

      mat-icon {
        font-size: 20px;
        width: 20px;
        height: 20px;
      }
    }
  }

  .input-container:has(input:focus) mat-icon.search {
    color: #1a73e8;
  }

  .search-results-container {
    overflow: hidden;
    position: absolute;
    top: calc(100% + 12px);
    left: -4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 380px;
    display: flex;
    flex-direction: column;
    background-color: white;
    box-shadow:
      0 4px 6px -1px rgb(0 0 0 / 0.1),
      0 2px 4px -2px rgb(0 0 0 / 0.1);

    .title-container {
      background-color: #f6f6f6;
      border-bottom: 1px solid #ddd;
      box-sizing: border-box;
      padding: 0 10px 10px;
    }

    .title {
      height: 28px;
      min-height: 28px;
      font-size: 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .title-label {
        white-space: nowrap;
      }
    }

    .content {
      flex-grow: 1;
      min-height: 0;
      overflow-y: auto;
      padding-bottom: 6px;

      .empty-results {
        padding: 12px 8px 6px;
        display: flex;
        align-items: center;
        font-size: 12px;
        color: #ccc;
      }
    }

    .search-result-type-selector-container {
      display: flex;
      align-items: center;
      font-size: 12px;
      margin-top: 2px;

      .options-container {
        display: flex;
        align-items: center;
        gap: 6px;
      }

      .option-container {
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        user-select: none;
        border: 1px solid #ccc;
        padding: 4px 14px;
        border-radius: 6px;
        background-color: white;
        color: #474747;

        &.selected {
          border-color: #a3c9ff;
          background-color: #a3c9ff;
          color: #001d35;

          mat-icon {
            color: #001d35;
          }
        }

        .icon-container {
          width: 18px;
          height: 18px;
          display: flex;
          align-items: center;
          justify-content: center;
          box-sizing: border-box;
          margin-right: 4px;
        }

        mat-icon {
          font-size: 16px;
          width: 16px;
          height: 16px;
          color: #474747;
        }

        .option-label {
          font-size: 12px;
          font-family: 'Google Sans Text', Arial, Helvetica, sans-serif;
          letter-spacing: normal;
        }
      }
    }
  }

  .footer {
    height: 32px;
    min-height: 32px;
    background-color: #f6f6f6;
    border-top: 1px solid #ddd;
    box-sizing: border-box;
    padding: 0 10px;
    font-size: 12px;
    display: flex;
    align-items: center;
    color: #777;

    mat-icon {
      font-size: 16px;
      height: 16px;
      width: 16px;
      color: #777;
      margin-right: 4px;
    }
  }

  .no-matches {
    position: absolute;
    top: calc(100% + 12px);
    left: -4px;
    color: #999;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: white;
    font-size: 12px;
    box-shadow:
      0 4px 6px -1px rgb(0 0 0 / 0.1),
      0 2px 4px -2px rgb(0 0 0 / 0.1);
  }
}

::ng-deep .model-explorer-search-help-popup {
  padding: 12px;
  font-size: 12px;
  background-color: white;

  ul {
    margin-block-end: 0;
  }

  .code {
    display: inline-block;
    background-color: #fffdd0;
    font-family: monospace;

    &.regex {
      background-color: #e6d0ff;
    }
  }
}
