/*
 * Copyright (c) 2016
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
 *
 * See the COPYING-README file.
 *
 */

#chatView .comments,
#chatView .emptycontent {
	flex-grow: 1;
}

#chatView .emptycontent {
	margin-top: 0;
}

#chatView .newCommentForm {
	position: relative;
}

#chatView .newCommentForm .message {
	width: calc(100% - 36px);
	margin-left: 36px;
	padding-right: 30px;
	/**
	 * The div needs to be inline-block, so Chrome/Chromium correctly insert
	 * div-ed multi-line-text with new lines.
	 * Otherwise they are just chained together on posting.
	 *
	 * See https://stackoverflow.com/a/24689420
	 * See https://github.com/nextcloud/spreed/issues/1561
	 */
	display: inline-block;
}

#chatView .newCommentForm .submit,
#chatView .newCommentForm .submitLoading,
#chatView .newCommentForm .share,
#chatView .newCommentForm .shareLoading {
	position: absolute;

	width: 44px;
	height: 44px;

	bottom: -1px;
	margin: 0;
}

#chatView .newCommentForm .submit,
#chatView .newCommentForm .submitLoading {
	right: 0;
}

#chatView .newCommentForm .share,
#chatView .newCommentForm .shareLoading {
	right: -44px;
}

#chatView .newCommentForm .message:focus + .submit:not(:hover):not(:focus) {
	opacity: .6;
}
#chatView .newCommentForm .submit,
#chatView .newCommentForm .share {
	background-color: transparent;
	border: none;
	opacity: .3;
}
#chatView .newCommentForm .submit:hover:not(:disabled),
#chatView .newCommentForm .submit:focus:not(:disabled),
#chatView .newCommentForm .share:hover:not(:disabled),
#chatView .newCommentForm .share:focus:not(:disabled) {
	opacity: 1;
}

#chatView .newCommentForm .cancel {
	margin-right: 6px;
}

#chatView .newCommentForm div.message {
	resize: none;
}

#chatView .newCommentForm div.message:empty:before {
	content: attr(data-placeholder);
	color: grey;
}

/* Internal wrappers used by the virtual list. */
#chatView .comments .wrapper-background,
#chatView .comments .wrapper {
	position: absolute;
	left: 0;
	right: 0;
}

#chatView .comment {
	position: relative;
	margin-bottom: 20px;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

#chatView .comment .avatar,
.atwho-view-ul .chat-view-mention-autocomplete .avatar{
	width: 32px;
	height: 32px;
	line-height: 32px;
	margin-right: 5px;
}

#chatView .comment .message .avatar,
.atwho-view-ul .chat-view-mention-autocomplete .avatar
{
	display: inline-block;
}

#chatView .comment.collapsed .message {
	white-space: pre-wrap;
}

#chatView .comment.collapsed .message {
	max-height: 70px;
	overflow: hidden;
}

#chatView .comment .message-overlay {
	display: none;
}

#chatView .comment.collapsed .message-overlay {
	display: block;
	position: absolute;
	z-index: 2;
	height: 50px;
	pointer-events: none;
	left: 0;
	right: 0;
	bottom: 0;
	background: -moz-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
	background: -webkit-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
	background: -o-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
	background: -ms-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
	background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
	filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#00FFFFFF', endColorstr='#FFFFFFFF');
	background-repeat: no-repeat;
}

#chatView .authorRow>div {
	display: inline-block;
	vertical-align: middle;
}

#chatView .authorRow>div.hidden {
	display: none !important;
}

.atwho-view-ul .chat-view-mention-autocomplete .avatar-name-wrapper,
#chatView .comment .authorRow {
	position: relative;
	display: inline-flex;
	align-items: center;
	width: 100%;
}

#chatView .comment .authorRow .contactsmenu-popover {
	top: 32px;
}

body:not(#body-public) #chatView .comment .authorRow:not(.currentUser):not(.guestUser) {
	.avatar,
	.avatar img,
	.author {
		cursor: pointer;
	}
}

.atwho-view-ul .chat-view-mention-autocomplete .avatar-name-wrapper,
.atwho-view-ul .chat-view-mention-autocomplete .avatar-name-wrapper .avatar,
.atwho-view-ul .chat-view-mention-autocomplete .avatar-name-wrapper .avatar img {
	cursor: pointer;
}

.atwho-view-ul .chat-view-mention-autocomplete .avatar-name-wrapper {
	white-space: nowrap;
}

#chatView .comment .author,
#chatView .comment .date {
	color: var(--color-text-maxcontrast);
}
#chatView .comment .author {
	margin-left: 5px;
}
#chatView .comment .date {
	/* "margin-left: auto" aligns the block to the right, while
	 * "text-align: right" aligns the text inside the block to the right, for
	 * example, when it uses two lines due to a limited width. */
	margin-left: auto;
	text-align: right;
	display: inline-block;
	vertical-align: top;
}

#chatView .comment.systemMessage:not(.grouped) {
	margin-top: -10px;
}

#chatView .comment:not(.systemMessage):not(.grouped):not(.same-author) .date {
	margin-top: -32px;
}

#chatView .comment.grouped .date {
	display: none;
}

#chatView .comments .authorRow,
#chatView .comments li .message {
	/* Makes the container slightly narrower in order not to cover the date on
	 * the right side, thus allowing the date tooltip to be shown properly. */
	width: calc(100% - 80px)
}

#chatView .comments li .message {
	padding-left: 40px;
	display: inline-block;
}

#chatView .comment .action {
	opacity: 0;
	vertical-align: middle;
	display: inline-block;
}

#chatView .comment:hover .action {
	opacity: 0.3;
}

#chatView .comment .action:hover {
	opacity: 1;
}

#chatView .comment .action.delete {
	position: absolute;
	right: 0;
}

#chatView .comment.disabled {
	opacity: 0.3;
}

#chatView .comment.disabled .action {
	visibility: hidden;
}

#chatView .message.error {
	color: #e9322d;
	border-color: #e9322d;
	box-shadow: 0 0 6px #f8b9b7;
}

#chatView .comment.grouped .authorRow,
#chatView .comment.same-author .authorRow {
	display: none;
}

#chatView .comment.grouped,
#chatView .comment.same-author {
	margin-top: -15px;
}

#chatView .comment.showDate {
	margin-top: 40px;
	border-top: 1px solid var(--color-border);
	padding-top: 20px;
}

#chatView .comment.showDate:before {
	content: attr(data-date);

	position: absolute;
	top: 0;
	left: 50%;
	transform: translateX(-50%) translateY(-50%);
	padding: 0 7px 0 7px;

	text-align: center;
	white-space: nowrap;

	color: var(--color-text-maxcontrast);
	background-color: var(--color-main-background);
}

#chatView .comment.showDate .authorRow {
	display: inline-flex;
}

#chatView .comment .message .mention-call,
#chatView .comment .message .mention-user {
	/* Make the mention the positioning context of its child contacts menu */
	position: relative;

	display: inline;
	vertical-align: top;
	background-color: var(--color-background-dark);
	border-radius: 50vh;
	padding: 1px 7px 1px 1px;

	/* Ensure that the avatar and the user name will be kept together;
	 * otherwise a line break could be added between them when the wrapper
	 * is close to the right border of the message. */
	white-space: nowrap;

	.avatar {
		img {
			vertical-align: top;
		}
		height: 16px;
		width: 16px;
		vertical-align: middle;
		padding: 1px;
		margin-top: -4px;
		margin-left: 0;
		margin-right: 2px;

		&.icon {
			margin-top: -2px;
			margin-left: 1px;
			background-color: var(--color-background-darker);
		}
	}
}

#chatView .comment:not(.systemMessage) .message .mention-call,
#chatView .comment:not(.systemMessage) .message .mention-user {
	font-weight: bold;

	&.currentUser {
		background-color: var(--color-primary);
		color: var(--color-primary-text);
	}
}

#chatView .comment.systemMessage .message .mention-call,
#chatView .comment.systemMessage .message .mention-user {
	color: var(--color-main-text);
}

#chatView .comment.systemMessage .message {
	color: var(--color-text-maxcontrast);
}

body:not(#body-public) #chatView .comment:not(.newCommentRow) .message .mention-user:not(.currentUser),
body:not(#body-public) #chatView .comment:not(.newCommentRow) .message .mention-user:not(.currentUser) .avatar,
body:not(#body-public) #chatView .comment:not(.newCommentRow) .message .mention-user:not(.currentUser) .avatar img {
	cursor: pointer;
}

#chatView .comment .message .contactsmenu-popover {
	left: -6px;
	top: 24px;
}

#chatView .comment .message .filePreviewContainer .filePreview {
	/* The file preview can not be a block; otherwise it would fill the whole
	 * width of the container and the loading icon would not be centered on the
	 * image. */
	display: inline-block;
}

#chatView .comment .message .filePreviewContainer strong {
	/* As the file preview is an inline block the name is set as a block to
	 * force it to be on its own line below the preview. */
	display: block;
}

#chatView .comment .message .external:after {
	content: " ↗";
}
