@import './../theme/vars.scss';
@import './../mixins/icon.scss';

$uploadPrefixCls: #{$vender-prefix}-upload;
$uploadItem: #{$uploadPrefixCls}-list-item;
$upload-pictrue-card-size: 96px;
$upload-icon-prefix: $aficon-css-prefix;

.#{$uploadPrefixCls} {
  font-size: $font-size-base;
  outline: 0;

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

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

  &.#{$uploadPrefixCls}-select {
    display: inline-block;
  }

  &.#{$uploadPrefixCls}-select-picture-card {
    display: inline-block;
    width: $upload-pictrue-card-size;
    height: $upload-pictrue-card-size;
    margin-right: 8px;
    margin-bottom: 8px;
    text-align: center;
    vertical-align: top;
    cursor: pointer;
    background-color: #fbfbfb;
    border: $border-width-base dashed $border-color-base;
    border-radius: $border-radius-base;
    transition: border-color 0.3s ease;

    > .#{$uploadPrefixCls} {
      display: block;
      width: 100%;
      height: 100%;
      padding: 20px 0;
    }

    &:hover {
      border-color: var(--primary-color);
    }
  }

  &.#{$uploadPrefixCls}-drag {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    cursor: pointer;
    border: $border-width-base dashed $border-color-base;
    border-radius: $border-radius-base;
    transition: border-color 0.3s ease;

    &.#{$uploadPrefixCls}-drag-hover:not(.#{$uploadPrefixCls}-disabled) {
      border: 2px dashed var(--primary-5);
    }

    &.#{$uploadPrefixCls}-disabled {
      cursor: not-allowed;
    }

    .#{$uploadPrefixCls}-btn {
      display: table;
      height: 100%;
    }

    .#{$uploadPrefixCls}-drag-container {
      display: table-cell;
      vertical-align: middle;
    }

    &:not(.#{$uploadPrefixCls}-disabled):hover {
      border-color: var(--primary-5);
    }

    p.#{$uploadPrefixCls}-drag-icon {
      height: 60px;
      margin-bottom: 24px;

      i[class*='icon'] {
        margin-top: -5px;
        font-size: 80px;
        color: var(--primary-5);
      }
    }

    p.#{$uploadPrefixCls}-text {
      font-size: $font-size-lg;
    }

    p.#{$uploadPrefixCls}-hint {
      font-size: $font-size-base;
      color: $text-color-secondary;
    }

    .#{$upload-icon-prefix}-plus {
      font-size: 30px;
      color: $color-disable;
      transition: all 0.3s ease;

      &:hover {
        color: $text-color-secondary;
      }
    }

    &:hover .#{$upload-icon-prefix}-plus {
      color: $text-color-secondary;
    }
  }
}

.#{$uploadPrefixCls}-list {
  overflow: hidden;

  &-item {
    position: relative;
    height: 24px;
    margin-top: 8px;
    overflow: hidden;
    font-size: $font-size-base;

    &-name {
      display: inline-block;
      width: 100%;
      padding-left: 16px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    &-info {
      padding: 0 12px 0 4px;
      line-height: 24px;
      transition: background-color 0.3s;

      .#{$upload-icon-prefix}-loading,
      .#{$upload-icon-prefix}-paper-clip {
        position: absolute;
        top: 5.5px;
        margin-right: 4px;
        font-size: $font-size-base;
        line-height: 1;
        color: $text-color-secondary;
      }
    }

    .#{$upload-icon-prefix}-cross {
      @include iconfont-size-under-12px(10px);

      position: absolute;
      top: 0;
      right: 4px;
      line-height: 24px;
      color: $text-color-secondary;
      cursor: pointer;
      opacity: 0;
      transition: all 0.3s;

      &:hover {
        color: $text-color;
      }
    }

    &:hover &-info {
      background-color: $item-hover-bg;
    }

    &:hover .#{$upload-icon-prefix}-cross {
      opacity: 1;
    }

    &-error,
    &-error .#{$upload-icon-prefix}-paper-clip,
    &-error &-name {
      color: $error-color;
    }

    &-error .#{$upload-icon-prefix}-cross {
      color: $error-color;
      opacity: 1;
    }

    &-progress {
      position: absolute;
      bottom: 0;
      width: 100%;
      font-size: $font-size-base;
      line-height: 0;
    }
  }

  &-picture,
  &-picture-card {
    .#{$uploadItem} {
      position: relative;
      height: 66px;
      padding: 8px;
      border: $border-width-base $border-style-base $border-color-base;
      border-radius: $border-radius-base;

      &:hover {
        background: transparent;
      }

      &-error {
        border-color: $error-color;
      }
    }

    .#{$uploadItem}-info {
      padding: 0;
    }

    .#{$uploadItem}:hover .#{$uploadItem}-info {
      background: transparent;
    }

    .#{$uploadItem}-uploading {
      border-style: dashed;
    }

    .#{$uploadItem}-thumbnail {
      position: absolute;
      top: 8px;
      left: 8px;
      width: 48px;
      height: 48px;
    }

    .#{$uploadItem}-thumbnail img {
      display: block;
      width: 48px;
      height: 48px;
      overflow: hidden;
      border-radius: $border-radius-base;
    }

    .#{$uploadItem}-thumbnail.#{$upload-icon-prefix}::before {
      font-size: 24px;
      line-height: 48px;
      color: $text-color-secondary;
    }

    .#{$uploadItem}-name {
      display: inline-block;
      max-width: 100%;
      padding-right: 8px;
      padding-left: 48px;
      margin: 0 0 0 8px;
      overflow: hidden;
      line-height: 44px;
      text-overflow: ellipsis;
      white-space: nowrap;
      box-sizing: border-box;
      transition: all 0.3s;
    }

    .#{$uploadItem}-uploading .#{$uploadItem}-name {
      line-height: 28px;
    }

    .#{$uploadItem}-progress {
      padding-left: 56px;
      margin-top: 0;
    }

    .#{$upload-icon-prefix}-cross {
      position: absolute;
      top: 8px;
      right: 8px;
      line-height: 1;
    }
  }

  &-picture-card {
    display: inline;

    .#{$uploadItem} {
      float: left;
      width: $upload-pictrue-card-size;
      height: $upload-pictrue-card-size;
      margin: 0 8px 8px 0;
    }

    .#{$uploadItem}-info {
      position: relative;
      height: 100%;

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

    .#{$uploadItem}:hover .#{$uploadItem}-info::before {
      opacity: 1;
    }

    .#{$uploadItem}-actions {
      position: absolute;
      top: 50%;
      left: 50%;
      z-index: 10;
      white-space: nowrap;
      opacity: 0;
      transform: translate(-50%, -50%);
      transition: all 0.3s;

      .#{$upload-icon-prefix}-eye-o,
      .#{$upload-icon-prefix}-delete {
        z-index: 10;
        width: 16px;
        margin: 0 4px;
        font-size: 16px;
        color: $text-color-dark;
        cursor: pointer;
        transition: all 0.3s;

        &:hover {
          color: white;
        }
      }
    }

    .#{$uploadItem}-info:hover + .#{$uploadItem}-actions,
    .#{$uploadItem}-actions:hover {
      opacity: 1;
    }

    .#{$uploadItem}-thumbnail,
    .#{$uploadItem}-thumbnail img {
      position: static;
      display: block;
      width: 100%;
      height: 100%;
    }

    .#{$uploadItem}-name {
      display: none;
    }

    .#{$uploadItem}-uploading {
      &.#{$uploadItem} {
        background-color: #fbfbfb;
      }

      .#{$uploadItem}-info {
        height: auto;

        &::before,
        .#{$upload-icon-prefix}-eye-o,
        .#{$upload-icon-prefix}-delete {
          display: none;
        }
      }

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

    .#{$uploadItem}-progress {
      padding-left: 0;
    }
  }

  .#{$uploadPrefixCls}-success-icon {
    font-weight: bold;
    color: $success-color;
  }

  .#{$uploadPrefixCls}-animate-enter,
  .#{$uploadPrefixCls}-animate-leave,
  .#{$uploadPrefixCls}-animate-inline-enter,
  .#{$uploadPrefixCls}-animate-inline-leave {
    animation-duration: 0.3s;
    animation-fill-mode: $ease-in-out-circ;
  }

  .#{$uploadPrefixCls}-animate-enter {
    animation-name: uploadAnimateIn;
  }

  .#{$uploadPrefixCls}-animate-leave {
    animation-name: uploadAnimateOut;
  }

  .#{$uploadPrefixCls}-animate-inline-enter {
    animation-name: uploadAnimateInlineIn;
  }

  .#{$uploadPrefixCls}-animate-inline-leave {
    animation-name: uploadAnimateInlineOut;
  }
}

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

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

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

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