@import "@wordpress/base-styles/breakpoints";
@import "@wordpress/base-styles/mixins";

.plans-filter-bar {
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	flex: 0 0 250px;
	padding: 16px 0;
	color: var(--studio-gray-50);

	box-sizing: border-box;

	@include break-medium {
		flex-direction: row;
	}

	.plans-filter-bar__duration-toggle-wrapper {
		position: relative;
	}

	.plans-filter-bar__duration-toggle {
		display: flex;
		justify-content: center;
		align-items: center;
		font-weight: 700;
		padding-bottom: 10px;

		.plans-filter-bar__toggle-off-label {
			color: var(--color-primary);
		}

		&.checked {
			.plans-filter-bar__toggle-on-label {
				color: var(--color-primary);
			}
			.plans-filter-bar__toggle-off-label {
				color: var(--studio-gray-50);
			}
		}

		@include break-medium {
			padding-bottom: 0;
		}
	}
	.plans-filter-bar__toggle-control {
		> .components-base-control__field {
			margin-bottom: 0;

			.components-form-toggle {
				margin-right: 18px;
				margin-left: 18px;
			}
		}
		.components-form-toggle {
			.components-form-toggle__input:focus + .components-form-toggle__track {
				box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--color-primary);
			}

			.components-form-toggle__track {
				width: 42px;
				height: 22px;
				border-radius: 11px; /* stylelint-disable-line scales/radii */
			}

			.components-form-toggle__thumb {
				width: 16px;
				height: 16px;
			}

			&.is-checked {
				.components-form-toggle__track {
					background-color: var(--color-primary);
				}

				.components-form-toggle__thumb {
					transform: translateX(20px);
				}
			}
		}
	}
}

.plans-filter-bar__discount-message {
	padding-top: 2px;
	color: var(--color-primary);
	white-space: nowrap;
	text-align: center;
	font-weight: 700;
	font-size: 16px;
	padding-left: 10px;

	@include break-medium {
		padding-top: 0;
		position: absolute;
		left: calc(100% + 12px);
		top: 0;
	}

	.plans-filter-bar__discount-message-text {
		padding-right: 6px;
	}
}

.plans-filter-bar__discount-message.treatment .plans-filter-bar__discount-message-text {
	text-decoration: underline;
}

.plans-filter-bar.sticky {
	position: fixed;
	width: 100%;
	left: 0;
	top: var(--masterbar-height);

	background-color: var(--color-surface);
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.05), inset 0 0 0 1px #dcdcde;

	z-index: 2;
}
.is-section-jetpack-connect,
.is-group-jetpack-cloud.is-section-jetpack-cloud-pricing {
	.plans-filter-bar.sticky {
		top: 0;
	}
}

// target Calypso pricing filter bar, not jetpack cloud
.is-group-sites.is-section-plans .plans-filter-bar.sticky {
	// At this screen size, the left sidebar is 228px;
	@include breakpoint-deprecated( ">660px" ) {
		width: calc(100% - 228px);
		left: 228px;
	}

	// At this screen size, the lft sidebar is 272px;
	@include breakpoint-deprecated( ">960px" ) {
		width: calc(100% - 272px);
		left: 272px;
	}
}
