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

@use "sass:math";

.popup-new-media {
  $parent: ".popup";

  #{$parent} {
    &-container {
      width: 420px;
      max-width: 420px;
      /* padding: 12px 20px 50px; */
      padding: 12px 20px 32.5px;
      //max-height: unquote('min(640px, 100%)');
      max-height: 100%;

      img, 
      video {
        border-radius: inherit;
      }
    }

    &-header {
      flex: 0 0 auto;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 9px;
      padding: 12px 20px 15px;
      position: relative;
  
      .btn-primary {
        width: auto;
        height: 2.25rem;
        font-size: var(--font-size-14);
        padding: 0 1.375rem;
        border-radius: $border-radius-medium;
        text-transform: uppercase;
        line-height: 2.25rem;
      }
    }
  
    &-close {
      margin: -1px 0 0 -4px;
    }
  
    &-photo {
      max-width: 100%;
      overflow: hidden;
      // width: fit-content;
      width: 100%;
      border-radius: $border-radius-medium;
      user-select: none;
      position: relative;
    }
  }

  .scrollable {
    position: relative;
  }

  .input-field {
    width: 100%;
    margin-top: 25px;
    flex: 0 0 auto;

    &-input {
      //height: 54px;
      font-size: 1rem;
      border-radius: $border-radius-medium;

      &[data-placeholder]:not(:focus):empty ~ label {
        opacity: 0;
      }
    }

    label {
      font-size: inherit;
    }
  }

  .btn-menu-overlay {
    z-index: 3;
  }

  .menu-send {
    z-index: 4;
    top: calc(100% + .25rem);
  }
}

.popup-new-media.popup-send-photo {
  .popup-container {
    width: 25rem;
    max-width: 25rem;
    padding: 0;

    &.border-top-offset {
      .popup-input-container {
        overflow: unset;

        &:before {
          top: -8px;
        }
      }
    }
  }

  .menu-send {
    top: unset;
    bottom: 3.5rem;
    right: .5rem;
  }

  .popup-header {
    padding: 0 1rem;
    height: 3.5rem;
    margin: 0;
  }

  .popup-title {
    padding-inline-start: 1.5rem;
  }

  .popup-close {
    margin: 0;
  }

  .popup-body {
    position: relative;

    .scrollable {
      padding: 0 .5rem;
    }
  }

  .input-message-container {
    min-height: inherit;
    max-height: inherit;
    // margin-top: -.5rem;
  }

  .input-message-input {
    max-height: inherit !important;
  }

  .btn-primary {
    flex: 0 0 auto;
    width: auto;
    padding: 0 1rem;
    height: 2.5rem;
    line-height: 2.5rem;
    text-transform: uppercase;
    margin-bottom: .5rem;
  }

  .popup-input-container {
    --height: 3.5rem;
    --max-height: 8.375rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 .5rem;
    min-height: var(--height);
    max-height: var(--max-height);
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;

    &:before {
      content: " ";
      position: absolute;
      height: 1px;
      top: 0;
      left: 0;
      right: 0;
      background-color: var(--border-color);
      opacity: 0;

      @include animation-level(2) {
        transition: opacity var(--transition-standard-in);
      }
    }

    &.has-border-top:before {
      opacity: 1;
    }
  }

  .checkbox-field {
    margin-bottom: 0;
    margin-left: 0;
  }

  .popup-item-album {
    position: relative;

    .album-item {
      position: absolute;
    }

    img, 
    video {
      object-fit: cover;
      width: 100%;
      height: 100%;
    }
  }

  .popup-photo > .popup-item-media {
    display: flex;
    justify-content: center;
    margin: 0 auto;

    img {
      object-fit: contain;
    }
  }

  .popup-photo > .popup-item {
    position: relative;
    border-radius: inherit;
    overflow: hidden;
  }

  .popup-photo > .popup-item + .popup-item {
    margin-top: .5rem;
  }

  .drop {
    border-radius: 0;
  }

  .document,
  .audio {
    --icon-margin: .5rem;
    --icon-size: 3rem;
    --padding: .25rem;
    margin: 0 .25rem;
    border-radius: $border-radius-medium;
    cursor: default;
    height: 3.5rem;

    @include hover-background-effect() {
      --message-background-color: var(--light-filled-secondary-text-color);
    }
  }

  .document {
    max-width: 100%;
    overflow: hidden;

    &.document-with-thumb {
      --icon-size: 4.5rem;
      height: 5rem;
    }

    &-name {
      width: 100%;
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      line-height: 1.5;
      margin-bottom: .125rem;
    }

    &-ico {
      font-size: 16px;
      font-weight: normal;
      line-height: 11px;
      letter-spacing: 0;
      border-radius: #{math.div($border-radius-medium, 2)};
    }

    /* &.photo {
      .document-ico {
        border-radius: $border-radius;
      }
    } */
  }
}

.popup-create-contact {
  .popup-container {
    padding: 0 1rem 1rem !important;
  }

  .popup-header {
    padding: 0 !important;
  }

  .btn-primary {
    margin-bottom: 0 !important;
  }

  .name-fields {
    display: flex;
    flex-direction: column;
    position: relative;
    padding-left: 116px;
    margin-top: 1rem;

    .input-field:first-child {
      margin-top: 0;
    }
  }

  .avatar-placeholder {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
  }
}
