.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.archive-button {
  height: 20px;
  border-radius: 4px;
}

.unread-button {
  height: 20px;
  border-radius: 4px;
}

.chat-title {
  margin-bottom: 5px;
}

.messages {
  display: flex;
  flex-direction: column;
  padding: 0.5rem; // Prevent edge clipping
}

.message {
  position: relative;
  border-radius: 20px;
  padding: 0.25rem 0.8rem;
  word-wrap: break-word;

  &-img {
    max-width: 10rem;
    max-height: 10rem;
    object-fit: contain;
    margin: 0.2rem;
    border-radius: 4px;
  }

  &-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

.chat-send-message-button {
  margin: 0.3rem;
  padding-left: 0.5rem;
}

.message-icon {
  position: absolute;
  bottom: 0.1rem;
  right: 0.3rem;
  margin: 0 0.1rem;
  color: var(--message-icon-color);
  z-index: 5;
}

.msgmargin {
  margin: 0.1rem 0;
}

.yours,
.mine {
  display: flex;
  flex-direction: column;

  .message {
    position: relative;

    &:last-child:before,
    &:last-child:after {
      content: "";
      position: absolute;
      bottom: 0;
      height: 20px;
      width: 20px;
      z-index: 0;
    }

    &:last-child:after {
      width: 10px;
      background: var(--message-mine-tail-bg);
      z-index: 1;
    }
  }
}

/* "Yours" (incoming) message styles */
.yours {
  align-items: flex-start;

  .message {
    margin-right: 20%;
    background-color: var(--message-yours-bg);

    &:last-child:before {
      left: -7px;
      background: var(--message-yours-bg);
      border-bottom-right-radius: 15px;
    }

    &:last-child:after {
      left: -10px;
      border-bottom-right-radius: 10px;
    }
  }
}

/* "Mine" (outgoing) message styles */
.mine {
  align-items: flex-end;

  .message {
    color: var(--message-mine-text);
    margin-left: 25%;
    background: linear-gradient(to bottom, var(--message-mine-bg-start) 0%, var(--message-mine-bg-end) 100%);
    padding-bottom: 0.6rem;

    &:last-child:before {
      right: -8px;
      background: linear-gradient(to bottom, var(--message-mine-bg-start) 0%, var(--message-mine-bg-end) 100%);
      border-bottom-left-radius: 15px;
    }

    &:last-child:after {
      right: -10px;
      border-bottom-left-radius: 10px;
    }
  }
}

.system {
  align-items: center;
  margin: 0.5rem 10%;

  .message {
    background-color: var(--system-message-bg);
    border-radius: 10px;
    padding: 0.5rem 1rem;
    text-align: center;
    font-style: italic;
    color: var(--system-message-text);
    width: fit-content;
    max-width: 80%;
  }

  .system-label {
    font-size: 0.75rem;
    color: var(--system-label-text);
    margin-bottom: 0.2rem;
    display: block;
  }

  .system-date {
    font-size: 0.75rem;
    color: var(--system-label-text);
    margin-top: 0.2rem;
    text-align: center;
  }
}

.virtuoso-container {
  flex: 1;
  overflow: auto;
}
