//TODO: Refactor these styles into separate smaller files.

@import '~mixins.scss';
@import '~variables/_typography.scss';
@import '~variables/_colors.scss';
@import '~draft-js/dist/Draft.css';

// colors
$editor-neutral-border: rgba(150,150,150,0.4);
$editor-neutral-bg: rgba(150,150,150,0.25);
$editor-neutral-color: rgba(123,123,123,0.8);

$editor-styleButton-color:inherit;
$editor-styleButton-active-color:#5890ff;
$editor-styleButton-size: 3rem;

.main-article .abstract div.Editor3-root div.link-toolbar {
	font-size: 13px !important;
	font-style: normal;
	padding: 0 10px;
	border-top: 1px solid $editor-neutral-border;
	//background-color: #fdfdfd;
	height: 0;
	min-height: auto;
	opacity: 0;
	transition: all .2s ease-out;

	&.is-link {
		height: 26px;
		padding: 5px 10px;
		opacity: 1;
	}
}

.Editor3-root {
	iframe {
		width: 97%;
	}
	border: 1px solid $editor-neutral-border;
	font-weight: 300;
	padding: 0;
	position: relative;

	&.no-toolbar {
		padding-top: 5px;
	}

	.link-toolbar {
		font-size: 13px;
		color: $editor-neutral-color;
		padding: 0 10px;
		border-top: 1px solid rgba(150,150,150,0.25);
		height: 0;
		opacity: 0;
		transition: all .2s ease-out;

		&.is-link {
			height: 26px;
			padding: 5px 10px;
			opacity: 1;
		}

		a {
			margin-left: 10px;
			cursor: pointer;
			color: $editor-neutral-color;
			&:hover {
				color: scale-color($editor-neutral-border, $alpha: +100%);
				border-bottom: 1px dotted $sd-blue;
			}
		}
	}

	audio {
		width: 100%;
	}


	.Editor3-controls.floating-toolbar {
		position: sticky;
		top: 0;
		left: auto;
		right: auto;
		z-index: 10;
		box-shadow: 0px 1px 5px rgba(0,0,0,0.4);
		background-color: #f8f8f8;
		.link-toolbar.empty {
			display: none;
		}
	}

	&.read-only {
		cursor: not-allowed;

		.Editor3-controls {
			* {
				pointer-events: none;
			}

			&.table-controls {
				* {
					pointer-events: all;
				}

				opacity: 1;

				.Editor3-styleButton:hover {
					color: #555;

					[class*="icon-"] {
						color: #555;
					}
				}

				[class*="icon-"] {
					color: #999;
					position: relative;
					top: 3px;

					&:hover {
						color: #555;
					}
				}
			}

			opacity: 0.98;

			[class*="icon-"] {
				color: #ddd;

				&:hover {
					color: #ddd;
				}
			}
		}
	}

    .image-block, .embed-block {
		cursor: default;
        position: relative;
		padding: 1.4rem 1rem 1rem;
		border-radius: 2px;
		box-shadow: 0 1px 6px rgba(0, 0, 0, 0.26), 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(123, 123, 123, 0.3) !important;
		transition: 0.3s linear box-shadow;
		&:hover {
			box-shadow: 0 1px 8px rgba(0, 0, 0, 0.46), 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(123, 123, 123, 0.6) !important;
			.image-block__remove {
				visibility: visible;
			}
			.embed-block__remove {
				visibility: visible;
			}
			.embed-block__edit {
				visibility: visible;
			}
		}
	}
	.image-block__title, .image-block__description {
		border: 1px solid rgba(123, 123, 123, 0);
		border-bottom-color: rgba(123, 123, 123, 0.3);
		padding: 0;
		border-radius: 0;
		background-color: transparent;
		color: inherit;
		font-size: 1.4rem;
		resize: none;
		-webkit-appearance: none;
		-moz-appearance: none;
		box-shadow: none !important;
		outline: none;
		padding: 0 0 0 0.2rem;
		&:hover {
			border-bottom-color: rgba(123, 123, 123, 0.6);
		}
		&:focus {
			border-width: 1px !important;
			border-color: rgba(94, 169, 200, 0.3) !important;
			border-bottom-color: $sd-blue !important;
			box-shadow: 0 1px 0 $sd-blue !important;
		}
	}

	.image-block__title {
		margin-bottom: 1.6rem;
		font-size: 1.5rem;
		font-weight: 500;
	}
	.image-block__description {
		margin-top: 1rem;
		margin-bottom: 0.2rem;
		font-weight: 300;
	}
	.image-block__remove, .embed-block__remove, .embed-block__edit {
		z-index: 6;
		position: absolute;
		top: -1rem;
		right: -1rem;
		box-shadow: 0 1px 6px rgba(0, 0, 0, 0.36), 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(123, 123, 123, 0.3) !important;
		background-color: $white !important;
		color: $sd-text;
		visibility: hidden;
		opacity: 1 !important;
	}

	.embed-block__edit {
		top: 3rem;
	}

	.image-block__image {
		position: relative;
		background-color: rgb(37, 37, 37);
		margin: 0 -1rem;
		&:hover {
			.image-block__image-overlay {
				opacity: 1;
			}
		}
		video, audio {
			display: block;
		}
	}
	.image-block__image-overlay {
		@include image-overlay;
	}
	.image-block__metadata {
		@include two-col-list;
		margin: 1.6rem 1.6rem 0;
	}
	.image-block__action-bar {
		text-align: right;
		padding: 0.6rem 0 0;
	}
	.image-block__icons-block {
		@include image-overlay_actions-block;
	}
	.image-block__image-action {
        @include image-overlay_action-button;

        & + .image-block__image-action {
            margin-left: 2rem;
        }
	}

	[class^="__image-overlay"],
	[class*="__image-overlay"] {
		.image-block__metadata {
			span {
				border-color: rgba(255, 255, 255, 0.5) !important;
				&:last-child {
					border-bottom: none;
				}
			}
		}
	}

	.table-block {
		table td {
			font-weight: 300;
		}
		&.table-header {
			tr:first-child td {
				font-weight: 500;
			}
		}

		&__controls {
			margin-bottom: 6px;

			span {
				background: #000;
				color: #fff;
				padding: 5px 10px;
				cursor: pointer;
				font-size: 13px;
				font-family: $baseFontFamily;

				&:hover {
					background: #444;
				}

				&:first-child {
					border-radius: 5px 0 0 5px;
					border-right: 1px solid #999;
				}

				&:last-child {
					border-radius: 0 5px 5px 0;
				}
			}
		}

		table td {
			.public-DraftEditor-content {
				margin: 0;
				padding: 0;
			}

			position: relative;
			border: 1px solid rgba(150,150,150,0.25);
			padding: 5px;
			min-width: 20px;
		}
	}

	.spelling-error {
	    border-bottom-width: 1px;
	    border-bottom-style: dotted;
	    border-bottom-color: red;
	    position: relative;
	}

	.grammar-error {
	    border-bottom-width: 1px;
	    border-bottom-style: dotted;
	    border-bottom-color: blue;
	    position: relative;
	}

	.suggestions-dropdown {
		font-family: $baseFontFamily;
		display: block;
		position: absolute;
		top: 24px;
		left: -10px;
	}

	.qumu-embed {
		white-space: initial;
	}

	.media-block {
		text-align: left;
		font-family: $baseFontFamily;

		&__wrapper {
			display: inline-block;
		}

		&__title {
			resize: none;
			font-size: 16px;
			line-height: 140%;
			padding: 5px 5px 5px 0;
			margin-bottom: 5px;
			min-height: 28px;
			background-color: transparent;
			border: none;
		}
		&__description {
			font-size: 13px;
			line-height: 140%;
			resize: none;
			padding: 5px 5px 5px 0;
			min-height: 28px;
			color: #747474;
			background-color: transparent;
			border: none;
		}

		img, video, audio {
			display: inline-block;
			cursor: pointer;
		}
	}

	ul.public-DraftStyleDefault-ul, ol.public-DraftStyleDefault-ol {
		margin: 8px 0 0 20px;
		padding: 0 0 0 20px;

		.public-DraftStyleDefault-depth1 {margin-left: 40px;}
		.public-DraftStyleDefault-depth2 {margin-left: 60px;}
		.public-DraftStyleDefault-depth3 {margin-left: 80px;}
		.public-DraftStyleDefault-depth4 {margin-left: 100px;}
		& > li {
			border-bottom-width: 0.6em !important;
		}
	}

	ul.public-DraftStyleDefault-ul > li { list-style-type: disc; }
}

.Editor3-editor {
	cursor: text;
	font-size: 16px;
	line-height: 140%;
    word-break: break-word;
}

.Editor3-editor-single-line {
	border-bottom: 1px solid #ddd;
	cursor: text;
	font-size: 16px;
	margin-bottom: 10px;
}

.Editor3-editor .public-DraftEditorPlaceholder-root,
.Editor3-editor .public-DraftEditor-content {
	padding: 10px 15px 0 15px;
	span[style*="super"] {
		display: inline-block;
		margin-top: -6px;
	}
	span[style*="sub"] {
		display: inline-block;
		margin-bottom: -6px;
	}
}

.Editor3-editor.unstyled__block--invisibles {
	[data-block]:after {
		content: '\E690';
		font-family: 'sd_icons';
		font-size: 16px;
		color: $sd-blue;
	}
}

.Editor3-editor .public-DraftEditor-content {
	min-height: 20px;

	[data-block="true"] {
        border-bottom: 1.5em solid transparent;

        &.unstyled__block--over {
            border-bottom-color: scale-color($blue, $alpha: -70%);
		}
		&:only-child {
			border-bottom-width: 0.6em;
		}
	}
	h1, h2, h3, h4, h5, h6 {
		z-index: 1;
		&[data-block="true"] {
			border-bottom-width: 0.5em;
		}
	}
    .unstyled  {
		padding-top: 0.4em;
		border-top-width: 0;
		transition: border-width 0.1s ease-in-out;
	}
    .unstyled:first-child {
        padding-top: 0.6em;
	}
	.unstyled:last-child {
        padding-bottom: 1em;
    }

    .unstyled--over {
        padding-top: 0;
		border-top: 1.5em solid scale-color($blue, $alpha: -70%);
		transition: border-width 0.1s ease-in-out;
	}

	.unstyled {
		+ h3, + h4, + h5, + h6 {
			&[data-block="true"] {
				padding-top: .4em;
			}
		}
		+ h1, + h2 {
			&[data-block="true"] {
				padding-top: 0.2em;
			}
		}
	}
}

.Editor3-hidePlaceholder .public-DraftEditorPlaceholder-root {
	display: none;
}

.Editor3-editor .Editor3-blockquote {
	border-left: 5px solid #eee;
	font-style: italic;
	margin: 16px 0;
	padding: 10px 20px;
}

.Editor3-editor .public-DraftStyleDefault-pre {
	background-color: rgba(123, 123, 123, 0.1);
	font-family: 'Roboto Mono', monospace !important;
	padding: 0 2ch;
	overflow-y: auto;

	[data-block="true"] {
		border-bottom: none;
		margin: 0 0 0.5;
	}
	pre {
		position: relative;
		white-space: pre !important;
		padding-right: 2ch;
		.public-DraftStyleDefault-block {
			white-space: inherit;
		}

		&.showCharacterLimit:after {
			content: '';
			display: block;
			position: absolute;
			left: 0;
			top: 0;
			bottom: 0;
			width: var(--preCharacterLimit);
			border-right: 1px dotted red;
			z-index: 1;
			pointer-events: none;
		}
	}
}

.Editor3-controls {
	width: 100%;
	min-width: 300px;
	font-family: $baseFontFamily;
	font-size: 14px !important;
	user-select: none;
	background-color: scale-color($editor-neutral-bg, $alpha: -70%);
	border-bottom: 1px solid;
	border-bottom-color: scale-color($editor-neutral-border, $alpha: -50%);
	line-height: 100% !important;

	&.disabled {
		* {
			pointer-events: none;
		}
	}

	.embed-dialog {
		color: $sd-text;
		position: absolute;
		left: 0;
		top: 0;
		z-index: 2000;
		display: flex;
		align-items: center;
		flex-direction: row;
		background-color: #fff;
		width: 100%;
		border: 1px solid #dedede;
		margin: -1px 0px;
		padding: 4px;
		border: 1px solid rgba(0, 0, 0, 0.4);
		box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);

		&__error {
			padding: 3px;
			font-size: 13px;
			color: #a80000;
			font-weight: 400;
		}

		input {
			height: 30px;
			padding: 8px 47px 8px 15px;
		}
	}

	.input-controls {
		flex-grow: 0;
		display: flex;
	}

	.link-input {
		display: block;
		background: #fff;
		flex-grow: 1;
		position: relative;

		input[type="url"] {

			padding: 0px 47px 0px 5px;
		}
	}
}


.Editor3-styleButton {
	&--short {
		padding-right: 0.2rem;
		margin-right: -1rem;
	}
	color: $editor-styleButton-color;
	cursor: pointer;
	margin: 0.4rem 0.2rem;
	height: $editor-styleButton-size;
	min-width: $editor-styleButton-size;
	padding: 0.6rem;
	display: inline-block;
	border-radius: $editor-styleButton-size / 2;
	text-align: center;
	line-height: 1.6rem;
	[class*="icon-"] {
		color: inherit;
		opacity: 0.5;
		vertical-align: middle;
	}
	&:hover {
		[class*="icon-"] {
			color: inherit;
			opacity: 0.9;
		}
	}
	.inactive {
		[class*="icon-"] {
			opacity: 0.2;
		}
		&:hover {
			[class*="icon-"] {
				opacity: 0.2;
			}
		}
	}
	&.Editor3-activeButton, &.Editor3-activeButton:hover {
		color: $editor-styleButton-active-color;
		background-color: rgba(0, 0, 0, 0.075);
		[class*="icon-"] {
			opacity: 1;
		}
	}
}

.main-article {
	.dropdown__menu {
		color: $sd-text;
	}
}

.annotation-input {
	.dropdown__menu {
		width: 465px;
	}

	.Editor3-editor {
		font-size: 13px;
		margin-bottom: 10px;

		.public-DraftEditor-content {
			[data-block="true"]            { margin-bottom: 0.7em; }
			[data-block="true"]:last-child { margin-bottom: 0.3em; }

			padding: 5px 10px 0 10px;
		}

		.DraftEditor-root {
			max-height: 15rem;
			min-height: 3.6rem;
			overflow-y: auto;
		}
	}
}

/** COMMENTS **/
.comment-input, .annotation-input {
	.dropdown a { color: $sd-blue; }
	.dropdown__menu {
		padding: 15px;

		label    { margin-bottom: 5px; }
		textarea { margin-bottom: 10px; }

	}
}

.mentions-input {
	width: 300px;
	max-width: 100%;
	margin-bottom: 10px;

	&__suggestions__item {
		height: 33px;
		width: 240px;

		&__display {
			overflow: hidden;
			text-overflow: ellipsis;
			width: 175px;
			white-space: nowrap;
		}
	}

	.entry {
		.icon-tasks {
			margin: 0 5px 0 2px;
			position: relative;
			top: 2px;
		}
	}
}

.comment-textarea {
	position: relative;
	overflow: visible;
}

.main-article {
	.btn {
		font-family: 'Roboto', Helvetica, sans-serif;
	}
	.sd-editor__default-input {
		border: 1px solid rgba(123, 123, 123, 0.3);
		border-bottom-color: rgba(123, 123, 123, 0.3);
		padding: 0;
		border-radius: 0;
		background-color: transparent;
		color: inherit;
		font-size: 1.4rem;
		resize: none;
		-webkit-appearance: none;
		-moz-appearance: none;
		box-shadow: none !important;
		outline: none;
		padding: 0 0.3rem;
		&--embed {
			font-size: 1.3rem;
			font-family: 'Roboto', Helvetica, sans-serif;
		}
		&:hover {
			border-bottom-color: rgba(123, 123, 123, 0.6);
		}
		&:focus {
			border-width: 1px !important;
			border-color: rgba(94, 169, 200, 0.3) !important;
			border-bottom-color: $sd-blue !important;
			box-shadow: 0 1px 0 $sd-blue !important;
		}
	}
	.sd-editor__info-text {
		font-size: 1.3rem;
		font-family: 'Roboto', Helvetica, sans-serif;
		font-weight: 300;
		color: inherit;
		opacity: 0.7;
		margin: 0.6rem 0;
	}
}

// Link input dropdown
.dropdown--link-input {
	.dropdown__menu {
		padding:0;
		max-width: 400px;
		color: $sd-text;
	}
	.nav-tabs--small {
		padding: 0 !important;
	}
	.nav-tabs__tab {
		flex-grow: 1;
		&.nav-tabs-small {
			padding: 0;
		}
		button.nav-tabs__link {
			text-align: center !important;
			background-color: transparent !important;
			margin: 0 !important;
			cursor: pointer;
			color: #747474 !important;
		}
		&.nav-tabs__tab--active {
			button.nav-tabs__link {
				cursor: default !important;
				color: #333 !important;
			}
		}
	}
	.nav-tabs__content {
		font-weight: 400;
		p {
			font-size: 1.4rem;
			line-height: 140%;
			margin-bottom: 0;
		}
	}
}


// Theme specific overrides

.sd-editor--theme-turquoise, .sd-editor--theme-military {
	.Editor3-controls, .item-association {
		background-color: rgba(0, 0, 0, 0.03);
		border-bottom-color: rgba(0, 0, 0, 0.1);
	}
	.Editor3-root, .item-association {
		border-color: rgba(0, 0, 0, 0.1);
	}
	.Editor3-styleButton.Editor3-activeButton,
	.Editor3-styleButton.Editor3-activeButton:hover {
		color: #9c27b0;
	}
	.Editor3-root .Editor3-controls.floating-toolbar {
		background-color: rgba(255, 255, 255, 0.85);
	}
	.DraftEditor-root {
		a {
			color: #9c27b0;
		}
	}
}

.sd-editor--theme-dark, .sd-editor--theme-blue {
	.Editor3-styleButton.Editor3-activeButton,
	.Editor3-styleButton.Editor3-activeButton:hover {
		background-color: rgba(0, 0, 0, 0.3);
	}
	.Editor3-root .Editor3-controls.floating-toolbar {
		background-color: rgba(51, 51, 51, 0.95);
	}
}
.sd-editor--theme-blue {
	.Editor3-root .Editor3-controls.floating-toolbar {
		background-color: rgba(27, 68, 115, 0.95);
	}
}

.sd-editor--theme-turquoise,
.sd-editor--theme-military,
.sd-editor--theme-dark,
.sd-editor--theme-blue {
	.btn.btn--hollow {
		color: inherit;
	}
}

.sd-editor--theme-dark {
	.btn.btn--hollow {
		border-color: rgba(170,204,209, 0.5);
		&:hover {
			border-color: rgba(170,204,209, 1);
		}
	}

}
.sd-editor--theme-blue {
	.btn.btn--hollow {
		border-color: rgba(255,255,255, 0.5);
		&:hover {
			border-color: rgba(255,255,255, 1);
		}
	}
}

.sd-editor--theme-blue, .sd-editor--theme-dark  {
	.Editor3-root .image-block, .Editor3-root .embed-block {
		box-shadow: 0 1px 6px rgba(0, 0, 0, 0.26), 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.25) !important;
		&:hover {
			box-shadow: 0 1px 6px rgba(0, 0, 0, 0.26), 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.5) !important;
		}
	}
	.media-container {
		box-shadow: 0 1px 6px rgba(0, 0, 0, 0.26), 0 0 1px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.25) !important;
	}
}

// Style overrides for Custom fields in the article header

.authoring-header__input-editor3 {
	.Editor3-editor .public-DraftEditorPlaceholder-root,
	.Editor3-editor .public-DraftEditor-content {
		padding: 3px 0 2px;
	}
	.Editor3-root {
		border: none !important;
	}
	.DraftEditor-root {
		border-bottom: 1px solid var(--color-input-border);
		background-color: var(--color-input-bg);
		transition: all 0.3s cubic-bezier(0.55, 0, 0.55, 0.2);
		min-height: 32px;
		padding: 0.4rem 0.8rem 0;
		&:hover {
			border-color: var(--color-input-border-hover);
            background-color: var(--color-input-bg--hover);
		}
		&:focus-within {
			background-color: var(--color-input-bg--focus);
            box-shadow: 0 1px 0 0 #5ea9c8;
            border-color: #5ea9c8;
		}
	}
	.Editor3-editor {
		font-family: "Roboto", Helvetica, Arial, sans-serif;
		font-weight: 400;
		font-size: 13px;

		&.no-toolbar {
			padding-top: 0;
		}
	}

	.Editor3-editor .public-DraftEditor-content [data-block="true"] {
		border-bottom: none;
	}
}

.Editor3-editor {
	q::before, q::after, blockquote::before, blockquote::after {
		content: "";
		display: none;
	}
}
