// Using BEM syntax explained here: https://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/

// Module: Contact Name
.module-contact-name {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow-x: hidden;
  font-weight: 400;
}

.module-contact-name span {
  text-overflow: ellipsis;
  overflow-x: hidden;
  width: 100%;
  text-align: left;
  user-select: none;
}

.module-contact-name__profile-number.italic {
  font-style: italic;
}
// Module: Message

.module-message__error-container {
  width: 28px;
  position: relative;
}

.module-message__error {
  width: 20px;
  height: 20px;
  display: inline-block;
  position: absolute;
  bottom: 4px;
  @include color-svg('../images/error.svg', var(--danger-color));
}

.module-message__error--outgoing {
  left: 8px;
}

.module-message__error--incoming {
  right: 8px;
}

.module-message__img-attachment {
  cursor: pointer;
}

.module-message__generic-attachment {
  display: flex;
  flex-direction: row;
  align-items: center;
  cursor: pointer;
  padding: 10px;
  border-radius: var(--border-radius-message-box);

  .module-message__container--outgoing & {
    color: var(--message-bubbles-sent-text-color);
    background: var(--message-bubbles-sent-background-color);
  }

  .module-message__container--incoming & {
    color: var(--message-bubbles-received-text-color);
    background: var(--message-bubbles-received-background-color);
  }
}

.module-message__generic-attachment__icon-container {
  position: relative;
}
.module-message__generic-attachment__spinner-container {
  padding-inline-start: 4px;
  padding-inline-end: 4px;
}

.module-message__generic-attachment__icon {
  background: url('../images/file-gradient.svg') no-repeat center;
  height: 44px;
  width: 56px;
  margin-inline-start: -13px;
  margin-inline-end: -14px;
  margin-bottom: -4px;

  // So we can center the extension text inside this icon
  display: flex;
  flex-direction: row;
  align-items: center;
}

.module-message__generic-attachment__icon__extension {
  font-size: 9px;
  line-height: 13px;
  letter-spacing: 0.1px;
  text-transform: uppercase;

  // Along with flow layout in parent item, centers text
  text-align: center;
  width: 25px;
  margin-inline-start: auto;
  margin-inline-end: auto;

  // We don't have much room for text here, cut it off without ellipse
  overflow-x: hidden;
  white-space: nowrap;
  text-overflow: clip;

  color: var(--black-color);
}

.module-message__generic-attachment__text {
  flex-grow: 1;
  margin-inline-start: 8px;
  // The width of the icon plus our 8px margin
  max-width: calc(100% - 37px);
}

.module-message__generic-attachment__file-name {
  font-size: 14px;
  line-height: 18px;
  font-weight: 500;
  margin-top: 2px;

  // Handling really long filenames - cut them off
  overflow-x: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.module-message__generic-attachment__file-name,
.module-message__generic-attachment__file-size {
  color: var(--text-primary-color);
}

.module-message__generic-attachment__file-size {
  font-size: var(--font-size-xs);
  line-height: 16px;
  letter-spacing: 0.3px;
  margin-top: 3px;
  text-align: start;
  white-space: nowrap;
}

.module-message__generic-attachment__file-name--incoming,
.module-message__generic-attachment__file-size--incoming,
.module-message__link-preview--incoming {
  color: var(--message-bubbles-received-text-color);
}

.module-message__generic-attachment__file-name--outgoing,
.module-message__generic-attachment__file-size--outgoing,
.module-message__link-preview--outgoing {
  color: var(--message-bubbles-sent-text-color);
}

.module-message__link-preview {
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: var(--border-radius-message-box);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background-color: var(--message-link-preview-background-color);
  margin: var(--padding-link-preview);

  .module-image {
    margin-top: -1px;
    margin-left: -1px;
    margin-bottom: 0;
    border-radius: 0;
    border-top-left-radius: var(--border-radius-message-box);
  }

  &__text {
    padding-block: var(--margins-sm);
  }
}

.module-message__link-preview__content {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-grow: 1;
  margin-right: var(--margins-sm);
}

.module-message__link-preview__image_container {
  margin-inline-end: 8px;
  display: inline-block;
}

.module-message__link-preview__icon_container {
  display: flex;
  justify-content: center;
  flex: initial;
  width: 100px;
  height: 100px;
  position: relative;
  margin-left: -2px;
  margin-inline-end: 8px;

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

  &__inner {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;

    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.module-message__link-preview__icon-container__circle-background {
  display: flex;
  align-items: center;
  justify-content: center;

  height: 32px;
  width: 32px;
  border-radius: 50%;
  background-color: var(--message-link-preview-background-color);
}

.module-message__link-preview__title {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.15px;
  line-height: 22px;

  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.module-message__link-preview__location {
  margin-top: 4px;
  font-size: 12px;
  height: 16px;
  letter-spacing: 0.4px;
  line-height: 16px;
}

.module-conversation__user,
.module-message__author {
  font-size: var(--font-size-sm);
  font-weight: 300;
  line-height: 18px;
  overflow-x: hidden;
  overflow-y: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.module-conversation__user__profile-name,
.module-message__author__profile-name {
  font-style: italic;
}

// Module: Contact List Item

.module-contact-list-item {
  padding-top: 5px;
  padding-bottom: 5px;
  display: flex;
  flex-direction: row;
  align-items: center;

  color: var(--conversation-tab-text-color);
}

.module-contact-list-item--with-click-handler {
  cursor: pointer;
}

.module-contact-list-item__text {
  margin-inline-start: 8px;
}

.module-contact-list-item__text__name {
  font-weight: 300;
  font-size: 14px;
}

.module-contact-list-item__text__profile-name {
  font-style: italic;
}

.module-contact-list-item__text__additional-data {
  margin-top: 3px;
  font-size: 14px;
}

// Module: Conversation Header

.module-conversation-header {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.module-conversation-header__title-container {
  min-width: 0;
  display: block;
  text-align: center;
  flex-grow: 1;
}

.module-conversation-header__title-flex {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  max-width: 100%;
}

.module-conversation-header__avatar {
  cursor: pointer;
  min-width: 28px;
  user-select: none;
}

.module-conversation-header__title {
  margin: 0px 20px;

  min-width: 0;
  font-size: 16px;
  line-height: 26px;
  font-weight: 400;
  color: var(--text-primary-color);

  // width of avatar (28px) and our 6px left margin
  max-width: calc(100% - 34px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  display: flex;
  align-items: center;

  user-select: text;
  cursor: pointer;

  .module-contact-name__profile-name {
    width: 100%;
    overflow: hidden !important;
    text-overflow: ellipsis;
  }
}

// Module: Media Gallery

.module-media-gallery {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  width: 100%;
  overflow: hidden;
}

.module-media-gallery__tab-container {
  display: flex;
  flex-grow: 0;
  flex-shrink: 0;
  cursor: pointer;
  width: 100%;
}

.module-media-gallery__tab {
  width: 100%;
  padding: 20px;
  text-align: center;
}

.module-media-gallery__content {
  display: flex;
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
}

.module-media-gallery__sections {
  display: flex;
  flex-grow: 1;
  flex-direction: column;
  width: 100%;
}

// Module: Attachment Section

.module-attachment-section {
  width: 100%;
}

.module-attachment-section__header {
  font-size: 14px;
  font-weight: normal;
  line-height: 28px;
}

.module-attachment-section__items {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: flex-start;
}

// Module: Document List Item

.module-document-list-item {
  padding-inline-end: 10px;
  width: 100%;
  height: 72px;
}

.module-document-list-item--with-separator {
  border-bottom: 1px solid var(--border-color);
}

.module-document-list-item__content {
  cursor: pointer;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  height: 100%;
}

.module-document-list-item__icon {
  flex-shrink: 0;

  width: 48px;
  height: 48px;
  @include color-svg('../images/file.svg', var(--button-icon-stroke-color));
}

.module-document-list-item__metadata {
  display: inline-flex;
  flex-direction: column;
  flex-grow: 1;
  margin-inline-start: 8px;
  margin-inline-end: 8px;
  min-width: 0;
}

.module-document-list-item__file-name {
  font-weight: bold;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow-x: hidden;
}

.module-document-list-item__file-size {
  display: inline-block;
  margin-top: 8px;
  font-size: 80%;
}

.module-document-list-item__date {
  display: inline-block;
  flex-shrink: 0;
}

// Module: Media Grid Item

.module-media-grid-item {
  height: 94px;
  width: 94px;
  cursor: pointer;
  background-color: var(--message-link-preview-background-color);
  margin-inline-end: 4px;
  margin-bottom: 4px;
  position: relative;
}

.module-media-grid-item__image {
  height: 94px;
  width: 94px;
  object-fit: cover;
}

.module-media-grid-item__icon {
  position: absolute;
  top: 15px;
  bottom: 15px;
  left: 15px;
  right: 15px;
}

.module-media-grid-item__icon-image {
  @include color-svg('../images/image.svg', var(--button-icon-stroke-color));
}

.module-media-grid-item__image-container {
  object-fit: cover;
  position: relative;
}

.module-media-grid-item__circle-overlay {
  position: absolute;
  left: 50%;
  top: 50%;

  transform: translate(-50%, -50%);

  width: 42px;
  height: 42px;
  background-color: var(--chat-buttons-background-color);
  border-radius: 21px;

  &:hover {
    background-color: var(--chat-buttons-background-hover-color);
  }
}

.module-media-grid-item__play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  height: 36px;
  width: 36px;
  @include color-svg('../images/play.svg', var(--chat-buttons-icon-color));
}

.module-media-grid-item__icon-video {
  @include color-svg('../images/movie.svg', var(--button-icon-stroke-color));
}

.module-media-grid-item__icon-generic {
  @include color-svg('../images/file.svg', var(--button-icon-stroke-color));
}

/* Module: Empty State*/

.module-empty-state {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  margin-top: var(--margins-sm);
  font-size: 16px;
}

// Module: Conversation List Item

.module-conversation-list-item {
  max-width: 300px;
  display: flex;
  flex-direction: row;
  padding-inline-end: 16px;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-inline-start: 16px;
  align-items: center;

  cursor: pointer;

  &:hover {
    background-color: var(--conversation-tab-background-hover-color);
  }

  &--is-blocked {
    border-left: 4px solid var(--danger-color) !important;
  }
}

.module-conversation-list-item__unread-count {
  background-color: var(--unread-messages-alert-background-color);
  color: var(--unread-messages-alert-text-color);
  text-align: center;

  padding-top: 1px;
  padding-inline-start: 3px;
  padding-inline-end: 3px;

  position: absolute;
  right: -6px;
  top: -6px;

  font-weight: 300;
  font-size: var(--font-size-xs);
  letter-spacing: 0.25px;

  height: 16px;
  min-width: 16px;
  line-height: 16px;
  border-radius: 8px;
}

.module-conversation-list-item__content {
  flex-grow: 1;
  margin-inline-start: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  max-height: 100%;
  display: flex;
  gap: 5px;

  .session-icon-button:first-child {
    margin-right: var(--margins-sm);
  }
}

.module-conversation-list-item__header {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.module-conversation-list-item__header__name {
  flex-grow: 1;
  flex-shrink: 1;
  font-size: 14px;
  line-height: 18px;

  overflow-x: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

  font-weight: 300;
}

.module-conversation-list-item__header__date {
  flex-shrink: 0;
}

.module-conversation-list-item__header__name--with-unread {
  font-weight: 300;
}

.module-conversation-list-item__header__date--has-unread {
  font-weight: 300;
  color: var(--conversation-tab-text-unread-color);
}

.module-conversation-list-item__message {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.module-conversation-list-item__message__text {
  flex-grow: 1;
  flex-shrink: 1;

  font-size: var(--font-size-sm);
  color: var(--conversation-tab-text-color);

  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  .text-selectable {
    user-select: none;
  }
}

.module-conversation-list-item__message__text--has-unread {
  font-weight: 400;
  color: var(--conversation-tab-text-unread-color);
}

// Module: Image

.module-image {
  overflow: hidden;
  background: none;
  position: relative;
  display: inline-block;
  margin: 1px;
  vertical-align: middle;
}

.module-image__caption-icon {
  position: absolute;
  top: 6px;
  left: 6px;
}

.module-image__with-click-handler {
  cursor: pointer;
}

.module-image--soft-corners {
  border-radius: var(--border-radius-message-box);
}

.module-image__loading-placeholder {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  background-color: var(--message-link-preview-background-color);
}

.module-image__image {
  object-fit: contain;
  cursor: pointer;

  &-cover {
    object-fit: cover;
  }
}

.module-image__play-overlay__circle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  width: 48px;
  height: 48px;
  background-color: var(--chat-buttons-background-color);
  border-radius: 24px;
  z-index: 1;

  &:hover {
    background-color: var(--chat-buttons-background-hover-color);
  }
}

.module-image__play-overlay__icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  height: 36px;
  width: 36px;
  @include color-svg('../images/play.svg', var(--chat-buttons-icon-color));
}

.module-image__text-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;

  color: var(--white-color);

  font-size: 20px;
  font-weight: normal;
  letter-spacing: 0;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.7);
}

.module-image__close-button {
  cursor: pointer;
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  z-index: 2;
  background-image: url('../images/x-shadow-16.svg');
}

// Module: Attachments

.module-attachments {
  border-top: 1px solid var(--border-color);
}

.module-attachments__header {
  height: 24px;
  position: relative;
}

.module-attachments__close-button {
  cursor: pointer;
  position: absolute;
  top: 8px;
  right: 16px;

  width: 20px;
  height: 20px;

  z-index: 2;
  @include color-svg('../images/x-16.svg', var(--button-icon-stroke-color));
}

// Module: Staged Generic Attachment

.module-staged-generic-attachment {
  height: 120px;
  width: 120px;
  margin: 1px;
  display: inline-block;
  position: relative;
  border-radius: 4px;
  box-shadow: inset 0px 0px 0px 1px var(--border-color);
  background-color: var(--message-link-preview-background-color);
  vertical-align: middle;
}

.module-staged-generic-attachment__close-button {
  cursor: pointer;
  position: absolute;
  top: 5px;
  right: 5px;
  width: 16px;
  height: 16px;
  z-index: 2;
  @include color-svg('../images/x-16.svg', var(--button-icon-stroke-color));
}

.module-staged-generic-attachment__icon {
  margin-top: 30px;

  background: url('../images/file-gradient.svg') no-repeat center;
  height: 44px;
  width: 56px;
  margin-inline-start: 32px;
  margin-inline-end: 32px;
  margin-bottom: -4px;

  // So we can center the extension text inside this icon
  display: flex;
  flex-direction: row;
  align-items: center;
}

.module-staged-generic-attachment__icon__extension {
  font-size: 10px;
  line-height: 13px;
  letter-spacing: 0.1px;
  text-transform: uppercase;

  // Along with flow layout in parent item, centers text
  text-align: center;
  width: 25px;
  margin-inline-start: auto;
  margin-inline-end: auto;

  // We don't have much room for text here, cut it off without ellipse
  overflow-x: hidden;
  white-space: nowrap;
  text-overflow: clip;

  color: var(--black-color);
}

.module-staged-generic-attachment__filename {
  margin: 7px;
  margin-top: 5px;
  text-align: center;

  font-family: var(--font-default);
  font-size: 14px;

  overflow: hidden;
  height: 2.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
}

// Module: Caption Editor
.module-caption-editor {
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 20;

  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;

  display: flex;
  flex-direction: column;
  height: 100%;

  .session-button {
    margin-inline-start: 15px;
  }
}

.module-caption-editor__close-button {
  z-index: 21;
  cursor: pointer;
  position: absolute;

  top: 12px;
  right: 16px;
  width: 30px;
  height: 30px;
  z-index: 2;
  // the background of the lightbox is dark
  @include color-svg('../images/x-16.svg', var(--white-color));
}
.module-caption-editor__media-container {
  flex-grow: 1;
  flex-shrink: 1;
  text-align: center;
  margin: 50px;
  overflow: hidden;
  height: 100%;
}
.module-caption-editor__image {
  width: 100%;
  height: 100%;
  object-fit: contain;

  flex-grow: 1;
  flex-shrink: 1;
}
.module-caption-editor__video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;

  flex-grow: 1;
  flex-shrink: 1;
}
.module-caption-editor__placeholder {
  width: 100%;
  height: 100%;
  object-fit: contain;

  flex-grow: 1;
  flex-shrink: 1;
}

// Module: Staged Placeholder Attachment

.module-staged-placeholder-attachment__plus-icon {
  position: absolute;
  left: 50%;
  top: 50%;

  transform: translate(-50%, -50%);

  height: 36px;
  width: 36px;

  @include color-svg('../images/plus-36.svg', var(--chat-buttons-icon-color));
}

// Module: Left Pane

.module-left-pane {
  display: inline-flex;
  flex-direction: column;
  width: var(--left-panel-width);
  height: 100%;
}

.module-left-pane__virtual-list {
  outline: none;
}

// Module H5AudioPlayer
$rhap_background-color: var(--transparent-color) !default;
$rhap_font-family: inherit !default;

.module-message__container--outgoing {
  .rhap_container {
    background-color: var(--message-bubbles-sent-background-color);
    .rhap_play-pause-button,
    .session-button {
      color: var(--message-bubbles-sent-text-color);
      &:hover {
        color: var(--message-bubbles-sent-text-color);
      }
    }
  }

  .rhap_volume-button {
    color: var(--message-bubbles-sent-text-color);
  }

  .rhap_time {
    color: var(--message-bubbles-sent-text-color);
  }

  .rhap_progress-bar {
    background-color: var(--button-icon-stroke-color);
  }

  .rhap_progress-filled {
    background-color: var(--button-icon-stroke-hover-color);
  }

  .rhap_download-progress {
    background-color: var(--button-icon-stroke-hover-color);
  }

  .rhap_progress-indicator {
    background: var(--primary-color);
  }
}

.module-message__container--incoming {
  .rhap_container {
    background-color: var(--message-bubbles-received-background-color);
    .rhap_play-pause-button,
    .session-button {
      color: var(--message-bubbles-received-text-color);
      &:hover {
        color: var(--message-bubbles-received-text-color);
      }
    }
  }

  .rhap_volume-button {
    color: var(--message-bubbles-received-text-color);
  }

  .rhap_time {
    color: var(--message-bubbles-received-text-color);
  }

  .rhap_progress-bar {
    background-color: var(--button-icon-stroke-color);
  }

  .rhap_progress-filled {
    background-color: var(--button-icon-stroke-hover-color);
  }

  .rhap_download-progress {
    background-color: var(--button-icon-stroke-hover-color);
  }

  .rhap_progress-indicator {
    background: var(--primary-color);
  }
}
