@import '../../styles/mixins/text-ellipsis.scss';

.nut-uploader {
  position: relative;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;

  &__slot {
    position: relative;
    margin-bottom: 2px;
  }

  &__upload {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: $uploader-background;
    width: $uploader-image-height;
    height: $uploader-image-height;
    border: $uploader-image-border;
    border-radius: $uploader-image-border-radius;
    &.col-3 {
      width: $uploader-image-height;
      height: $uploader-image-height;
    }
    &.col-4 {
      width: 71px;
      height: 71px;
    }
  }

  &__icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 $spacing-2;

    i {
      line-height: 1;
    }

    &-tip {
      font-size: $uploader-image-icon-tip-font-size;
      color: $uploader-image-icon-tip-color;
      margin-top: $uploader-image-icon-margin-bottom;
    }

    .iconfont {
      font-size: 20px;
    }
  }

  &__input {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden;
    cursor: pointer !important;
    opacity: 0;

    &:disabled {
      cursor: not-allowed;
    }
  }

  &__upload-disabled {
    background: $uploader-background-disabled;

    .nut-uploader__icon {
      i {
        opacity: 0.3;
        margin-bottom: $uploader-image-icon-margin-bottom;
      }
    }
  }

  &__upload__multiple {
    width: calc((100% - 24px) / 3) !important;
    aspect-ratio: 1/1;
    height: auto !important;
    margin-bottom: $uploader-preview-margin-bottom;
  }

  &__preview {
    position: relative;
    margin-right: $uploader-preview-margin-right;
    margin-bottom: $uploader-preview-margin-bottom;
    border-radius: $uploader-image-border-radius;
    overflow: hidden;
    &.last-row {
      margin-right: 0;
    }

    &.single {
      margin: 0;
    }

    &.multiple {
      width: calc((100% - 24px) / 3) !important;
    }
    &.error {
      .nut-uploader__preview__progress {
        box-sizing: border-box;
      }
    }

    &__progress {
      position: absolute;
      left: 0;
      top: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      background: $uploader-preview-progress-background;
      border-radius: $uploader-image-border-radius;
      z-index: 99;

      i,
      img {
        margin-bottom: $uploader-image-icon-margin-bottom;
      }
      
      img {
        border: 0 none;
        vertical-align: bottom;
        -ms-interpolation-mode: bicubic;
      }

      &__msg {
        color: #fff;
        font-size: $font-size-1;
        line-height: 1.5;
      }

      .extra-loading-style {
        margin-bottom: 1px;
        padding-top: 2px;
      }
    }

    &.list {
      width: 100%;
      margin-right: 0px;
      margin-bottom: 0px;
      margin-top: 12px;
      border-radius: $uploader-image-border-radius;
      overflow: hidden;
      box-shadow:
        0px 2px 4px -2px rgba(0, 0, 0, 0.02),
        0px 2px 4px 0px rgba(0, 0, 0, 0.02),
        0px 4px 8px 4px rgba(0, 0, 0, 0.04);
    }

    &-list {
      width: 100%;
      height: 42px;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 16px;
      background-color: $color-background;

      .nut-uploader__preview-img__file__name {
        flex: 1;
        padding: 0 10px;
        color: $color-title !important;
        font-size: $font-size-2;
        display: block;
        @include text-ellipsis;
        &.success {
          color: $color-title !important;
        }
      }
      .icon-file,
      .icon-delete {
        font-size: 16px;
        color: $color-title;
      }

      .nut-progress {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;

        .nut-progress-outer {
          height: 2px !important;
        }
      }
    }

    .close {
      position: absolute;
      right: $uploader-preview-close-right;
      top: $uploader-preview-close-top;
      font-size: 20px;
      line-height: 20px;
      color: $color-mask;
      z-index: 999;
      cursor: pointer;
    }

    &-img {
      position: relative;
      width: $uploader-image-height;
      height: $uploader-image-height;
      background: #f8f8f8;
      border-radius: $uploader-image-border-radius;
      overflow: hidden;
      &.col-3 {
        width: $uploader-image-width;
        height: $uploader-image-height;
      }
      &.col-4 {
        width: 70px;
        height: 70px;
      }

      &.multiple {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1/1;
      }

      i {
        color: $color-title;
      }

      .tips {
        position: absolute;
        bottom: 0;
        left: 0;
        font-size: $font-size-1;
        color: $color-white;
        text-align: center;
        box-sizing: border-box;
        height: $uploader-preview-tips-height;
        line-height: $uploader-preview-tips-height;
        border-radius: $uploader-image-border-radius;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        padding: $uploader-preview-tips-padding;
        background: $uploader-preview-tips-background;
        @include oneline-ellipsis();
      }

      &__c {
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        position: initial;
        border-radius: $uploader-image-border-radius;
      }

      &__file {
        height: 100%;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s;

        &__name {
          display: flex;
          width: 90%;
          font-size: $font-size-1;
          color: $color-text;

          &.error {
            color: red !important;
          }

          &.success {
            color: #1890ff !important;
          }

          .nut-icon-link {
            &::before {
              margin-left: -45%;
              margin-top: -45%;
              transform: none;
            }
          }

          @include moreline-ellipsis();
        }
      }
    }
  }
}
