// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE in the project root for license information.

//
// Office UI Fabric
// --------------------------------------------------
// Single line (input) and multiline (textarea) form field styles


@import '../Label/Label.scss';


.ms-TextField {
  @include ms-font-m;
  @include ms-u-normalize;
  margin-bottom: 8px;
}

//= State: A disabled textfield
.ms-TextField.is-disabled {
  .ms-TextField-field {
    background-color: $ms-color-neutralLighter;
    border-color: $ms-color-neutralLighter;
    pointer-events: none;
    cursor: default;
  }

  @include input-placeholder {
    color: $ms-color-neutralTertiary;
  }
}

//= State: A required textfield
.ms-TextField.is-required {
  .ms-Label {
    @include ms-Label-is-required
  }

  @include input-placeholder {
    @include ms-Label-is-required
  }
}

//= State: An active textfield
.ms-TextField.is-active {
  border-color: $ms-color-themePrimary;
}

.ms-TextField-field {
  @include ms-u-normalize;
  border: 1px solid $ms-color-neutralTertiaryAlt;
  border-radius: 0;
  font-family: $ms-font-family-semilight;
  font-size: $ms-font-size-s;
  color: $ms-color-neutralPrimary;
  height: 32px;
  padding: 6px 10px 8px;
  width: 100%;
  min-width: 180px;
  outline: 0;

  &:hover {
    border-color: $ms-color-neutralSecondaryAlt;
  }

  &:focus {
    border-color: $ms-color-themePrimary;
  }

  &:hover,
  &:focus {
    @media screen and (-ms-high-contrast: active) {
      border-color: $ms-color-contrastBlackSelected;
    }

    @media screen and (-ms-high-contrast: black-on-white) {
      border-color: $ms-color-contrastWhiteSelected;
    }
  }

  @include input-placeholder {
    color: $ms-color-neutralSecondary;
  }
}

.ms-TextField-description {
  color: $ms-color-neutralSecondaryAlt;
  font-size: $ms-font-size-xs;
}


//== Modifier: Single line (default), placeholder label
//
.ms-TextField.ms-TextField--placeholder {
  position: relative;

  .ms-Label {
    position: absolute;
    font-family: $ms-font-family-semilight;
    font-size: $ms-font-size-s;
    color: $ms-color-neutralSecondary;
    padding: 7px 0 7px 10px;
  }

  &.is-disabled {
    color: $ms-color-neutralTertiary;

    .ms-Label {
      @include ms-Label-is-disabled;
    }
  }
}


//== Modifier: Single line (default), underlined
//
.ms-TextField.ms-TextField--underlined {
  border-bottom: 1px solid $ms-color-neutralTertiaryAlt;
  display: table;
  width: 100%;
  min-width: 180px;

  &:hover {
    border-color: $ms-color-neutralSecondaryAlt;

    @media screen and (-ms-high-contrast: active) {
      border-color: $ms-color-contrastBlackSelected;
    }

    @media screen and (-ms-high-contrast: black-on-white) {
      border-color: $ms-color-contrastWhiteSelected;
    }
  }

  &:active,
  &:focus {
    border-color: $ms-color-themePrimary;
  }

  .ms-Label {
    font-size: $ms-font-size-s;
    margin-right: 8px;
    display: table-cell;
    vertical-align: bottom;
    padding-left: 12px;
    padding-bottom: 5px;
    height: 32px;
    width: 1%;
    white-space: nowrap;
  }

  .ms-TextField-field {
    border: 0;
    float: left;
    display: table-cell;
    text-align: left;
    padding-top: 8px;
    padding-bottom: 2px;

    &:active,
    &:focus,
    &:hover {
      outline: 0;
    }
  }

  &.is-disabled {
    border-bottom-color: $ms-color-neutralLight;

    .ms-Label {
      @include ms-Label-is-disabled;
    }

    .ms-TextField-field {
      background-color: transparent;
      color: $ms-color-neutralTertiary;
    }
  }

  &.is-active {
    border-color: $ms-color-themePrimary;

    @media screen and (-ms-high-contrast: active) {
      border-color: $ms-color-contrastBlackSelected;
    }

    @media screen and (-ms-high-contrast: black-on-white) {
      border-color: $ms-color-contrastWhiteSelected;
    }
  }
}


//== Modifier: Multiline textfield
//
.ms-TextField.ms-TextField--multiline {
  .ms-TextField-field {
    @include ms-font-s;
    line-height: 17px;
    min-height: 60px;
    min-width: 260px;
    padding-top: 6px;
    overflow: auto;
  }
}
