@use "sass:color";

:root {
	--mediumScreen: 768px;
	--smallScreen: 480px;
	--fontColor: #eee;
	--backgroundColor: #32373c;
	--borderColor: #555;
	--backgroundColorDark: #23282d;
}

$fontColor: #eee;
$backgroundColor: #32373c;

$mediaSmallScreen : "min-width: 480px";
$mediaMediumScreen : "min-width: 768px";
$mediaGutenbergSmallScreen : "max-width: 782px";

#wp-admin-bar-distributor.hide {
	display: none;
}

#distributor-push-wrapper,
#wpadminbar #wp-admin-bar-distributor-placeholder > .ab-item {
	display: none;
}

#wpadminbar #distributor-push-wrapper {
	display: flex;
	font-size: 13px;
	font-weight: normal;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	position: absolute;
	top: 32px;
	left: 0;
	right: 0;
	padding: 2em 1em;
	height: auto;
	background-color: var(--backgroundColor);
	align-items: center;
	color: var(--fontColor);
	justify-content: center;
	z-index: 9999;
	box-shadow: 0 2px 1px 0 rgba(0, 0, 0, 1);
	line-height: 1.5;

	@media ($mediaSmallScreen) {
		padding: 2em 0;
	}
}

#wpadminbar #distributor-push-wrapper * {
	line-height: 1.5;
}

#wp-admin-bar-distributor.syncing > .ab-sub-wrapper {
	display: block;
}

#wp-admin-bar-distributor.hover + #distributor-overlay,
#wp-admin-bar-distributor.syncing + #distributor-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.6);
}

#wpadminbar #distributor-push-wrapper .inner {
	width: 100%;
	max-width: var(--mediumScreen);
	margin: 0 auto;
}

#wpadminbar #distributor-push-wrapper .new-connections-list {
	border: 1px solid var(--borderColor);
	max-height: 155px;
	overflow: auto;

	.no-results {
		margin: 0 !important;
		padding: 0.5em;
	}
}

#wpadminbar #distributor-push-wrapper .selected-connections-list {
	margin-bottom: 0.5em;
	max-height: 145px;
	overflow: auto;
}

#wpadminbar #distributor-push-wrapper .connections-selected {
	margin-top: 2em;
	position: relative;
}

#wpadminbar #distributor-push-wrapper .connections-selected .no-selected {
	display: none;
}

#wpadminbar #distributor-push-wrapper .connections-selected.empty {
	opacity: 0.5;

	.no-selected {
		display: block;
	}

	.with-selected {
		display: none;
	}
}

#wpadminbar #distributor-push-wrapper .connections-selected button.selectno-connections {
	margin-left: 10px;
}

#wpadminbar #distributor-push-wrapper .connections-selected label {
	color: inherit;
}

#wpadminbar #distributor-push-wrapper .connections-selected input[type="checkbox"] {
	vertical-align: middle;
	margin-right: 2px;
}

#wpadminbar #distributor-push-wrapper .connections-selected.empty::after {
	content: " ";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: transparent;
}

#wpadminbar #distributor-push-wrapper .syndicated-notice a {
	display: inline-block;
	padding: 0;
	margin: 0;
}

/* stylelint-disable-next-line no-duplicate-selectors */
#wpadminbar #distributor-push-wrapper {

	@media ($mediaSmallScreen) {
		position: fixed;

		.connections-selector {
			width: 60%;
			position: relative;
			float: left;
			padding-right: 0;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.connections-selector div {
			width: 100%;
		}

		.connections-selected {
			width: 40%;
			float: right;
			margin-top: 0;
			padding-left: 3em;
			box-sizing: border-box;
		}
	}
}

#wpadminbar #distributor-push-wrapper .syndicated-notice,
#wpadminbar #distributor-push-wrapper .no-connections-notice {
	text-align: center;
	margin: 0;

	a {
		color: inherit;
		text-decoration: underline;
	}
}

#wpadminbar #distributor-push-wrapper input[type="checkbox"] {
	height: 16px !important;
}

#wpadminbar #distributor-push-wrapper input[type="text"] {
	font-size: inherit;
	padding: 0.5278em;
	width: calc(100% - 1.0556em - 2px);
	background-color: var(--backgroundColor);
	border: 2px solid var(--borderColor);
	color: var(--fontColor);
	margin-bottom: 0.5em;

	&::placeholder {
		color: color.adjust($fontColor, $blackness: 50%);
	}

	&:focus {
		color: var(--fontColor);
		background-color: var(--backgroundColor);
		border-color: color.adjust($fontColor, $blackness: 50%);
	}
}

#wpadminbar #distributor-push-wrapper button {
	padding: 0.5em 1em;
	border-radius: 3px;
	min-height: 0;

	&.button-link {
		margin: 0;
		padding: 0;
		box-shadow: none;
		border: 0;
		border-radius: 0;
		background: none;
		cursor: pointer;
		text-align: left;

		/* Mimics the default link style in common.css but brighter due to dark bg */
		color: #00a0d2;
		text-decoration: underline;
		transition-property: border, background, color;
		transition-duration: 0.05s;
		transition-timing-function: ease-in-out;

		&:hover {
			color: #fff;
			text-decoration: none;
		}
	}

	/* avoid being overridden by themes, darker than admin due to dark bg */
	&.button-primary:hover {
		background-color: #005b85;
		border-color: #005b85;
	}

	&.selectall-connections {
		margin-top: 0.5em;
		margin-bottom: -10px; /* compensation for margin above messages div to reduce jumping */
	}
}

#wpadminbar #distributor-push-wrapper .new-connections-list > .add-connection:nth-child(odd) {
	background-color: var(--backgroundColorDark);
}

#wpadminbar #distributor-push-wrapper .add-connection,
#wpadminbar #distributor-push-wrapper .added-connection {
	background-color: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	display: block;
	width: 100%;
	padding: 0.5em;
	box-sizing: border-box;
	color: inherit;
	cursor: pointer;
	text-align: left;

	&:focus {
		box-shadow: inset 0 0 0 2px #fff;
		outline: 2px solid transparent;
		outline-offset: 0;
	}

	&:hover {
		text-decoration: underline;
	}
}

#wpadminbar #distributor-push-wrapper .new-connections-list .add-connection.added {
	background-color: color.adjust($backgroundColor, $lightness: 40%);
}

#wpadminbar #distributor-push-wrapper .add-connection.syndicated {
	position: relative;
	pointer-events: none;
	cursor: not-allowed;

	&::after {
		content: "\f147";
		font-family: dashicons;
		color: var(--borderColor);
	}

	&:hover {
		text-decoration: none;
	}

	span {
		color: var(--borderColor);
	}

	a {
		color: inherit;
		text-decoration: underline;
		float: right;
		height: auto;
		pointer-events: all;

		&:focus {
			box-shadow: inset 0 0 0 1px #fff;
		}

		&:hover {
			text-decoration: none;
		}
	}
}

#wpadminbar #distributor-push-wrapper .added-connection {
	background-color: var(--borderColor);
	margin-bottom: 0.5em;
	cursor: normal;
	position: relative;

	&:hover {
		text-decoration: none;

		.remove-connection::after {
			color: #f00;
		}
	}

	.remove-connection {
		cursor: pointer;
		top: 1px;
		display: inline-block;
		float: right;
		font-size: 20px;
		line-height: 19px;
		vertical-align: middle;
		margin-left: 6px;
		position: relative;
	}

	.remove-connection::after {
		content: "\f335";
		font-family: dashicons;
	}
}

#wpadminbar #distributor-push-wrapper p,
#wpadminbar #distributor-push-wrapper header {
	margin: 0 0 1em 0 !important;
	padding: 0;
}

#wpadminbar #distributor-push-wrapper .as-draft {
	margin-left: 0.5em;
	height: 30px;
	line-height: 28px;
	padding: 2px 12px 2px;
	display: inline-block;
	box-sizing: border-box;
}

#wpadminbar .syncing #distributor-push-wrapper .action-wrapper .syndicate-button::after,
#wpadminbar .syncing #distributor-push-wrapper .action-wrapper .selectall-connections::after,
#wpadminbar .syncing #distributor-push-wrapper .action-wrapper .selectno-connections::after {
	content: " ";
	vertical-align: middle;
	border-radius: 50%;
	width: 6px;
	margin-left: 8px;
	height: 6px;
	display: inline-block;
	font-size: 9px;
	text-indent: -9999em;
	border-top: 3px solid #cfcfcf;
	border-right: 3px solid #cfcfcf;
	border-bottom: 3px solid #cfcfcf;
	border-left: 3px solid color.adjust(#0085ba, $blackness: 5%);
	transform: translateZ(0);
	animation: load8 1.1s infinite linear;
	position: relative;
	top: -1px;
	box-sizing: initial;
}

#wpadminbar #distributor-push-wrapper .messages {
	margin-top: 1em;
	box-sizing: border-box;

	@media ($mediaSmallScreen) {
		width: 40%;
		float: right;
		clear: right;
		padding-left: 3em;
	}
}

#wpadminbar #distributor-push-wrapper .messages > * {
	display: none;
}

#wpadminbar #distributor-push-wrapper.message-error .messages .dt-error {
	display: block;
}

#wpadminbar #distributor-push-wrapper.message-success .messages .dt-success {
	display: block;
}

#wpadminbar #distributor-push-wrapper .messages ul.details {
	padding-left: 1.5rem;
}

#wpadminbar #distributor-push-wrapper .messages ul.details li {
	list-style: disc;
}

#distributor-push-wrapper .loader-item {
	position: relative;
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-ms-flex-wrap: wrap;
	flex-wrap: wrap;
	overflow: hidden;
}

#distributor-push-wrapper.message-error .loader-item {
	display: none;
}

#wpadminbar #distributor-push-wrapper .loader-messages {

	@media ($mediaSmallScreen) {
		width: 100%;
		float: none;
		padding-left: 0;
	}
}

.distributor-panel {

	@media ($mediaGutenbergSmallScreen) {
		display: none;
	}
}

#distributor-push-wrapper .loader-item,
#distributor-push-wrapper .loader-item *,
#distributor-push-wrapper .loader-item ::after,
#distributor-push-wrapper .loader-item ::before {
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
}

#distributor-push-wrapper .loader-item::before {
	content: " ";
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 50%;
	z-index: 1;
	width: 349%;
	margin-left: -250%;
	-webkit-animation: loaderanimation 0.8s linear infinite;
	animation: loaderAnimation 0.8s linear infinite;
	background: -webkit-gradient(linear, left top, right top, color-stop(46%, rgba(255, 255, 255, 0)), color-stop(50%, rgba(255, 255, 255, 0.35)), color-stop(54%, rgba(255, 255, 255, 0))) 50% 50%;
	background: linear-gradient(to right, rgba(255, 255, 255, 0) 46%, rgba(255, 255, 255, 0.35) 50%, rgba(255, 255, 255, 0) 54%) 50% 50%;
}

#distributor-push-wrapper .loader-item > * {
	-webkit-box-flex: 1;
	-ms-flex: 1 1 auto;
	flex: 1 1 auto;
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-orient: vertical;
	-webkit-box-direction: normal;
	-ms-flex-flow: column;
	flex-flow: column;
}

#distributor-push-wrapper .loader-row {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-ms-flex-wrap: wrap;
	flex-wrap: wrap;
}

#distributor-push-wrapper .loader-row.border {
	border: 1px solid #555;
}

#distributor-push-wrapper .loader-row div {
	height: 15px;
}

#distributor-push-wrapper .loader-row .big,
#distributor-push-wrapper .loader-row.big div {
	height: 30px;
}

#distributor-push-wrapper .loader-row .odd {
	background-color: #23282d;
}

#distributor-push-wrapper .loader-row .bottom {
	margin-bottom: 15px;
}

#distributor-push-wrapper .loader-col-4 {
	-webkit-box-flex: 0;
	-ms-flex: 0 0 30%;
	flex: 0 0 30%;
	padding-left: 3em;
}

#distributor-push-wrapper .loader-col-8 {
	-webkit-box-flex: 0;
	-ms-flex: 0 0 60%;
	flex: 0 0 60%;
}

#distributor-push-wrapper .loader-col-12 {
	-webkit-box-flex: 0;
	-ms-flex: 0 0 100%;
	flex: 0 0 100%;
}

@-webkit-keyframes load8 {

	0% {
		-webkit-transform: rotate(0deg);
		transform: rotate(0deg);
	}

	100% {
		-webkit-transform: rotate(360deg);
		transform: rotate(360deg);
	}
}

@keyframes load8 {

	0% {
		-webkit-transform: rotate(0deg);
		transform: rotate(0deg);
	}

	100% {
		-webkit-transform: rotate(360deg);
		transform: rotate(360deg);
	}
}

@-webkit-keyframes loaderAnimation {

	0% {
		-webkit-transform: translate3d(-30%, 0, 0);
		transform: translate3d(-30%, 0, 0);
	}

	100% {
		-webkit-transform: translate3d(30%, 0, 0);
		transform: translate3d(30%, 0, 0);
	}
}

@keyframes loaderAnimation {

	0% {
		-webkit-transform: translate3d(-30%, 0, 0);
		transform: translate3d(-30%, 0, 0);
	}

	100% {
		-webkit-transform: translate3d(30%, 0, 0);
		transform: translate3d(30%, 0, 0);
	}
}
