@use "sass:math";
@import "@automattic/color-studio/dist/color-variables";
@import "@wordpress/base-styles/breakpoints";
@import '@automattic/components/src/styles/typography';


$section-max-width: 1224px;

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

	.notice-banner,
	.notice-banner__title {
		font-size: $font-body-small;
		margin-bottom: 4px;
	}

	@media (max-width: $break-medium) {
		gap: 0;
	}

	.performance-profiler-insights-section {
		.subtitle {
			font-size: $font-body-small;
		}

		.insight-header-container {
			font-size: $font-body-small;
		}

		.description-area {
			font-size: $font-body-small;
			word-break: break-word;
		}
	}

	.performance-profiler-content .container {
		padding-top: 0;
		gap: 16px;

		@media (max-width: $break-medium) {
			padding-top: 24px;
		}
	}

	.site-performance__loader {
		display: flex;
		flex-direction: column;
		gap: 64px;

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

	.notice-banner {
		box-shadow: none;
		padding: 16px;

		.notice-banner__icon-wrapper {
			margin-right: 8px;
			position: unset;
		}

		.notice-banner__action-bar {
			margin-top: 12px;
		}

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

	.notice-banner.is-info {
		border: none;
		background-color: $studio-wordpress-blue-5;
		color: $studio-wordpress-blue-80;

		.notice-banner__icon {
			fill: $studio-wordpress-blue-80;
		}
	}

	.notice-banner.is-warning {
		border: none;
		background-color: $studio-red-0;
		color: $studio-red-80;

		.notice-banner__icon {
			fill: $studio-red-80;
		}
	}

	@media (max-width: $break-large) {
		.insight-header-container .counter {
			display: none;
		}

		.metrics-insight-item .foldable-card__content > div {
			padding-inline: 0;
		}
	}
}

.site-performance-device-tab-controls__container {
	display: flex;
	gap: 16px;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;

	@media (max-width: $break-medium) {
		flex-wrap: wrap;
	}

	.site-performance__page-selector {
		display: flex;
		align-items: flex-start;
		flex-grow: 1;
		justify-content: flex-end;
		gap: 10px;
		max-height: 36px;

		@media (max-width: $break-medium) {
			flex-direction: column;
			align-items: start;
			justify-content: center;
			gap: 6px;
			max-height: unset;

			.searchable-dropdown {
				width: 100%;
			}
		}


	}

	.components-base-control {
		margin: 0 !important;
	}

	.navigation-header-title {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.site-performance__page-selector-search-icon {
		position: absolute;
		right: 10px;
		top: 50%;
		transform: translateY(-50%);
		display: flex;
		align-self: start;
		z-index: 2;
		height: 100%;
		margin-top: 6px;
		pointer-events: none;
	}
}

.site-performance__navigation-header.navigation-header {
	width: auto;
	padding-bottom: 0;

	.gridicon {
		fill: var(--color-neutral-100);
	}

	@media (max-width: $break-medium) {
		width: 100%;

		.formatted-header__subtitle {
			display: block;
		}

		.navigation-header__main {
			align-items: center;
		}
	}
}

.site-performance__navigation-header {
	display: flex;
	flex-grow: 1;
	flex-flow: column;
}

.site-performance__page-selector-drowdown {
	max-width: 240px;
	min-width: 240px;
	margin: 0;

	.components-combobox-control__suggestions-container {
		position: relative;
		z-index: 1;
		background: var(--color-surface);

		.components-flex {
			height: 36px;
		}

	}

	.message {
		padding-inline: 18px;
		padding-block: 16px;
		font-size: $font-body-extra-small;
		font-family: $font-sf-pro-text;
		color: #949494 !important;
		background: var(--color-surface);
	}

	.site-performance__page-selector-item {
		display: flex;
		flex-direction: column;
		padding-inline: 16px;
		padding-block: 8px;
		font-size: $font-body-small;
		font-family: $font-sf-pro-text;

		.subtitle {
			font-size: $font-body-extra-small;
			color: #949494;
			font-family: $font-sf-pro-text;
			line-height: 20px;
		}

	}

	input.components-combobox-control__input[type="text"] {
		height: 34px;
		padding-right: 30px;
		font-size: 0.875rem;
	}

	.components-form-token-field__suggestions-list {
		max-height: initial !important;
	}

	.components-form-token-field__suggestions-list li {
		padding: 0 !important;
		&:not(:first-child) {
			border-top: 1px solid #F0F0F0;
		}

		&.is-selected > .site-performance__page-selector-item > .subtitle {
			color: #fff !important;
		}
	}

	@media (max-width: $break-medium) {
		max-width: unset;
	}
}

.site-performance__page-selector-container {
	position: relative;
	display: flex;

	@media (max-width: $break-medium) {
		width: 100%;

		// To ensure the search icon is contained in the search input
		div:first-child {
			width: 100%;
		}
	}
}
