// Copyright 2018-Present Okta, Inc.

// 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.

.ods-field--hint,
.ods-field--error {
  font-size: $size-body-caption;
}

.ods-field--hint {
  margin-bottom: $spacing-xs;
  color: $text-body;

  .ods-text-input:disabled ~ &,
  .ods-text-input[readonly] ~ & {
    color: $text-sub;
  }
}

.ods-field--error {
  display: flex;
  align-items: center;
  margin-top: $spacing-xs;
  color: $text-danger;
}

.ods-fieldset--pair {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  .ods-number-input,
  .ods-text-input,
  .ods-select {
    width: calc(50% - #{$spacing-s});
  }
}

.ods-fieldset-flex {
  display: flex;
  flex-direction: column;
  max-width: $max-line-length;

  .ods-label,
  .ods-input-legend {
    order: 1;
    margin-bottom: $spacing-xs;
  }

  .ods-number-input,
  .ods-text-input,
  .ods-select,
  .ods-input--unavailable,
  .ods-fieldset--pair,
  output:not([class]) {
    order: 3;
  }

  .ods-input--unavailable {
    margin: 0;
  }

  /* stylelint-disable-next-line no-descending-specificity  */
  .ods-field--hint {
    order: 2;
    margin-bottom: $spacing-xs;

    + .ods-label {
      margin-bottom: 0;
    }
  }

  .ods-field--error {
    order: 4;
  }
}

.ods-fieldset--attached {
  display: flex;
  max-width: $max-line-length;

  .ods-button {
    border-radius: 0 $base-border-radius $base-border-radius 0;
  }

  .ods-text-input {
    border-right: 0;
    border-radius: $base-border-radius 0 0 $base-border-radius;

    &:focus {
      z-index: 1;
    }
  }
}

/* stylelint-disable-next-line no-descending-specificity  */
.ods-input-legend {
  margin: 0 0 $spacing-xs;
  color: $text-heading;
  font-size: $size-body-base;
  font-weight: 600;
}

.ods-group-legend {
  margin: 0 0 $spacing-s;
  color: $text-heading;
  font-size: $size-body-sentence;
  font-weight: 600;
}
