@use "sass:math";
@import "uplot/dist/uPlot.min.css";
@import "@automattic/typography/styles/variables";
@import "@wordpress/base-styles/breakpoints";
@import "@wordpress/base-styles/mixins";

$section-max-width: 1224px;

.is-section-site-monitoring.theme-default:not(:has(.is-global-sidebar-visible)) {
	background-color: var(--studio-white);
	.focus-content:not(.has-no-sidebar) .layout__content {
		@media screen and (max-width: 782px) {
			padding-top: 71px;
		}
	}
}

div.is-section-site-monitoring:not(.is-global-sidebar-visible) {
	// this overrides the default .layout__content that adds unwanted padding
	& .layout__content,
	&.theme-default .focus-content .layout__content {
		padding-left: 0;
		padding-right: 0;

		@media (min-width: 1401px) {
			padding-bottom: 88px;
		}

		@media (min-width: 782px) {
			padding-inline-start: calc(var(--sidebar-width-max) + 1px);
		}
	}
	&:not(.has-no-masterbar) .layout__content {
		padding-block-start: 79px;
	}
	.site-monitoring__formatted-header.formatted-header.modernized-header.is-left-align {
		padding: 0 max(calc(50% - #{math.div( $section-max-width, 2 )}), 32px);
		padding-bottom: 24px;
		margin-left: 0;
		margin-right: 0;
	}
	& .site-logs-container {
		padding: 0 max(calc(50% - #{math.div( $section-max-width, 2 )}), 32px);
		@media screen and (max-width: 782px) {
			padding: 0;
			margin-left: 16px;
			margin-right: 16px;
		}
	}
}

.is-mobile-app-view {
	.site-monitoring__formatted-header,
	.site-monitoring-tab-panel {
		display: none;
	}

	.site-monitoring-time-controls__title {
		font-family: $sans;
		font-size: $font-body-large;
	}
	.site-monitoring__chart-subtitle {
		margin-bottom: 0;
	}

	&.is-section-site-monitoring .focus-content:not(.has-no-sidebar) .layout__content {
		padding-top: 40px;
	}

	.site-monitoring__chart {
		border: 0;
		padding: 0;
	}

	.u-legend {
		padding: 0 24px 0 50px;
	}

	.site-monitoring-http-verbs-pie-chart .pie-chart__legend {
		flex-direction: column;
		justify-content: space-around;
		gap: 4px;
		align-items: center;

		.legend-item {
			align-items: center;
		}
	}
}

.site-monitoring {
	position: relative;
}

.site-monitoring .components-tab-panel__tab-content,
.site-monitoring .components-tab-panel__tabs {
	margin-left: 16px;
	margin-right: 16px;
	max-width: 1224px;
}

.site-monitoring-metrics-tab {
	padding: 0 max(calc(50% - #{math.div( $section-max-width, 2 )}), 32px);
	display: flex;
	flex-direction: column;
	gap: 16px;

	&.tools-monitoring {
		padding: 0;
	}
}

.site-monitoring-time-controls__container {
	display: flex;
	gap: 24px;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
}

.site-monitoring-time-controls__title {
	font-family: $brand-serif;
	font-size: $font-title-large;
	line-height: 40px;
	color: var(--studio-gray-100);
	span {
		white-space: nowrap;
	}
}

.site-monitoring__chart {
	position: relative;

	.components-spinner {
		position: absolute;
		top: calc(50% - 8px);
		left: calc(50% - 8px);
	}
}

.site-monitoring__chart-header {
	margin-bottom: 24px;
}

.site-monitoring__chart-title {
	font-family: "SF Pro Text", $sans;
	font-size: rem(20px);
	line-height: rem(26px);
	font-weight: 500;
	color: var(--black-white-black);
}

.site-monitoring__chart-subtitle {
	color: var(--studio-gray-60);
	font-family: "SF Pro Text", $sans;
	font-size: rem(14px);
	font-weight: 400;
	line-height: rem(20px);
	letter-spacing: -0.15px;
}

.site-monitoring__pie-charts {
	display: flex;
	gap: 16px;
	flex-direction: column;
	.site-monitoring__chart {
		flex: 1;
	}
	@include break-large {
		flex-direction: row;
	}
}

.site-monitoring-http-verbs-pie-chart {
	.pie-chart__chart-section-verb-post,
	.pie-chart__legend-sample-verb-post {
		fill: var(--studio-wordpress-blue-60);
	}
	.pie-chart__chart-section-verb-get,
	.pie-chart__legend-sample-verb-get {
		fill: var(--studio-wordpress-blue-30);
	}
	.pie-chart__chart-section-verb-delete,
	.pie-chart__legend-sample-verb-delete {
		fill: var(--studio-red-10);
	}
	.pie-chart__chart-section-verb-head,
	.pie-chart__legend-sample-verb-head {
		fill: var(--studio-wordpress-blue-10);
	}
}

.site-monitoring-php-static-pie-chart {
	.pie-chart__chart-section-dynamic,
	.pie-chart__legend-sample-dynamic {
		fill: var(--studio-celadon-30);
	}
	.pie-chart__chart-section-static,
	.pie-chart__legend-sample-static {
		fill: var(--studio-celadon-5);
	}
}

.site-monitoring__pagination-text {
	text-align: center;
	margin: 0 0 1rem;
}

.site-monitoring-line-chart {
	.u-legend {
		color: var(--studio-gray-100);

		// Disable rendering first u-marker, which is for "Date" and is empty.
		> tbody > .u-series:first-child {
			display: none;
		}

		tr.u-series th {
			font-weight: 400;
		}

		// Use increased specificity to override original uPlot styles.
		> tbody > tr.u-series > th {
			cursor: initial;
			pointer-events: none;

			> .u-marker {
				// Nudge marker down to align with text.
				margin-top: -2px;
				border-radius: 4px;
				width: 12px;
				height: 3px;
			}

			> .u-label {
				vertical-align: baseline;
			}
		}
		tr.u-series th::after,
		tr.u-series .u-value {
			display: none;
		}
	}
}

.site-monitoring-bar-chart {
	tr.u-series th {
		font-weight: 400;
	}
}

.site-monitoring__navigation-header.navigation-header {
	width: auto;
	padding-bottom: 0;
	margin-bottom: 16px;

	@media (max-width: $break-medium) {
		margin-bottom: 8px;
	}
}

.site-logs-container {
	@media (max-width: $break-small) {
		margin-top: -12px !important;
	}
}
