@use '../../styles/global';
@use '~styles/breakpoints.scss' as *;

@mixin apply-color($color) {
  &.containerFocus {
    color: $color;
  }

  .inputWrapper {
    .label {
      &.labelAnimate {
        color: $color;
      }
    }
  }
}

.container {
  width: 100%;

  color: global.$secondaryGray;
  font-size: 1.4rem;

  margin-top: 1rem;

  letter-spacing: 0;

  &.containerError {
    color: global.$secondaryRed;
  }

  &.containerFocus {
    color: global.$secondaryPurple;
  }

  &.containerFilled {
    color: #34495e;
  }

  .inputWrapper {
    width: 100%;
    height: 5.6rem;

    display: none;

    align-items: center;

    justify-content: space-between;

    position: relative;

    .label {
      color: currentColor;
      font-size: 1.4rem;

      position: absolute;

      top: 19px;
      left: 50px;

      transform: translate3d(0, 0, 0);

      transition: all 0.2s ease-in-out;

      pointer-events: none;

      &.labelAnimate {
        color: global.$secondaryPurple;
        font-size: 1rem;

        transform: translate3d(-3.6rem, -2.45rem, 0);
      }

      &.labelError {
        color: global.$secondaryRed;
      }

      &.labelFilled {
        color: global.$secondaryGray;
      }
    }

    .input {
      width: 100%;

      color: #000;
      font-size: 1.1rem;

      padding: 1.6rem 4rem;
      border: 0;
      box-sizing: border-box;

      position: absolute;

      background: none;

      &:focus {
        outline: 0;
      }

      &::placeholder {
        color: transparent;
      }
    }

    .fieldset {
      padding: 0 0.8rem;
      border: 1px solid currentColor;

      position: absolute;
      top: -5px;
      right: 0;
      bottom: 0;
      left: 0;

      border-radius: 4px;

      pointer-events: none;

      &.fieldsetFocus {
        border: 2px solid;
      }

      &.fieldsetError {
        border: 2px solid global.$secondaryRed;
      }

      .legend {
        width: auto;
        max-width: 0.01px;
        height: 11px;

        display: block;

        text-align: left;

        padding: 0;

        transition: max-width 50ms cubic-bezier(0, 0, 0.2, 1) 0ms;

        visibility: hidden;

        &.legendFocus {
          max-width: 100%;
        }

        &.legendFilled {
          width: auto;
        }

        .legendTitle {
          font-size: 1rem;

          padding: 0 0.2rem;
        }
      }
    }
  }

  .iconLeft {
    width: 20px;
    height: 20px;

    display: flex;

    align-items: center;

    position: absolute;
    left: 15px;
  }

  .iconRight {
    width: 20px;
    height: 20px;

    display: flex;

    align-items: center;

    position: absolute;
    right: 15px;

    z-index: 11;

    &:hover {
      transform: scale(0.94);

      cursor: pointer;
    }
  }

  .errorWrapper {
    display: flex;

    align-items: center;

    color: currentColor;
    font-weight: normal;

    margin: 0.5rem 0 0 0.5rem;

    .errorMessage {
      color: global.$secondaryRed;
      text-align: start;
      font-size: 1.1rem;

      margin-bottom: -0.1rem;
    }
  }
}

@include from905 {
  .container {
    margin-bottom: 2.4rem;

    .inputWrapper {
      display: flex;
    }
  }
}
