@import '../common/style/var.less';

.van-uploader {
  position: relative;
  display: inline-block;

  &__wrapper {
    display: flex;
    flex-wrap: wrap;
  }

  &__slot:empty {
    display: none;
  }

  &__slot:not(:empty) + &__upload {
    display: none !important;
  }

  &__upload {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: var(--uploader-size, @uploader-size);
    height: var(--uploader-size, @uploader-size);
    margin: 0 @padding-xs @padding-xs 0;
    background-color: var(
      --uploader-upload-background-color,
      @uploader-upload-background-color
    );

    &:active {
      background-color: var(
        --uploader-upload-active-color,
        @uploader-upload-active-color
      );
    }

    &-icon {
      color: var(--uploader-icon-color, @uploader-icon-color);
      font-size: var(--uploader-icon-size, @uploader-icon-size);
    }

    &-text {
      margin-top: var(--padding-xs, @padding-xs);
      color: var(--uploader-text-color, @uploader-text-color);
      font-size: var(--uploader-text-font-size, @uploader-text-font-size);
    }

    &--disabled {
      opacity: var(--uploader-disabled-opacity, @uploader-disabled-opacity);
    }
  }

  &__preview {
    position: relative;
    cursor: pointer;
    margin: 0 @padding-xs @padding-xs 0;

    &-image {
      display: block;
      overflow: hidden;
      width: var(--uploader-size, @uploader-size);
      height: var(--uploader-size, @uploader-size);
    }

    &-delete {
      position: absolute;
      top: 0;
      right: 0;
      width: var(--uploader-delete-icon-size, @uploader-delete-icon-size);
      height: var(--uploader-delete-icon-size, @uploader-delete-icon-size);

      &::after {
        position: absolute;
        top: 0;
        right: 0;
        content: '';
        width: var(--uploader-delete-icon-size, @uploader-delete-icon-size);
        height: var(--uploader-delete-icon-size, @uploader-delete-icon-size);
        background-color: var(
          --uploader-delete-background-color,
          @uploader-delete-background-color
        );
        border-radius: 0 0 0 12px;
      }

      &-icon {
        position: absolute;
        top: 0;
        right: 0;
        z-index: 1;
        color: var(--uploader-delete-color, @uploader-delete-color);
        font-size: var(--uploader-delete-icon-size, @uploader-delete-icon-size);
        transform: scale(0.7) translate(10%, -10%);
      }
    }
  }

  &__file {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: var(--uploader-size, @uploader-size);
    height: var(--uploader-size, @uploader-size);
    background-color: var(
      --uploader-file-background-color,
      @uploader-file-background-color
    );

    &-icon {
      color: var(--uploader-file-icon-color, @uploader-file-icon-color);
      font-size: var(--uploader-file-icon-size, @uploader-file-icon-size);
    }

    &-name {
      box-sizing: border-box;
      width: 100%;
      text-align: center;
      margin-top: var(
        --uploader-file-name-margin-top,
        @uploader-file-name-margin-top
      );
      padding: var(--uploader-file-name-padding, @uploader-file-name-padding);
      color: var(
        --uploader-file-name-text-color,
        @uploader-file-name-text-color
      );
      font-size: var(
        --uploader-file-name-font-size,
        @uploader-file-name-font-size
      );
    }
  }

  &__mask {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: @white;
    background-color: var(
      --uploader-mask-background-color,
      @uploader-mask-background-color
    );

    &-icon {
      font-size: var(--uploader-mask-icon-size, @uploader-mask-icon-size);
    }

    &-message {
      margin-top: 6px;
      padding: 0 var(--padding-base, @padding-base);
      font-size: var(
        --uploader-mask-message-font-size,
        @uploader-mask-message-font-size
      );
      line-height: var(
        --uploader-mask-message-line-height,
        @uploader-mask-message-line-height
      );
    }
  }

  &__loading {
    width: var(--uploader-loading-icon-size, @uploader-loading-icon-size);
    height: var(--uploader-loading-icon-size, @uploader-loading-icon-size);
    color: var(
      --uploader-loading-icon-color,
      @uploader-loading-icon-color
    ) !important;
  }
}
