@use "../abstracts/variables" as *;

.firevert-powerwidget {
	position: fixed;
	bottom: 140px;
	right: 50%;
	transform: translateX(50%);
	z-index: $z-index;

	@media #{$md} {
		right: 62px;
		transform: unset;
	}

	&--box-shadow {
		box-shadow: var(--firevert-box-shadow);
	}

	&--active {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		right: 10px;
		bottom: 160px;
		width: calc(100% - 20px);
		animation: fadeInUp 0.4s ease-out forwards;

		@media #{$md} {
			max-width: 360px;
		}
	}

	&--bottom-left {
		right: unset;
		left: 50%;
		transform: translateX(-50%);

		@media #{$md} {
			left: 62px;
			transform: unset;
		}

		&.firevert-powerwidget--active {
			right: unset;
			left: 10px;
		}
	}

	&--image {
		bottom: 160px;

		&.firevert-powerwidget--active {
			bottom: 190px;
		}

		&.firevert-powerwidget--mobile-bottom-position {
			bottom: 110px;
		}

		&.firevert-powerwidget--mobile-bottom-position-active {
			bottom: 124px;
		}
	}

	&--mobile-bottom-position {
		bottom: 80px;
	}

	&--mobile-bottom-position-active {
		bottom: 100px;
	}

	&--init-desktop-position {
		@media #{$xl} {
			bottom: 85px !important;
		}

		&.firevert-powerwidget--image {
			@media #{$xl} {
				bottom: 115px !important;
			}
		}
	}

	&--init-desktop-active-position {
		@media #{$xl} {
			bottom: 105px !important;
		}

		&.firevert-powerwidget--image {
			@media #{$xl} {
				bottom: 135px !important;
			}
		}
	}

	&,
	* {
		font-family: var(--firevert-font-family);
	}

	&__accordion {
		display: none;
		justify-content: space-between;
		align-items: center;
		width: 248px;
		height: 23px;
		background-color: var(--firevert-accent);
		border-top-right-radius: 50px;
		border-top-left-radius: 50px;
		color: var(--firevert-white);
		font-size: 14px;
		line-height: 10px;
		cursor: pointer;
		user-select: none;
		padding-inline: 35px;

		&--active {
			display: flex;
		}

		&--collapsed {
			& svg {
				transform: rotate(0deg) !important;
			}
		}

		svg {
			transform: rotate(180deg);
		}
	}

	&__container {
		display: none;

		&--active {
			display: block;
			height: calc(100vh - 160px);
			width: 100%;
			background-color: var(--firevert-white);
			box-shadow: 0px 2px 14px #00082933;
			border-radius: var(--firevert-border-radius-primary);
			animation: fadeInUp 0.4s ease-out forwards;

			@media #{$md} {
				height: 374px;
				max-width: 360px;
			}

			@media #{$xxl} {
				height: 474px;
			}
		}
	}

	&__top {
		display: flex;
		justify-content: space-between;
		padding: 18px 16px 15px 16px;
		border-bottom: 1px solid var(--firevert-border-color);
	}

	&__tab {
		font-size: 13px;
		line-height: 10px;
		color: var(--firevert-accent);
		font-weight: 500;

		&--active {
			position: relative;

			& .firevert-powerwidget__tab-active-line {
				display: block;
			}
		}
	}

	&__tab-text {
		user-select: none;
	}

	&__tab-active-line {
		display: none;
		position: absolute;
		bottom: -16px;
		left: 0;
		content: "";
		background: var(--firevert-accent) 0% 0% no-repeat padding-box;
		opacity: 1;
		width: 100%;
		height: 3px;
	}

	&__logo-wrapper {
		display: flex;
		align-items: center;
		gap: 17px;
		cursor: pointer;
	}

	&__logo-text {
		font-size: 12px;
		line-height: 10px;
		font-weight: 600;
		color: var(--firevert-red);
	}

	&__products-list {
		display: flex;
		flex-direction: column;
		gap: 10px;
		overflow-y: auto;
		overflow-x: hidden;
		padding: 10px;
		height: 270px;
		height: calc(100vh - 270px);

		@media #{$md} {
			height: 270px;
		}

		@media #{$xxl} {
			height: 370px;
		}
	}

	&__product {
		display: flex;
		gap: 10px;
		padding: 5px;
		border: 1px solid var(--firevert-border-color);
		border-radius: 3px;

		&:hover,
		&:focus {
			border-color: var(--product-accent-color, var(--firevert-accent));
			cursor: pointer;
		}
	}

	&__product-info {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		max-width: 161px;
	}

	&__image-wrapper {
		width: 60px;
		height: 60px;

		& > img {
			width: 60px;
			height: 60px;
			object-fit: cover;
		}
	}

	&__product-name {
		font-size: 13px;
		line-height: 19px;
		color: var(--firevert-black);
	}

	&__product-omnibus {
		font-size: 10px;
		line-height: 10px;
		color: rgba(#000000, 0.8);
		margin-top: auto;
	}

	&__product-price-wrapper {
		display: flex;
		justify-content: flex-end;
		flex-direction: column;
		gap: 2px;
		margin-left: auto;
		margin-top: auto;
	}

	&__product-price {
		font-weight: 700;
	}

	&__product-price,
	&__product-price-old {
		font-size: 14px;
		line-height: 23px;
		color: var(--firevert-accent);
	}

	&__product-price-old {
		color: rgba(#000000, 0.6);
		text-decoration: line-through;
	}

	&__bottom {
		display: grid;
		place-items: center;
		height: 42px;
		background-color: var(--firevert-white);
		border-top: 1px solid var(--firevert-border-color);
	}

	&__bottom-text {
		font-size: 14px;
		line-height: 17px;
		color: var(--firevert-black);
		text-align: center;
		text-decoration: underline;
		margin-top: 8px;
		font-weight: 700;
		cursor: pointer;
	}

	&__loading {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 20px;
		opacity: 0;
		transform: translateY(20px);
		transition: all 0.3s ease-in-out;
		animation: fadeInUp 0.4s ease-out forwards;
	}

	&__loading-spinner {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-bottom: 12px;
		animation: pulse 1.5s ease-in-out infinite;

		svg {
			filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
			animation: spin 1s linear infinite;

			circle {
				&:first-child {
					stroke: var(--firevert-accent);
					animation: dash 2s ease-in-out infinite;
				}

				&:last-child {
					stroke: var(--firevert-red);
					opacity: 0.6;
					animation: dash 2s ease-in-out infinite reverse;
				}
			}
		}
	}

	&__loading-text {
		color: #555;
		font-size: 14px;
		font-weight: 500;
		text-align: center;
		animation: fadeInText 0.6s ease-out 0.2s forwards;
		opacity: 0;
	}
}

@keyframes slideInScale {
	0% {
		opacity: 0;
		transform: translateY(15px);
	}
	100% {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes fadeInText {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

@keyframes dash {
	0% {
		stroke-dasharray: 0 31.416;
		stroke-dashoffset: 0;
	}
	50% {
		stroke-dasharray: 15.708 15.708;
		stroke-dashoffset: -7.854;
	}
	100% {
		stroke-dasharray: 0 31.416;
		stroke-dashoffset: -31.416;
	}
}

@keyframes pulse {
	0%,
	100% {
		transform: scale(1);
		opacity: 1;
	}
	50% {
		transform: scale(1.05);
		opacity: 0.8;
	}
}
