@import './colors';
@import './typography';
@import './mixins';

$form-control_color: $deep-gray;
$form-control--dark_color: $deep-gray;
$form-control_bgcolor: $white;
$form-control--dark_bgcolor: $light-gray;
$form-control--disabled_bgcolor: $faint-gray;
$form-control_border-color: $gray;
$form-control--dark_border-color: $gray-80;
$form-control-border: 1px solid $form-control_border-color;
$form-control-border-color-focus: $primary-color;
$form-control-padding-x: 12px;
$form-control-padding-y: 9px;
$form-control-height: 35px;
$form-control-small-height: 28px;
$form-control-font-size: $bodyFontSize5;
$form-control-line-height: 17px;
$form-control-font-weight: 400;
$form-control-border-radius: 3px;
$form-control-box-shadow-color: $deepest-gray;
$form-control-box-shadow: inset 0 1px 3px rgba($form-control-box-shadow-color, 0.1);
$form-control-placeholder-color: $form-control_border-color;

$form-checkbox-group-spacing: 2px;
$form-checkbox-label-line-height: 24px;

$form-label-font-size: $bodyFontSize5;
$form-label-margin-bottom: 4px;

$form-error-color: $red;
$form-error-font-size: $bodyFontSize6;
$form-error-margin-top: 7px;

$checkbox-control-border-color: $gray;
$checkbox-control-check-color: $white;
$checkbox-control-active-bgcolor: $primary-color;
$checkbox-control-animation-duration: 0.1s;
$checkbox-control-size: 18px;

%form-control {
    display: block;
    width: 100%;
    height: $form-control-height;
    padding: 0 $form-control-padding-x;
    background-color: $form-control_bgcolor;
    border: $form-control-border;
    font-size: $form-control-font-size;
    line-height: $form-control-line-height;
    font-weight: $form-control-font-weight;
    border-radius: $form-control-border-radius;
    box-shadow: $form-control-box-shadow;
    color: $form-control_color;

    &::placeholder { 
        color: $form-control-placeholder-color;
    }

    &:read-only,
    &:disabled {
        background-color: $faint-gray;
    }
}

%form-control-with-error {
    border-color: $form-error-color;
}

%form-control-with-addon {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

%form-label {
    display: inline-block;
    margin-bottom: $form-label-margin-bottom;
    font-size: $form-label-font-size;
    font-weight: 700;
}

%input-error {
    display: block;
    margin: $form-error-margin-top 0 0;
    color: $form-error-color;
    font-size: $form-error-font-size;
}

%form-hint {
    display: block;
    margin-top: 8px;
    @include text-6;
}

%form-addon {
    @include text-6;
    display: flex;
    align-items: center;
    padding: 0 9px;
    background-color: $form-control--dark_bgcolor;
    color: $form-control--dark_color;
    border-top: $form-control-border;
    border-left: $form-control-border;
    border-bottom: $form-control-border;
    border-top-left-radius: $form-control-border-radius;
    border-bottom-left-radius: $form-control-border-radius;
}

%form-select {
    height: $form-control-height;
    background-color: $form-control_bgcolor;
    border-radius: $form-control-border-radius;
    border: $form-control-border;
    box-shadow: $form-control-box-shadow;
}

%form-fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

%form-control-search {
    /* clears the ‘X’ from input search */
    &::-webkit-search-decoration,
    &::-webkit-search-cancel-button,
    &::-webkit-search-results-button,
    &::-webkit-search-results-decoration {
        display: none;
    }
    &::-ms-clear,
    &::-ms-reveal { display: none; width : 0; height: 0; }
}

%form-checkbox-before {
  content: '';
  position: absolute;
  top: $form-checkbox-label-line-height / 2;
  left: 0;
  width: $checkbox-control-size;
  height: $checkbox-control-size;
  background-color: $checkbox-control-check-color;
  border: 1px solid $checkbox-control-border-color;
  border-radius: 4px;
  transform: translateY(-50%);
  transition: border $checkbox-control-animation-duration cubic-bezier(.4,.0,.23,1);
}

%form-checkbox-after {
  content: '';
  position: absolute;
  top: $form-checkbox-label-line-height / 2;
  left: $checkbox-control-size / 2;
  width: 10px;
  height: 5px;
  border-left: 2px solid $white;
  border-bottom: 2px solid $white;
  opacity: 0;
  transform: translate(-50%, -75%) rotate(-45deg);
  transition: opacity 0.2s ease $checkbox-control-animation-duration;
}

%form-checkbox-checked-before {
  border: $checkbox-control-size / 2 solid $checkbox-control-active-bgcolor;
  animation: shrink-bounce 200ms cubic-bezier(.4,.0,.23,1);
}

%form-checkbox-text {
  position: relative;
  display: inline-block;
  cursor: pointer;
  padding-left: $checkbox-control-size + 10px;
  font-size: $bodyFontSize5;
  line-height: $form-checkbox-label-line-height;
}

@mixin content-dropdown-label {
    @include title-5;
    margin-bottom: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-weight: 500;
    svg {
        width: 13px;
        margin-left: 8px;
    }
    &--closed {
        svg {
            transform: rotate(180deg);
        }
    }
}
