// Copyright 2015 Palantir Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0.

@use "sass:map";
@import "../../common/variables";

.#{$ns}-input {
  @include pt-input;

  &.#{$ns}-large {
    @include pt-input-large;
  }

  &.#{$ns}-small {
    @include pt-input-small;
  }

  &.#{$ns}-fill {
    flex: 1 1 auto;
    width: 100%;
  }

  .#{$ns}-dark & {
    @include pt-dark-input;
  }

  @each $intent, $color in $pt-intent-colors {
    &.#{$ns}-intent-#{$intent} {
      @include pt-input-intent($color);

      .#{$ns}-dark & {
        @include pt-dark-input-intent(map.get($pt-dark-input-intent-box-shadow-colors, $intent));
      }
    }
  }

  &::-ms-clear {
    display: none;
  }
}

// for iOS support
@supports (-webkit-touch-callout: none) {
  // only html input elements require a fix on iOS
  input.#{$ns}-input {
    &:disabled,
    &.#{$ns}-disabled {
      opacity: 1;
      -webkit-text-fill-color: $input-color-disabled;

      .#{$ns}-dark & {
        -webkit-text-fill-color: $dark-input-color-disabled;
      }
    }
  }
}

/* stylelint-disable-next-line selector-no-qualifying-type */
textarea.#{$ns}-input {
  max-width: 100%;
  padding: $input-padding-horizontal;

  &,
  &.#{$ns}-large,
  &.#{$ns}-small {
    // override input styles for these modifiers.
    // line-height is needed to center text on <input> but not on multiline <textarea>
    height: auto;
    line-height: inherit;
  }

  &.#{$ns}-small {
    padding: $input-small-padding;
  }
}

.#{$ns}-text-area {
  &.#{$ns}-text-area-auto-resize {
    // we are controlling vertical resizing automatically, so restrict user resizing to horizontal dimension only
    resize: horizontal;
  }
}
