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

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

  &-slot {
    position: relative;
  }

  &-upload {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: $uploader-background;
    width: $uploader-image-width;
    height: $uploader-image-height;
    border: $uploader-image-border;
    border-radius: $uploader-image-border-radius;
  }

  &-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: $uploader-image-color;

    i,
    .nut-icon {
      color: $uploader-image-color;
      margin-bottom: $uploader-image-icon-margin-bottom;
    }

    &-tip {
      font-size: $uploader-image-icon-tip-font-size;
    }
  }

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

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

  &-upload-disabled {
    background: $uploader-background-disabled;
    color: $uploader-image-disabled;

    .nut-uploader-icon {
      i,
      .nut-icon {
        color: $uploader-image-disabled;
        margin-bottom: $uploader-image-icon-margin-bottom;
      }
    }
  }

  &-preview {
    position: relative;
    margin-right: $uploader-preview-margin-right;
    margin-bottom: $uploader-preview-margin-bottom;
    border-radius: $uploader-image-border-radius;
    box-shadow: 0 scale-px(2px) scale-px(10px) 0 rgb(0 0 0 / 10%);

    &-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: 10;

      i {
        margin-bottom: $uploader-image-icon-margin-bottom;
      }

      &-msg {
        color: $color-text-help;
        font-size: $font-size-s;
      }
    }

    &.list {
      width: 100%;
      margin-right: 0;
      margin-bottom: 0;
      margin-top: scale-px(10px);
      box-shadow: 0 scale-px(2px) scale-px(10px) 0 rgb(0 0 0 / 1%);
    }

    &-list {
      width: 100%;
      height: scale-px(32px);
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 scale-px(10px);
      background-color: $color-background-sunken;

      .nut-uploader-preview-img-file-name {
        display: flex;
        align-items: center;
        -webkit-line-clamp: 1;
        padding: scale-px(2px);
        height: scale-px(24px);
        @include text-ellipsis();
      }

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

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

    .close {
      position: absolute;
      right: $uploader-preview-close-right;
      top: $uploader-preview-close-top;
      transform: translate(50%, -50%);
      z-index: 1;
    }

    &-img {
      position: relative;
      width: $uploader-image-width;
      height: $uploader-image-height;
      border-radius: $uploader-image-border-radius;
      overflow: hidden;

      i {
        color: $color-title;
      }

      .tips {
        position: absolute;
        bottom: 0;
        left: 0;
        font-size: $font-size-s;
        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 {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100%;
        /* #ifndef dynamic*/
        position: initial;
        /* #endif */
        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-s;
          color: $color-text;
          @include moreline-ellipsis();

          &.error {
            color: red !important;
          }

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

          .nut-icon-Link {
            flex-shrink: 0;
          }
        }
      }
    }
  }
}

[dir='rtl'] .nut-uploader,
.nut-rtl .nut-uploader {
  &-input {
    left: auto;
    right: 0;
  }

  &-preview {
    margin-right: 0;
    margin-left: $uploader-preview-margin-right;
    &-progress {
      left: auto;
      right: 0;
    }

    &.list {
      margin-right: 0;
      margin-left: 0;
    }

    .close {
      right: auto;
      left: $uploader-preview-close-right;
      transform: translate(-50%, -50%);
    }

    &-img {
      .tips {
        left: auto;
        right: 0;
      }
    }
  }
}
