.chat-popup, .chat-popup-group {
  position: fixed;
  z-index: 1150;
  bottom: 0;
  right: -100%;
  margin-right: 15px;
  height: 375px;
  width: $chat-popup-width;
  overflow: hidden;
  border: 1px solid rgba(125, 125, 125, .3);
  border-bottom: 0;
  box-shadow: 0px 0px 8px rgba(125, 125, 125, .4);
  line-height: normal;
  border-top-right-radius: $chat-default-border-radius;
  border-top-left-radius: $chat-default-border-radius;
  transition: right .3s ease;

  &.popup-enter {
    transition: top .3s ease;    
  }

  &.popup-leave {
    bottom: -100%;
  }

  &.highlight {
    animation-name: ChatCallAttention;
    transform-origin: center bottom;
    animation-duration: 0.75s;
    .popup-head {
      animation: colorPulse .3s 2;
      background-color: lighten($chat-primary, 15%);
    }
  }

  &.popup-closed {
    height: auto;

    .chat-popup-toggle {
      a > .fa-angle-down:before {
        content: "";
      }
    }

    .popup-messages, .popup-messages-footer, .chat-tab-content {
      display: none;
    }

    .popup-head .chat-loading-dots {
      display: inline-block !important;
      margin-left: 5px;

      > span {
        background: #FFF;
        width: 4px;
        height: 4px;
      }
    }
  }

  &.popup-on {
    border-color: $chat-secondary;

    .popup-head {
      animation: colorPulse 1s 2;
      background-color: $chat-secondary;

      .popup-head-buttons a {
        &:hover, &:active, &:focus {
          background-color: $chat-secondary-dark;
        }
      }
    }
  }

  .popup-action-list {
    border-bottom: 1px solid #e5e5e5;
    background: #f5f5f5;
    clear: both;

    .popup-participants-counter {
      font-size: 16px;
    }

    @media (min-width: 768px) {
      height: 36px;
      line-height: 16px;
    }

    .popup-action-item {
      padding: 8px 10px;
      display: inline-block;
      color: #777;
      font-size: 18px;
      text-decoration: none;

      &:hover {
        color: darken(#666, 10%);
      }

      @media (max-width: 767px) {
        font-size: 1.125rem;
      }

      &.disabled, &[disabled="disabled"] {
        cursor: default;
        opacity: 0.5;
      }

      i {
        vertical-align: middle;
        display: inline-block;
      }
    }
  }

  .popup-head {
    background-color: $chat-primary;
    float: left;
    clear: both;
    width: 100%;
    height: 45px;
    line-height: 19px;
    margin: 0;

    &.chat-navbar {
      li > a, ul > li > a {
        line-height: 19px;
      }

      .chat-navbar-brand {
        line-height: 20px;
        max-width: 190px;
        cursor: default;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;

        > i {
          margin-right: 5px;
        }

        &:hover, &:focus, &:active {
          background-color: inherit;
          color: #FFF;
        }
      }
    }

    .chat-status {
      margin-right: 5px;
    }

    .chat-loading-dots {
      display: none !important;
    }

  }

  .popup-messages {
    position: relative;
    background: #EEEEEE none repeat scroll 0 0;
    clear: both;
    height: calc(100% - 90px);

    .popup-messages-container {
      position: relative;
    }

    .highlighted {
      background-color: #FFFF00;
    }

    .chat-loader {
      .chat-loader-message {
        border-radius: 20px;
        background: #888;
        color: #FFF;
        padding: 5px 10px;
        display: inline-block;
      }

      .chat-loader-container.first .chat-loader-path {
        fill: #EEEEEE;
      }
    }

    .direct-chat-timestamp {
      i {
        vertical-align: middle;
        font-size: 10px;

        &.read {
          color: darken($chat-secondary, 5%);
          animation-name: ChatBounceIn;
          animation-duration: 1s;
        }
      }
    }

    .chat-box-single-line {
      border-bottom: 1px solid #a4c6b5;
      height: 12px;
      margin: 7px 0 20px;
      position: relative;
      text-align: center;
    }

    .direct-chat-messages {
      width: 100%;
      height: 248px;
      overflow-x: hidden;
      overflow-y: auto;
      padding: 15px;
      color: #111;
      background-image: url("https://chat.ingaia.com.br/assets/img/popup-bg.png");
      background-color: #e1e3e6;
      background-position: center;
      background-size: contain;
      box-shadow: inset 0px 3px 5px -2px #b9b9b9;

      .direct-chat-msg-block {
        float: left;
        width: 100%;
        margin-top: 6px;
        margin-bottom: 6px;

        &.direct-chat-msg-error {
          .direct-chat-text > div {
            opacity: 0.3;
          }
        }
      }

      .direct-chat-msg {
        margin-bottom: 0;
        position: relative;

        &.first {
          border: 1px solid red;

          .direct-chat-timestamp {
            display: none;
          }
        }

        &.middle {
          border: 1px solid blue;
          margin-top: 0;

          .direct-chat-timestamp {
            display: none;
          }

          .direct-chat-text {
            &:before {
              display: none;
            }
          }
        }

        &.last {
          border: 1px solid green;
          margin-top: 0;

          .direct-chat-text {
            &:before {
              display: none;
            }
          }
        }

        &.me {
          float: left;
          width: 100%;
          clear: both;
          @include animation(ChatFadeInRight, 0.3s);

          .direct-chat-img {
            right: 0;
            top: 0;
          }

          .direct-chat-text {
            float: right;
            border-top-right-radius: 0;
            background-color: #CECECE;
            box-shadow: -1px 1px 1px darken(#CECECE, 10%);

            &:before {
              right: -7px;
              border-left-width: 10px;
              border-right-width: 0;
              border-left-color: #CECECE;
            }
          }

          .direct-chat-timestamp {
            text-align: right;
          }

          &.direct-typing-message {
            text-align: right;
          }
        }

        &.user {
          float: left;
          width: 100%;
          clear: both;

          @include animation(ChatFadeInLeft, 0.3s);

          .direct-chat-img {
            left: 0;
            top: 0;
          }

          .direct-chat-text {
            border-top-left-radius: 0;
            margin-left: 42px;

            &:before {
              left: -7px;
              border-left-width: 0;
              border-right-width: 10px;
              border-right-color: #FFF;
            }
          }

          .direct-chat-timestamp {
            text-align: left;
            margin-left: 45px;
          }
        }

        &.direct-typing-message {
          .direct-chat-text {
            white-space: normal;
            display: inline-block;
            padding: 5px 14px;
          }
        }

        .direct-chat-msg-error {
          color: $chat-danger;
        }
      }

      .direct-chat-system {
        clear: both;
        text-align: center;

        .direct-chat-text {
          padding: 4px 8px;
          border-radius: 20px;
          display: inline-block;
          background-color: #888;
          color: #fff;

          &:before {
            display: none;
          }
        }
      }

      .direct-typing-message {
        height: 35px;
      }

      .direct-typing-user {
        opacity: 0.5;

        &.active {
          opacity: 1;
        }
      }
    }

    .direct-chat-text {
      position: relative;
      max-width: 100%;
      background: #FFFFFF none repeat scroll 0 0;
      display: inline-block;
      clear: both;
      border-radius: 4px;
      padding: 6px 10px;
      color: #111;
      white-space: pre-wrap;
      margin-bottom: 3px;
      font-size: 18px;
      box-shadow: 1px 1px 1px darken(#CECECE, 10%);

      @media (min-width: 768px) {
        font-size: 13px;
      }

      > div {
        overflow: hidden;
        text-overflow: ellipsis;
      }

      &:before {
        content: "";
        position: absolute;
        display: block;
        width: 0;
        height: 0;
        top: 0;
        right: -7px;
        border-color: transparent;
        border-style: solid;
        border-left-width: 10px;
        border-right-width: 0;
        border-top-width: 0px;
        border-bottom-width: 8px;
        border-left-color: #FFF;
      }

      a {
        color: $chat-secondary;

        &:hover {
          color: $chat-secondary-dark;
        }
      }
    }

    .direct-chat-name {
      font-size: 15px;
      font-weight: 600;
      margin: 0 0 0 49px !important;
      color: $chat-text-inverse;
      opacity: 0.9;
    }

    .direct-chat-timestamp {
      clear: both;
      color: $chat-grey;
      display: block;
      margin-bottom: 0;
      font-size: 14px;

      @media (min-width: 768px) {
        font-size: 11px;
      }
    }

    .direct-chat-img {
      border-radius: 50%;
      height: 32px;
      width: 32px;
      position: absolute;
      z-index: 1;
      background-color: #DADADA;
      box-shadow: 0px 1px 1px #A9A9A9;
    }

    .auto-scroll-button {
      display: none;
      opacity: 0.7;
      background-color: #fff;
      padding: 5px;
      border-radius: 100%;
      width: 28px;
      height: 28px;
      font-size: 16px;
      color: $chat-secondary;
      line-height: 22px;
      text-align: center;
      position: absolute;
      right: 10px;
      bottom: 10px;
      z-index: 100;
      transition: background 0.3s ease;
      box-shadow: 1px 1px 1px #C9C9C9;

      &:hover {
        opacity: 1;
        cursor: pointer;
      }

      &.show {
        display: block;
        animation-name: ChatBounceIn;
        animation-duration: 0.5s;
      }
    }
  }

  .popup-messages-footer {
    width: 100%;
    background: #F9F9F9 none repeat scroll 0 0;
    box-shadow: 0px 0px 5px #CCC;
    position: absolute;
    bottom: -($chat-text-box-height);
    z-index: 10;

    .button {
      font-size: 1.5rem;
      margin: 0;
      background-color: #fff;
      border: 0;
      display: table-cell;
      vertical-align: middle;
    }

    .popup-text-box {
      display: inline-flex;
      width: 100%;
      min-height: $chat-text-box-height;
      max-height: 100px;
    }

    .emoji-button {
      width: 50px;
      color: lighten(#7A7A7A, 25%);
      border-radius: 0;
      padding: 0;

      > .ing {
        vertical-align: middle;
      }

      &.on, &:hover, &:focus {
        color: #7A7A7A;
        outline: none;
      }

      &.active {
        color: $chat-icon;
      }

      &:not(.disabled) {
        cursor: pointer;
      }
    }

    .send-message-button {
      width: 50px;
      display: none;

      i {
        opacity: 0.2;
        color: $chat-secondary;
      }

      &.active {
        i {
          opacity: 1;
        }
      }
    }

    .popup-textarea {
      padding: 12px;
    }

    .popup-textarea, .emoji-wysiwyg-editor {
      display: table-cell;
      vertical-align: middle;
      font-size: 14px;
      line-height: 20px;
      color: #7A7A7A;
      background-color: #FFF;
      width: 100%;
      height: auto;
      min-height: $chat-text-box-height;
      max-height: 100px;
      border: none;
      border-radius: 0;
      box-shadow: none;
      resize: none;
      padding-top: 12px;
      margin: 0;
      overflow: hidden;
      box-sizing: border-box;

      &:focus {
        outline: none;
        border: 1px solid $chat-background;
        border: 1px solid $chat-background;
        box-shadow: 0px 0px 5px $chat-background inset;
      }

      &:hover {
        cursor: text;
      }

      &[contenteditable="false"] {
        opacity: 0.5;
        cursor: not-allowed !important;
      }
    }
  }

  .popup-search-message {
    position: absolute;
    width: 100%;
    z-index: 1;
    background: #f5f5f5;

    input[type=text] {
      border-radius: 0;
      color: #777;
    }
  }

  .chat-tab-content {
    padding-bottom: 97px;

    .chat-tab-footer .button {
      font-size: 12px;
    }

    input[type=text] {
      border: 1px solid $chat-border-light;
      padding: 12px;
    }

    .chat-tab-list > .chat-tab-list-item {

      &.disabled {
        opacity: 0.7;
        cursor: default;
      }

      > li:not(:last-child) {
        margin-bottom: 8px;
      }

      > .ing {
        cursor: pointer;
        margin-right: 2px;
        display: inline;
        vertical-align: middle;
      }
    }
  }

  // TOASTER
  .chat-toaster {
    .chat-toaster-content {
      text-align: left;

      .chat-toaster-icon {
        font-size: 1.25rem;
        padding-left: 10px;
        padding-right: 5px;
      }
    }
  }

  // .chat-popup
  @media (max-width: 767px) {
    z-index: 9999;
    width: 100%;
    height: 100%;
    left: 0 !important;
    margin-left: 0;

    .popup-messages {
      //height: 100%;
      .popup-messages-container {
        height: calc(100% - #{$chat-text-box-height});
        .direct-chat-messages {
          height: 100%;
        }
      }
    }

    .chat-tab-content {
      padding-bottom: 0;
      height: 100%;
    }

    .chat-popup-toggle {
      display: none;
    }

    .send-message-button {
      display: table-cell !important;
    }
  }
}

.chat-popup:last-of-type {
  z-index: 1149 !important;
}

// Responsive
@media (max-width: 768px) {
  .emoji-menu {
    width: 100% !important;
  }

  .popup-group {
    display: none;
  }
}
