@import "../../style/themes/default";
@import "../../style/mixins/index";

@upload-prefix-cls: ~"@{ui-prefix}-upload";
@upload-item: ~"@{ui-prefix}-upload-item";
@upload-pictrue-card-size: 104px;

.@{upload-prefix-cls}__list {
  .reset-component;
  .clearfix;
  &_picture,
  &_picture-card {
    .@{upload-item} {
      padding: 8px;
      border-radius: @border-radius-base;
      border: @border-width-base @border-style-base @border-color-base;
      height: 66px;
      position: relative;
      &__info {
        padding: 0 !important;
      }
      &__uploading {
        border-style: dashed;
      }
      &__thumbnail {
        width: 48px;
        height: 48px;
        position: absolute;
        top: 8px;
        left: 8px;
        img {
          width: 48px;
          height: 48px;
          display: block;
          overflow: hidden;
        }
      }
      &:hover .@{upload-item}__info {
        background: transparent;
      }
      &__thumbnail.@{iconfont-css-prefix}:before {
        line-height: 48px;
        font-size: 24px;
        color: @text-color-secondary;
      }
      &__name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin: 0 0 0 8px;
        line-height: 44px;
        transition: all .3s;
        padding-left: 48px;
        padding-right: 8px;
        max-width: 100%;
        display: inline-block;
        box-sizing: border-box;
      }
      &__uploading .@{upload-item}__name {
        line-height: 28px;
      }
      &:hover {
        background: transparent;
      }
      &_error {
        border-color: @error-color;
      }
    }

    .@{upload-item}__progress {
      padding-left: 56px;
      margin-top: 0;
      bottom: 14px;
      width: ~"calc(100% - 24px)";
    }

    .@{iconfont-css-prefix}_cross {
      position: absolute;
      right: 8px;
      top: 8px;
      line-height: 1;
    }
  }
  &_picture-card {
    display: inline;

    &.@{upload-prefix-cls}__list:after {
      display: none;
    }
    .@{upload-item} {
      float: left;
      width: @upload-pictrue-card-size;
      height: @upload-pictrue-card-size;
      margin: 0 8px 8px 0;
    }

    .@{upload-item}__info {
      height: 100%;
      position: relative;
      overflow: hidden;

      &:before {
        content: ' ';
        position: absolute;
        z-index: 1;
        background-color: rgba(0, 0, 0, 0.5);
        transition: all .3s;
        width: 100%;
        height: 100%;
        opacity: 0;
      }
    }

    .@{upload-item}:hover .@{upload-item}__info:before {
      opacity: 1;
    }

    .@{upload-item}__actions {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      z-index: 10;
      white-space: nowrap;
      opacity: 0;
      transition: all .3s;

      .@{iconfont-css-prefix}_eye-o,
      .@{iconfont-css-prefix}_delete {
        z-index: 10;
        transition: all .3s;
        cursor: pointer;
        font-size: 16px;
        width: 16px;
        color: @text-color-dark;
        margin: 0 4px;
        &:hover {
          color: #fff;
        }
      }
    }

    .@{upload-item}__info:hover + .@{upload-item}__actions,
    .@{upload-item}__actions:hover {
      opacity: 1;
    }

    .@{upload-item}__thumbnail,
    .@{upload-item}__thumbnail img {
      display: block;
      width: 100%;
      height: 100%;
      position: static;
    }

    .@{upload-item}__name {
      margin: 8px 0 0;
      padding: 0;
      text-align: center;
      line-height: @line-height-base;
      display: none;
    }

    .icon_picture + .@{upload-item}__name {
      display: block;
    }

    .@{upload-item}__uploading {
      &.@{upload-item} {
        background-color: @background-color-light;
      }

      .@{upload-item}__info {
        height: auto;
        &:before,
        .@{iconfont-css-prefix}_eye-o,
        .@{iconfont-css-prefix}_delete {
          display: none;
        }
      }

      &-text {
        margin-top: 18px;
        color: @text-color-secondary;
      }
    }

    .@{upload-item}__progress {
      padding-left: 0;
      bottom: 32px;
    }
  }
}

.@{upload-prefix-cls}-item {
  margin-top: 8px;
  font-size: @font-size-base;
  position: relative;
  height: 22px;
  &__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: @font-size-base + 8px;
    width: 100%;
    display: inline-block;
  }

  &__info {
    height: 100%;
    padding: 0 12px 0 4px;
    transition: background-color .3s;

    > span {
      display: block;
    }

    .@{iconfont-css-prefix}_loading,
    .@{iconfont-css-prefix}_paper-clip {
      font-size: @font-size-base;
      color: @text-color-secondary;
      position: absolute;
      top: @font-size-base / 2 - 2px;
    }
  }

  .@{iconfont-css-prefix}_cross {
    .iconfont-size-under-12px(10px);
    transition: all .3s;
    opacity: 0;
    cursor: pointer;
    position: absolute;
    top: 0;
    right: 4px;
    color: @text-color-secondary;
    line-height: 22px;
    &:hover {
      color: @text-color;
    }
  }

  &:hover &__info {
    background-color: @item-hover-bg;
  }

  &:hover .@{iconfont-css-prefix}_cross {
    opacity: 1;
  }

  &_error,
  &_error .@{iconfont-css-prefix}_paper-clip,
  &_error &__name {
    color: @error-color;
  }

  &_error .@{iconfont-css-prefix}_cross {
    opacity: 1;
    color: @error-color !important;
  }

  &__progress {
    line-height: 0;
    font-size: @font-size-base;
    position: absolute;
    width: 100%;
    bottom: -12px;
    padding-left: @font-size-base + 12px;
  }

  .@{upload-prefix-cls}-success-icon {
    color: @success-color;
    font-weight: bold;
  }

  .@{upload-prefix-cls}-animate-enter,
  .@{upload-prefix-cls}-animate-leave,
  .@{upload-prefix-cls}-animate-inline-enter,
  .@{upload-prefix-cls}-animate-inline-leave {
    animation-duration: .3s;
    animation-fill-mode: @ease-in-out-circ;
  }

  .@{upload-prefix-cls}-animate-enter {
    animation-name: uploadAnimateIn;
  }

  .@{upload-prefix-cls}-animate-leave {
    animation-name: uploadAnimateOut;
  }

  .@{upload-prefix-cls}-animate-inline-enter {
    animation-name: uploadAnimateInlineIn;
  }

  .@{upload-prefix-cls}-animate-inline-leave {
    animation-name: uploadAnimateInlineOut;
  }
}

.@{upload-prefix-cls} {
  .reset-component;
  outline: 0;

  p {
    margin: 0;
  }

  &-btn {
    display: block;
    width: 100%;
    outline: none;
  }

  input[type="file"] {
    cursor: pointer;
  }

  &&__select {
    display: inline-block;
  }

  &&__select_picture-card {
    border: @border-width-base dashed @border-color-base;
    width: @upload-pictrue-card-size;
    height: @upload-pictrue-card-size;
    border-radius: @border-radius-base;
    background-color: @background-color-light;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s ease;
    vertical-align: top;
    margin-right: 8px;
    margin-bottom: 8px;
    display: table;

    > .@{upload-prefix-cls} {
      width: 100%;
      height: 100%;
      display: table-cell;
      text-align: center;
      vertical-align: middle;
      padding: 8px;
    }

    &:hover {
      border-color: @primary-color;
    }
  }

  &&__drag {
    border: @border-width-base dashed @border-color-base;
    transition: border-color .3s;
    cursor: pointer;
    border-radius: @border-radius-base;
    text-align: center;
    width: 100%;
    height: 100%;
    position: relative;
    padding: 16px 0;
    background: @background-color-light;

    &.@{upload-prefix-cls}__drag_hover:not(.@{upload-prefix-cls}__disabled) {
      border: 2px dashed @primary-5;
    }

    &.@{upload-prefix-cls}__disabled {
      cursor: not-allowed;
    }

    .@{upload-prefix-cls}__btn {
      display: table;
      height: 100%;
    }

    .@{upload-prefix-cls}__drag-container {
      display: table-cell;
      vertical-align: middle;
    }

    &:not(.@{upload-prefix-cls}__disabled):hover {
      border-color: @primary-5;
    }

    p.@{upload-prefix-cls}-drag-icon {
      .@{iconfont-css-prefix} {
        font-size: 48px;
        color: @primary-5;
      }
      margin-bottom: 20px;
    }
    p.@{upload-prefix-cls}-text {
      font-size: @font-size-lg;
      margin: 0 0 4px;
      color: @heading-color;
    }
    p.@{upload-prefix-cls}-hint {
      font-size: @font-size-base;
      color: @text-color-secondary;
    }
    .@{iconfont-css-prefix}_plus {
      font-size: 30px;
      transition: all .3s;
      color: @disabled-color;
      &:hover {
        color: @text-color-secondary;
      }
    }
    &:hover .@{iconfont-css-prefix}_plus {
      color: @text-color-secondary;
    }
  }
}

@keyframes uploadAnimateIn {
  from {
    height: 0;
    margin: 0;
    opacity: 0;
    padding: 0;
  }
}

@keyframes uploadAnimateOut {
  to {
    height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
  }
}

@keyframes uploadAnimateInlineIn {
  from {
    width: 0;
    height: 0;
    margin: 0;
    opacity: 0;
    padding: 0;
  }
}

@keyframes uploadAnimateInlineOut {
  to {
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
  }
}
