body:has(.im-modal.in) {
  overflow: auto;
  padding-right: 0 !important;
}
.im-modal {
  box-shadow: 0 0 5px rgba(0,0,0,0.5);
  padding-right: 0 !important;
  border-radius: 5px;
  left: auto;
  top: auto;
  right: 5px;
  bottom: 5px;
  @media (max-width: 480px) {
    bottom: 0;
    right: 0;
    top: 0;
    left: 0;
    border-radius: 0;
    box-shadow: none;
    height: 100dvh;
    min-height: 100dvh;
    &:has(.im__sidebar.another-state) .close {
      display: none;
    }
  }
  & .close {
    float: none;
    position: absolute;
    right: 20px;
    top: 15px;
    z-index: 2;
    opacity: 0.6;
    &:hover {
      opacity: 1;
    }
  }
  & > div {
    width: 100%;
  }
}
.im {
  max-height: 500px;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  display: flex;
  background-color: #d1d1d1;
  @media (max-width: 480px) {
    max-height: none;
  }
}

.im .im__sidebar {
  height: calc(100% - 5px);
  width: 170px;
  overflow-y: auto;
  margin: 5px 5px 0 0;
  flex-shrink: 0;
  display: none;
  &.another-state {
    display: block;
  }
  @media (max-width: 480px) {
    display: none;
    width: 200px;
    &.another-state {
      display: block;
    }

  }
  & .chats {
    list-style: none;
    padding: 0;
    margin: 0 0 0 5px;
    & .chats__item {
      width: 100%;
      cursor: pointer;
      margin: 4px 0;
      &:first-child {
        margin-top: 0;
      }
      & .list-message_alt {
        display: flex;
        align-items: center;
        padding: 8px 12px;
        white-space: nowrap;
        outline: none;
        background-color: #fff;
        justify-content: space-between;
        box-shadow: 0 0 2px rgba(0,0,0,0.4);
        border-radius: 3px;
        &.active {
          background-color: #537eff;
          color: #fff;
        }
        & .main {
          display: flex;
          align-items: center;
          overflow: hidden;
          & .name {
            text-overflow: ellipsis;
            overflow: hidden;
            max-width: 100%;
          }
        }
      }
      & .user-avatar-holder {
        position: relative;
        margin: 0 6px 0 0;
        & .user-online {
          position: absolute;
          bottom: 0;
          right: 2px;
          width: 6px;
          height: 6px;
          background-color: green;
          border-radius: 100%;
        }
      }
      & .user-avatar {
        border-radius: 100%;
      }
      & .unread-messages {
        background-color: #7c7c7c;
        color: #fff;
        border-radius: 100%;
        width: 16px;
        height: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
        line-height: 1;
      }
    }
  }
}

.im .chat {
  height: 100%;
  width: 325px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background-color: #eee;
  padding: 54px 0 0 0;
  position: relative;
  flex-shrink: 0;
  @media (max-width: 480px) {
    width: 100vw;
  }
}

.im .chat .chat__container {
  overflow: auto;
  & .chat__header {
    height: 50px;
    background-color: #ffffff;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    padding: 0 50px 0 0;
    & .title {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      display: flex;
      align-items: center;
      line-height: 1;
      & .online-stat {
        font-size: 1.1rem;
        color: #707070;
        margin-block-start: 3px;
      }
    }
    & .avatar img {
      width: 30px;
      height: 30px;
      border-radius: 100%;
      margin: 0 10px 0 0;
    }
    & button {
      background-color: transparent;
      border: none;
      opacity: 0.5;
      line-height: 1;
      box-shadow: none;
      &:hover,&.active {
        opacity: 1;
      }
      & .svg-icon-bg {
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg fill='%23555555' width='24px' height='24px' class='svg-icon' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3e%3crect x='3' y='17' width='18' height='2' rx='1' ry='1'/%3e%3crect x='3' y='11' width='18' height='2' rx='1' ry='1'/%3e%3crect x='3' y='5' width='18' height='2' rx='1' ry='1'/%3e%3c/svg%3e");
      }
      & .svg-icon-bg.block {
        transform: translateY(2px);
        width: 22px;
        height: 22px;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3e%3cdefs%3e%3cstyle%3e.cls-1%7bfill:none;stroke:%23020202;stroke-miterlimit:10;stroke-width:1.4px;%7d%3c/style%3e%3c/defs%3e%3ccircle class='cls-1' cx='12' cy='10.07' r='4.77'/%3e%3cline class='cls-1' x1='15.38' y1='6.69' x2='8.62' y2='13.44'/%3e%3cpath class='cls-1' d='M1.5,5.3v9.54a3.82,3.82,0,0,0,3.82,3.82H7.23v2.86L13,18.66h5.73a3.82,3.82,0,0,0,3.82-3.82V5.3a3.82,3.82,0,0,0-3.82-3.82H5.32A3.82,3.82,0,0,0,1.5,5.3Z'/%3e%3c/svg%3e");
      }
      &.active .svg-icon-bg.block {
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3e%3cdefs%3e%3cstyle%3e.cls-1%7bfill:none;stroke:%23cc0000;stroke-miterlimit:10;stroke-width:1.4px;%7d%3c/style%3e%3c/defs%3e%3ccircle class='cls-1' cx='12' cy='10.07' r='4.77'/%3e%3cline class='cls-1' x1='15.38' y1='6.69' x2='8.62' y2='13.44'/%3e%3cpath class='cls-1' d='M1.5,5.3v9.54a3.82,3.82,0,0,0,3.82,3.82H7.23v2.86L13,18.66h5.73a3.82,3.82,0,0,0,3.82-3.82V5.3a3.82,3.82,0,0,0-3.82-3.82H5.32A3.82,3.82,0,0,0,1.5,5.3Z'/%3e%3c/svg%3e");
      }
    }
    & button:first-child {
      margin-right: 16px;
      margin-left: 8px;
    }
    & button:last-child {
      margin-left: auto;
    }
  }
  & .chat__messages {
    background-color: #eee;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    justify-content: flex-end;

    & .separator {
      color: #5a5a5a;
      text-align: center;
      line-height: 1;
      border-bottom: 1px solid #ccc;
      transform: translateY(-10px);
      margin: 0 10px;
      & span {
        background-color: #eee;
        transform: translateY(10px);
        padding: 5px 15px;
        display: inline-flex;
      }
    }
  }
}

.chat__messages .chat__messages__item {
  margin: 10px;
  display: flex;
  justify-content: flex-end;
  & .message-inner-wrapper {
    position: relative;
    max-width: 90%;
    min-width: min-content;
    & .user-link {
      flex-shrink: 0;
    }
    & .item__avatar {
      width: 30px;
      height: 30px;
      margin: 5px 10px 0 0;
    }
    &:has(.item__avatar ){
      display: flex;
    }
    & .item__author {
      font-weight: bold;
      margin: 10px 0 0 0;
      display: block;
    }
    & .item__message {
      background: #c6e6ff;
      padding: 0 6px;
      border-radius: 6px;
      font-size: 1.3rem;
      box-shadow: 0 0 1px rgba(107, 171, 245, 0.2);
    }
    & .footer {
      text-align: right;
      & .item__time {
        color: #b4b4b4;
        font-size: 1rem;
        line-height: 1;
      }
      .item__unread {
        width: 6px;
        height: 6px;
        background: #2167a5;
        border-radius: 100%;
        display: inline-block;
        margin: 0 0 0 5px;
      }
    }
    & .item__delete {
      background-color: rgba(0,0,0,0.1);
      border: 0;
      outline: 0;
      color: #000;
      position: absolute;
      left: -12px;
      bottom: 14px;
      font-size: 1.1rem;
      display: none;
      width: 20px;
      height: 20px;
      border-radius: 100%;
      justify-content: center;
      align-items: center;
    }
  }
  &.item_interlocutor {
    justify-content: flex-start;
    & .item__message {
      background: #fff;
      color: #444;
    }
    & .footer{
      text-align: left;
      & .item__delete {
        left: auto;
        right: -12px;
      }
    }
  }
  & .item__message {
    font-family: Arial, Helvetica, sans-serif;
    & p {
      padding: 5px 0;
      margin: 0;
      line-height: 1.2;
      word-break: break-word;
      & a {
        color: #3292e5;
        &:hover {
          color: #b31919
        }
      }
    }
    & figure {
      padding: 5px 0;
      & img {
        border-radius: 4px;
      }
    }
    & pg-embed {
      display: block;
      padding: 5px 0;
      & iframe {
        display: block;
        position: static;
        aspect-ratio: 16/9;
      }
    }
    & .pg-gallery {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: 3px;
        padding: 5px 0;
        & .pg-gallery-item {
            flex-basis: calc(100% / 3 - (3px * 2 / 3));
            margin: 0;
          & figure {
            padding: 0;
          }  
        }
        & .pg-gallery-item-more a {
          position: relative;
          display: block;
          color: #fff;
        }
        & .pg-gallery-item-more div {
          display: flex;
          align-items: center;
          justify-content: flex-start;
          width: 100%;
          height: 100%;
          font: bold 1.4rem "Roboto Condensed", Arial, Helvetica, sans-serif;
          position: absolute;
          left: 0;
          top: 0;
          background-color: rgba(0,0,0,0.5);
          color: #fff;
        }
        & .pg-gallery-item img {
          height: auto;
        }

        & .pg-gallery-item a::before {
          content: none;
        }
    }
  }
  &:hover .item__delete {
    display: flex;
  }
}

.chat__messages .item__avatar {
  border-radius: 100%;
}


.chat__area {
  display: flex;
  align-items: flex-end;
  background-color: #fff;
  padding: 8px 10px 8px;
  width: 100%;
  box-shadow: 0 -1px 1px rgba(0,0,0,0.1);
  & .chat__attach {
    height: 34px;
    width: 34px;
    & button {
      background-color: transparent;
      border: none;
      width: 100%;
      height: 100%;
      & .icon-image {
        font-size: 1.6rem;
      }
    }
  }
  & .button-send {
    border: none;
    margin: 0 0 0 auto;
    background-color: #658cff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    border-radius: 5px;
    display: flex;
    height: 34px;
    width: 34px;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    &:hover {
      background-color: #4772f3;
    }
    & .glyphicon {
      color: #fff;
      left: -2px;
    }
  }
  & .pg-editor {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1.3rem;
    & p {
      margin: 0;
    }
  }
  .chat__editor {
    min-height: 26px;
    max-height: 280px;
    overflow-y: auto;
    width: calc(100% - 100px);
    margin-left: 10px;
    margin-right: 20px;
    margin-top: 0;
    background: #fff;
  }
  & .text-center {
    margin-inline: auto;
  }
  &:has(.text-danger){
    background-color: #ff4848;
  }
  & .text-danger {
    color: #fff;
  }
}

@supports not selector(::-webkit-scrollbar) {
  .chat__container {
    scrollbar-width: thin;
    scrollbar-color: #bebebe #DFE9EB;
  }
}
.chat__container::-webkit-scrollbar {
  height: 5px;
  width: 5px;
}
.chat__container::-webkit-scrollbar-track {
  border-radius: 4px;
  background-color: transparent;
}
.chat__container::-webkit-scrollbar-thumb{
  border-radius: 4px;
  background-color: #c0c0c0;
}
.chat__container::-webkit-scrollbar-thumb:hover {
  background-color: #c0c0c0;
}
.chat__container::-webkit-scrollbar-thumb:active {
  background-color: #c0c0c0;
}
.chat__editor {
  scrollbar-width: thin;
  scrollbar-color: #bebebe #DFE9EB;
  &::-webkit-scrollbar {
    height: 1px;
    width: 1px;
  }
}
@supports not selector(::-webkit-scrollbar) {
  .im__sidebar {
    scrollbar-width: thin;
    scrollbar-color: #bebebe #DFE9EB;
  }
}
.im__sidebar::-webkit-scrollbar {
  height: 5px;
  width: 5px;
}
.im__sidebar::-webkit-scrollbar-track {
  border-radius: 4px;
  background-color: transparent;
}
.im__sidebar::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background-color: #919191;
}

@keyframes detect-scroll {
  from, to { --can-scroll: ; }
}
.im__sidebar {
  animation: detect-scroll linear;
  animation-timeline: scroll(self);
  --bg-if-can-scroll: var(--can-scroll) 5px;
  --bg-if-cant-scroll: 0;
  padding-right: var(--bg-if-can-scroll, var(--bg-if-cant-scroll));
}
@media (max-width: 480px) {
  .bootstrap-dialog.above {
    z-index: 11000 !important;
  }
}