// Copyright (C) 2023 The Android Open Source Project
//
// 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 "../assets/theme";

.pf-text-input {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--pf-font-compact);
  font-size: inherit;
  outline: none; // Disable the default outline
  padding: 2px 4px;
  gap: 4px;
  background: var(--pf-color-void);
  border: solid 1px var(--pf-color-border-secondary);
  border-radius: $border-radius;

  &__input {
    appearance: none;
    font-size: inherit;
    line-height: inherit;
    font-family: inherit;
    padding: 0;
    margin: 0;
    color: inherit;
    flex: 1; // Allow input to grow and shrink to fill available space

    // Disable default styles
    outline: none;
    border: none;
    background: none;
    min-width: 0; // input elements have a default min-width, set to 0 to allow flexbox to work properly
  }

  &__left-icon {
    align-self: center;
    line-height: inherit;
    color: var(--pf-color-text-muted);
  }

  // The gentle hover effect indicates this component is interactive
  &:hover {
    border-color: var(--pf-color-border);
  }

  &:has(.pf-text-input__input:focus) {
    border-color: var(--pf-color-primary);
  }

  &:has(.pf-text-input__input[disabled]) {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
  }
}
