.lazyblock-align-left {
	text-align: left;
}

.lazyblock-align-center {
	text-align: center;
}

.lazyblock-align-right {
	text-align: right;
}

.lzb-description-edit-link {
	display: inline-block;
	margin-top: 5px;
}

.lazyblock {
	--lzb-controls-columns-gap: 15px;

	display: block;
	padding: 20px;
	background-color: #fff;
	box-shadow: 0 0 0 1px #e6e6e6;

	.lzb-content-title {
		display: flex;
		align-items: center;
		padding: 20px;
		padding-top: 0;
		padding-bottom: 15px;
		margin-top: -5px;
		margin-right: -20px;
		margin-bottom: 20px;
		margin-left: -20px;
		font-size: 0.8em;
		border-bottom: 1px solid #e6e6e6;

		svg {
			display: block;
		}

		> span {
			height: auto;
			font-size: 1.2em;
			opacity: 0.8;

			+ h6 {
				margin-left: 10px;
			}
		}

		h6 {
			margin: 0;
			font-size: 13px;
			font-weight: 600;
		}
	}

	.lzb-content-title .lzb-content-edit-link {
		margin-left: auto;
		color: inherit;
		opacity: 0;
		transition: 0.15s opacity ease-in-out;

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

	&:hover .lzb-content-title .lzb-content-edit-link {
		opacity: 0.2;

		&:hover {
			opacity: 0.4;
		}
	}

	// Columns
	.lzb-content-controls {
		display: flex;
		flex-wrap: wrap;
		margin-bottom: calc(-1 * var(--lzb-controls-columns-gap));
		margin-left: calc(-1 * var(--lzb-controls-columns-gap));

		> div > div {
			margin-bottom: var(--lzb-controls-columns-gap);
			margin-left: var(--lzb-controls-columns-gap);
		}
	}

	// Repeater item content with columns support.
	.lzb-gutenberg-repeater-item .lzb-gutenberg-repeater-item-content {
		display: flex;
		flex-wrap: wrap;
		margin-left: calc(-1 * var(--lzb-controls-columns-gap));

		> div {
			padding-left: var(--lzb-controls-columns-gap);
		}
	}

	.components-base-control__help {
		margin-bottom: 8px;
		font-size: 1em;
		opacity: 0.6;
	}

	.components-base-control__label .required {
		margin-left: 5px;
	}

	.lzb-preview-server {
		margin-top: 15px;

		.components-spinner {
			position: absolute;
			top: 14px;
			right: 11px;
		}
	}
}

/**
 * Block validation.
 */
.lzb-invalid {
	box-shadow: 0 0 0 2px #cc1818 !important;
}
.lzb-invalid-notice {
	padding: 16px;
	background-color: #f4a2a2;
}

/**
 * Better appender styles for Free block.
 */
.wp-block.lazyblocks-free:not(.is-selected) > .block-list-appender:only-child {
	pointer-events: none;

	&::after {
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		pointer-events: none;
		content: "";
		border: 1px dashed;
		border-radius: 2px;
	}

	.block-editor-inserter {
		visibility: hidden;
	}
}

// Fix for long words.
.lazyblock .lzb-content-title h6,
.lzb-content-controls .components-base-control__label,
.lzb-content-controls .components-base-control__help,
.lzb-inspector-controls .components-base-control__label,
.lzb-inspector-controls .components-base-control__help {
	word-break: break-word;
}

// Select control
.lazyblocks-control-select {
	select {
		max-width: none;
	}

	select[multiple].components-select-control__input {
		height: auto;
		padding-right: 8px;
		overflow: auto;

		+ .components-input-control__suffix {
			display: none;
		}
	}
}

// Date Time Picker control
.lzb-gutenberg-date-time-picker {
	min-width: 230px;

	&:not(.lzb-gutenberg-date-time-picker-allowed-time) {
		.components-datetime__time > fieldset:nth-of-type(1) {
			display: none;
		}
	}

	&:not(.lzb-gutenberg-date-time-picker-allowed-date) {
		.components-datetime__time > fieldset:nth-of-type(2) {
			display: none;
		}

		.components-datetime__time {
			padding-bottom: 0;
		}
	}

	&.lzb-gutenberg-date-time-picker-allowed-date .components-datetime__time > fieldset:nth-of-type(2) {
		margin-bottom: 15px;
	}
}

.lzb-date-time-picker-toggle.components-button {
	padding: 7px;
	margin-left: -7px;
	text-decoration: none;

	svg {
		width: 20px;
		margin-right: 5px;
	}
}

.lzb-date-time-picker-reset {
	display: flex;
	justify-content: flex-end;
	margin-top: 0.5rem;
}

// Color Picker control
.lazyblocks-control-color {
	// Combine multiple color pickers without label.
	&:has(+ .lazyblocks-control-color > .lazyblocks-control-color-picker__dropdown:first-child) {
		margin-bottom: 0;

		.lazyblocks-control-color-toggle {
			border-bottom: none;
		}
	}
}
.lazyblocks-control-color-toggle {
	position: relative;
	width: 100%;
	height: auto;
	padding: 10px 12px;
	margin-bottom: 0;
	border: 1px solid rgba(0, 0, 0, 10%);
	border-radius: 0;

	&.lazyblocks-control-color-toggle-active {
		color: var(--wp-admin-theme-color);
		background-color: #f0f0f0;
	}

	.lazyblocks-control-color-toggle-indicator {
		position: relative;
		display: block;
		width: 20px;
		height: 20px;
		padding: 0;
		margin-right: 8px;
		color: transparent;
		cursor: pointer;
		background: linear-gradient(-45deg, transparent 48%, #ddd 0, #ddd 52%, transparent 0);
		border: none;
		border-radius: 50%;
		box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 20%);
	}

	.lazyblocks-control-color-toggle-label {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
}
.lazyblocks-control-color-picker__dropdown {
	display: block;
	width: 100%;
}
.lazyblocks-control-color-picker__dropdown-content {
	.components-popover__content {
		width: 260px;
		padding: 16px;
	}

	.components-tab-panel__tabs {
		margin-top: -16px;
		margin-right: -16px;
		margin-bottom: 16px;
		margin-left: -16px;
	}
}


// URL picker
.lazyblocks-control-url {
	position: relative;

	.block-editor-link-control {
		min-width: 100%;
	}

	.block-editor-link-control__settings,
	.block-editor-link-control__tools {
		display: none;
	}

	.block-editor-link-control__search-input {
		margin: 0;
	}

	.block-editor-link-control__search-input.block-editor-link-control__search-input input[type="text"] {
		width: 100%;
		padding: 6px 4px;
		margin: 0;
		border-color: #757575;

		&:focus {
			color: #191e23;
			border-color: #007cba;
			outline: 2px solid transparent;
			box-shadow: 0 0 0 1px #007cba;
		}
	}

	.block-editor-link-control__search-actions {
		top: 2px;
		right: 2px;

		.components-button {
			height: 30px;
		}
	}

	.block-editor-link-control__search-results-wrapper {
		margin-top: 0;
	}

	.block-editor-link-control__search-results {
		padding-bottom: 0;
		margin-top: 0;
		margin-right: -16px;
		margin-left: -16px;
	}

	.block-editor-link-control__search-item.is-current {
		padding: 5px 0;
	}

	.lzb-inspector-controls & {
		.block-editor-url-input {
			min-width: 200px;
		}
		.components-menu-item__item {
			min-width: 130px;
		}
	}
}

// Gallery and Image controls
.lzb-gutenberg-image-wrap {
	position: relative;
}

.lzb-gutenberg-gallery,
.lzb-gutenberg-image {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	padding: 0;
	margin: 0 -5px !important;
	list-style-type: none;
	cursor: pointer;

	// fix flex items shrink.
	&::after {
		display: block;
		width: 100%;
		content: "";
	}

	// edit button.
	.lzb-gutenberg-gallery-button,
	.lzb-gutenberg-image-button {
		position: absolute;
		top: 0;
		left: 0;
		z-index: 1;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: rgba(255, 255, 255, 0.5);
		backdrop-filter: blur(2px);
		width: 100%;
		height: 100%;
		opacity: 0;
		transition: 0.15s opacity;

		> .components-button {
			background-color: #fff;
			color: #000;
		}
	}

	&:hover .lzb-gutenberg-gallery-button,
	&:hover .lzb-gutenberg-image-button {
		opacity: 1;
	}

	.lzb-gutenberg-gallery-button-edit:hover,
	.lzb-gutenberg-gallery-button-edit:focus {
		color: #2279ea;
	}

	.lzb-gutenberg-gallery-button-remove {
		&:hover,
		&:focus {
			color: #ea2c22;
		}

		svg {
			width: 1em;
			height: 1em;
			fill: none;
		}
	}

	.lzb-gutenberg-image-item,
	.lzb-gutenberg-gallery-item {
		position: relative;
		display: block;
		background-color: #e6e6e6;
		border-radius: 3px;

		&::after {
			display: block;
			padding-top: 100%;
			content: "";
		}

		img {
			position: absolute;
			top: 0;
			left: 0;
			display: block;
			width: 100%;
			height: 100%;
			border-radius: 3px;
			object-fit: cover;
			object-position: 50% 50%;
		}
	}

	.lzb-gutenberg-gallery-item {
		width: calc(12.5% - 10px);
		margin: 5px;

		// width
		@media (max-width: 1000px) {
			width: calc(14.22% - 10px);
		}
		@media (max-width: 900px) {
			width: calc(16.66% - 10px);
		}
		@media (max-width: 800px) {
			width: calc(25% - 10px);
		}

		.lzb-inspector-controls & {
			width: calc(25% - 10px);
		}
	}

	.lzb-gutenberg-image-item {
		width: 30%;
		margin: 0 auto;
	}
}

// File control
.lzb-gutenberg-file-wrap {
	.lzb-gutenberg-file-item {
		display: flex;
		margin-bottom: 10px;
		border: 1px solid #757575;
		border-radius: 2px;
	}

	.lzb-gutenberg-file-item-icon {
		display: flex;
		align-items: center;
		padding: 10px 15px;
		border-right: 1px solid #757575;
	}

	.lzb-gutenberg-file-item-content {
		display: flex;
		flex-direction: column;
		padding: 10px;
	}

	.lzb-gutenberg-file-item-content-title {
		font-weight: 600;
	}

	.lzb-gutenberg-file-item-content-filename {
		opacity: 0.5;
	}
}

// Rich Text control
.lazyblocks-control-rich_text {
	.block-editor-rich-text__inline-toolbar {
		position: relative;
		top: 0;
		justify-content: flex-start;

		.block-editor-format-toolbar,
		.block-editor-format-toolbar > .components-toolbar {
			width: 100%;
		}

		.block-editor-format-toolbar > .components-toolbar {
			border-bottom: 0;
		}
	}

	.block-editor-rich-text__editable,
	.block-editor-rich-text__tinymce {
		padding: 10px 15px;
		background-color: #fff;
		border: 1px solid #757575;
		border-radius: 2px;

		p:last-of-type {
			margin-bottom: 0;
		}
	}
}

// Classic Editor control
.lazyblocks-control-classic_editor-modal {
	max-height: 70%;
	max-width: calc(100% - 32px);
	min-width: 350px;

	.block-library-rich-text__tinymce {
		padding: 20px;
		border: 1px solid #757575;
		border-radius: 0 0 2px 2px;
		outline: none;
	}

	.mce-container-body {
		min-width: 50vw;
	}

	.block-library-classic__toolbar {
		display: block;
		margin: 0;
		border-color: #757575;

		div.mce-toolbar-grp {
			border-bottom: none;
		}

		&,
		.mce-container,
		.mce-toolbar-grp {
			border-radius: 2px 2px 0 0;
		}

		&:empty {
			display: none;

			+ .block-library-rich-text__tinymce {
				border-radius: 2px;
			}
		}
	}
}

// Code Editor control
.lazyblocks-control-code_editor textarea {
	padding: 15px;
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 13px;
	border: 1px solid #757575;
	border-radius: 2px;
}

// repeater
.components-base-control__label + .lzb-gutenberg-repeater {
	margin-top: 8px;
}

.lzb-gutenberg-repeater-item {
	position: relative;
	background-color: #fff;
	border-bottom: 1px solid rgba(#888, 0.25);

	&:last-child {
		border-bottom: none;
	}

	.lzb-gutenberg-repeater-btn {
		position: relative;
		display: flex;
		align-items: center;
		width: 100%;
		padding: 15px;
		padding-left: 0;
		padding-right: 0;
		margin-bottom: -1px;
		text-align: left;
		cursor: pointer;
		background: none;
		border: none;
		outline: none;
	}

	.lzb-gutenberg-repeater-btn-title {
		flex: 1;

		img {
			width: auto;
			height: 17px;
			vertical-align: bottom;
		}
	}

	// Button Arrow.
	.lzb-gutenberg-repeater-btn-arrow {
		display: block;
		font-size: 1.7em;
		border-radius: 50%;

		svg {
			display: block;
			width: 1em;
			height: 1em;
			fill: currentcolor;
		}
	}

	&:hover .lzb-gutenberg-repeater-btn-arrow {
		background-color: rgba(#888, 0.1);
	}

	.lzb-gutenberg-repeater-btn-active .lzb-gutenberg-repeater-btn-arrow {
		color: #fff;
		background-color: #1e1e1e;
		transform: rotate(180deg);
	}

	// Button Clone & Remove.
	.lzb-gutenberg-repeater-btn-duplicate,
	.lzb-gutenberg-repeater-btn-remove {
		display: block;
		width: 1.13em;
		height: 1.13em;
		padding: 0;
		font-size: 1.5em;
		cursor: pointer;
		background: none;
		border: none;
		opacity: 0;

		> svg {
			display: block;
			width: 0.8em;
			height: 0.8em;
			margin: 0 auto;
		}
	}
	.lzb-gutenberg-repeater-btn-duplicate {
		right: 50px;
	}

	&:hover .lzb-gutenberg-repeater-btn-duplicate,
	.lzb-gutenberg-repeater-btn-duplicate:hover,
	.lzb-gutenberg-repeater-btn-duplicate:focus,
	&:hover .lzb-gutenberg-repeater-btn-remove,
	.lzb-gutenberg-repeater-btn-remove:hover,
	.lzb-gutenberg-repeater-btn-remove:focus {
		opacity: 1;
	}

	.lzb-gutenberg-repeater-btn-duplicate:hover,
	.lzb-gutenberg-repeater-btn-duplicate:focus {
		color: #2279ea;
	}
	.lzb-gutenberg-repeater-btn-remove:hover,
	.lzb-gutenberg-repeater-btn-remove:focus {
		color: #ea2c22;
	}

	// Button Drag.
	.lzb-gutenberg-repeater-btn-drag {
		left: 0;
		display: block;
		height: auto;
		padding: 0;
		margin: 0;
		margin-right: 5px;
		font-size: 1.3em;
		cursor: move;
		opacity: 0.3;

		svg {
			display: block;
			width: 1em;
			height: 1em;
			margin-left: -3px;
		}
	}

	&:hover .lzb-gutenberg-repeater-btn-drag {
		opacity: 0.7;
	}

	.lzb-gutenberg-repeater-btn-drag:hover,
	.lzb-gutenberg-repeater-btn-drag:focus,
	.lzb-gutenberg-repeater-btn-active .lzb-gutenberg-repeater-btn-drag {
		color: inherit;
		opacity: 1;
	}

	// Repeater item content with columns support
	.lzb-gutenberg-repeater-item-content {
		padding-bottom: 13px;
		margin: 0;

		.components-notice {
			margin: 0;
			margin-top: 15px;
		}

		> .components-panel__body {
			width: 100%;
			padding-right: 0;
			padding-left: 0;
			border: none;
		}
	}
}

.lzb-gutenberg-repeater-item-dragging {
	z-index: 2;
}

.lzb-gutenberg-repeater-items {
	margin-bottom: 3px;
}

.lzb-gutenberg-repeater-options {
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	text-align: center;

	.components-button {
		&:not(.is-primary):not(:hover,:focus) {
			--wp-components-color-accent: #949494;

			color: #292929;
		}

		justify-content: center;
		text-transform: uppercase;
		font-size: 12px;
		font-weight: 500;
	}

	.lzb-gutenberg-repeater-options-add {
		flex: 1;
	}
	.lzb-gutenberg-repeater-options-expand {
		padding-left: 6px;
		padding-right: 6px;

		svg {
			fill: none;
			width: 1.5em;
			height: 1.5em;
		}
	}
}

.lzb-inspector-controls {
	.lzb-gutenberg-repeater {
		padding-right: 0;
		padding-left: 0;
	}

	.lzb-gutenberg-repeater-item {
		padding-top: 0;
		margin-right: 0;
		margin-left: 0;
	}

	.lzb-gutenberg-repeater-item-content > .components-panel__body:first-child {
		margin-top: -15px;
	}

	.components-notice {
		margin: 0;
		margin-top: -10px;
		margin-bottom: 24px;
	}
}
.lzb-inspector-controls-advanced > .components-panel__body {
	margin: -16px;
}
