/**
 * Editor only styles for the Icon Block.
 */

// Register our variables.
$r90: rotate(90deg);
$r180: rotate(180deg);
$r270: rotate(270deg);

// Editor specific styles for the block itself.
.wp-block-outermost-icon-block {

	// Placeholder styles.
	.components-placeholder {
		line-height: normal;
		min-height: 160px;

		.components-placeholder__label {
			svg {
				max-width: 24px;
			}
		}

		svg.components-placeholder__illustration {
			max-width: 80px;

			// Needed for WordPress 6.0 and below.
			position: absolute;
		}
	}

	&.is-selected {
		// Placeholder styles.
		.components-placeholder {
			background-color: #fff;
			border: none;
			border-radius: 2px;
			box-shadow: inset 0 0 0 1px #1e1e1e;
			color: #1e1e1e;
			filter: none;

			.components-placeholder__illustration {
				display: none;
			}
		}
	}
}

.wp-block-outermost-icon-inserter__quick-inserter {
	.icons-list {
		.icons-list__item {
			width: 33.33%;

			// The quick inserter in core does not have border hover effects.
			&:hover {
				border-color: transparent;
			}
		}
	}

	// Temporary fix until updated in core.
	.block-editor-inserter__no-results {
		margin-top: 0;
	}
}

.wp-block-outermost-icon-inserter__modal {
	.components-modal__content {
		flex: 1 1 0%;
	    overflow: auto;
	    padding: 0px;

		&:before {
			margin-bottom: 0;
		}
	}

	.icon-inserter {
		align-items: stretch;
	    display: flex;
	    height: 100%;
	}

	.icon-inserter__sidebar {
		display: none;
	    flex-direction: column;
	    flex-shrink: 0;
	    overflow-y: scroll;
	    width: 280px;
	    padding: 24px 32px 32px;

		@media ( min-width: 900px ) {
			display: flex;
		}

		&__search {
			margin-bottom: 16px;

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

		&__category-type {
			// Override core component styles.
			border: none;

			.components-menu-group__label {
				margin: 0;
			    padding: 16px 12px 16px;
			}

			.components-menu-item__item {
				text-transform: capitalize;
				display: inline-flex;
				justify-content: space-between;
				width: 100%;

				&>span {
					opacity: 0.5;
				}
			}
		}
	}

	.icon-inserter__content {
		display: flex;
		flex-direction: column;
		flex-shrink: 0;
		overflow: auto;
		padding-top: 24px;
		padding-right: 32px;
		width: 100%;

		@media ( min-width: 900px ) {
			width: calc(100% - 281px);
		}

		.icon-inserter__content-header {
			align-items: center;
			display: flex;
			justify-content: space-between;
			margin-bottom: 24px;

			.search-results {
				color: #757575;
			}

			.icon-controls__size {
				display: flex;
				align-items: center;
				margin-right: 6px;

				&>span {
					margin-bottom: 6px;
					margin-right: 16px;
				}

				.components-range-control {
					width: 72px;

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

		.icons-list {
			padding: 4px 4px 72px 4px;
			margin: 0;
			display: grid;
			grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);

			@media ( min-width: 600px ) {
				grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
			}

			@media ( min-width: 900px ) {
				grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
			}

			@media ( min-width: 1100px ) {
				grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
			}

			@media ( min-width: 1450px ) {
				grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
			}

			@media ( min-width: 1600px ) {
				grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
			}

			.icons-list__item {
				&.is-active {
					background-color: var(--wp-admin-theme-color);
					color: rgb(255 255 255 / 80%);

					&:hover {
						color: #fff !important;
					}

					svg {
						fill: #fff;
					}

					&.has-no-icon-fill {
						svg {
							color: #fff;
							fill: none;
						}
					}
				}
			}
		}

		.block-editor-inserter__no-results {
			height: calc(100% - 56px);
			margin-top: 0;
			display: flex;
			flex-direction: column;
			justify-content: center;

			svg {
				margin: 0 auto;
			}
		}
	}
}

.wp-block-outermost-icon-custom-inserter__modal {
	.components-modal__content {
		flex: 1 1 0%;
		overflow: auto;
		padding: 0px;

		&:before {
			margin-bottom: 0;
		}
	}

	.icon-custom-inserter {
		align-items: stretch;
		display: flex;
		flex-direction: column;
		gap: 32px;
		height: 100%;
		padding: 32px;

		@media ( min-width: 900px ) {
			flex-direction: row;
		}
	}

	.icon-custom-inserter__content {
		min-height: 400px;

		@media ( min-width: 900px ) {
			width: calc(100% - 400px);
		}

		.components-base-control,
		.components-base-control__field,
		.components-textarea-control__input {
			height: 100%
		}

		textarea {
			resize: none;
		}
	}

	.icon-custom-inserter__sidebar {
		flex-shrink: 0;
		display: flex;
		flex-direction: column;
		justify-content: space-between;

		@media ( min-width: 900px ) {
			width: 400px;
		}

		.icon-preview__window {
			border: 1px solid #ddd;
			display: flex;
			justify-content: center;
			align-items: center;
			padding: 20px;
			min-height: 250px;
			max-height: 400px;
			overflow: scroll;

			&.is-default {
				svg {
					opacity: .3;
				}
			}

			svg {
				max-width: 100%;
			}
		}

		.icon-controls {
			display: flex;
			justify-content: center;
			padding: 12px 24px;
		}

		.icon-controls__size {
			display: flex;
			align-items: center;

			&>span {
				margin-bottom: 6px;
				margin-right: 16px;
			}

			.components-range-control {
				width: 90px;

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

		.components-notice {
			margin: 12px 0 24px;

			// Needed to fix color error in Notice component.
			&.is-error {
				background-color: #f8ebea;
			}
		}

		.icon-insert-buttons {
			display: flex;
			justify-content: space-between;
		}
	}
}

// Custom styles for the block's toolbar controls.
.block-editor-block-toolbar {
	.outermost-icon-block__rotate-button-90 {
		svg {
			transform: $r90;
		}
	}

	.outermost-icon-block__rotate-button-180 {
		svg {
			transform: $r180;
		}
	}

	.outermost-icon-block__rotate-button-270 {
		svg {
			transform: $r270;
		}
	}
}

// Custom styles for the block's inspector controls.
.block-editor-block-inspector {

	// Styles for main icon settings.
	.outermost-icon-block__icon-settings {
		.components-range-control {
			margin-bottom: 12px;
		}
		.components-button-group {
			margin-bottom: 12px;
		}
		.components-notice {
			margin: 0 0 24px 0;

			// Needed to fix color error in Notice component
			&.is-error {
				background-color: #f8ebea;
			}
		}

		.icon-settings__width {
			margin-bottom: 12px;
		}
	}

	// Styles for color settings.
	.outermost-icon-block__color-settings {
		.outermost-icon-block__color-settings__help {
			font-size: 12px;
			font-style: normal;
			color: rgb(117, 117, 117);
			margin-top: -6px;
			margin-bottom: 24px;
	
			&:first-child {
				margin-top: 0;
			}
		}

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

		.block-editor-contrast-checker {
			margin-top: 24px;

			.components-notice__content {
				margin-right: 0;
			}
		}
	}

	// Styles for advanced settings.
	.outermost-icon-block__title-control {
		.components-external-link {
			display: block;
			margin-top: 8px;
		}
	}
}

.icons-list {
	display: flex;
	flex-wrap: wrap;

	.icons-list__item {
		align-items: stretch;
		background: transparent;
		border: 1px solid transparent;
		border-radius: 2px;
		color: #1e1e1e;
		cursor: pointer;
		display: flex;
		flex-direction: column;
		font-size: 13px;
		height: auto;
		justify-content: center;
		padding: 8px;
		position: relative;
		transition: all .05s ease-in-out;
		word-break: break-word;

		&:hover {
			border-color: var(--wp-admin-theme-color);
			color: var(--wp-admin-theme-color) !important;
		}

		&.has-no-icon-fill {
			svg {
				fill: none;
			}
		}

		.icons-list__item-icon {
			border-radius: 2px;
			color: #1e1e1e;
			padding: 12px;
			transition: all .05s ease-in-out;
		}

		.icons-list__item-title {
			font-size: 12px;
			padding: 4px 2px 8px;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
	}
}