@upload-prefix: ~'@{icecream-prefix}-upload';
@upload-button: ~'@{upload-prefix}-button';
@upload-list: ~'@{upload-prefix}-list';
@upload-item: ~'@{upload-list}-item';

.@{upload-prefix} {
  .extendBaseEnhanced();
  width: 400px;

  .@{upload-button} {
    &.@{upload-prefix}-drag {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 200px;
      background-color: @icecream-color-grey-2;
      border: 1px dashed @icecream-color-grey-7;
      border-radius: 4px;
      cursor: pointer;

      &:hover {
        border-color: @icecream-color-blue-6;
        background: none;
      }

      &.@{upload-prefix}-dragover {
        border-color: @icecream-color-blue-6;
        background-color: fade(@icecream-color-blue-6, 10%);
      }

      // 防止拖动文件经过子元素时触发 dragleave，参考：https://stackoverflow.com/a/18582960
      & * {
        pointer-events: none;
      }
    }
  }

  &&-disabled {
    .@{upload-button} {
      cursor: not-allowed;

      &.@{upload-prefix}-drag {
        background-color: @icecream-color-grey-3;
        border-color: @icecream-color-grey-6;
      }
    }
  }

  .@{upload-list} {
    margin-top: 20px;

    &.@{upload-list}-hidden {
      display: none;
    }
  }

  .@{upload-item} {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 7px 14px;

    .@{upload-item}-progress {
      display: none;
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      background: #E5F6FC;
    }

    &-uploading {
      .@{upload-item}-progress {
        display: block;
      }
    }

    &-ready, &-success, &-uploading, &-stopped, &-error {
      background-color: @icecream-color-grey-2;
    }

    &-error {
      .@{upload-item}-content, .@{upload-item}-tip-icon {
        color: @icecream-color-red-6;
      }
    }

    &-title {
      display: flex;
      align-items: center;
      overflow: hidden;
      flex: 1;
      // z-index 与进度条组合使用
      z-index: 1;

      .@{upload-item}-icon {
        flex: none;
        margin-right: 10px;
      }

      .@{upload-item}-tip-icon {
        flex: none;
        margin-left: 4px;
        cursor: pointer;
      }

      .@{upload-item}-content {
        overflow: hidden;

        &.@{upload-item}-content-grow {
          // 用于支持上传成功等文件名展示长度变大的情况
          flex: 1;
        }
      }
    }

    &-operation {
      display: flex;
      align-items: center;
      // z-index 与进度条组合使用
      z-index: 1;

      .@{upload-item}-operation-button {
        margin: 0 18px 0 16px;
      }

      .@{upload-item}-delete {
        cursor: pointer;
      }
    }
  }

  .@{upload-item} + .@{upload-item} {
    margin-top: @icecream-gap-sm;
  }
}