@import "./input";
@import "./input.md.vars";

// Material Design Input
// --------------------------------------------------

.native-input-md {
  @include placeholder($input-md-placeholder-color);
  @include margin($input-md-margin-top, $input-md-margin-end, $input-md-margin-bottom, $input-md-margin-start);
  @include padding(0);

  width: calc(100% - #{$input-md-margin-end} - #{$input-md-margin-start});

  font-family: $input-md-font-family;
  font-size: $input-md-font-size;
}


// Material Design Inset Input
// --------------------------------------------------

.input-md .inset-input {
  @include padding($input-md-inset-padding-top, $input-md-inset-padding-end, $input-md-inset-padding-bottom, $input-md-inset-padding-start);
  @include margin($input-md-inset-margin-top, $input-md-inset-margin-end, $input-md-inset-margin-bottom, $input-md-inset-margin-start);
}


// Material Design Highlighted Input
// --------------------------------------------------

// Input highlight mixin for focus, valid, and invalid states
@mixin md-input-highlight($highlight-color) {
  border-bottom-color: $highlight-color;
  box-shadow: inset 0 -1px 0 0 $highlight-color;
}

// Show the focus highlight when the input has focus
@if ($input-md-show-focus-highlight) {
  // In order to get a 2px border we need to add an inset
  // box-shadow 1px (this is to avoid the div resizing)

  .item-md.item-input.item-input-has-focus .item-inner {
    @include md-input-highlight($input-md-highlight-color);
  }

  // The last item in a list has a border on the item, not the
  // inner item, so add it to the item itself
  .list-md .item-input.item-input-has-focus:last-child {
    @include md-input-highlight($input-md-highlight-color);

    .item-inner {
      box-shadow: none;
    }
  }
}

// TODO this is angular specific scss

// Show the valid highlight when it has the .ng-valid class and a value
@if ($input-md-show-valid-highlight) {
  .item-md.item-input.ng-valid.item-input-has-value:not(.item-input-has-focus) .item-inner {
    @include md-input-highlight($input-md-highlight-color-valid);
  }

  .list-md .item-input.ng-valid.item-input-has-value:not(.item-input-has-focus):last-child {
    @include md-input-highlight($input-md-highlight-color-valid);

    .item-inner {
      box-shadow: none;
    }
  }
}

// Show the invalid highlight when it has the invalid class and has been touched
@if ($input-md-show-invalid-highlight) {
  .item-md.item-input.ng-invalid.ng-touched:not(.item-input-has-focus) .item-inner {
    @include md-input-highlight($input-md-highlight-color-invalid);
  }

  .list-md .item-input.ng-invalid.ng-touched:not(.item-input-has-focus):last-child {
    @include md-input-highlight($input-md-highlight-color-invalid);

    .item-inner {
      box-shadow: none;
    }
  }
}


// Material Design Stacked & Floating Inputs
// --------------------------------------------------

.item-label-stacked .native-input-md,
.item-label-floating .native-input-md {
  @include margin(8px, null, 8px, 0);

  width: calc(100% - #{$input-md-margin-end});
}


// Material Design Clear Input Icon
// --------------------------------------------------

.input-md[clear-input] {
  position: relative;
}

.input-md[clear-input] .native-input {
  @include padding-horizontal(null, $input-md-input-clear-icon-width);
}

.input-md .native-input-clear-icon {
  @include position-horizontal(null, 0);
  @include svg-background-image($input-md-input-clear-icon-svg);

  width: $input-md-input-clear-icon-width;

  background-color: transparent;
  background-size: $input-md-input-clear-icon-size;
}
