$gf-msg-primary: #0da88c;
$gf-msg-primary-dark: #0c9b81;
$gf-msg-heading: #1e1e1e;
$gf-msg-body: #6e7376;
$gf-msg-border: #dedede;
$gf-msg-border-light: #e2e2e2;
$gf-message-editor-content-height: 150px;
$gf-message-editor-content-min-height: $gf-message-editor-content-height;
$gf-message-editor-toolbar-min-height: 32px;
$gf-message-editor-max-height: 480px;

@mixin gf-message-editor-shell {
	display: flex;
	flex-direction: column;
	max-height: $gf-message-editor-max-height;
	min-height: $gf-message-editor-content-height;
	overflow: hidden;
	resize: vertical;

	&:has(.gf-editor-toolbar) {
		min-height: calc(
			#{$gf-message-editor-content-height} + #{$gf-message-editor-toolbar-min-height}
		);
	}
}

@mixin gf-message-editor-content-area {
	box-sizing: border-box;
	flex: 1 1 auto;
	height: auto;
	max-height: none;
	min-height: $gf-message-editor-content-height;
	overflow-y: auto;
	resize: none;
}

.gutena-forms-notification-merge-tag-popover {
	position: relative;
}

.gutena-forms-notification-merge-tag-popover__dots-button.components-button {
	align-items: center;
	background: #fff;
	border: 1px solid $gf-msg-border;
	border-radius: 6px;
	box-shadow: none;
	color: $gf-msg-heading;
	display: inline-flex;
	height: 32px;
	justify-content: center;
	min-width: 36px;
	padding: 7px 15px;

	&:hover,
	&:focus {
		background: #fff;
		border-color: $gf-msg-border;
		color: $gf-msg-heading;
	}
}

.gutena-forms-notification-merge-tag-popover__form-tags-button.components-button {
	background: #0da88c;
	border: 0.833px solid #0c9b81;
	border-radius: 4.167px;
	box-shadow: none;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	height: auto;
	min-height: 0;
	padding: 5px 9px;

	&:hover,
	&:focus {
		background: #0c9b81;
		border-color: #0c9b81;
		box-shadow: none;
		color: #fff;
	}
}

.gutena-forms-notification-merge-tag-popover__segment-button.components-button {
	background: transparent;
	border: 1px solid #e9e9e9;
	border-radius: 5px;
	box-shadow: none;
	color: $gf-msg-heading;
	font-size: 11px;
	font-weight: 500;
	height: auto;
	min-height: 0;
	padding: 5px 9px;

	&:hover,
	&:focus {
		background: #efefef;
		border-color: #e9e9e9;
		box-shadow: none;
		color: $gf-msg-heading;
	}
}

.gutena-forms-notification-merge-tag-popover__panel {
	.components-popover__content {
		padding: 0;
	}
}

.gutena-forms-notification-merge-tag-popover__content {
	min-width: 180px;
	padding: 0;
}

.gutena-forms-notification-merge-tag-popover__title {
	color: $gf-msg-heading;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.2;
	margin: 0;
	padding: 10px 10px 8px;
}

.gutena-forms-notification-merge-tag-popover__items,
.gutena-forms-notification-merge-tag-popover__tags {
	list-style: none;
	margin: 0;
	padding: 0;
}

.gutena-forms-notification-merge-tag-popover__items--grouped {
	border-top: 1px solid $gf-msg-border-light;
	margin-top: 0;
	padding-top: 0;
}

.gutena-forms-notification-merge-tag-popover__items {
	display: flex;
	flex-direction: column;
	gap: 0;
	width: 100%;

	li {
		display: block;
		margin: 0;
		min-height: 28px;
		padding: 0;
		width: 100%;
	}
}

.gutena-forms-notification-merge-tag-popover__item {
	align-items: center;
	background: transparent;
	border: none;
	box-sizing: border-box;
	cursor: pointer;
	display: flex;
	font-size: 11px;
	height: 100%;
	justify-content: space-between;
	line-height: 1.2;
	min-height: 28px;
	padding: 0 10px;
	text-align: left;
	width: 100%;

	&:hover,
	&:focus-visible {
		background: #f5f6f7;
		color: $gf-msg-primary;
	}
}

.gutena-forms-notification-merge-tag-popover__item-label {
	color: $gf-msg-heading;
	font-weight: 500;
}

.gutena-forms-notification-merge-tag-popover__item-tag {
	color: $gf-msg-body;
	font-weight: 400;
}

.gutena-forms-notification-merge-tag-popover__tags {
	display: flex;
	flex-direction: column;
	gap: 0;
	width: 100%;

	li {
		display: block;
		margin: 0;
		min-height: 28px;
		padding: 0;
		width: 100%;
	}
}

.gutena-forms-notification-merge-tag-popover__tag {
	align-items: center;
	background: transparent;
	border: none;
	box-sizing: border-box;
	color: $gf-msg-body;
	cursor: pointer;
	display: flex;
	font-size: 11px;
	height: 100%;
	min-height: 28px;
	padding: 0 10px;
	text-align: left;
	width: 100%;

	&:hover,
	&:focus-visible {
		background: #f5f6f7;
		color: $gf-msg-primary;
	}
}

.gutena-forms-notification-message-field {
	display: flex;
	flex-direction: column;
	gap: 6px;

	&.is-disabled {
		opacity: 0.7;
		pointer-events: none;

		.gutena-forms-notification-message-field__editor {
			resize: none;
		}
	}
}

.gutena-forms__html-editor-field.is-disabled {
	.gutena-forms-notification-message-field__editor {
		resize: none;
	}
}

.gutena-forms-notification-message-field__header {
	align-items: center;
	display: flex;
	gap: 12px;
	justify-content: space-between;
}

.gutena-forms-notification-message-field__label {
	color: $gf-msg-heading;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	margin: 0;
}

.gutena-forms-notification-message-field__toolbar {
	align-items: center;
	display: flex;
	flex-shrink: 0;
	gap: 5px;
}

.gutena-forms-notification-message-field__mode {
	background: transparent;
	border: 1px solid #e9e9e9;
	border-radius: 5px;
	color: $gf-msg-heading;
	cursor: pointer;
	font-size: 11px;
	font-weight: 500;
	line-height: 1.2;
	padding: 5px 9px;

	&.is-active {
		background: #efefef;
	}

	&:disabled {
		cursor: not-allowed;
		opacity: 0.6;
	}
}

.gutena-forms-notification-message-field__editor {
	@include gf-message-editor-shell;
	border: 1px solid $gf-msg-border-light;
	border-radius: 6px;
}

.gutena-forms-notification-message-field__textarea {
	@include gf-message-editor-content-area;
	border: none;
	border-radius: 0;
	box-shadow: none;
	color: $gf-msg-heading;
	display: block;
	font-size: 12px;
	line-height: 1.5;
	padding: 10px;
	width: 100%;

	&:focus {
		border: none;
		box-shadow: none;
		outline: none;
	}

	&.is-code {
		font-family: Consolas, Monaco, monospace;
		font-size: 11px;
	}

	&:disabled {
		background: #f5f6f7;
		cursor: not-allowed;
	}
}

.gutena-forms-notification-message-field__contenteditable {
	@include gf-message-editor-content-area;
	color: $gf-msg-heading;
	font-size: 12px;
	line-height: 1.5;
	outline: none;
	padding: 10px;

	&:empty::before {
		color: $gf-msg-body;
		content: attr(aria-label);
		pointer-events: none;
	}

	&:focus {
		outline: none;
	}

	a {
		color: $gf-msg-primary;
		text-decoration: underline;
	}

	ul,
	ol {
		margin: 0;
		padding-left: 20px;
	}
}

.gf-editor-toolbar {
	align-items: center;
	background: #f8f8f8;
	border-bottom: 1px solid $gf-msg-border-light;
	display: flex;
	flex-shrink: 0;
	flex-wrap: wrap;
	gap: 2px;
	padding: 4px 8px;
}

.gf-editor-toolbar__format-label {
	color: $gf-msg-heading;
	font-size: 10px;
	font-weight: 500;
	padding: 0 6px;
}

.gf-editor-toolbar__separator {
	background: $gf-msg-border-light;
	display: inline-block;
	height: 14px;
	margin: 0 3px;
	width: 1px;
}

.gf-editor-toolbar__btn {
	align-items: center;
	background: transparent;
	border: none;
	border-radius: 3px;
	color: $gf-msg-body;
	cursor: pointer;
	display: inline-flex;
	height: 22px;
	justify-content: center;
	padding: 2px;
	width: 22px;

	&:hover {
		background: #e9e9e9;
		color: $gf-msg-heading;
	}

	&.is-active {
		background: #e0e0e0;
		color: $gf-msg-heading;
	}

	&:disabled {
		cursor: not-allowed;
		opacity: 0.5;
	}

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

@media (max-width: 782px) {
	.gutena-forms-notification-message-field__header {
		align-items: flex-start;
		flex-direction: column;
	}
}
