$block-inserter-preview-height: 350px;
$block-inserter-width: 350px;
$block-inserter-tabs-height: 44px;

.block-editor-inserter {
	display: inline-block;
	background: none;
	border: none;
	padding: 0;
	font-family: $default-font;
	font-size: $default-font-size;
	line-height: 0;

	@include break-medium {
		position: relative;
	}
}

.block-editor-inserter__content {
	position: relative;
}

.block-editor-inserter__popover.is-quick {
	.components-popover__content {
		border: none;

		.block-editor-inserter__quick-inserter > * {
			border-left: $border-width solid $gray-400;
			border-right: $border-width solid $gray-400;

			&:first-child {
				border-top: $border-width solid $gray-400;
			}

			&:last-child {
				border-bottom: $border-width solid $gray-400;
			}

			&.components-button {
				border: $border-width solid $gray-900;
			}
		}
	}
}

.block-editor-inserter__popover .block-editor-inserter__menu {
	margin: -$grid-unit-15;

	.block-editor-inserter__tabs .components-tab-panel__tabs {
		top: $grid-unit-10 + $grid-unit-20 + $grid-unit-60 - $grid-unit-15;
	}

	.block-editor-inserter__main-area {
		overflow: visible;
		height: auto;
	}

	.block-editor-inserter__preview-container {
		display: none;
	}
}

.block-editor-inserter__toggle.components-button {
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	border: none;
	outline: none;
	padding: 0;
	transition: color 0.2s ease;
	@include reduce-motion("transition");
}

.block-editor-inserter__menu {
	height: 100%;
	position: relative;
	overflow: visible;
}

.block-editor-inserter__main-area {
	width: auto;
	overflow-y: auto;
	height: 100%;
	@include break-medium {
		width: $block-inserter-width;
	}
}

.block-editor-inserter__inline-elements {
	margin-top: -1px;
}

.block-editor-inserter__menu.is-bottom::after {
	border-bottom-color: $white;
}

.components-popover.block-editor-inserter__popover {
	z-index: z-index(".components-popover.block-editor-inserter__popover");
}

.block-editor-inserter__search {
	background: $white;
	padding: $grid-unit-20 $grid-unit-20 0 $grid-unit-20;
	position: sticky;
	top: 0;
	z-index: z-index(".block-editor-inserter__search");

	.components-search-control__icon {
		right: $grid-unit-10 + ($grid-unit-60 - $icon-size) * 0.5;
	}

	.components-base-control__field {
		margin-bottom: 0;
	}
}

.block-editor-inserter__tabs {
	display: flex;
	flex-direction: column;

	.components-tab-panel__tabs {
		position: sticky;
		// Computed based off the search input height and paddings
		top: $grid-unit-20 + $grid-unit-60;
		background: $white;
		z-index: z-index(".block-editor-inserter__tabs .components-tab-panel__tabs");
		border-bottom: $border-width solid $gray-300;

		.components-tab-panel__tabs-item {
			flex-grow: 1;
			margin-bottom: -$border-width;
		}
	}

	.components-tab-panel__tab-content {
		display: flex;
		flex-grow: 1;
		flex-direction: column;
		// Make a stacking context that keeps all descendents behind the sticky tabs
		position: relative;
		z-index: z-index(".block-editor-inserter__tabs .components-tab-panel__tab-content");
	}
}

.block-editor-inserter__panel-header {
	display: inline-flex;
	align-items: center;
	padding: $grid-unit-20 $grid-unit-20 0;
}

.block-editor-inserter__panel-header-patterns {
	padding: $grid-unit-20 $grid-unit-20 0;
}

.block-editor-inserter__panel-content {
	padding: $grid-unit-20;
}

.block-editor-inserter__panel-title,
.block-editor-inserter__panel-title button {
	margin: 0 $grid-unit-15 0 0;
	color: $gray-700;
	text-transform: uppercase;
	font-size: 11px;
	font-weight: 500;
}

.block-editor-inserter__panel-dropdown select.components-select-control__input.components-select-control__input.components-select-control__input {
	height: 36px;
	line-height: 36px;
}

.block-editor-inserter__panel-dropdown select {
	border: none;
}

.block-editor-inserter__block-list {
	flex-grow: 1;
	position: relative;
}

.block-editor-inserter__reusable-blocks-panel {
	position: relative;
	text-align: right;
}

.block-editor-inserter__manage-reusable-blocks {
	display: inline-block;
	margin: $grid-unit-20;
}

.block-editor-inserter__no-results {
	padding: $grid-unit-40;
	text-align: center;
}

.block-editor-inserter__no-results-icon {
	fill: $gray-600;
}

.block-editor-inserter__child-blocks {
	padding: 0 $grid-unit-20;
}

.block-editor-inserter__parent-block-header {
	display: flex;
	align-items: center;

	h2 {
		font-size: 13px;
	}

	.block-editor-block-icon {
		margin-right: $grid-unit-10;
	}
}

.block-editor-inserter__preview-container {
	display: none;
	width: 300px;
	background: $white;
	border-radius: $radius-block-ui;
	border: $border-width solid $gray-300;
	position: absolute;
	top: $grid-unit-20;
	left: calc(100% + #{$grid-unit-20});
	max-height: calc(100% - #{$grid-unit-40});
	overflow-y: hidden;

	@include break-medium {
		display: block;
	}

	.block-editor-block-card {
		padding: $grid-unit-20;
	}

	.block-editor-block-card__title {
		font-size: $default-font-size;
	}
}

.block-editor-inserter__preview-content {
	min-height: $grid-unit-60 * 3;
	background: $gray-100;
	display: grid;
	flex-grow: 1;
	align-items: center;
}

.block-editor-inserter__preview-content-missing {
	flex: 1;
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: $grid-unit-60 * 3;
	color: $gray-700;
	background: $gray-100;
}

.block-editor-inserter__tips {
	border-top: $border-width solid $gray-300;
	padding: $grid-unit-20;
	flex-shrink: 0;
	position: relative; // prevents overscroll when block library is open
}

.block-editor-inserter__manage-reusable-blocks-container {
	padding: $grid-unit-20;
}

.block-editor-inserter__quick-inserter {
	width: 100%;

	// Constrain to container. Avoids overflow bug on FF 79
	// see https://github.com/GeChiUI/gutenberg/issues/24529.
	max-width: 100%;

	@include break-medium {
		width: $block-inserter-width;
	}
}

.block-editor-inserter__quick-inserter-results .block-editor-inserter__panel-header {
	height: 0;
	padding: 0;
	float: left;
}

.block-editor-inserter__quick-inserter.has-search .block-editor-inserter__panel-content,
.block-editor-inserter__quick-inserter.has-expand .block-editor-inserter__panel-content {
	padding: $grid-unit-20;
}

.block-editor-inserter__quick-inserter-patterns {
	.block-editor-block-patterns-list {
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-gap: $grid-unit-10;
		.block-editor-block-patterns-list__list-item {
			margin-bottom: 0;
		}
		.block-editor-block-preview__container {
			min-height: 100px;
		}
	}
}

.block-editor-inserter__quick-inserter-separator {
	border-top: $border-width solid $gray-300;
}

.block-editor-inserter__popover.is-quick > .components-popover__content > div {
	padding: 0;
}

.block-editor-inserter__quick-inserter-expand.components-button {
	display: block;
	background: $gray-900;
	color: $white;
	width: 100%;
	height: ($button-size + $grid-unit-10);
	border-radius: 0;

	&:hover {
		color: $white;
	}

	&:active {
		color: $gray-400;
	}

	// Specificity is needed for the border color.
	&.components-button:focus:not(:disabled) {
		box-shadow: none;
		background: var(--gc-admin-theme-color);
		border-color: var(--gc-admin-theme-color);
	}
}

.block-editor-block-patterns-explorer {
	&__sidebar {
		position: absolute;
		top: $header-height;
		left: 0;
		bottom: 0;
		width: $sidebar-width;
		padding: $grid-unit-30 $grid-unit-40 $grid-unit-40;
		overflow-x: visible;
		overflow-y: scroll;

		&__categories-list__item {
			display: block;
			width: 100%;
			height: 48px;
			text-align: left;
		}
	}

	&__search {
		margin-bottom: $grid-unit-40;
	}

	&__search-results-count {
		padding-bottom: $grid-unit-40;
	}

	&__list {
		margin-left: $sidebar-width - $grid-unit-40;
	}

	.block-editor-block-patterns-list {
		display: grid;
		grid-gap: $grid-unit-40;
		grid-template-columns: repeat(1, 1fr);

		@include break-xlarge() {
			grid-template-columns: repeat(2, 1fr);
		}

		@include break-huge() {
			grid-template-columns: repeat(3, 1fr);
		}

		.block-editor-block-patterns-list__list-item {
			min-height: 240px;
		}

		.block-editor-block-preview__container {
			height: inherit;
			min-height: 100px;
			max-height: 800px;
		}
	}
}
