@import '../variables';
@import '../theme-colors';

@mixin form-inputs {
  height: auto !important;
  font-size: 100% !important;
  border-radius: 5px !important;
  padding: $default-input-box-padding !important;
  border-color: var(--default-border-color) !important;
}

label {
  color: var(--default-font-color) !important;
}

::placeholder {
  color: $muted-color !important;
}

textarea {
  width: 100%;
  outline: none;
  display: block;
  line-height: 1.5;
  font-weight: 400;
  font-size: 100% !important;
  background-clip: padding-box;
  border-radius: 5px !important;
  color: var(--default-font-color);
  background-color: var(--form-control-bg);
  padding: $default-input-box-padding !important;
  border-color: var(--default-border-color) !important;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;

  &:focus {
    box-shadow: none;
    color: var(--default-font-color);
    background-color: var(--form-control-bg);
    border-color: $inputs-focus-color !important;
  }
}

input {
  &[type='color'] {
    height: 42px !important;
  }
}

.form-control {
  @include form-inputs;
  color: var(--default-font-color);
  background-color: var(--form-control-bg);

  &:focus {
    box-shadow: none;
    color: var(--default-font-color);
    background-color: var(--form-control-bg);
    border-color: $inputs-focus-color !important;
  }
}

.form-control:disabled,
.form-control[readonly] {
  background-color: var(--bg-input-readonly);
}

// Form group with icon
.form-group-with-icon {
  display: flex;
  position: relative;
  align-items: center;

  .form-control {
    background-color: var(--form-control-bg);

    &.text-right-padding {
      padding-right: 44px !important;
    }
  }

  .form-control-feedback {
    position: absolute;
    right: 0;
    padding: 0 14px;
    display: inline-block;
    color: lighten($muted-color, 5%);
    transition: all $default-transition-duration $action-transition-timing-function;

    &.disabled {
      color: lighten($muted-color, 23%);
    }

    &:hover {
      color: $brand-color;
    }
  }
}

// After form validation
label {
  &.error {
    color: $danger-color !important;
  }
}

.form-control, textarea {
  &.error {
    border-color: $danger-color !important;
  }
}

// SCSS for RTL Layout
[dir="rtl"] {
  .form-group > label {
    display: block;
    text-align: start;
  }
}
