:root {
  --van-uploader-size: 80px;
  --van-uploader-icon-size: 24px;
  --van-uploader-icon-color: var(--van-gray-4);
  --van-uploader-text-color: var(--van-text-color-2);
  --van-uploader-text-font-size: var(--van-font-size-sm);
  --van-uploader-upload-background: var(--van-gray-1);
  --van-uploader-upload-active-color: var(--van-active-color);
  --van-uploader-delete-color: var(--van-white);
  --van-uploader-delete-icon-size: 14px;
  --van-uploader-delete-background: rgba(0, 0, 0, 0.7);
  --van-uploader-file-background: var(--van-background);
  --van-uploader-file-icon-size: 20px;
  --van-uploader-file-icon-color: var(--van-gray-7);
  --van-uploader-file-name-padding: 0 var(--van-padding-base);
  --van-uploader-file-name-margin-top: var(--van-padding-xs);
  --van-uploader-file-name-font-size: var(--van-font-size-sm);
  --van-uploader-file-name-text-color: var(--van-gray-7);
  --van-uploader-mask-text-color: var(--van-white);
  --van-uploader-mask-background: rgba(50, 50, 51, 0.88);
  --van-uploader-mask-icon-size: 22px;
  --van-uploader-mask-message-font-size: var(--van-font-size-sm);
  --van-uploader-mask-message-line-height: var(--van-line-height-xs);
  --van-uploader-loading-icon-size: 22px;
  --van-uploader-loading-icon-color: var(--van-white);
  --van-uploader-disabled-opacity: var(--van-disabled-opacity);
}

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

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

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

  &__input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; // to clip file-upload-button
    cursor: pointer;
    opacity: 0;

    &-wrapper {
      position: relative;
    }

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

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

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

    &--readonly:active {
      background-color: var(--van-uploader-upload-background);
    }

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

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

  &__preview {
    position: relative;
    margin: 0 var(--van-padding-xs) var(--van-padding-xs) 0;
    cursor: pointer;

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

    &-delete {
      position: absolute;
      top: 0;
      right: 0;

      &--shadow {
        width: var(--van-uploader-delete-icon-size);
        height: var(--van-uploader-delete-icon-size);
        background: var(--van-uploader-delete-background);
        border-radius: 0 0 0 12px;
      }

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

    &-cover {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
    }
  }

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

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

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

  &__loading {
    width: var(--van-uploader-loading-icon-size);
    height: var(--van-uploader-loading-icon-size);
    color: var(--van-uploader-loading-icon-color);
  }

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

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

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