//
//  MESSAGES STRUCTURE
//



.ps-messages {
  position: relative;

  .ps-avatar-comment {
    padding-top: 0;
    vertical-align: middle;
  }

  @extend %clearfix;
}


.ps-messages-chat {
  overflow-x: hidden !important;

  .ps-comment-item {
    @if $scss-direction == rtl {
      padding-left: $padding-base;
    }
  }
}


/*  Wrapping all conversations on main messages page  */
.ps-messages-wrapper {
  overflow: auto;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 75vh;
}


.ps-messages-item {
  margin-bottom: $padd;
  background-color: $scss-messages-item-bg;

  // ROUNDED CORNERS
  @if $scss-rounded == true {
    border-radius: 6px;
    overflow: hidden;
  }

  &:last-of-type {
    margin-bottom: 0;
  }

  > .ps-comment-item {
    border-top: none;
  }

  .ps-comment-body {
    font-size: $font-size-sm;
    line-height: $line-height-sm;
    cursor: pointer;

    @if $scss-direction == rtl {
      padding-right: $padding-sm;
    } @else {
      padding-left: $padding-sm;
    }
  }

  &.unread {
    //color: $message-unread-color;
    background-color: $scss-messages-item-bg-unread;
  }
}


.ps-messages-check {
  display: table-cell;
  width: 20px;
  vertical-align: middle;
}


.ps-messages-title {
  font-size: $font-size-sm;
  line-height: $line-height-sm;
  word-break: break-word;

  #wpadminbar & {
    font-size: $font-size-sm;
    line-height: $line-height-sm;

    > a {
      display: inline;
      padding: 0;
    }

    span {
      font-size: $font-size-sm;
      line-height: $line-height-sm;
    }
  }
}


.ps-messages-options {
  display: table-cell;
  width: 100%;

  .ps-select {
    width: auto;
    height: 28px;
  }
}


.ps-messages-actions {
  position: relative;
  display: table;
  width: 100%;
  margin-bottom: $padding-base;

  .ps-messages-check {
    padding-left: $padding-base;
  }
}


.ps-messages-sent {
  .ps-avatar-comment {
    display: none;
  }

  .ps-comment-body {
    padding-left: 0;
  }
}


.ps-messages-chat {
  .ps-comment-loading {
    display: none;
    padding: 10px 0;
    text-align: center;

    img {
      display: inline;
    }
  }

  .ps-comment-item {
    padding-top: $padding-base;
    padding-bottom: $padding-base;
    background-color: $scss-messages-item-bg;
  }

  .ps-avatar-comment {
    padding-top: 0;
  }

  .ps-comment-content {
    line-height: $line-height-base;

    p {
      margin-bottom: $padding-sm !important;
      font-size: $font-size-alt;
    }
  }
}


.ps-messages-postbox {
  .ps-postbox {
    margin-bottom: 0;
  }

  .ps-postbox-action {
    width: 100%;

    @if $scss-direction == rtl {
      left: 0;
      text-align: left;

      .ps-button-cancel,
      .ps-button-action {
        float: left;
      }
    } @else {
      right: 0;
      text-align: right;
    }
  }

  .ps-list-inline {
    border-bottom: $divider;

    @include media('medium') {
      border-bottom: none;
    }
  }

  .ps-postbox-tab a {
    position: relative;
    z-index: map-get($zindex, normal);
  }

  .ps-postbox-tab-more {
    margin-bottom: 22px;
  }

  @include media('medium') {
    .ps-postbox-action {
      width: auto;
    }

    .ps-postbox-tab-more {
      margin-bottom: 0;
    }
  }
}


.ps-messages-item-head {
  margin-bottom: ($padding-sm / 2);

  > a {
    vertical-align: middle;
  }

  .ps-icon-ok {
    color: #2FBA34;
    display: none;
    font-size: 9px;
    font-weight: normal;

    &.read {
      display: inline;
    }
  }
}


.ps-messages-header {
  width: 100%;
  margin-bottom: -1px;
  padding: $padding-base;
  font-size: $font-size-sm;
  line-height: $line-height-sm;
  border: 1px solid $scss-messages-header-border;

  .ps-icon-bell-off,
  .ps-icon-ok.disable-checkmark {
    color: #e53935;
  }

  @include media('medium') {
    display: table;
  }
}

.ps-messages-participants {
  display: block;

  @include media('medium') {
    display: table-cell;
  }
}


.ps-messages-add-users {
  display: block;
  margin-top: $padding-sm;

  @include media('medium') {
    display: table-cell;
    margin-top: 0;

    @if $scss-direction == rtl {
      text-align: left;
    } @else {
      text-align: right;
    }
  }
}


.ps-messages-recipients {
  padding: $padding-base;

  .ps-btn {
    margin-top: $padding-sm;
  }
}


.ps-messages-recipient {
  display: table;
  width: 100%;
  margin-bottom: $padding-sm;

  .ps-avatar img {
    max-width: 20px;
    max-height: 20px;
    padding: 0;
    margin: 0;
    border: 0;
    vertical-align: middle;
  }

  .ps-comment-body {
    display: inline-block;
    padding-left: ($padding-sm / 2);
    font-size: inherit;
  }
}


.ps-messages-label {
  display: table-cell;
  vertical-align: middle;

  &:first-child {
    @if $scss-direction == rtl {
      padding-left: $padding-base;
    } @else {
      padding-right: $padding-base;
    }
  }

  &:last-child {
    width: 100%;
  }
}


.ps-typing-indicator {
  background-color: $scss-typing-indicator-bg;
  width: auto;
  border-radius: 50px;
  padding: 10px;
  margin-top: $padding-sm;
  display: table;
  position: relative;
  animation: 2s bulge infinite ease-out;

  &:before, &:after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: -2px;
    height: 10px;
    width: 10px;
    border-radius: 50%;
    background-color: $scss-typing-indicator-bg;
  }

  span {
    height: 6px;
    width: 6px;
    float: left;
    margin: 0 1px;
    background-color: $scss-typing-indicator-color;
    display: block;
    border-radius: 50%;
    opacity: 0.4;

    @for $i from 1 through 3 {
      &:nth-of-type(#{$i}){
        animation: 1s blink infinite ($i * .3333s);
      }
    }
  }

  &-small {
    padding: 8px;
    margin-top: 0;
    background-color: $conversation-msg-bg;

    span {
      width: 4px;
      height: 4px;
    }

    &:before, &:after {
      width: 8px;
      height: 8px;
      background-color: $conversation-msg-bg;
    }
  }
}


.ps-messages-status {
  .ps-icon-clock {
    color: $color-icon;
  }

  .ps-icon-circle {
    color: $member-online-color;
  }
}


@keyframes blink{
  50% {
    opacity: 1;
  }
}


@keyframes bulge{
  50% {
    transform: scale(1.05);
  }
}


/*  Overrides recipents select  */
.ps-message-form .chosen-container-multi > .chosen-choices {
  background-color: $input-bg;
  background-image: none;
  border: $input-border;
}


/*  Overrides dropdown list with recipents  */
.ps-message-form .chosen-container > .chosen-drop {
  background-color: $dropdown-bg;
  border: $dropdown-border;
}


/*  Overrides selected recipent label  */
.ps-message-form .chosen-container-multi > .chosen-choices {
  > li.search-choice {
    color: $btn-color;
    background-color: $btn-bg;
    background-image: none;
    border: $btn-border;
    box-shadow: none;
  }
}
