@import "@wordpress/base-styles/colors.native"; // stylelint-disable-line scss/at-import-partial-extension
@import "./styles/admin-color-scheme";
@import "./styles/animations";

.vrts-list-table-page {

	.vrts-page-title-action {
		color: #fff;
		border-color: var(--vrts-admin-theme-color);

		&:hover {
			color: #fff;
			border-color: var(--vrts-admin-theme-color);
		}
	}

	tbody {
		background-color: #f6f7f9;
	}

	tr {
		position: relative;
	}

	th,
	td {
		padding: 10px;
		border-bottom: 1px solid $gray-10;

		&:where(:not(.column-title)) > * {
			position: relative;
			z-index: 2;
		}
	}

	.vrts-testing-status {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		margin: 0;

		&--paused {
			color: $alert-red;
		}

		&--running {
			color: $alert-green;
		}

		&--waiting {
			color: #f97b06;
		}
	}

	// .test-run-row {
	// 	background-color: #fff;
	// 	border: 1px solid $gray-10;

	// 	&[data-unread] {
	// 		background-color: #FCFCFC;
	// 	}
	// }
}

.vrts-test-runs-list-table:not(.vrts-test-runs-list-queue-table) {

	.test-run-row[data-has-alerts] {
		background-color: #fff;
	}

	td {

		> div,
		strong {
			align-self: flex-start;

			@media (min-width: 783px) {
				display: inline-block;
			}
		}


		&.column-title {
			position: relative;
			display: flex;
			flex-direction: column;
		}

		&.column-trigger,
		&.column-status {

			@media (max-width: 782px) {
				padding-block: 10px !important;
			}
		}
	}
}

.column-vrts_testing_status {
	width: 3.5rem;

	.vrts-status {
		display: block;
		width: 20px;
		height: 20px;
	}

	.vrts-icon-status {
		display: inline-block;
		width: 12px;
		height: 12px;
		border-radius: 50%;
		margin: 3px 10px 0 3px;
		background: $gray-700;
		vertical-align: top;

		&--paused {
			background: $alert-red;
		}

		&--running {
			background: $alert-green;
		}
	}
}

.vrts-metabox-notice {
	background: #fff;
	border: 1px solid $gray-10;
	border-left-width: 4px;
	padding: 12px;

	&-is-info {
		border-left-color: $blue-50;
	}

	&-is-error {
		border-left-color: $red-50;
	}

	&-is-success {
		border-left-color: $alert-green;
	}

	+ .vrts-metabox-notice {
		margin-top: 1rem;
	}

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

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

.vrts-test-run-trigger {
	display: inline-block;
	border-radius: 32px;
	padding: 4px 10px;
	font-size: 13px;
	background: rgba(192, 192, 192, 0.15);
	color: $gray-80;

	&--api {
		background: rgba(224, 84, 6, 0.15);
		color: #ae4204;
	}

	&--scheduled {
		background: rgba(106, 26, 185, 0.1);
		color: #591b98;
	}

	&--manual {
		background: rgba(5, 116, 206, 0.1);
		color: #045495;

	}

	&--update {
		background: rgba(200, 11, 147, 0.1);
		color: #a51d7f;
	}

	&-notes {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
}

.vrts-tooltip {
	position: relative;

	&-icon {
		color: $blue-50;
		display: flex;
		align-items: center;
		justify-content: center;

		&::before {
			font-size: 1rem;
		}

		svg {
			fill: currentcolor;
		}
	}

	&-content {
		display: block;
		position: absolute;
		visibility: hidden;
		padding: 0.5rem;
		width: 240px;
		z-index: 1000002;
		top: -10px;
		right: 20px;
	}

	&-content-inner {
		display: block;
		background: #000;
		border-radius: 2px;
		color: #f0f0f0;
		font-size: 12px;
		line-height: 1.4;
		padding: 0.725rem;

		a {
			color: #fff;
		}
	}

	&:hover &-content {
		visibility: visible;
	}
}

.vrts-testing-toogle {
	display: flex;
	align-items: center;
	gap: 0.25rem;

	.vrts-tooltip {
		margin-left: auto;
	}
}

.vrts-action-button {
	display: grid !important;
	grid-template-columns: max-content max-content;

	&__icons {
		position: relative;
		display: grid;
	}

	&__icon {
		display: flex;
		transition: opacity 0.3s;
		grid-row: 1 / 1;
		grid-column: 1 / 1;
	}

	&__info {
		grid-row: 1 / 1;
		grid-column: 2 / 3;
		text-align: left;
	}

	&__spinner {
		display: flex;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		z-index: 1;
		visibility: hidden;
		opacity: 0;
		transition: all 0.3s;

		svg {
			overflow: visible;
			width: 14px;
			height: 14px;
		}

		circle {
			stroke-width: 1.5px;
			stroke: $gray-5;
		}

		path {
			stroke-width: 1.5px;
			animation: 1.4s linear 0s infinite normal both paused vrts-rotate;
		}
	}

	&[data-vrts-loading="true"] {

		.vrts-action-button__icon {
			opacity: 0;
		}

		.vrts-action-button__spinner {
			visibility: visible;
			opacity: 1;

			path {
				animation-play-state: running;
			}
		}
	}

	&[data-vrts-action-state="primary"] {

		[data-vrts-action-state-secondary] {
			display: none;
		}
	}

	&[data-vrts-action-state="secondary"] {

		[data-vrts-action-state-primary] {
			display: none;
		}
	}
}

.vrts-gradient-loader {
	position: absolute;
	top: 1px;
	left: 0;
	width: 100%;
	height: calc(100% - 1px);
	background: linear-gradient(90deg, #ddd, #fff, #ddd);
	background-size: 200% 100%;
	animation: vrts-shimmer 1.5s linear paused infinite;
	transition: opacity 0.2s, visibility 0.2s;
	opacity: 0;
	visibility: hidden;
	z-index: 10;

	[data-vrts-loading="true"] > & {
		opacity: 0.6;
		visibility: visible;
		animation-play-state: running;
	}
}
