@import "../../settings/includes/colors";
@import "../../tools/includes/browsers/ie";

.o-form {
  width: 100%;

  &--mb32 {
    margin-bottom: 32px;
  }

  &--mt32 {
    margin-top: 32px;
  }
}

.c-form {
  &--input {
    width: 100%;
    position: relative;

    .c-form {
      &-input {
        height: 48px;
        width: 100%;
        padding: 13px 16px 0;
        border: 2px solid map-get($MonoPalette, 60);
        border-radius: 4px;
        font-size: 14px;
        font-weight: 500;
        line-height: 1.29;
        background-color: $White;
        color: map-get($MonoPalette, 70);

        &--custom-icon {
          padding-left: 46px;

          + .c-form-label {
            left: 32px;
          }
        }

        &--card-number {
          padding-left: 54px;

          + .c-form-label {
            left: 40px;
          }
        }

        &--search {
          padding-top: 0;
        }

        &:focus,
        &--focus {
          outline: 0;
          border-color: $Pacific;

          + .c-form-label {
            color: $Pacific;
          }
        }

        &--success {
          &:not([type="search"]):not(:disabled) {
            border-color: $Paradiso;

            + .c-form-label {
              color: $Paradiso;
            }
          }
        }

        &--error {
          &:not(:disabled) {
            border-color: $Demask;

            + .c-form-label {
              color: $Demask;

              + .c-form-message {
                color: $Demask;
              }
            }
          }
        }

        &--success,
        &--error,
        &--loading {
          padding-right: 48px;

          &.c-form-input--focus.c-form-input--character-count {
            padding-right: 96px;
          }
        }

        &:disabled,
        &--loading {
          cursor: not-allowed;
          color: $Mono;

          + .c-form-label {
            pointer-events: none;
          }
        }

        &:disabled {
          background-color: map-get($MonoPalette, 30);
        }

        &--loading {
          background-color: map-get($MonoPalette, 40);
        }

        &--password-text {
          padding-right: 56px;
        }

        &:focus,
        &--active,
        &--focus {
          color: $Fiord;

          + .c-form-label {
            font-size: 10px;
            transform: translateY(0.85em);
            font-weight: bold;

            + .c-form-icon {
              + .c-form-message {
                color: $Fiord;
              }
            }
          }

          &[type="search"] {
            + .c-form-label {
              display: none;
            }
          }
        }

        &:hover {
          &[type="search"] {
            border-color: $Pacific;
          }
        }

        &[type="search"] {
          box-sizing: border-box;

          /* Chrome/Safari/Edge/Opera */
          &::-webkit-search-decoration,
          &::-webkit-search-cancel-button,
          &::-webkit-search-results-button,
          &::-webkit-search-results-decoration {
            -webkit-appearance: none;
          }

          /* IE fix */
          &::-ms-clear,
          &::-ms-reveal {
            display: none;
            width: 0;
            height: 0;
          }
        }

        /* Chrome, Safari, Edge, Opera */
        &[type="number"]::-webkit-outer-spin-button {
          -webkit-appearance: none;
          margin: 0;
        }

        &[type="number"]::-webkit-inner-spin-button {
          -webkit-appearance: none;
          margin: 0;
        }

        /* Firefox */
        &[type="number"] {
          -moz-appearance: textfield;
        }

        @include ie11_above_only('&::-ms-clear') {
          width: 0;
          height: 0;
        }
      }

      &-label {
        position: absolute;
        top: 0;
        margin: 0 16px;
        transform: translateY(1.1em);
        left: 2px;
        width: calc(100% - 34px);
        line-height: 1.4em;
        font-size: 14px;
        font-weight: 500;
        transition: all 0.35s;
        cursor: text;
        color: map-get($MonoPalette, 70);
      }

      &-icon::after {
        content: "";
        display: flex;
        width: 16px;
        height: 16px;
        background-position: center;
        background-repeat: no-repeat;
        background-size: contain;
      }

      &-message {
        font-size: 12px;
        font-weight: 500;
        color: $Fiord;
        display: block;
        clear: both;
        line-height: 1.33;
        margin-top: 8px;

        &--help {
          color: $Mono;
        }
      }

      &-icons {
        > * {
          position: absolute;
          right: 16px;
          top: 12px;
        }

        > .c-spinner {
          right: 12px;
          top: 16px;
        }

        > .c-form-input__character-count,
        .c-form-input__show-password-text {
          top: 18px;
        }

        > .c-form--input-cardtype {
          width: 48px;
          height: 48px;
          left: 6px;
          top: 0;
          padding-right: 4px;

          &-default {
            padding: 0 6px;
          }

          &-loading {
            filter: grayscale(100%);
          }
        }

        > .c-form-input--close {
          cursor: pointer;
          top: 16px;
        }

        &--loading {
          animation: rotation 1s infinite linear;
        }
      }
    }
  }
}

.c-form--input-icon {
  left: 16px;
}

.c-form-input__show-password-text,
.c-form-input__character-count {
  user-select: none;
}

.c-form-input__show-password-text {
  cursor: pointer;
}

@-webkit-keyframes rotation {
  from {
    -webkit-transform: rotate(0deg);
  }

  to {
    -webkit-transform: rotate(359deg);
  }
}
