/*
 * https://github.com/morethanwords/tweb
 * Copyright (C) 2019-2021 Eduard Kuzmenko
 * https://github.com/morethanwords/tweb/blob/master/LICENSE
 */

.document {
  --background-color: #{var(--primary-color)};
  $border-radius: .375rem;
  height: 70px;

  .media-photo {
    border-radius: inherit;

    &.thumbnail {
      left: 0;
    }
  }

  &-ico {
    background-color: var(--background-color);
    border-radius: $border-radius;
    line-height: 1;
    text-align: center;

    html.is-safari & {
      -webkit-mask-image: -webkit-radial-gradient(circle, white 100%, black 100%); // fix safari overflow
    }

    &-text {
      opacity: 0;

      @include animation-level(2) {
        transition: opacity .2s ease-in-out;
      }
    }

    .document:not(.document-with-thumb) & {
      padding: 1.5625rem .25rem 0 .25rem;

      @include respond-to(handhelds) {
        padding: 1.5rem 0px 0px 0px;
        font-size: 14px;

        &:after {
          --size: .875rem;
        }
      }
    }

    &:after {
      --size: 1.125rem;
      content: "";
      display: block;
      position: absolute;
      top: 0;
      right: 0;
      // width: var(--size);
      // height: var(--size);
      border-bottom-left-radius: .25rem;
      border-style: solid;
      border-width: calc(var(--size) / 2);
      border-left-color: rgba(0, 0, 0, .25);
      border-bottom-color: rgba(0, 0, 0, .25);
      border-top-color: var(--message-background-color);
      border-right-color: var(--message-background-color);

      @include animation-level(2) {
        transition: border-width .2s ease-in-out;
      }
    }
  }

  &:not(.downloaded) {
    @include hover() {
      .document-ico:after {
        border-width: 0;
      }

      .document-ico-text {
        opacity: 0;
      }

      .preloader-container {
        opacity: 1 !important;
      }
    }
  }

  &:not(.downloading) {
    .document-ico-text {
      opacity: 1;
    }

    .preloader-container {
      opacity: 0 !important;
    }
  }

  &.downloading {
    .document-ico:after {
      border-width: 0;
    }
  }
  
  &-ico {
    font-size: 1.125rem;
    background-size: contain;
  }

  &-ico, 
  &-name,
  &-size {
    @include text-overflow();
  }

  &.ext-zip {
    --background-color: #FB8C00;
  }

  &.ext-pdf {
    --background-color: #DF3F40;
  }

  &.ext-apk {
    --background-color: #43A047;
  }

  &.document-with-thumb {
    --background-color: #fff;

    .document-ico {
      &:after {
        display: none;
      }
    }

    .document-download {
      background-color: rgba(0, 0, 0, .2);
      border-radius: $border-radius;
    }

    .preloader-circular {
      transition: background-color .2s;
    }

    .preloader-container:not(.manual) {
      .preloader-circular {
        background-color: rgba(0, 0, 0, .3) !important;
      }
    }
  }

  &-thumb {
    object-fit: cover;
    width: 100%;
    height: 100%;
  }
  
  &-name {
    white-space: nowrap;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-16);
    line-height: var(--line-height-16);
  }

  &-size {
    color: var(--secondary-text-color);
    font-size: var(--font-size-14);
    line-height: var(--line-height-14);
    //padding-right: 32px;
    pointer-events: none;
    position: relative;
  }

  .preloader-container {
    width: 2.5rem;
    height: 2.5rem;

    @include respond-to(handhelds) {
      width: 1.625rem;
      height: 1.625rem;
    }
  }

  .preloader-circular {
    background-color: transparent !important;
  }

  .preloader-path-new {
    stroke-width: 2.5;
  }
}

.document, 
.audio {
  --padding: 0px;
  --icon-size: 3.375rem;
  --icon-margin: .875rem;
  --padding-left: calc(var(--icon-size) + var(--icon-margin) + var(--padding));
  padding: var(--padding);
  padding-inline-start: var(--padding-left);
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: pointer;
  // position: relative;
  user-select: none;

  &-ico, 
  &-download {
    position: absolute;
    // left: 0;
    margin-inline-start: calc((var(--padding-left) - var(--padding)) * -1);
    width: var(--icon-size);
    height: var(--icon-size);
    color: #fff;
  }

  &-download {
    z-index: 1;
    align-items: center;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    transition: opacity .2s ease-in-out/* , transform .2s ease-in-out */;
    opacity: 1;
    //transform: scale(1);

    &.downloaded {
      opacity: 0;
      //transform: scale(0);
    }
  }
  
  &-description {
    @include text-overflow();
  }

  &:not(.corner-download) .preloader-container:not(.preloader-streamable) {
    transform: scale(1) !important;
  }

  .checkbox-field-round {
    --margin-top: .25rem;
    --margin-left: .125rem;
    margin-left: calc(var(--padding-left) * -1 + var(--icon-size) - var(--size) + var(--margin-left));
    margin-top: calc(var(--icon-size) - var(--size) + var(--margin-top));
    top: auto;
    left: auto;
  }
}

.audio {
  &-ico {
    display: flex;
    justify-content: center;

    &.tgico-largeplay:before {
      margin-right: -1px;
    }
  }

  .preloader-circular {
    background-color: transparent !important;
  }

  .preloader-container:not(.preloader-streamable) {
    width: 100%;
    height: 100%;
  }
}
