@import "utils/_reset.import.less";
@import "utils/_variables.import.less";
@import "utils/_keyframes.import.less";
@import "utils/_loading.import.less";

* {
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
}

html,
body {
	height: 100%;
}

body {
	margin: 0;
	font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif, "Meiryo UI";
	font-size: 0.8rem;
	color: @primary-font-color;
	height: 100%;
	width: 100%;
	-webkit-font-smoothing: antialiased;
	line-height: 1rem;
	padding: 0;
	overflow: hidden;
	position: relative;
	border-top-right-radius: 5px;
	border-top-left-radius: 5px;
}

input,
select,
textarea {
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	padding: 5px;
	margin: 5px 0;
	border: 1px solid #e7e7e7;
	border-radius: 5px;
	outline: none;
}

button {
	background: none;
	border: none;
	padding: 0;
	text-align: left;
	cursor: pointer;
	text-transform: inherit;
	color: inherit;
	font-style: inherit;
}

input:focus {
	outline: none;
	box-shadow: 0 0 0;
}

.button {
	&:extend(.unselectable);
	display: inline-block;
	padding: 9px 12px;
	font-weight: 500;
	font-size: 13px;
	margin: 4px;
	text-transform: uppercase;
	word-spacing: 0;
	box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.125);
	border: none;
	border-radius: 0;
	line-height: 16px;
	position: relative;
	cursor: pointer;
	color: rgba(255, 255, 255, 0.85);
	background-color: lighten(desaturate(@primary-background-color, 15%), 12.5%);

	span {
		position: relative;
		z-index: 2;
	}

	&::before {
		background-color: rgba(0, 0, 0, 0.1);
		content: " ";
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		opacity: 0;
		z-index: 1;
		transition: opacity 0.1s ease-out;
	}

	&:hover {
		text-decoration: none;
		color: #ffffff;

		&::before {
			opacity: 1;
		}
	}

	&.secondary {
		background-color: @tertiary-background-color;
		color: @primary-font-color;

		&::before {
			background-color: rgba(0, 0, 0, 0.045);
		}
	}

	&.clean {
		font-size: 14px;
		box-shadow: 0 0 3px rgba(0, 0, 0, 0.08);

		&.primary {
			font-weight: 600;
		}
	}

	&.button-block {
		display: block;
		width: 100%;
	}
}

.field-error {
	border: 1px solid red;
}

.livechat-room {
	display: flex;
	flex-direction: column;
	height: 100%;
	border-top-right-radius: inherit;
	border-top-left-radius: inherit;

	&.popout {
		border-top-right-radius: 0;
		border-top-left-radius: 0;

		.title {
			cursor: default;
		}
	}

	.title {
		flex: 1 0 @header-min-height;
		line-height: @header-min-height;
		border-top-right-radius: inherit;
		border-top-left-radius: inherit;
		color: #ffffff;
		z-index: 10;
		cursor: pointer;
		padding: 0 10px;

		h1 {
			margin: 0;
			font-size: 10pt;
			display: inline-block;
		}

		.toolbar {
			display: inline-block;
			float: right;

			svg {
				cursor: pointer;
				fill: currentColor;
				width: 14px;
				margin: 0 5px;
				vertical-align: middle;

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

	.header {
		flex: 1 0 60px;
		display: flex;
		box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.2);
		background-color: #fcfcfc;
		color: @secondary-font-color;
		z-index: 2;

		.picture {
			flex: 0 1 60px;
			padding: 5px 10px;

			img {
				width: 50px;
				height: 50px;
				border-radius: 6px;
				border: 1px solid @window-border-color;
			}
		}

		.info {
			flex: 1;
			padding: 5px 0;

			h2 {
				color: @primary-font-color;
				font-size: 14px;
			}

			li {
				font-size: 11px;
			}
		}
	}

	.messages {
		flex: 1 1 100%;
		background-color: #ffffff;
		border-left: 1px solid @window-border-color;
		border-right: 1px solid @window-border-color;
		overflow-y: auto;

		.wrapper {
			padding-bottom: 6px;

			ul {
				list-style-type: none;
				padding: 0;

				li {
					padding: 0;
				}
			}

			.message {
				font-size: 12px;
				padding: 8px 10px 0;
				position: relative;
				line-height: 18px;
				min-height: 36px;

				&::after {
					content: '';
					display: block;
					clear: both;
				}

				.content {
					width: 75%;
					background-color: #f3f3f3;
					border: 1px solid desaturate(darken(#f3f3f3, 10%), 40%);
					margin-left: 38px;
					border-radius: 6px;
					padding: 5px;
					float: left;
					word-wrap: break-word;
					word-break: break-word;
					-ms-hyphens: auto;
					-moz-hyphens: auto;
					-webkit-hyphens: auto;
					hyphens: auto;

					&::before {
						border-style: solid;
						border-color: transparent desaturate(darken(#f3f3f3, 10%), 40%) transparent transparent;
						content: " ";
						height: 0;
						width: 0;
						font-size: 0;
						pointer-events: none;
						border-width: 5px;
						position: absolute;
						left: 38px;
					}
				}

				&:nth-child(1) {
					margin-top: 0;
				}

				&.new-day {
					margin-top: 60px;

					&::before {
						content: attr(data-date);
						display: block;
						position: absolute;
						top: -30px;
						left: calc(~'50% - 70px');
						font-size: 10px;
						font-weight: 600;
						text-align: center;
						color: @secondary-font-color;
						z-index: 1;
						padding: 0 10px;
						background-color: #ffffff;
						min-width: 120px;
					}

					.content {
						&::after {
							content: " ";
							display: block;
							position: absolute;
							top: -20px;
							left: 0;
							width: 100%;
							border-top: 1px solid #dddddd;
						}
					}
				}

				.edit-message {
					display: none;
					cursor: pointer;
				}

				&.own {
					.content {
						background-color: #feffd7;
						border: 1px solid desaturate(darken(#feffd7, 10%), 40%);
						float: right;
						margin-right: 3px;

						&::before {
							border-style: solid;
							border-color: transparent transparent transparent desaturate(darken(#feffd7, 10%), 40%);
							content: " ";
							height: 0;
							width: 0;
							font-size: 0;
							pointer-events: none;
							border-width: 5px;
							position: absolute;
							right: 3px;
							left: inherit;
						}
					}

					.thumb {
						display: none;
					}
				}

				.delete-message {
					display: none;
					cursor: pointer;
				}

				.user {
					display: inline-block;
					font-weight: 600;
					color: #444444;
					margin-right: 5px;
					outline: none;

					&:hover {
						color: #333333;
					}
				}

				.thumb {
					position: absolute;
					left: 10px;
					top: 6px;
					display: block;
					width: 30px;
					height: 30px;
				}

				.info {
					color: @info-font-color;
					display: inline-block;
					float: right;
					margin: 9px -1px -5px 9px;
					font-size: 9px;
					text-align: right;
					left: -10px;
					width: 55px;

					.edited {
						display: inline-block;
					}

					.edit-message {
						float: left;
						margin-left: 1px;
					}

					.delete-message {
						float: left;
					}
				}

				&.sequential {
					padding-top: 2px;
					min-height: 20px;

					.user {
						display: none;
					}

					.thumb {
						display: none;
					}
				}

				&.system {
					.body {
						color: @info-font-color;
						font-style: italic;

						em {
							font-weight: 600;
						}
					}
				}

				.avatar-initials {
					line-height: 40px;
				}

				a {
					color: @link-font-color;
					font-weight: 400;

					&:hover {
						color: darken(@link-font-color, 10%);
						text-decoration: underline;
					}
				}

				.body {
					opacity: 1;
					transition: opacity 1s linear;

					.inline-image {
						display: inline-block;
						overflow: hidden;
			
						border-radius: 3px;
						background-repeat: no-repeat;
						background-position: center left;
						background-size: contain;
						box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
			
						line-height: 0;
			
						img {
							max-width: 100%;
							max-height: 200px;
			
							cursor: pointer;
			
							opacity: 0;
						}
					}								
				}

				&.temp .body {
					opacity: 0.5;
				}

				&.msg-error .body {
					text-decoration: line-through;
				}

				.avatar {
					height: 100%;
					width: 100%;

					.avatar-image {
						height: 100%;
						width: 100%;
						min-height: 20px;
						min-width: 20px;
						display: block;
						position: relative;
						background-color: transparent;
						background-size: cover;
						background-repeat: no-repeat;
						background-position: center;
						border-radius: 4px;
					}
				}
			}
		}

		.new-message {
			margin: 0 -65px;
			position: absolute;
			background: #428bca;
			border-radius: 20px;
			width: 130px;
			height: 30px;
			text-align: center;
			color: #ffffff;
			line-height: 30px;
			font-size: 0.8em;
			cursor: pointer;
			bottom: 8px;
			left: 50%;
			z-index: 5;
			transition: transform 0.3s ease-out;
			transform: translateY(-40px);

			&.not {
				transform: translateY(100%);
			}
		}

		.error {
			bottom: @footer-min-height;
			position: fixed;
			width: 100%;
			background-color: #f7d799;
			padding: 5px;
			z-index: 8;
			transition: transform 0.2s ease-out;
			transform: translateY(100%);

			&.show {
				transform: translateY(0);
			}
		}
	}

	.footer {
		flex: 1 0 @footer-min-height;
		z-index: 10;
		background-color: #fcfcfc;
		border-top: 1px solid @window-border-color;
		border-left: 1px solid @window-border-color;
		border-right: 1px solid @window-border-color;

		.message-bar {
			display: flex;
			flex-direction: row;
			padding-top: 6px;

			.input-wrapper {
				flex-grow: 1;
				border-width: 1px;
				border-radius: 4px;
				margin-left: 6px;
				border-color: @input-border-color;
				display: flex;
				align-items: center;

				textarea {
					display: block;
					padding: 6px 8px;
					padding-right: 38px;
					overflow-y: auto;
					resize: none;
					margin: 0;
					max-height: 200px;
					width: 100%;
					font-size: 12px;
					-webkit-appearance: none;
					height: 28px;
					line-height: normal;
					background-color: transparent;
					position: relative;
					border: 0;
				}

				.upload-button-box {
					display: flex;
					padding: 0 5px;

					svg {
						width: 15px;
						height: 15px;
						cursor: pointer;
						color: @secondary-font-color;
						fill: @secondary-font-color;
	
						&:hover {
							fill: @primary-font-color;
						}
					}						
				}
			}

			.buttons {
				color: @secondary-font-color;
				fill: @secondary-font-color;
				display: flex;
				align-items: center;
				padding: 0 5px;

				svg {
					width: 15px;
					height: 15px;
					margin: 0 4px;
					cursor: pointer;
					transition: fill 0.15s ease-out;

					&:hover {
						fill: @primary-font-color;
					}
				}
			}
		}

		.toggle-options {
			clear: both;
			color: @secondary-font-color;
			margin-left: 6px;
			outline: none;
			margin-top: 5px;
			font-size: 0.65rem;
		}

		.typing {
			clear: both;
			color: @secondary-font-color;
			margin-left: 8px;
			outline: none;
			margin-top: 2px;
			font-size: 0.65rem;
		}

		.options-menu {
			min-width: 100px;
			bottom: 21px;
			left: 6px;
			border-radius: 2px;
			padding: 6px 0;
			background-color: #ffffff;
			color: @secondary-font-color;
			box-shadow:
				0 1px 1px 0 rgba(0, 0, 0, 0.2),
				0 2px 10px 0 rgba(0, 0, 0, 0.16);
			position: absolute;
			z-index: 200;
			transition: transform 0.15s ease, visibility 0.15s ease, opacity 0.15s ease;
			transform: translateY(30px);
			opacity: 0;
			visibility: hidden;

			&.show {
				transform: translateY(0);
				opacity: 1;
				display: block;
				visibility: visible;
			}

			ul {
				li {
					padding: 0 13px 0 8px;

					&:hover {
						background-color: #eeeeee;
					}

					button {
						display: block;
						padding: 4px 2px;
						outline: none;
					}
				}
			}
		}
	}

	.offline {
		flex: 1 1 100%;
		background-color: white;
		padding: 1em 10px;
		border-left: 1px solid @window-border-color;
		border-right: 1px solid @window-border-color;

		.offline-message {
			padding: 1em 0;
		}

		.message-sent {
			text-align: center;
		}

		form {
			input,
			textarea {
				display: block;
				width: 100%;
			}

			.buttons {
				text-align: center;
			}

			.error {
				display: none;
				background-color: #f7d799;
				padding: 5px;

				&.show {
					display: block;
				}
			}
		}
	}
}

.livechat-form {
	flex: 1 1 100%;
	display: block;
	background-color: #ffffff;
	border-left: 1px solid @window-border-color;
	border-right: 1px solid @window-border-color;
	padding: 5px;

	input,
	select {
		display: block;
		background-color: #ffffff;
	}

	.error {
		display: none;
		background-color: #f7d799;
		padding: 5px;

		&.show {
			display: block;
		}
	}

	form {
		padding: 0 1em;
		text-align: center;

		input,
		select {
			width: 100%;
		}
	}
}

.modal {
	border-top-right-radius: inherit;
	border-top-left-radius: inherit;

	.overlay {
		border-top-right-radius: inherit;
		border-top-left-radius: inherit;
		background-color: rgba(0, 0, 0, 0.5);
		position: fixed;
		height: 100%;
		width: 100%;
		z-index: 990;
		top: 0;
		left: 0;
	}

	.wrapper {
		z-index: 999;
		background: white;
		position: fixed;
		height: 80%;
		width: 80%;
		top: 15%;
		left: 10%;
		border-radius: 6px;
		display: flex;
		flex-direction: column;

		header {
			flex: 1 0 40px;
			padding: 0 15px;
			border-bottom: 1px solid rgba(0, 0, 0, 0.1);
			line-height: 40px;
			white-space: nowrap;
			text-overflow: ellipsis;
			overflow: hidden;
		}

		.content {
			overflow-y: auto;
			padding: 10px;
			flex: 1 1 100%;

			.instructions {
				margin-top: 5px;
			}

			.survey-item {
				margin-top: 20px;

				.question {
					display: block;
				}

				.answer {
					margin-right: 5px;
					display: inline-block;
					text-align: center;
				}
			}
		}

		footer {
			flex: 1 0 60px;
			border-top: 1px solid rgba(0, 0, 0, 0.1);
			line-height: 60px;
			text-align: right;
			padding-right: 20px;
		}
	}
}

.powered-by {
	margin-top: -20px;
	line-height: 20px;
	right: 0;
	z-index: 10;
	text-align: right;
	font-size: 0.65rem;
	height: 20px;
	color: #666666;
	padding: 0 1em;
	opacity: 0.5;
	align-self: flex-end;
	transition: opacity 0.15s ease-out;

	&:hover {
		opacity: 1;
	}

	a {
		text-decoration: none;
		margin-left: 1px;

		img {
			height: 14px;
			vertical-align: middle;
		}
	}
}

.sweet-overlay {
	border-top-right-radius: inherit;
	border-top-left-radius: inherit;
}

.video-call {
	position: fixed;
	top: @header-min-height;
	bottom: 0;
	left: 0;
	right: 0;
	background-color: #000000;
	z-index: 11;

	.video-overlay {
		position: fixed;
		top: @header-min-height;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 13;

		.toolbar {
			position: absolute;
			bottom: 40px;
			width: 100%;
			text-align: center;
			opacity: 0;
			visibility: hidden;
			transform: translateY(50px);
			transition: opacity 0.175s ease-out, transform 0.175s ease-out, visibility 0.175s ease-out;

			&.visible {
				opacity: 1;
				visibility: visible;
				transform: translateY(0);
			}

			.end-call {
				background-color: red;
				fill: white;
				border-radius: 50%;
				height: 60px;
				width: 60px;
				text-align: center;
				outline: none;

				svg {
					width: 30px;
					height: 30px;
				}
			}
		}
	}

	.container {
		z-index: 12;
	}
}

.upload-preview {
	.upload-preview-file {
		height: 200px;

		background-repeat: no-repeat;
		background-position: center center;
		background-size: contain;
	}
}

@media all and(max-height: 200px) {
	.livechat-room {
		.title {
			height: 100%;
		}

		.footer {
			display: none;
		}

		.messages {
			display: none;
		}

		.powered-by {
			display: none;
		}
	}
}
