.header-search {
	width: 100%;
	z-index: 1000;
}

.header-search--form {
	max-width: 655px;
	--mt-search__height: 60px;
}

.header-search__form {
	position: relative;
	display: flex;
	width: 100%;
	max-width: 100%;
	height: 100%;

	.header-search__field,
	.header-search__icon,
	.header-search__categories-label,
	.header-search__divider {
		opacity: 1;
	}

	&.categories--open {
		.header-search__container {
			box-shadow: none;
		}

		.header-search__field,
		.header-search__icon,
		.header-search__categories-label,
		.header-search__divider {
			opacity: 0;
		}
	}

	&.header-search__form--focused {
		.motta-type--input-text {
			border-color: $color__border-input-focus;
			box-shadow: 0px 4px 8px 0px var(--mt-input__box-shadow);
		}
	}

	&.searching {
		.close-search-results {
			&::before {
				position: absolute;
				top: 11px;
				right: 5px;
				opacity: 1;
				width: 15px;
				border-radius: 50%;
				border: 2px solid;
				border-top-color: transparent;
				animation: mottaSpin infinite 1s linear;
				transition: none;
			}

			svg {
				display: none;
			}
		}
	}

	&.searched {
		.header-search__results {
			opacity: 1;
			visibility: visible;
			pointer-events: initial;
		}
	}

	&.searching,
	&.actived {
		.close-search-results {
			opacity: 1;
			visibility: visible;
			pointer-events: initial;
		}
	}
}

.header-search__container {
	display: flex;
	width: 100%;
	position: relative;
	padding-right: 24px;
	padding-left: 0;

	.header-search__field {
		width: 100%;
		height: auto;
		box-shadow: none;
		outline: none;
		border: none;
		padding: 0;
		transition: 0s;
		background-color: transparent;

		&:hover {
			box-shadow: none;
		}

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

.header-search__field {
	margin-left: 22px;
}

.header-search__icon {
	display: flex;
	align-items: center;
	margin-left: 22px;

	span {
		color: $color__gray;
	}

	.motta-svg-icon {
		@include font-size(20);
	}

	+ .header-search__field {
		margin-left: 10px;
	}
}

.header-search__button {
	margin-left: 12px;
}

.header-search__divider {
	display: flex;
	align-items: center;
	margin-left: 20px;

	&::before {
		display: block;
		content: '';
		width: 1px;
		height: 50%;
		background-color: $color__border-main;
	}
}

.header-search--large {
	.header-search__divider {
		margin-left: 24px;
		margin-right: 4px;
	}
}

.header-search--small {
	.header-search__divider {
		margin-left: 16px;
		margin-right: 9px;
	}
}

.header-search--inside {
	padding: 0;

	.header-search__form {
		position: relative;
	}

	.header-search__container {
		position: static;
		box-shadow: none;
	}

	.header-search__icon {
		margin-left: 14px;
	}

	.header-search__button {
		margin: 6px 6px 6px 0;
		padding-left: 17px;
		padding-right: 17px;
		min-width: auto;

		&.motta-button--subtle {
			border: none;
		}

		&.motta-button--text {
			min-width: auto;
			margin-right: 0;
			color: $color__gray;
		}
	}

	.header-search__trending--outside {
		border-top: none;
	}

	.motta-type--input-text {
		padding: 0;
	}

	.motta-shape--circle & {
		.header-search__container {
			border-radius: 30px;
		}
	}

	.motta-button--smooth {
		margin-top: 0;
		margin-bottom: 0;
	}

	.motta-button--subtle {
		border: none;
	}
}

.header-search__trending--outside {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	text-align: left;
	opacity: 0;
	visibility: hidden;
	padding: 21px 23px 10px;
	background-color: #ffffff;
	pointer-events: none;
	box-shadow: 0px 7px 8px 0px rgba(0, 0, 0, 0.16);
	border-radius: 0 0 2px 2px;
	border-top: 1px solid $color__border-main;
	color: $color__dark;

	.header-search__trending-label {
		@include font-size(14);
		font-weight: 500;
		color: inherit;
		display: block;
		margin: 0 0 12px;
	}

	ul {
		list-style: none;
		margin: 0;
		padding: 0;
	}

	li {
		padding: 4px 0;

		a {
			width: 100%;
			display: inline-block;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
			color: inherit;
			font-weight: 400;
			@include font-size(14);
		}
	}
}

.motta-shape--circle {
	.header-search__trending--outside {
		border-radius: 2px;
	}
}

.motta-shape--round {
	.header-search__trending--outside {
		border-radius: 2px;
	}
}

.header-search__trending--open {
	opacity: 1;
	visibility: visible;
	pointer-events: initial;
	z-index: 101;
}

.header-search__trending--inside {
	margin-left: 16px;
	margin-right: -15px;
	overflow: hidden;
	// flex: 0 0 70%;

	.header-search__trending-label {
		display: none;
	}

	ul {
		display: flex;
		// justify-content: flex-end;
		height: 100%;
		list-style: none;
		margin: 0;
		padding: 8px 0;
		@include scrollbar();
	}

	li {
		display: flex;
		height: 100%;
		margin-left: 8px;

		a {
			display: flex;
			align-items: center;
			@include font-size(11);
			color: #08091b;
			white-space: nowrap;
			background-color: $color__background-gray;
			border-radius: var(--mt-border__radius);
			height: 100%;
			padding-left: 11px;
			padding-right: 11px;
		}
	}
}

.header-search__field--trending-inside {
	flex: 1;
	min-width: 240px;
}

.motta-search--button-no-spacing {
	.header-search__container {
		border-top-right-radius: 0;
		border-bottom-right-radius: 0;
	}

	.header-search__button {
		margin-left: 0;
		border-top-left-radius: 0;
		border-bottom-left-radius: 0;
	}
}

.header-search__categories-label {
	position: relative;
	display: flex;
	align-items: center;
	cursor: pointer;
	padding-right: 27px;
	margin-left: 24px;
	border-radius: var(--mt-border__radius);

	span {
		display: inline-block;
		@include font-size(14);
		font-weight: 500;
		line-height: 1;
		color: $color__gray;
		white-space: nowrap;

		&.motta-svg-icon {
			position: absolute;
			right: 0;
			top: 50%;
			transform: translateY(-50%);
			@include font-size(11);

			svg {
				vertical-align: 0;
			}
		}
	}
}

.header-search__categories {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	text-align: left;
	opacity: 0;
	visibility: hidden;
	background-color: #ffffff;
	pointer-events: none;
	box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.16);
	transform: translateY(35px);
	border-radius: 0 0 2px 2px;

	&.header-search__categories--open {
		visibility: visible;
		opacity: 1;
		transform: none;
		pointer-events: initial;
		z-index: 9999;
	}
}

.header-search__categories-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 24px;
	line-height: calc( var(--mt-search__height) - 1px );
	border-bottom: 1px solid $color__border-main;
	@include font-size(16);
	color: $color__dark;
	font-weight: 500;

	span {
		margin: 0;

		&.motta-svg-icon {
			cursor: pointer;
			@include font-size(18);
		}
	}
}

.header-search__categories-container {
	--mt-header-search-cats-rows: 5;
	display: grid;
	grid-auto-flow: column;
	grid-template-columns: auto auto auto;
	grid-template-rows: repeat( var(--mt-header-search-cats-rows), auto );
	width: 100%;
	max-height: 270px;
	padding: 17px 23px 5px;
	margin: 0;
	list-style: none;
	overflow-y: auto;
	scroll-behavior: smooth;
	scrollbar-color: $color__dark rgba( $color__gray, .3 );
	scrollbar-width: thin;

	&::-webkit-scrollbar {
		width: 2px;
	}

	&::-webkit-scrollbar-track {
		background-color: rgba( $color__gray, .3 );
	}

	&::-webkit-scrollbar-thumb {
		background-color: $color__dark;
	}

	li {
		margin-bottom: 13px;

		a {
			display: inline-block;
			@include font-size(14);
			font-weight: 400;
			transition: 0s;

			&::after {
				display: block;
				content: '';
				width: 0;
				height: 1px;
				background-color: $color__dark;
				transition: 0s;
			}

			&.active,
			&:hover {
				&::after {
					width: 100%;
				}
			}
		}
	}
}

.header-search__form,
.search-modal__form {
	&.searching {
		.close-search-results {
			&::before {
				position: absolute;
				top: 11px;
				right: 5px;
				opacity: 1;
				width: 15px;
				border-radius: 50%;
				border: 2px solid;
				border-top-color: transparent;
				animation: mottaSpin infinite 1s linear;
				transition: none;
			}

			svg {
				display: none;
			}
		}
	}

	&.searched {
		.header-search__results {
			opacity: 1;
			visibility: visible;
			pointer-events: initial;
		}
	}

	&.searching,
	&.actived {
		.close-search-results {
			opacity: 1;
			visibility: visible;
			pointer-events: initial;
		}
	}
}

.search-modal__form {
	&.searching,
	&.searched,
	&.actived {
		.modal__button-close {
			display: none;
		}
	}

	&.searching {
		.close-search-results::before {
			top: -8px;
		}
	}

	.header-search__results {
		top: 70px;
	}
}

.header-search__results {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	text-align: left;
	opacity: 0;
	visibility: hidden;
	background-color: #ffffff;
	pointer-events: none;
	box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.16);
	transform: translateY( var( --mt-search__height ) );
	transition: transform 0.7s, opacity 0.3s;
	border-radius: 0 0 2px 2px;
	z-index: 200;

	.search-list {
		overflow-y: auto;
		scroll-behavior: smooth;
		scrollbar-color: $color__dark rgba($color__gray, 0.3);
		scrollbar-width: thin;
		max-height: calc( ( 100px * 4 ) + 20px );
		padding-top: 20px;
		padding-bottom: 20px;

		&::-webkit-scrollbar {
			width: 2px;
		}

		&::-webkit-scrollbar-track {
			background-color: rgba($color__gray, 0.3);
		}

		&::-webkit-scrollbar-thumb {
			background-color: $color__dark;
		}

		.list-item {
			display: flex;
			align-items: center;
			margin-top: 20px;
			padding: 0 22px;

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

			&.view-more {
				justify-content: center;


				a {
					border-color: $color__dark;
					line-height: 1.2;
				}
			}

			img {
				max-width: 80px;
				margin-right: 30px;
			}

			.title-item {
				display: block;
				@include font-size(14);
				font-weight: 400;
				margin-top: 7px;

				&:hover {
					box-shadow: inset 0 -1px $color__dark;
				}
			}

			.star-rating {
				float: none;
				margin-top: 3px;
			}

			.price-item {
				font-weight: 500;
				@include font-size(16);
				display: flex;
				margin-top: 10px;

				.woocs_price_code {
					display: flex;
					align-items: center;
				}

				.sale {
					display: none;
				}
			}

			del {
				order: 2;
				font-size: 84.25%;
				font-weight: 500;
				color: $color__gray;
				margin-top: 3px;
			}

			ins {
				order: 1;
				background-color: transparent;
				color: #ff311c;
				margin-right: 6px;
			}
		}

		.search-item {
			display: flex;
			align-items: center;
		}
	}

	.result-list-not-found {
		padding: 20px;

		.list-item {
			justify-content: center;
		}
	}
}

.header-search,
.search-modal {
	.close-search-results {
		@include font-size(18);
		cursor: pointer;
		display: flex;
		align-items: center;
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		position: relative;

		&::before {
			content: "";
			display: inline-block;
			width: 0;
			height: 15px;
			opacity: 0;
			transition: width .2s;
		}
	}

	.header-search__categories + .close-search-results {
		position: absolute;
		top: 50%;
		transform: translateY(-50%);

		&::before {
			top: -8px;
		}
	}
}

.search-modal {
	.close-search-results {
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
	}

	.modal__content {
		position: relative;
		padding: 0;
		margin-left: 16px;
		margin-right: 16px;
	}

	.header-search--form {
		--mt-size__header-item: 60px
	}
}

.header-search--icon {
	--mt-size__medium: 44px;
	max-width: 284px;
	min-width: 284px;

	.header-search__form {
		position: relative;
		width: 100%;
		padding: 0;
		justify-content: flex-end;
		cursor: pointer;

		&.header-search__form--focused {
			.header-search__container {
				box-shadow: none;
				padding: 0;
			}
		}

		.header-search__container {
			position: relative;
			z-index: 2;
			width: 0;
			overflow: hidden;
			opacity: 0;
			box-shadow: none;
			padding: 0;
			border: 2px solid transparent;
			border-radius: var(--mt-border__radius);
			background-color: $color__light;
			transition: width 0.3s, opacity 0.3s;
		}
	}

	.header-search__field {
		width: 100%;
		padding-left: 2px;
		padding-right: 14px;
		transition: 0.5s linear;
		margin: 0;
	}

	.header-search__button {
		margin: 0;
	}

	.header-search__icon {
		position: absolute;
		height: 100%;
		opacity: 1;
		padding-left: 14px;
		padding-right: 14px;
		transition: opacity 0.3s;
		z-index: 9;

		span {
			color: inherit;
		}
	}

	&.header-search--icon-open {
		width: 100%;

		.header-search__form {
			width: 100%;

			&.header-search__form--focused {
				.header-search__container {
					border-color: $color__dark;
				}
			}

			.header-search__container {
				overflow: visible;
				opacity: 1;
				width: 100%;
				border-color: $color__border-input;
			}
		}

		.header-search__icon {
			opacity: 0;
			z-index: 1;
		}

		.header-search__trending--outside {
			top: calc( 100% + 2px );
		}
	}
}

.header-mobile-contents {
	.header-search--form,
	.motta-skin--raised.header-search--form  {
		--mt-search__height: 48px;
		--mt-size__header-item: 48px;
		max-width: 100%;
	}

	.header-search__form {
		height: var(--mt-search__height);
		padding-left: 0;
	}

	div.motta-type--input-text {
		padding-top: 0;
		padding-bottom: 0;
	}

	.motta-button--display-text {
		min-width: auto;
	}

	.motta-search--button-no-spacing {
		margin-left: 0;
	}

	.header-search:not( .motta-search--button-no-spacing ) {
		.header-search__button {
			margin-left: 8px;
		}
	}

	.header-search--inside {
		.header-search__field {
			margin-left: 10px;

			&:first-child {
				margin-left: 16px;
			}
		}

		.header-search__container {
			padding-right: 0;
		}
	}

	.header-search__form{
		&.searching {
			.close-search-results{
				&:before {
					top: 17px;
				}
			}
		}
	}

	.header-search__results {
		.search-list {
			.list-item {
				padding: 0 10px;

				&:first-child {
					margin-top: 20px;
				}

				img {
					max-width: 60px;
					margin-right: 20px;
				}
			}
		}
	}

	.header-search {
		.close-search-results {
			right: 0 !important;
		}
	}
}

.header-mobile-search {
	color: inherit;

	a {
		@include font-size(24);
		color: inherit;
	}

	.motta-button--icon {
		display: inline-block;
		text-align: center;
		outline: none;

		span {
			color: inherit;
		}

		&.motta-button--medium {
			padding: 0;
			@include font-size(24);
		}

		&.motta-button--base,
		&.motta-button--raised {
			min-width: var(--mt-size__header-item);

			span {
				color: inherit;
			}
		}
	}
}

.motta-skin--base {
	&.header-search--form:not(.header-search--custom) {
		--mt-input__border-width: 0;
	}
}

.motta-skin--raised {
	.header-contents & {
		&.header-search--form {
			--mt-size__header-item: 60px;
		}
	}
}

.motta-skin--smooth {
	.header-search--inside {
		.header-search__button {
			margin-top: 0;
			margin-bottom: 0;
		}
	}
}

.motta-skin--subtle,
.motta-skin--text {
	&.header-search--outside {
		.header-search__button {
			border-width: var(--mt-input__border-width);
			border-style: solid;
			border-color: #dadfe3;

			.motta-button__icon {
				line-height: 47px;
			}
		}
	}
}

.header-search--form:not(.header-search--custom) {
	&.header-search--simple {
		.motta-type--input-text {
			padding-top: 0;
			padding-bottom: 0;
			border: none;
		}
	}
}