/*! _forms.scss | Friendkit | © Css Ninja. 2020-2021 */

/* ==========================================================================
Form controls styles
========================================================================== */

/*
    0. Input and textarea shared styles
    1. Input styles
    2. Textarea styles
    3. Control wrappers
    4. Combo Box
    5. Custom select
*/

/* ==========================================================================
1. Input and textarea shared styles
========================================================================== */

.input,
.textarea {
  box-shadow: none !important;

  &.is-light {
    &::-webkit-input-placeholder {
      color: $placeholder;
    }

    &::-moz-placeholder {
      color: $placeholder;
    }

    &:-ms-input-placeholder {
      color: $placeholder;
    }

    &:-moz-placeholder {
      color: $placeholder;
    }
  }

  &.is-dark {
    color: lighten($sidebar, 40%) !important;

    &::-webkit-input-placeholder {
      color: lighten($sidebar, 25%) !important;
    }

    &::-moz-placeholder {
      color: lighten($sidebar, 25%) !important;
    }

    &:-ms-input-placeholder {
      color: lighten($sidebar, 25%) !important;
    }

    &:-moz-placeholder {
      color: lighten($sidebar, 25%) !important;
    }
  }
}

/* ==========================================================================
1. Input styles
========================================================================== */

.input {
  font-size: 0.9rem;
  height: 36px;
  border-radius: 0.65rem;
  transition: all 0.3s;

  &:focus {
    border-color: $accent;
  }

  &.is-sm {
    height: 32px;
    font-size: 0.9rem;
  }

  &.no-radius {
    border-radius: 1px;
  }

  &.is-fade {
    &:hover {
      border: 1px solid darken($fade-grey, 2%);
    }

    &:focus {
      border: 1px solid darken($fade-grey, 2%);
      box-shadow: $light-box-shadow !important;
    }
  }

  &.is-bordered {
    &:focus {
      border-color: $medium-text;
    }
  }
}

/* ==========================================================================
2. Textarea styles
========================================================================== */

.textarea {
  font-size: 0.9rem;
  border-radius: 0.65rem;
  transition: all 0.3s;

  &.is-sm {
    font-size: 0.9rem;
    resize: none;
  }

  &.no-radius {
    border-radius: 1px;
  }

  &.is-fade {
    &:hover {
      border: 1px solid darken($fade-grey, 2%);
    }

    &:focus {
      border: 1px solid darken($fade-grey, 2%);
      box-shadow: $light-box-shadow !important;
    }
  }
}

/* ==========================================================================
3. Control wrappers
========================================================================== */

.field {
  label {
    font-size: 0.9rem;
    font-weight: 500;
    color: $dark-text;
  }
}

.control {
  &.has-icon {
    position: relative;

    .form-icon {
      position: absolute;
      top: 0;
      left: 0;
      height: 36px;
      width: 36px;
      display: flex;
      justify-content: center;
      align-items: center;

      svg {
        height: 20px;
        width: 20px;
        stroke: $placeholder;
        transition: all 0.3s;
      }
    }

    .input {
      height: 36px;
      padding-left: 40px;

      &:focus {
        + .form-icon svg {
          stroke: $accent;
        }
      }
    }
  }

  &.has-validation {
    position: relative;

    .error-icon {
      position: absolute;
      top: 0;
      right: 0;
      height: 36px;
      width: 36px;
      display: flex;
      justify-content: center;
      align-items: center;
      opacity: 0;
      transition: opacity 0.3s;

      svg {
        height: 16px;
        width: 16px;
        stroke: $red;
      }
    }

    .success-icon {
      position: absolute;
      top: 0;
      right: 0;
      height: 36px;
      width: 36px;
      display: flex;
      justify-content: center;
      align-items: center;
      opacity: 0;
      transition: opacity 0.3s;

      svg {
        height: 16px;
        width: 16px;
        stroke: $green;
      }
    }

    &.has-error {
      input {
        border-color: $red !important;

        + label {
          font-size: 0.75rem;
          color: $red;
        }
      }

      .error-icon {
        opacity: 1;
      }

      .success-icon {
        opacity: 0;
      }
    }

    &.has-success {
      input {
        border-color: $green !important;
      }

      .error-icon {
        opacity: 0;
      }

      .success-icon {
        opacity: 1;
      }
    }
  }
}

/* ==========================================================================
4. Combo Box
========================================================================== */

.is-combo {
  .combo-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: $muted-grey;
  }

  .combo-box,
  .image-combo-box,
  .stacked-combo-box,
  .user-combo-box {
    position: relative;
    background: $white;
    border: 1px solid $accent-grey;
    border-radius: 4px;
    height: 40px;
    margin-top: 4px;
    cursor: pointer;
    transition: all 0.3s;

    &.has-rounded-images {
      .combo-item img,
      .item-icon img {
        border-radius: 50%;
      }
    }

    &.is-scrollable {
      .box-dropdown .dropdown-inner {
        max-height: 190px;
        overflow-y: auto;
      }
    }

    .box-inner {
      display: flex;
      justify-content: space-between;
      align-items: center;

      .combo-item {
        display: flex;
        align-items: center;
        height: 40px;
        padding-left: 8px;

        i {
          color: $muted-grey;
          font-size: 18px;
        }

        .fa {
          font-size: 14px;

          &.is-green {
            color: $green;
          }

          &.is-blue {
            color: $blue;
          }

          &.is-orange {
            color: $orange;
          }

          &.is-red {
            color: $red;
          }
        }

        img {
          display: block;
          height: 22px;
          width: 22px;
          object-fit: contain;
          margin-right: 8px;

          &.is-stacked {
            height: 26px;
            width: 26px;
            border: 2px solid $white;
            margin-right: 0 !important;

            &:not(:first-child) {
              $var: 9;

              @for $i from 1 through 5 {
                &:nth-child(#{$i}) {
                  margin-left: -#{$var}px;
                }
              }
            }
          }
        }

        .avatar-container {
          position: relative;
          display: block;
          height: 26px;
          width: 26px;

          .avatar {
            display: block;
            height: 26px;
            width: 26px;
            border-radius: 50%;
          }

          .badge {
            position: absolute;
            bottom: 0;
            right: -6px;
            height: 16px;
            width: 16px;
            border-radius: 50%;
            border: 2px solid $white;
            margin: 0;
          }
        }

        span {
          display: block;
          color: $dark-text;
          font-size: 0.9rem;
          font-weight: 500;
          margin-left: 8px;

          &.is-pushed {
            margin-left: 18px;
          }
        }
      }
    }

    .box-chevron {
      position: absolute;
      top: 0;
      right: 0;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 40px;
      width: 40px;

      svg {
        height: 18px;
        width: 18px;
        stroke: $dark-text;
        transform: rotate(0);
        transition: all 0.3s;
      }
    }

    .box-dropdown {
      position: absolute;
      top: 32px;
      left: 0;
      width: 100%;
      z-index: 50;
      opacity: 0;
      transform: translateY(20px);
      pointer-events: none;
      transition: all 0.3s;

      &.is-dropup {
        top: -165px;
        height: 148px;

        .dropdown-inner {
          overflow-y: auto;
        }
      }

      .dropdown-inner {
        position: relative;
        width: 100%;
        height: 100%;
        background: $white;
        border: 1px solid $accent-grey;
        border-radius: 4px;
        margin-top: 10px;
        max-height: 190px;
        overflow-y: auto;

        ul {
          padding: 10px 0;

          li {
            padding: 6px 8px;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            width: 100%;

            .item-icon {
              position: relative;
              display: flex;
              justify-content: center;
              align-items: center;
              height: 30px;
              width: 30px;
              margin-right: 8px;

              i {
                color: $muted-grey;
                font-size: 20px;
              }

              .fa {
                font-size: 16px;
                position: relative;
                top: 5px;

                &.is-green {
                  color: $green;
                }

                &.is-blue {
                  color: $blue;
                }

                &.is-orange {
                  color: $orange;
                }

                &.is-red {
                  color: $red;
                }
              }

              img {
                display: block;
                height: 22px;
                width: 22px;
                object-fit: contain;
                transition: opacity 0.3s;

                &.faded-img {
                  opacity: 0.4;
                }
              }

              .avatar {
                display: block;
                height: 22px;
                width: 22px;
                border-radius: 50%;
              }

              .badge {
                position: absolute;
                bottom: 0;
                right: 0;
                height: 12px;
                width: 12px;
                border-radius: 50%;
                border: 2px solid $white;
              }
            }

            .checkmark {
              display: flex;
              justify-content: center;
              align-items: center;
              height: 16px;
              width: 16px;
              margin-right: 8px;
              margin-left: auto;
              opacity: 0;
              transition: all 0.3s;

              svg {
                stroke: $accent;
                stroke-width: 3px;
                height: 16px;
                width: 16px;
              }
            }

            span {
              display: block;
              color: $muted-grey;
              font-size: 0.9rem;
              font-weight: 500;
            }

            &:hover {
              background: lighten($fade-grey, 2%);
            }

            &.is-active {
              .item-icon {
                i {
                  color: $dark-text;
                }

                .faded-img {
                  opacity: 1;
                }
              }

              span {
                color: $dark-text;
              }

              .checkmark {
                opacity: 1;
              }
            }
          }
        }
      }
    }

    &.is-active {
      border-color: $fade-grey;

      .box-chevron svg {
        transform: rotate(180deg);
      }

      .box-dropdown {
        opacity: 1;
        transform: translateY(0);
        pointer-events: all;
      }
    }
  }

  .help-text {
    font-size: 0.75rem;
    color: $muted-grey;
  }

  .big-combo-box {
    position: relative;
    background: $white;
    border: 1px solid $accent-grey;
    border-radius: 4px;
    height: 58px;
    margin-top: 4px;
    cursor: pointer;
    transition: all 0.3s;

    .box-inner {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 100%;

      .combo-item {
        display: flex;
        align-items: center;
        height: 58px;
        padding-left: 8px;

        i {
          color: $accent;
          font-size: 1.6rem;
        }

        .combo-text {
          margin-left: 16px;

          span {
            display: block;

            &:first-child {
              color: $dark-text;
              font-size: 0.9rem;
              font-weight: 500;
            }

            &:nth-child(2) {
              color: $muted-grey;
              font-size: 0.8rem;
              max-width: 330px;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
            }
          }
        }
      }
    }

    .box-chevron {
      position: absolute;
      top: 0;
      right: 0;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 58px;
      width: 58px;

      svg {
        height: 18px;
        width: 18px;
        stroke: $dark-text;
        transform: rotate(0);
        transition: all 0.3s;
      }
    }

    .box-dropdown {
      position: absolute;
      top: 54px;
      left: 0;
      width: 100%;
      z-index: 50;
      opacity: 0;
      transform: translateY(20px);
      pointer-events: none;
      transition: all 0.3s;

      .dropdown-inner {
        position: relative;
        width: 100%;
        height: 100%;
        background: $white;
        border: 1px solid $accent-grey;
        border-radius: 4px;
        margin-top: 10px;
        max-height: 190px;
        overflow-y: auto;
        overflow-x: hidden;

        ul {
          padding: 10px 0;

          li {
            padding: 6px 8px;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            width: 100%;

            .item-icon {
              display: flex;
              justify-content: center;
              align-items: center;
              height: 30px;
              width: 30px;
              min-height: 30px;
              min-width: 30px;
              margin-right: 16px;

              i {
                color: $muted-grey;
                font-size: 1.6rem;
              }
            }

            .item-name {
              span {
                display: block;

                &:first-child {
                  color: $dark-text;
                  font-size: 0.9rem;
                  font-weight: 500;
                }

                &:nth-child(2) {
                  color: $muted-grey;
                  font-size: 0.8rem;
                  white-space: nowrap;
                  overflow: hidden;
                  text-overflow: ellipsis;
                }
              }
            }

            &:hover {
              background: lighten($fade-grey, 2%);
            }

            &.is-active {
              .item-icon i {
                color: $accent;
              }

              span {
                color: $dark-text;
              }
            }
          }
        }
      }
    }

    &.is-active {
      border-color: $fade-grey;

      .box-chevron svg {
        transform: rotate(180deg);
      }

      .box-dropdown {
        opacity: 1;
        transform: translateY(0);
        pointer-events: all;
      }
    }
  }
}

/* ==========================================================================
5. Custom select
========================================================================== */

.custom-select {
  width: 100%;
  z-index: 3;

  &.is-dropup {
    .select-drop {
      top: -100%;
    }
  }

  .select-box {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 40px 0 10px;
    height: 36px;
    width: 100%;
    border: 1px solid $accent-grey;
    border-radius: 4px;
    color: darken($accent-grey, 20%);
    background: $white;
    cursor: pointer;
    transition: all 0.3s;

    &:hover {
      border-color: $fade-grey;
    }
  }

  .select-icon {
    position: absolute;
    top: 0;
    right: 0;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
    transform: rotate(0);

    svg {
      height: 20px;
      width: 20px;
      stroke: darken($placeholder, 8%) !important;
      transition: all 0.3s;
    }
  }

  .select-drop {
    position: absolute;
    top: 40px;
    left: 0;
    width: 100%;
    min-height: 135px;
    max-height: 138px;
    overflow-y: auto;
    background: $white;
    border: 1px solid $fade-grey;
    border-radius: 4px;
    z-index: 5;
    transition: all 0.3s;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;

    .drop-inner {
      position: relative;
      height: 100%;
      width: 100%;
      background: $white;

      .option-row {
        position: relative;
        display: flex;
        background: $white;

        input {
          position: absolute;
          top: 0;
          left: 0;
          height: 100%;
          width: 100%;
          opacity: 0;
          cursor: pointer;

          &:checked + .option-meta {
            background: lighten($fade-grey, 4%);

            span {
              color: $dark-text;
            }

            svg {
              &.is-purple {
                stroke: $purple;
              }
            }
          }
        }

        .option-meta {
          padding: 12px;
          width: 100%;
          display: flex;
          align-items: center;

          img {
            display: block;
            max-height: 20px;
          }

          svg {
            height: 20px;
            width: 20px;
            stroke: $placeholder;

            &.is-small {
              height: 14px;
              width: 14px;
            }
          }

          span {
            display: block;
            font-weight: 500;
            color: $muted-grey;
            font-size: 0.9rem;
            margin-left: 8px;
          }
        }
      }
    }
  }

  &.is-active {
    .select-drop {
      opacity: 1;
      transform: translateY(0);
      pointer-events: all;
    }

    .select-icon {
      transform: rotate(180deg);
    }
  }

  &.is-accounts {
    .option-meta {
      img {
        max-height: 36px !important;
        border-radius: 50%;
      }
    }
  }
}

/* ==========================================================================
6. Autocomplete with tag input
========================================================================== */

.tokenize {
  border: 1px solid darken($fade-grey, 3%);
  border-radius: 4px;
  transition: all 0.3s;

  &.focus {
    .tokens-container {
      box-shadow: $light-box-shadow;
    }
  }

  .tokens-container {
    transition: all 0.3s;
  }
}
