$font__sans-serif: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
$color__link: #0073aa;
$color__link--hover: #00a0d2;
$color__border: #e6eaee;
$color__option-description: #86909b;
$color__option-icon: #b9bcc2;
$color__alt-background: #fdfdfd;

/**
 * Products block preview mode.
 */

.wc-products-block-preview {
	overflow: hidden;

	.product-preview {
		float: left;
		text-align: center;
		margin-right: 3.8%;
	}

	&.cols-1 .product-preview {
		float: none;
		margin-right: 0;
	}

	&.cols-2 .product-preview {
		width: 48%;

		&:nth-of-type(2n) {
			margin-right: 0;
		}

		&:nth-of-type(2n + 1) {
			clear: both;
		}
	}

	&.cols-3 .product-preview {
		width: 30.75%;

		&:nth-of-type(3n) {
			margin-right: 0;
		}

		&:nth-of-type(3n + 1) {
			clear: both;
		}
	}

	&.cols-4 .product-preview {
		width: 22.05%;

		&:nth-of-type(4n) {
			margin-right: 0;
		}

		&:nth-of-type(4n + 1) {
			clear: both;
		}
	}

	&.cols-5 .product-preview {
		width: 16.9%;

		&:nth-of-type(5n) {
			margin-right: 0;
		}

		&:nth-of-type(5n + 1) {
			clear: both;
		}

		.product-add-to-cart {
			font-size: 0.75em;
		}
	}

	&.cols-6 .product-preview {
		width: 13.5%;

		&:nth-of-type(6n) {
			margin-right: 0;
		}

		&:nth-of-type(6n + 1) {
			clear: both;
		}

		.product-add-to-cart {
			font-size: 0.75em;
		}
	}

	.product-add-to-cart {
		display: inline-block;
		background: #ababab;
		border-radius: 1.5em;
		color: #fff;
		cursor: pointer;
		padding: 0.75em 1.25em;
		line-height: 1.2em;
		margin-top: 0.5em;
		margin-bottom: 1em;
	}

	.editor-block-preview & {
		min-width: 5em;

		.product-title,
		.product-price,
		.product-add-to-cart {
			font-size: 0.6em !important;
		}

		&.cols-2 {
			min-width: 2 * 5em;
		}
		&.cols-3 {
			min-width: 3 * 5em;
		}
		&.cols-4 {
			min-width: 4 * 5em;
		}
		&.cols-5 {
			min-width: 5 * 5em;
		}
		&.cols-6 {
			min-width: 6 * 5em;
		}
	}
}

/**
 * General styling
 */

.wc-products-settings {
	background-color: #f8f9f9;
	font-family: $font__sans-serif;
	font-size: 13px;
	position: relative;
}

/* Block title */
.wc-products-settings__title {
	margin: 0;
	padding: 1.5rem 0;
	text-align: center;
	border-bottom: 1px solid $color__border;

	.dashicon {
		vertical-align: top;
		margin-right: 0.25em;
	}
}

/* Block footer */
.wc-products-settings__footer {
	margin: 2em 0 0;
	padding: 1.5em 0;
	border-top: 1px solid $color__border;
	text-align: center;

	.button {
		padding-left: 1.5em;
		padding-right: 1.5em;
	}
}

.wc-products-settings-heading + .wc-products-settings__footer,
.wc-products-display-options--popover + .wc-products-settings__footer {
	margin-top: -2em;
	border-top: none;
}

/**
 * Menu
 */

/* Select an option description */
p.wc-products-block-description {
	margin: 2em 0 1.5em 0;
	font-family: $font__sans-serif;
	font-size: 1em;
	text-align: center;
}

/* Select option */
.wc-products-display-options {
	margin: 0 0 2.5em;
}

.wc-products-display-options__option {
	display: flex;
	align-items: flex-start;
	flex-wrap: wrap;
	margin: 0 auto;
	padding: 1.25em 1.5em;
	max-width: 80%;
	background: #fff;
	border-width: 1px 1px 0;
	border-style: solid;
	border-color: $color__border;
	cursor: pointer;

	&:last-of-type {
		border-bottom-width: 1px;
	}

	&--featured,
	&--best_selling,
	&--top_rated,
	&--on_sale,
	&--attribute {
		display: none;
		background-color: $color__alt-background;
		padding-top: 1em;
		padding-bottom: 1em;

		.wc-products-display-options__option-title {
			font-size: 1.15em;
		}

		.wc-products-display-options__icon {
			.dashicon {
				height: 20px;
				width: 20px;
			}
		}
	}

	&--current {
		cursor: default;

		.wc-products-display-options__option-title {
			color: $color__option-description;
		}
	}
}

.wc-products-display-options__option-content {
	width: 85%;
	align-self: center;
}

.wc-products-display-options__option-title {
	display: block;
	font-size: 1.25em;
}

p.wc-products-display-options__option-description {
	margin: 0;
	font-family: $font__sans-serif;
	font-size: 1em;
	color: $color__option-description;
}

.wc-products-display-options__icon {
	align-self: center;
	margin-left: auto;
	color: $color__option-icon;

	.dashicon {
		height: 25px;
		width: 25px;
	}
}

/* Select options popover */
.wc-products-display-options--popover {
	position: absolute;
	right: -2em;
	max-width: 60%;
	margin: 0;
	z-index: 999;
	box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.1);
	margin-top: -2.15em;

	.wc-products-display-options__option {
		margin: 0;
		max-width: none;
	}
}

.wc-products-display-options--popover__arrow {
	width: 2em;
	height: 1.25em;
	position: absolute;
	top: -1.15em;
	right: 30%;
	overflow: hidden;

	&::after {
		content: "";
		position: absolute;
		width: 1.25em;
		height: 1.25em;
		background: #fff;
		transform: rotate(45deg);
		top: 0.625em;
		left: 0.3125em;
		box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.1);
		border: 1px solid $color__border;
	}
}

/* Select options extended */
.wc-products-display-options--extended {
	.wc-products-display-options__option {
		&--featured,
		&--best_selling,
		&--top_rated,
		&--on_sale,
		&--attribute {
			display: flex;
		}
	}

	&:not(.wc-products-display-options--popover) {
		.wc-products-display-options__option {
			&--category {
				border-bottom-width: 1px;
			}

			&--filter {
				margin-top: 0.5em;
			}

			&--attribute {
				margin-bottom: 0.5em;
				border-bottom-width: 1px;
			}
		}
	}
}

/**
 * Settings heading
 */

.wc-products-settings-heading {
	margin: 0 0 2em 0;
	padding: 1em 2em;
	text-align: center;
	border-bottom: 1px solid $color__border;
}

/**
 * List Card
 */

.wc-products-list-card {
	position: relative;
	margin-left: auto;
	margin-right: auto;
	padding: 0 1em;
	overflow: hidden;
	box-sizing: border-box;

	.wc-products-list-card__input-wrapper {
		position: relative;
		background: #fff;
		margin: 0 0 1em;

		.dashicon {
			position: absolute;
			top: calc(1em - 1px);
			left: 1em;
			z-index: 1;
		}
	}

	input[type="search"] {
		position: relative;
		width: 100%;
		margin: 0;
		padding: 1em 1.25em 1em 3em; // Override Gutenberg input style.
		border-radius: 0;
		background: transparent;
		border-color: $color__border;
		box-shadow: none;
		z-index: 2;
	}

	.wc-products-list-card__results {
		max-height: 200px;
		overflow-y: auto;
		overflow-x: hidden;
		box-sizing: border-box;

		ul {
			list-style: none;

			li {
				margin: 0;
				border: 1px solid $color__border;
				border-bottom-width: 0;

				&:last-child {
					border-bottom-width: 1px;
				}
			}
		}
	}

	.wc-products-list-card__content {
		display: flex;
		align-items: center;
		flex-direction: row;
		padding: 0.75em 1.25em;
		background: #fff;
		border-bottom: 1px solid $color__border;
	}

	&::after {
		content: "";
		position: absolute;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 1.5em;
		background: linear-gradient(rgba(255, 255, 255, 0.1) 0, #f8f9f9 100%);
	}
}

/**
 * Categories / Attributes
 */

.wc-products-list-card--taxonomy {
	.wc-products-list-card__taxonomy-count {
		text-align: center;
		width: 30px;
		font-size: 0.8em;
		border: 1px solid #e9e9e9;
		border-radius: 1em;
		color: #aaa;
	}

	input[type="checkbox"] {
		position: relative;
		margin-top: 0;
		margin-right: 0.75em;
		border-radius: 0;
	}
}

/**
 * Categories
 */

.wc-products-list-card--taxonomy-category {
	.wc-products-list-card__results {
		padding-bottom: 1.3em;

		ul {
			li {
				margin-top: -1px;

				&:first-child {
					margin-top: 0;
				}

				&:last-child {
					border-bottom-width: 0;
				}

				ul {
					display: none;
					padding: 1em 1.25em 1em 3.25em;
					background: $color__alt-background;
					border-bottom: 1px solid $color__border;

					li {
						margin-bottom: 0.25em;
						border: none;

						&:last-child {
							margin-bottom: 0;
						}
					}
				}

				&.wc-products-list-card__accordion-open {
					margin: 0.5em 0;

					&:first-child {
						margin-top: 0;
					}

					&:last-child {
						margin-bottom: 0;
					}

					ul {
						display: block;

						li {
							label {
								display: flex;
								align-items: center;
								flex-direction: row;
							}

							.wc-products-list-card__taxonomy-count {
								margin-left: auto;
							}
						}
					}
				}
			}
		}
	}

	.wc-products-list-card__accordion-button {
		cursor: pointer;
		color: #666;
		margin: 0 1em 0 auto;
		padding: 0 0 0 0.75em;
		border: none;
		border-radius: 0;
		background: none;
		outline: none;
		text-decoration: none;

		.dashicon {
			align-self: center;
			display: flex;
		}
	}

	input[type="checkbox"] {
		&:indeterminate {
			&::before {
				position: absolute;
				top: 0;
				bottom: 0;
				right: 0;
				left: 0;
				content: "";
				margin: 42% 20%;
				width: 60%;
				background: $color__link;
			}
		}
	}
}

/**
 * Attributes
 */

.wc-products-list-card--taxonomy-atributes {
	.wc-products-list-card__results {
		padding-bottom: 1.3em;

		ul {
			padding: 1em 1.25em 1em 3.25em;
			background: $color__alt-background;
			border-bottom: 1px solid $color__border;

			li {
				margin-bottom: 0.25em;
				border: none;

				.wc-products-list-card__content {
					padding: 0;
					background: transparent;
					border: none;
				}
			}
		}
	}

	&__atribute {
		margin: -1px 0 0;
		border-width: 1px 1px 0;
		border-style: solid;
		border-color: $color__border;

		&:first-child {
			margin-top: 0;
		}

		&.wc-products-list-card__accordion-open {
			margin-top: 0.5em;
			margin-bottom: 0.5em;

			&:first-child {
				margin-top: 0;
			}

			&:last-child {
				margin-bottom: 0;
			}
		}
	}

	.wc-products-list-card__taxonomy-count {
		margin-left: auto;
	}

	input[type="radio"] {
		position: relative;
		margin-top: 0;
		margin-right: 0.75em;
		border-radius: 100%;
	}
}

/**
 * Specific
 */

.wc-products-list-card--specific {
	overflow: visible;

	&::after {
		content: none;
	}

	.wc-products-list-card__item {
		position: relative;
		border: none;

		img {
			margin: 0;
			outline: 4px solid $color__link--hover;
			outline-offset: -4px;
		}

		button {
			position: absolute;
			top: 0;
			right: 0;
			background: $color__link--hover;
			padding: 0;
			margin: 0;
			border: none;
			margin-left: auto;
			line-height: 10px;
			cursor: pointer;
		}

		.dashicon {
			color: #fff;
		}
	}

	.wc-products-list-card__input-wrapper {
		margin: 0;
	}

	.wc-products-list-card__results-wrapper {
		@for $i from 1 through 6 {
			$width: percentage(1 / $i);

			&--cols-#{$i} {
				.wc-products-list-card__item {
					width: $width;
				}
			}
		}
	}

	.wc-products-list-card__results {
		max-height: none;
		overflow: visible;

		h3 {
			margin: 0 0 1em;
			font-size: 1em;
		}

		ul {
			display: flex;
			flex-wrap: wrap;
			margin: 0 -0.5em -1em;

			li {
				border: none;
				padding: 0 0.5em;
				margin: 0 0 1em;
			}
		}

		.wc-products-list-card__content {
			position: relative;
			display: block;
			padding: 0;
			background: transparent;
			border: none;
		}
	}
}

.wc-products-list-card__search-wrapper {
	position: relative;
	margin: 0 0 1.5em;
}

.wc-products-list-card__search-results {
	width: 100%;
	list-style: none;
	background: #fff;
	margin: -1px 0 0;
	border: 1px solid $color__border;
	box-shadow: 0 1px 3px $color__border;

	> div {
		max-height: 175px;
		overflow-y: auto;
	}

	.wc-products-list-card__content {
		position: relative;
		border-width: 1px 0 0;
		border-style: solid;
		border-color: $color__border;
		transition: opacity 0.7s;
		cursor: pointer;
		color: $color__link--hover;

		&--added {
			background-color: lighten($color__link, 65%);
		}

		&:hover {
			background-color: lighten($color__link, 65%);
		}

		&--transition-exit-active {
			opacity: 0;
		}

		&:first-child {
			border-top-width: 0;
		}

		img {
			object-fit: cover;
			object-position: center;
			width: 2.5em;
			height: 2.5em;
			margin: 0 1em 0 0;
		}

		.dashicon {
			color: $color__link;
			margin-left: auto;
		}
	}
}

.wc-products-list-card__search-wrapper--with-results + .wc-products-list-card__results-wrapper {
	.wc-products-list-card__item {
		img {
			outline: none;
		}

		button {
			display: none;
		}
	}
}

.wc-products-list-card__search-no-results {
	display: block;
	margin: 1em 0 0;
}

.wc-products-list-card__search-no-selected {
	display: block;
	margin: -0.75em 0 0;
}

.wc-products-list-card__results-wrapper {
	position: relative;
	overflow: hidden;
}

@media only screen and (min-width: 700px) {
	.wc-products-settings-heading {
		display: flex;
		justify-content: space-between;
	}

	.wc-products-list-card {
		max-width: 480px;
	}
}

/**
 * Sidebar area
 */
.edit-post-sidebar {
	.wc-products-scope-descriptions {
		margin-bottom: 1.5em;
		position: relative;
		padding-left: 46px;
		padding-top: 1em;
		padding-bottom: 1.5em;
		border-bottom: 1px solid $color__border;
		display: flex;
		justify-content: space-between;
	}

	h3 {
		font-weight: 500;
		margin-bottom: 5px;
		color: #555d66;
	}

	.scope-description {
		font-size: 12px;
	}

	.wc-products-scope-description--edit-quicklink {
		margin-left: 1em;
		min-width: 24px;

		a {
			cursor: pointer;
		}
	}
}
