@uploader-action-background: #f7f8fa;
@uploader-action-icon-color: #888;
@uploader-action-icon-size: 24px;
@uploader-action-margin: 0 10px 10px 0;
@uploader-file-size: 80px;
@uploader-file-margin: 0 10px 10px 0;
@uploader-file-name-background: #f7f8fa;
@uploader-file-name-color: #888;
@uploader-file-name-font-size: 12px;
@uploader-file-name-padding: 10px;
@uploader-file-text-align: center;
@uploader-file-close-background: rgba(0, 0, 0, 0.3);
@uploader-file-close-size: 24px;
@uploader-file-close-icon-font-size: 14px;
@uploader-file-close-icon-color: #fff;
@uploader-file-cover-fit: cover;
@uploader-file-cover-background: #f7f8fa;
@uploader-preview-video-width: 100vw;
@uploader-preview-video-height: 100vw;
@uploader-file-indicator-height: 4px;
@uploader-file-indicator-normal-color: var(--color-disabled);
@uploader-file-indicator-success-color: var(--color-success);
@uploader-file-indicator-error-color: var(--color-danger);
@uploader-disabled-color: var(--color-disabled);
@uploader-disabled-text-color: var(--color-text-disabled);
@uploader-loading-background: linear-gradient(
  90deg,
  hsla(0, 0%, 100%, 0),
  hsla(0, 0%, 100%, 0.3),
  hsla(0, 0%, 100%, 0)
);

:root {
  --uploader-action-background: @uploader-action-background;
  --uploader-action-icon-color: @uploader-action-icon-color;
  --uploader-action-icon-size: @uploader-action-icon-size;
  --uploader-action-margin: @uploader-action-margin;
  --uploader-file-size: @uploader-file-size;
  --uploader-file-margin: @uploader-file-margin;
  --uploader-file-name-background: @uploader-file-name-background;
  --uploader-file-name-color: @uploader-file-name-color;
  --uploader-file-name-font-size: @uploader-file-name-font-size;
  --uploader-file-name-padding: @uploader-file-name-padding;
  --uploader-file-text-align: @uploader-file-text-align;
  --uploader-file-close-background: @uploader-file-close-background;
  --uploader-file-close-size: @uploader-file-close-size;
  --uploader-file-close-icon-font-size: @uploader-file-close-icon-font-size;
  --uploader-file-close-icon-color: @uploader-file-close-icon-color;
  --uploader-file-cover-fit: @uploader-file-cover-fit;
  --uploader-file-cover-background: @uploader-file-cover-background;
  --uploader-preview-video-width: @uploader-preview-video-width;
  --uploader-preview-video-height: @uploader-preview-video-height;
  --uploader-file-indicator-height: @uploader-file-indicator-height;
  --uploader-file-indicator-normal-color: @uploader-file-indicator-normal-color;
  --uploader-file-indicator-success-color: @uploader-file-indicator-success-color;
  --uploader-file-indicator-error-color: @uploader-file-indicator-error-color;
  --uploader-disabled-color: @uploader-disabled-color;
  --uploader-disabled-text-color: @uploader-disabled-text-color;
  --uploader-loading-background: @uploader-loading-background;
}

@keyframes var-uploader-loading-animation {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(100%);
  }
}

.var-uploader {
  width: 100%;

  &__file-list {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }

  &__file {
    position: relative;
    width: var(--uploader-file-size);
    height: var(--uploader-file-size);
    margin: var(--uploader-file-margin);
    overflow: hidden;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }

  &__file-name {
    position: absolute;
    width: 100%;
    height: 100%;
    line-height: calc(var(--uploader-file-size) - var(--uploader-file-name-padding) * 2);
    font-size: var(--uploader-file-name-font-size);
    z-index: 0;
    background: var(--uploader-file-name-background);
    padding: var(--uploader-file-name-padding);
    color: var(--uploader-file-name-color);
    text-align: var(--uploader-file-text-align);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    user-select: none;
    transition: background-color 0.25s;
  }

  &__file-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: var(--uploader-file-cover-background);
    object-fit: var(--uploader-file-cover-fit);
    pointer-events: none;
    transition: background-color 0.25s;
  }

  &__file-close {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    border-top: var(--uploader-file-close-size) solid var(--uploader-file-close-background);
    border-left: var(--uploader-file-close-size) solid transparent;
  }

  &__file-close-icon[var-uploader-cover] {
    position: absolute;
    top: calc(-1 * var(--uploader-file-close-size));
    right: 0;
    font-size: var(--uploader-file-close-icon-font-size);
    color: var(--uploader-file-close-icon-color);
  }

  &__file-indicator {
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 2;
    width: 100%;
    height: var(--uploader-file-indicator-height);
    transition: all 0.25s;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    background: var(--uploader-file-indicator-normal-color);
  }

  &__action {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--uploader-action-icon-color);
    width: var(--uploader-file-size);
    height: var(--uploader-file-size);
    background: var(--uploader-action-background);
    margin: var(--uploader-action-margin);
    transition: background-color 0.25s;
  }

  &__action-icon[var-uploader-cover] {
    font-size: var(--uploader-action-icon-size);
  }

  &__action-input {
    position: absolute;
    z-index: 1;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }

  &__preview[var-uploader-cover] {
    background: #000;
    box-shadow: none;
  }

  &__preview-video {
    width: var(--uploader-preview-video-width);
    height: var(--uploader-preview-video-height);
  }

  &--loading {
    &::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 1;
      animation: var-uploader-loading-animation 0.6s infinite;
      background: var(--uploader-loading-background);
      transition: background-color 0.25s;
    }
  }

  &--success {
    background: var(--uploader-file-indicator-success-color);
  }

  &--error {
    background: var(--uploader-file-indicator-error-color);
  }

  &--disabled {
    background: var(--uploader-disabled-color);
    color: var(--uploader-disabled-text-color);
  }
}
