@use "sass:math";
@use '../../common/color.module.scss';

#message-accounts {
  padding-top: 20px;
  padding-bottom: 10px;
  text-align: right;

  a {
    $size: 40px;
    $border: 3px;
    $bg: #ccc;
    $selectedBg: color.$color-red;

    margin: 0 4px;
    display: inline-block;
    position: relative;
    background: $bg;
    height: $size + 2 * $border;
    width: $size + 2 * $border;
    border-radius: math.div($size, 2) + $border;
    box-sizing: border-box;
    padding: $border;
    font-size: 0;

    span {
      position: absolute;
      vertical-align: top;
      font-size: math.div($size, 3);
      display: inline-block;
      line-height: $size;
      height: $size + 2 * $border;
      padding: $border 10px + math.div($size, 2) $border 10px;
      box-sizing: border-box;
      background: $bg;
      margin-right: (math.div($size, 2) + $border);
      margin-top: -$border;
      border-radius: math.div($size, 2) + $border 0 0 math.div($size, 2) + $border;
      transform: scaleX(0);
      transform-origin: right;
      transition: transform 0.2s;
      z-index: -1;
      right: 0;
      pointer-events: none;
    }

    &:hover {
      z-index: 100;

      span {
        transform: scaleX(1);
      }
    }

    &.selected {
      background: $selectedBg;

      span {
        background: $selectedBg;
        color: white;
      }
    }

    &.has-unviewed-messages {
      &::before {
        content: '';
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        background: color.$color-red;
        width: 10px;
        height: 10px;
        border-radius: 5px;
        box-shadow: 0 0 0 2px #ccc;
      }
    }
  }
}

#messages-wrapper {
  header {
    justify-content: space-between;
    display: flex;
    margin: 10px 0;
    padding-bottom: 0;

    div {
      flex: 1;
    }

    input {
      margin-left: 40px;
      width: 200px;
    }
  }

  td {
    position: relative;
  }

  #loaddiv {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    background: rgba(#fff, 0.6);
    z-index: 10;
  }
}

#message-messages {
  #boxes {
    height: 0;

    .chatnotviewed::before {
      content: '';
      display: block;
      position: absolute;
      width: 15px;
      height: 15px;
      background: color.$color-red;
      border-radius: 50%;
    }
  }

  .chat-people {
    width: 30%;
    overflow-y: scroll;
    position: relative;

    & + td span:first-child {
      font-weight: 600;
    }
  }

  .selectbox {
    margin: 8px 0;
    display: flex;
    cursor: pointer;
  }

  .boxbackground {
    background-color: #e5e5e5;
  }

  .chat-subject {
    font-size: 13px;
    line-height: 1.1;
    color: gray;
  }

  .chat-created {
    font-size: 10px;
  }

  tr.messages-wrapper {
    overflow-y: auto;
  }

  #scrollthis {
    height: 300px;
    overflow-y: auto;
  }

  #chat-not-found {
    height: 100%;
    display: grid;
    place-items: center;
  }

  #sendform {
    #tmessage {
      border: 0;
      width: 100%;
      resize: none;
      padding: 10px;

      & + div {
        display: flex;
        align-items: center;
      }
    }

    [type='submit'] {
      width: 120px;
      margin-right: 20px;
    }
  }
}

@include media-breakpoint-down(sm) {
  #message-messages {
    .chat-people {
      padding: 0;
    }

    .selectbox {
      flex-direction: column;
      text-align: center;
      margin: 0 0 8px 0;
      padding: 8px 0;
    }

    .chat-subject,
    .chat-created {
      display: none;
    }
  }
}

@include media-breakpoint-up(sm) {
  #message-messages {
    .chat-avatar {
      margin-right: 10px;
    }
  }
}
