@import "./input.vars";

// Input
// --------------------------------------------------

:host {
  --placeholder-color: currentColor;
  --placeholder-font-style: inherit;
  --placeholder-font-weight: inherit;
  --placeholder-opacity: .5;
  --padding-top: 0;
  --padding-end: 0;
  --padding-bottom: 0;
  --padding-start: 0;
  --border-radius: 0;

  display: flex;
  position: relative;

  flex: 1;
  align-items: center;

  width: 100%;

  /* stylelint-disable */
  /* TODO: find a better solution in padding.css, that does not require !important, */
  padding: 0 !important;
  /* stylelint-enable */

  font-family: $font-family-base;
}

:host(.ion-color) {
  color: #{current-color(base)};
}

// Native Text Input
// --------------------------------------------------

.native-input {
  @include border-radius(var(--border-radius));
  @include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));
  @include text-inherit();

  display: inline-block;

  flex: 1;

  width: 100%;

  border: 0;

  outline: none;

  background: transparent;

  box-sizing: border-box;
  appearance: none;

  &::placeholder {
    color: var(--placeholder-color);

    font-family: inherit;
    font-style: var(--placeholder-font-style);
    font-weight: var(--placeholder-font-weight);

    opacity: var(--placeholder-opacity);
  }

  &:-webkit-autofill {
    background-color: transparent;
  }
}

.native-input[disabled] {
  opacity: .4;
}



// Input Cover: Unfocused
// --------------------------------------------------
// The input cover is the div that actually receives the
// tap/click event when scroll assist is configured to true.
// This make it so the native input element is not clickable.
// This will only show when the scroll assist is configured
// otherwise the .input-cover will not be rendered at all
// The input cover is not clickable when the input is disabled

.input-cover {
  @include position(0, null, null, 0);

  position: absolute;

  width: 100%;
  height: 100%;
}

:host([disabled]) .input-cover {
  pointer-events: none;
}


// Clear Input Icon
// --------------------------------------------------

.input-clear-icon {
  @include margin(0);
  @include padding(0);
  @include background-position(center);

  border: 0;

  outline: none;

  background-color: transparent;
  background-repeat: no-repeat;

  visibility: hidden;
  appearance: none;
}

:host(.has-focus.has-value) .input-clear-icon {
  visibility: visible;
}


// Input Has focus
// --------------------------------------------------
// When the input has focus, then the input cover should be hidden

:host(.has-focus) .input-cover {
  display: none;
}

:host(.has-focus) {
  pointer-events: none;
}

:host(.has-focus) input,
:host(.has-focus) a,
:host(.has-focus) button {
  pointer-events: auto;
}
