/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';
@import './vars.less';

@file-upload-prefix-cls: ~'@{css-prefix}file-upload';
@upload-list-prefix-cls: ~'@{css-prefix}upload-list';
@progress-prefix-cls: ~'@{css-prefix}progress';
@icon-close-tip-prefix-cls: ~'@{css-prefix}icon-close-tip';
@icon-check-prefix-cls: ~'@{css-prefix}icon-check';
@svg-prefix-cls: ~'@{css-prefix}svg';
@tooltip-prefix-cls: ~'@{css-prefix}tooltip';

.@{file-upload-prefix-cls} {
  .inject-UploadList-vars();

  &.@{tooltip-prefix-cls} {
    margin-bottom: 7px;
  }
}

.@{upload-list-prefix-cls} {
  margin: 0;
  padding: 0;
  list-style: none;

  &__wrapper {
    display: inline;
  }

  a:hover {
    color: var(--tv-UploadList-item-hover-text-color);
    text-decoration: none;
  }

  // 提高优先级覆盖ul.li样式
  &--text {
    li:first-of-type > .@{upload-list-prefix-cls}__item {
      margin-top: calc(var(--tv-UploadList-item-margin-top) + 4px);
    }

    li:not(:first-of-type) > .@{upload-list-prefix-cls}__item {
      margin-top: var(--tv-UploadList-item-margin-top);
    }

    li:last-of-type {
      margin-bottom: 8px;
    }

    li + li {
      .@{upload-list-prefix-cls}__item.is-uploading,
      .@{upload-list-prefix-cls}__item.is-downloading {
        margin-bottom: 14px;
      }
    }
  }

  &__item.is-fail {
    .@{upload-list-prefix-cls}__item-name {
      color: var(--tv-UploadList-item-fail-text-color);

      & .tiny-svg {
        fill: var(--tv-UploadList-item-fail-text-color);
      }
    }
  }

  &__item {
    transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);
    font-size: var(--tv-UploadList-item-font-size);
    color: var(--tv-UploadList-item-text-color);
    line-height: var(--tv-UploadList-item-line-height);
    position: relative;
    box-sizing: border-box;
    border-radius: var(--tv-UploadList-item-border-radius);
    width: 100%;
    outline: none;

    &:hover {
      background-color: var(--tv-UploadList-item-hover-background-color);

      .@{svg-prefix-cls}.icon-close,
      .@{svg-prefix-cls}.icon-refres {
        display: inline-block;
      }

      .@{progress-prefix-cls}__text {
        display: none;
      }
    }

    &.is-success {
      .@{upload-list-prefix-cls}__item-status-label {
        display: block;
      }

      .@{upload-list-prefix-cls}__item-name:focus,
      .@{upload-list-prefix-cls}__item-name:hover {
        color: var(--tv-UploadList-item-hover-text-color);
        cursor: pointer;
        text-decoration: none;
      }

      &:focus:not(:hover) .@{icon-close-tip-prefix-cls} {
        display: inline-block;
      }

      &:active,
      &:not(.focusing):focus {
        outline-width: 0;
      }

      &:active .@{icon-close-tip-prefix-cls},
      &:focus .@{upload-list-prefix-cls}__item-status-label,
      &:hover .@{upload-list-prefix-cls}__item-status-label,
      &:not(.focusing):focus .@{icon-close-tip-prefix-cls} {
        display: none;
      }
    }

    &.is-disabled &:hover &-status-label {
      display: block;
    }

    &.isEdm {
      .@{upload-list-prefix-cls}__item-name {
        display: inline-block;

        &.isFail {
          color: red;
        }
      }

      .@{upload-list-prefix-cls}__item-edminfo {
        margin-right: 46px;
      }

      .@{upload-list-prefix-cls}__item-status-label {
        right: 16px;
      }

      &:not(.showUpdate) {
        .icon-refres {
          display: none;
        }
      }

      &:not(.showDel) {
        .icon-close {
          display: none;
        }
      }

      &.showUpdate {
        .icon-refres {
          right: 16px;
        }
      }

      &.showDel {
        .icon-close {
          right: 16px;
        }
      }

      &.showUpdate.showDel {
        .icon-refres {
          right: 28px;
        }

        .icon-close {
          right: 8px;
        }
      }

      &:not(.showUpdate):not(.showDel) {
        .@{upload-list-prefix-cls}__item-status-label {
          display: block;
        }
      }
    }

    .@{progress-prefix-cls} {
      position: absolute;
      top: 26px;
      width: 100%;
    }

    .@{progress-prefix-cls}__text {
      position: absolute;
      right: 0;
      top: -13px;
    }

    .@{progress-prefix-cls}-bar {
      margin-right: 0;
      padding-right: 0;
    }

    &.is-fail
      > .@{upload-list-prefix-cls}__item-actions
      > &-delete
      > .@{svg-prefix-cls}.@{svg-prefix-cls}-size.icon-delete {
      fill: var(--tv-UploadList-svg-close-icon-color);

      &:hover {
        fill: var(--tv-UploadList-svg-close-hover-icon-color);
      }
    }

    .@{svg-prefix-cls} {
      &.icon-successful {
        font-size: var(--tv-UploadList-successful-icon-font-size);
        fill: var(--tv-UploadList-successful-status-bg-color);
      }

      &.icon-close {
        right: 8px;
      }

      &.icon-refres {
        right: 32px;
      }

      &.icon-close,
      &.icon-refres {
        display: none;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        fill: var(--tv-UploadList-svg-close-icon-color);
        font-size: var(--tv-UploadList-svg-icon-font-size);
        opacity: 0.75;
        cursor: pointer;

        &:hover {
          fill: var(--tv-UploadList-svg-close-hover-icon-color);
          opacity: 1;
        }
      }
    }

    .@{icon-close-tip-prefix-cls} {
      display: none;
      position: absolute;
      top: 5px;
      right: 5px;
      font-size: var(--tv-UploadList-svg-icon-font-size);
      cursor: pointer;
      opacity: 1;
      color: var(--tv-UploadList-item-hover-text-color);
    }
  }

  &__item-edminfo,
  &__item-folder {
    display: inline-block;
    vertical-align: top;
  }

  &__item-edminfo {
    margin-right: 20px;

    span {
      display: inline-block;
      margin-right: 10px;
    }

    &.isFail span {
      color: #f5222d;
    }
  }

  &__text-title {
    display: flex;
    align-items: center;
    font-size: 14px;
    height: 22px;
    line-height: 22px;
    color: var(--tv-UploadList-item-fail-text-color);
  }

  &__icon-operationfaild {
    fill: var(--tv-UploadList-item-fail-text-color);
    margin-right: 8px;
    margin-left: 4px;
    font-size: 16px;
  }

  &__text-desc {
    line-height: 30px;
  }


  &__item-name {
    color: var(--tv-UploadList-item-text-color);
    display: block;
    margin-right: 40px;
    padding-left: 4px;
    transition: color 0.3s;

    .@{svg-prefix-cls} {
      font-size: var(--tv-UploadList-item-name-icon-font-size);
      margin-right: 4px;
      fill: var(--tv-UploadList-item-name-icon-color);
    }
  }

  &__item-status-label {
    position: absolute;
    right: 5px;
    top: 0;
    line-height: inherit;
    display: none;
  }

  &__item-delete {
    position: absolute;
    right: 10px;
    top: 0;
    font-size: var(--tv-UploadList-svg-icon-font-size);
    color: var(--tv-UploadList-svg-close-icon-color);
    display: none;

    &:hover {
      color: var(--tv-UploadList-item-hover-text-color);
    }
  }

  &__download-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
  }

  &--picture-card {
    margin: 0;
    display: inline;
    vertical-align: top;

    .@{upload-list-prefix-cls}__li {
      display: inline-block;

      .is-fail {
        color: var(--tv-UploadList-item-fail-text-color);
      }

      &-title:not(.is-fail) {
        color: #595959;
      }

      &-title {
        margin-top: -4px;
        text-align: center;
        line-height: 1.5;
        width: var(--tv-UploadList-picture-card-width);
        height: 18px;
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }

    .@{upload-list-prefix-cls}__item {
      overflow: hidden;
      background-color: var(--tv-UploadList-picture-card-item-bg-color);
      border: 1px dashed var(--tv-UploadList-picture-card-item-border-color);
      border-radius: var(--tv-UploadList-item-border-radius);
      box-sizing: border-box;
      width: var(--tv-UploadList-picture-card-width);
      height: var(--tv-UploadList-picture-card-height);
      margin: 0 16px 8px 0;
      display: inline-block;

      &.is-success {
        border-width: 0;
      }

      &.is-fail {
        border-style: solid;
        border-color: var(--tv-UploadList-item-fail-text-color);
        background-color: var(--tv-UploadList-item-fail-bg-color);

        .@{upload-list-prefix-cls}__item-actions:hover {
          background-color: var(--tv-UploadList-item-fail-bg-color);

          & span .tiny-svg {
            fill: var(--tv-UploadList-svg-close-hover-icon-color);
          }
        }
      }

      .@{icon-check-prefix-cls} {
        fill: var(--tv-UploadList-picture-card-item-icon-color);
      }

      .@{svg-prefix-cls}.icon-close,
      .@{svg-prefix-cls}.icon-refres,
      &:hover .@{upload-list-prefix-cls}__item-status-label {
        display: none;
      }

      &:hover .@{progress-prefix-cls}__text {
        display: block;
      }
    }

    .@{upload-list-prefix-cls}__item-name {
      display: none;
    }

    .@{upload-list-prefix-cls}__item-thumbnail {
      width: 100%;
      height: 100%;
    }

    .@{upload-list-prefix-cls}__item-status-label {
      position: absolute;
      right: -15px;
      top: -6px;
      width: 40px;
      height: 24px;
      background: var(--tv-UploadList-successful-status-bg-color);
      text-align: center;
      transform: rotate(45deg);
      box-shadow: 0 0 1pc 1px rgba(0, 0, 0, 0.2);

      .@{svg-prefix-cls} {
        font-size: var(--tv-UploadList-svg-icon-font-size);
        margin-top: 11px;
        transform: rotate(-45deg);
      }
    }

    .@{upload-list-prefix-cls}__item-actions {
      position: absolute;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      cursor: default;
      text-align: center;
      fill: var(--tv-UploadList-picture-card-item-icon-color);
      opacity: 0;
      font-size: 20px;
      background-color: transparent;
      transition: opacity 0.3s;

      &:after {
        display: inline-block;
        content: '';
        height: 100%;
        vertical-align: middle;
      }

      &:hover {
        opacity: 1;
        background-color: var(--tv-UploadList-picture-card-item-bg-color-hover);

        span {
          display: inline-block;
        }
      }

      span {
        display: none;
        cursor: pointer;

        & + span {
          margin-left: 16px;
        }
      }

      .@{upload-list-prefix-cls}__item-preview {
        .tiny-svg-fullscreen {
          transform: rotate(90deg);
        }
      }

      .@{upload-list-prefix-cls}__item-delete,
      .@{upload-list-prefix-cls}__item-refres {
        position: static;
        font-size: inherit;
        color: inherit;
      }
    }

    .@{progress-prefix-cls} {
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      bottom: auto;
      width: var(--tv-UploadList-picture-card-progress-size);

      .@{progress-prefix-cls}__text {
        top: 50%;
      }
    }

    // smb取消上传功能
    .@{upload-list-prefix-cls}__item-cancel {
      position: absolute;
      left: 50%;
      bottom: 16px;
      transform: translateX(-50%);
      font-size: 14px;
      color: var(--tv-UploadList-item-cancel-text-color);
      line-height: 22px;
      letter-spacing: 0;
      white-space: nowrap;
      cursor: pointer;

      &:hover {
        color: var(--tv-UploadList-item-cancel-text-color-hover);
        text-decoration: underline;
      }
    }
  }

  &--picture &__item {
    overflow: hidden;
    z-index: 0;
    background-color: var(--tv-UploadList-picture-card-item-bg-color);
    box-sizing: border-box;
    margin-top: 8px;
    outline: 0;

    .@{icon-check-prefix-cls} {
      fill: var(--tv-UploadList-picture-card-item-icon-color);
    }

    &:hover {
      .@{upload-list-prefix-cls}__item-status-label {
        background: 0 0;
        box-shadow: none;
        top: -2px;
        right: -12px;
      }

      .@{progress-prefix-cls}__text {
        display: block;
      }
    }

    &.is-success {
      .@{upload-list-prefix-cls}__item-name {
        line-height: 56px;
        margin-top: 0;

        .@{svg-prefix-cls} {
          display: none;
        }
      }
    }
  }

  &--picture &__item-thumbnail {
    width: 56px;
    height: 56px;
    border: 1px solid var(--tv-UploadList-picture-card-item-border-color);
    border-radius: var(--tv-UploadList-item-border-radius);
    float: left;
    position: relative;
    z-index: 1;
    vertical-align: middle;
    margin-right: 12px;
  }

  &--picture &__item-name {
    display: block;
    line-height: 56px;

    .@{svg-prefix-cls} {
      font-size: var(--tv-UploadList-item-name-icon-font-size);
    }
  }

  &--picture &__item-status-label {
    position: absolute;
    right: -17px;
    top: -7px;
    width: 46px;
    height: 26px;
    background: var(--tv-UploadList-successful-status-bg-color);
    text-align: center;
    transform: rotate(45deg);
    box-shadow: 0 1px 1px #ccc;

    .@{svg-prefix-cls} {
      font-size: var(--tv-UploadList-svg-icon-font-size);
      margin-top: 12px;
      transform: rotate(-45deg);
    }
  }

  &--picture .@{progress-prefix-cls} {
    position: relative;
    top: -7px;
  }
}

// 多端fileUpload组件文件上传列表样式
.@{upload-list-prefix-cls}--saas {
  border: 0px dashed #c9c9c9;

  &.border-zero {
    border-width: 0;
  }

  &.border-top {
    border-top-width: 1px;
  }

  &.mode-bubble {
    height: 208px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .@{upload-list-prefix-cls}-panel {
    font-size: 0;

    .@{upload-list-prefix-cls}-item {
      position: relative;
      display: inline-block;
      min-width: 100%;
      padding: 12px;
      margin-right: 8px;
      border: 1px solid #dfdfdf;
      border-radius: 4px;
      background-color: var(--tv-UploadList-bg-color);

      &:hover {
        background-color: var(--tv-UploadList-bg-color-hover);

        .operate-panel {
          visibility: visible;
        }
      }

      &.selected {
        border-color: #0067d1;
      }

      &.compact {
        min-width: 448px;
      }

      &:not(:last-child) {
        margin-bottom: 8px;
      }
    }
  }

  .@{upload-list-prefix-cls}-thumb {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 32px;
    margin-right: 8px;
    vertical-align: top;

    .uploading-mask {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      background-color: #000;
      opacity: 0.5;
      border-radius: 2px;
    }

    .uploading-progress {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      overflow: hidden;
      display: flex;
      padding: 0 4px;
      align-items: center;
      justify-content: center;
      border-radius: 2px;
    }

    .uploading-progress-panel {
      background-color: #aeaeae;
      width: 100%;
      height: 2px;
      border-radius: 2px;
    }

    .uploading-progress-bar {
      background-color: #fff;
      height: 100%;
      transition: all cubic-bezier(0.4, 0, 0.2, 1) 150ms;
    }

    .file-icon {
      width: 100%;
      height: 100%;
      border-radius: 2px;
    }

    .upload-fail {
      position: relative;
      width: 100%;
      height: 100%;
      border-radius: 2px;
      background-color: #fee7e8;
    }

    .upload-fail-icon {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      fill: #e02128;
      font-size: 18px;
    }
  }

  .@{upload-list-prefix-cls}-content {
    position: relative;
    display: inline-block;
    width: calc(100% - 40px);
    font-size: 12px;

    .file-name {
      display: flex;
      height: 16px;
    }

    .file-name-box {
      flex: 1;
      margin-right: 24px;
      font-size: 12px;
      line-height: 12px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .operate-panel {
      visibility: hidden;
      min-width: fit-content;
      color: #2e86de;
      font-size: 12px;

      .operate-btn {
        cursor: pointer;
        margin-right: 8px;

        &:last-of-type {
          margin-right: 0px;
        }
      }
    }

    .file-size {
      display: flex;
      height: 16px;
      line-height: 20px;
    }

    .file-size-content {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: #aeaeae;

      .fail > span {
        color: #e7434a;
      }
    }

    .file-size-right {
      flex: 1;
      margin-left: 8px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      text-align: right;
      color: #aeaeae;
    }
  }

  .no-attachments {
    margin-top: 16px;
    color: #aeaeae;
    font-size: 12px;
  }
}