// Directly's Real Time Messaging (RTM) widget is an on-demand customer support tool.
// Read more about the RTM widget and how it's used in Calypso in the `lib/directly` README.
//
// The RTM widget loads in an iframe, so we can't adjust the widget's internal styles
// with the primary Calypso stylesheet. This file is bundled as a separate CSS file to be
// linked from inside the widget's iframe.
//
// We have two Directly builds — Production and Sandbox. Directly requires that all
// custom CSS files exist at a public web address, and these can't change on-the-fly
// based on the Calypso environment. So the CSS files Directly uses are hard-set to:
//
// Sandbox:    https://wpcalypso.wordpress.com/calypso/directly.css
// Production: https://wordpress.com/calypso/directly.css
//
// ## DEVELOPMENT ENVIRONMENT INSTRUCTIONS:
//
// Calypso's development environment uses the Sandbox Directly build, which requests custom
// CSS from the wpcalypso server. This means that to see local CSS changes you'll need to
// make your browser rewrite those CSS URLs to the local version:
//
// https://wpcalypso.wordpress.com/calypso/directly.css -> http://calypso.localhost:3000/calypso/directly.css
//
// You can accomplish this using a browser extension such as Switcharoo Redirector
// for Chrome: https://chrome.google.com/webstore/detail/switcheroo-redirector/cnmciclhnghalnpfhhleggldniplelbg
//
// An unfortunate side-effect is that the widget's iframe src is https, but this local
// CSS file is http. So most browsers will block the CSS by default to prevent mixed
// content. In order to see the custom CSS you will need to temporarily allow insecure
// content on the page. In Chrome for Mac you can issue this Terminal command:
//
// open -a Google\ Chrome --args --allow-running-insecure-content
//
// QUIT AND RESTART YOUR BROWSER NORMALLY WHEN YOU'RE DONE MAKING LOCAL CSS CHANGES.

@import 'shared/utils';

* {
	font-family: $sans;
}

body {
	color: var( --color-text );
	-webkit-font-smoothing: subpixel-antialiased;
}

html,
input,
select,
textarea {
	font-family: $sans;
}

// Main button
.btn {
	background: var( --color-primary );
	border: 1px solid var( --color-primary-40 );
	color: var( --color-text-inverted );
	border-width: 1px 1px 2px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	vertical-align: top;
	box-sizing: border-box;
	line-height: 21px;
	border-radius: 4px;
	padding: 7px 14px 9px;
	appearance: none;
	width: auto;
	&:hover {
		border-color: var( --color-primary-dark );
	}
	&:active,
	&:active:enabled {
		outline: 0;
		border-width: 2px 1px 1px;
		padding: 7px 14px 9px;
		color: var( --color-text-inverted );
	}
	&:focus {
		border-color: var( --color-primary-dark );
		box-shadow: 0 0 0 2px var( --color-primary-light );
	}
}

// Form inputs
input[type='text'],
input[type='password'],
input[type='email'],
input[type='tel'],
input[type='number'],
input[type='url'],
textarea {
	@extend %form-field;
	-webkit-font-smoothing: subpixel-antialiased;

	&::-webkit-input-placeholder {
		color: var( --color-neutral-light );
	}
}
textarea {
	vertical-align: inherit;
}

.minimized-view,
.maximized-view {
	background: #f2f6f8;
}
.minimized-view {
	background: var( --color-surface );
	box-shadow: 0 1px 10px rgba( 46, 68, 83, 0.1 );
	border: 1px solid var( --color-neutral-5 );
}
.maximized-view.is-ask-view {
	top: 0;
}
.message-list-transition-wrapper {
	background: #f2f6f8;
}

/* HEADER */

.header-container {
	border-bottom: 1px solid var( --color-neutral-0 );
	box-shadow: none;
	flex: 0 0 32px;
	height: 32px;

	.header-title {
		text-transform: uppercase;
		font-size: 11px;
		font-weight: 700;
		color: var( --color-neutral-light );
	}

	// Left hamburger button
	.menu {
		border-right: none;
		flex: 0 0 40px;
		.svg-icon {
			color: var( --color-neutral-light );
		}
		&.disabled {
			background: transparent;
			.svg-icon {
				color: var( --color-neutral-5 );
			}
		}
	}

	// Right minimize button
	.minimize-container {
		border-left: none;
		flex: 0 0 40px;
		.svg-icon {
			color: var( --color-neutral-light );
		}
	}

	.thread-view-title-container {
		&.has-notification {
			border-bottom-color: #14abdd;
		}
	}
}

/* CHAT LIST (opens with the hamburguer button on header) */

.chat-list-view-container {
	.chat-list-container {
		top: 32px;
		.question-bar,
		.question-bar.closed {
			background: var( --color-neutral-light );
			padding: 10px 14px;
		}
	}
}

.chat-list-view-item-container {
	background: var( --color-neutral-0 );
	border-bottom: 1px solid var( --color-neutral-5 );
	color: var( --color-text );
	padding: 18px 10px 18px 24px;
	.chat-list-item-title {
		margin-bottom: 2px;
		font-size: 16px;
	}
	.chat-list-item-meta {
		color: var( --color-neutral-light );
	}
	.unread-message-dot {
		background: var( --color-success );
		left: 10px;
		top: 25px;
	}
}

// Bubble when the chat list is minimized
.chat-list-view-minimized {
	.chat-list-status {
		margin-top: 2px;
	}
	.svg-icon {
		color: var( --color-primary );
	}
}

/* ASK QUESTION (opens from chat list) */

.ask-question-form-container {
	.input-group {
		padding-bottom: 12px;
		margin-top: 0;
		label {
			text-transform: none;
			font-size: 14px;
			font-weight: 600;
			margin-bottom: 5px;
			strong {
				font-weight: inherit;
			}
		}
	}
	.submit {
		width: 100%;
		padding-bottom: 9px;
		.svg-icon {
			display: none;
		}
		strong {
			margin-top: 0;
			font-weight: 500;
		}
	}
}

/* THREAD */

.thread-view-container {
	.expert-response-time {
		color: var( --color-neutral-light );
	}
}

// Message bubbles
.message-container {
	font-size: 14px;
	border-radius: 8px;
	&.is-poster {
		background: #14abdd;
		margin-left: inherit;
		margin-right: 20px;
		border-top-right-radius: 0;
		position: relative;
		&::after {
			// Triangle for the corner
			position: absolute;
			top: 0;
			right: -10px;
			content: '';
			display: block;
			width: 0;
			height: 0;
			border-style: solid;
			border-width: 10px 10px 0 0;
			border-color: #14abdd transparent transparent;
		}
	}

	&.is-expert {
		border: none;
		border-radius: 8px;
		border-top-left-radius: 0;
		margin-right: inherit;
		margin-left: 20px;
		position: relative;
		&::after {
			// Triangle for the corner
			position: absolute;
			top: 0;
			left: -10px;
			content: '';
			display: block;
			width: 0;
			height: 0;
			border-style: solid;
			border-width: 0 10px 10px 0;
			border-color: transparent var( --color-border-inverted ) transparent transparent;
		}
		.author img {
			// Need to override inline styles with !importants
			width: 32px !important;
			height: 32px !important;
		}
	}
}

// Avatar + name + reputation, used inside .message-container.is-expert
.author {
	.name-wrapper {
		font-size: 12px;
		font-weight: 500;
	}
	.profile .reputation {
		color: var( --color-neutral-20 );
	}
}
.avatar {
	background: var( --color-neutral-5 );
}

.system-message {
	border: 1px solid var( --color-neutral-5 );
	background: var( --color-neutral-0 );
	font-size: 14px;
	margin-right: 0;
	border-radius: 8px;
	&.has-sibling + .system-message {
		border-top: 1px solid var( --color-neutral-5 );
	}

	// Green border for success messages
	&.success {
		border-color: var( --color-success );
		background: #dceee5;
	}

	// Green background for highlighted success messages
	&.success.inverted {
		border-color: transparent;
		background: var( --color-success );
		color: var( --color-text-inverted );
		a {
			color: var( --color-text-inverted );
		}
	}

	// Yellow borders for warnings
	&.warning {
		background: var( --color-warning );
		border-color: transparent;
		color: var( --color-text-inverted );
		a {
			color: var( --color-text-inverted );
		}
	}

	// Placeholder displayed when the experts info is loading
	&.alerting-experts {
		.expert-name:empty {
			background: var( --color-neutral-5 );
		}
		.expert-last-active-date {
			color: var( --color-neutral-light );
			&:empty {
				background: var( --color-neutral-5 );
			}
		}
	}

	.icon-avatar {
		background: var( --color-neutral-5 );
	}

	// Icons inside system messages
	.icon {
		margin-top: 0;
		&.icon-primary {
			background-color: #14abdd;
		}
		&.icon-success {
			background-color: var( --color-surface );
			color: var( --color-success );
		}
		&.icon-warning {
			background-color: var( --color-surface );
			color: var( --color-warning );
		}
	}
	&.inverted .icon.icon-success {
		background-color: var( --color-surface );
		color: var( --color-success );
	}
}

// When nobody has answered a question yet, a carousel of last available experts is shown
.expert-carousel {
	box-shadow: none;
}

// Reply box and other tools in the thread view footer
.thread-view-footer {
	border-top: 1px solid var( --color-neutral-0 );
	box-shadow: none;
	background: var( --color-surface );
}

// Bubble when the thread view is minimized
.chat-view-minimized {
	// When no expert has replied yet
	.alerting {
		color: var( --color-neutral-light );
		.beacon {
			background: var( --color-primary );
			margin: 5px auto;
			&::after {
				background: var( --color-primary );
			}
		}
	}

	// When there's a chat going on
	.chatting img {
		height: 64px;
		width: 64px;
	}
	.notification {
		background: var( --color-primary );
		font-size: 12px;
		font-weight: 500;
		min-width: 24px;
		line-height: 24px;
		margin-top: -3px;
		margin-left: -3px;
	}
}

// Chat box
.message-form-container {
	.message-input {
		padding-right: 10px;
		align-self: center;
	}
	textarea:focus {
		box-shadow: none;
	}
	.submit-btn[disabled] {
		background-color: var( --color-neutral-5 );
		border: none;
	}
}

// Tools inside chat box
.toolbar-accepted-container,
.toolbar-default-container,
.toolbar-rate-container {
	border-top: 1px solid var( --color-neutral-0 );
}
.toolbar-container {
	.tooltip-wrapper {
		border-left: 1px solid var( --color-neutral-0 );
	}
	.toolbar-btn {
		color: var( --color-neutral-light );
		border-left: 1px solid var( --color-neutral-0 );
		.svg-icon {
			color: var( --color-success );
		}
	}
	.rate-icon {
		.dot {
			&.dot-green {
				background: var( --color-success );
			}
			&.dot-yellow {
				background: var( --color-warning );
			}
			&.dot-red {
				background: var( --color-error );
			}
		}
	}
}

// Displays when the user wants to accept the answer
.ActionBar {
	background: var( --color-surface );
}
.ActionBar__button {
	box-shadow: none;
	&:hover {
		box-shadow: none;
		transform: none;
	}
}
