@import "../../scss/variables/colors";
@import "../../scss/variables/transitions";
@import "../../scss/mixins/button";

$upload-bar: "upload-bar";
$file-upload-progress: "file-upload-progress";

.#{$upload-bar} {
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.2);
  border: solid 1px #dde2e6;
  background-color: #fff;
  padding: 10px;
  overflow: hidden;
  box-sizing: border-box;

  &__main {
    display: flex;
    align-content: center;
    justify-content: space-between;
    box-sizing: border-box;
    cursor: pointer;
  }

  &--single {
    .#{$upload-bar}__main {
      cursor: default;
    }

    &.#{$upload-bar}--success {
      padding: 13px 10px;
    }
  }

  &:not(.#{$upload-bar}--single) {
    &.#{$upload-bar}--error {
      padding: 12px 10px;
    }
  }

  &__success-icon,
  &__error-icon {
    margin-right: 8px;
    display: flex;
    align-items: center;
    flex: 0 1 auto;

    svg {
      width: 18px;
      height: 18px;
    }
  }

  &__success-icon {
    svg {
      fill: #21a961;
    }
  }

  &__error-icon {
    svg {
      fill: $error-color;
    }
  }

  &__header {
    display: flex;
    width: 100%;
    color: #424d57;
    font-size: 15px;
    align-items: center;

    .progress-circle {
      margin-right: 11px;
    }
  }

  &__files {
    max-height: 200px;
    box-sizing: border-box;
    display: flex;

    &--enter {
      max-height: 0;
    }

    &--enter-active {
      max-height: 200px;
      transition: max-height 300ms cubic-bezier(0.14, 0, 0, 1);
    }

    &--exit {
      max-height: 200px;
    }

    &--exit-active,
    &--exit-done {
      max-height: 0;
      transition: max-height 300ms cubic-bezier(0.14, 0, 0, 1);
    }

    &-wrapper {
      box-sizing: border-box;
      padding-top: 16px;
      width: 100%;
      max-height: inherit;
      display: flex;
      flex-direction: column;
    }
  }

  &__list {
    height: 100%;
    overflow-y: auto;
    padding-right: 20px;

    .#{$file-upload-progress}:not(:last-child) {
      margin-bottom: 14px;
      margin-top: 5px;
    }
  }

  &__collapse-btn {
    padding: 4px;
    margin: 0;
    border: none;
    margin-left: 8px;
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    cursor: pointer;
    color: $font-primary-color;
    border-radius: 4px;
    background-color: transparent;

    @include button-transition;
    @include icon-button-interactive-styles;
  }

  &--error {
    .#{$upload-bar}__title {
      color: $error-color;
    }
  }
}

.#{$file-upload-progress} {
  width: 100%;
  display: flex;
  align-items: center;

  &__actions {
    align-self: flex-start;
  }

  &--with-actions-on-hover {
    .#{$file-upload-progress}__actions {
      display: none;
    }

    &:hover {
      .#{$file-upload-progress}__actions {
        display: inline-flex;
      }
    }
  }

  &__header {
    display: flex;
    justify-content: space-between;
  }

  &__icon {
    height: 18px;
    margin-right: 8px;

    svg {
      width: 18px;
      max-height: 18px;
    }
  }

  &__wrapper {
    flex: 0 1 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-self: flex-end;
  }

  &__title {
    width: 100%;
    font-size: 14px;
    margin-bottom: 2px;
    line-height: 1.3;
    color: $font-primary-color;
    justify-self: flex-start;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }

  &--with-icon {
    .#{$file-upload-progress}__wrapper {
      width: calc(100% - 26px);
    }
  }

  &--error {
    .#{$file-upload-progress}__title {
      color: #f4574c;
    }
  }

  &--success {
    .#{$file-upload-progress}__title {
      margin-bottom: 0;
    }

    .#{$file-upload-progress}__wrapper {
      align-self: center;
    }
  }

  &__success-icon {
    margin-right: 8px;
    display: flex;
    align-items: center;
    flex: 0 1 auto;

    svg {
      fill: #21a961;
      width: 18px;
      height: 18px;
    }
  }
}

.#{$file-upload-progress},
.#{$upload-bar} {
  &__actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    flex: 1 0 auto;
    flex-wrap: nowrap;
  }

  &__close,
  &__retry {
    padding: 0;
    margin: 0;
    border: none;
    margin-left: 8px;
    display: flex;
    justify-self: flex-end;
    align-items: center;
    flex: 0 1 auto;
    color: $font-primary-color;
    border-radius: 4px;
    background-color: transparent;

    @include button-transition;
    @include icon-button-interactive-styles;

    svg {
      display: flex;
      fill: currentColor;
      height: 18px;
      width: 18px;
      cursor: pointer;
    }
  }
}
