@import '@wordpress/base-styles/breakpoints';
@import '@wordpress/base-styles/mixins';
@import '@wordpress/base-styles/variables';
@import './woocommerce-box';

.is-section-plugins .main {
	&.is-logged-out:not( .is-plugin-details ) {
		.navigation-header {
			visibility: hidden;
			position: absolute;
			top: 0;
		}
	}
	&.is-logged-out.is-plugin-details {
		.navigation-header {
			margin-top: -47px;
		}
	}

	.navigation-header {
		@include breakpoint-deprecated( '<660px' ) {
			padding-bottom: 16px;
			margin-bottom: 0;
		}
	}

	.upsell-nudge {
		margin-top: 40px;
		margin-bottom: 0;

		@include breakpoint-deprecated( '<660px' ) {
			margin: 16px 0 0;
		}
	}

	.upsell-nudge.is-jetpack {
		margin-top: 51px;
		margin-bottom: -20px;

		@include breakpoint-deprecated( '<660px' ) {
			margin-top: 86px;
			margin-bottom: -50px;
		}
	}
}

body.is-section-plugins {
	.is-section-plugins.is-global-sidebar-visible {
		.layout__content {
			min-height: 100vh;
		}

		.layout__primary > * {
			background-color: var( --color-surface );
			border-radius: 8px;
			height: calc(
				100vh - var( --masterbar-height ) - var( --content-padding-top ) - var(
						--content-padding-bottom
					)
			);
			max-width: none;
			overflow-y: auto;

			&:not( :has( .hosting-dashboard-layout-column__container ) ) {
				@include break-small {
					border: 1px solid $gray-200;
				}
			}
		}

		.plugins-browser,
		.is-plugin-details {
			overflow-x: hidden;
		}
	}

	.is-logged-in main:not( .hosting-dashboard-layout ):not( .hosting-dashboard-layout-column ) {
		&:not( .plugins-browser ),
		&.plugins-browser .plugins-browser__content-wrapper {
			padding-inline: 24px;

			@media ( max-width: $break-medium ) {
				padding-inline: 2rem;
			}

			@media ( max-width: $break-small ) {
				padding-inline: 16px;
			}
		}

		&.plugins-browser--site-view .plugins-browser__content-wrapper {
			box-sizing: border-box;
			margin: auto;
			max-width: 1040px;
		}
	}

	.is-section-plugins.is-global-sidebar-collapsed {
		.sidebar__back-link .sidebar__site-title {
			display: none;
		}
	}

	.hosting-dashboard-layout-column {
		height: 100%;
		overflow: auto;
	}

	.hosting-dashboard-layout-column.scheduled-updates-list-compact {
		width: 400px;
		flex: unset;
		transition: all 0.2s;

		.plugins-update-manager-multisite__header {
			padding: 1rem 1.125rem;

			h1 {
				font-size: 1.25rem;
			}
		}

		.plugins-update-manager-multisite-filters {
			padding: 0;
		}

		.plugins-update-manager-multisite-filter {
			margin: 0;
			padding: 1rem 1.5rem;

			.components-search-control {
				max-width: 100%;
			}
		}

		.plugins-update-manager-multisite-card {
			margin: 0;
			padding: 0.5rem 1.5rem;
		}

		@include breakpoint-deprecated( '<960px' ) {
			display: none;
		}
	}

	.hosting-dashboard-layout-column.scheduled-updates-list {
		.plugins-update-manager-multisite__header,
		.plugins-update-manager-multisite-filter {
			margin: 0;
		}

		.plugins-update-manager-multisite__header {
			display: flex;
			justify-content: space-between;
			align-items: flex-start;
			flex-wrap: nowrap;
			gap: 16px;

			p {
				margin-bottom: 0;
				font-size: 0.875rem;
				color: var( --color-neutral-60 );
			}
		}
	}

	.hosting-dashboard-layout-column.scheduled-updates-edit
		.hosting-dashboard-layout-column__container,
	.hosting-dashboard-layout-column.scheduled-updates-create
		.hosting-dashboard-layout-column__container {
		padding: 3rem;

		@include breakpoint-deprecated( '<660px' ) {
			padding: 1rem;
		}
	}
}

.is-section-plugins.has-no-sidebar .main {
	&:not( .hosting-dashboard-layout ):not( .hosting-dashboard-layout-column ):not( .plugins-browser ) {
		padding: 0;
	}

	&.is-plugin-details {
		.navigation-header {
			padding-top: 0;
			margin-top: -47px;

			@include breakpoint-deprecated( '<660px' ) {
				padding: 16px;
			}
		}
	}
}

body.is-section-plugins.theme-default.color-scheme {
	--color-surface-backdrop: var( --studio-white );
}

.plugin__installed-on,
.plugin-details__installed-on {
	margin-bottom: 16px;
}

.plugin__installed-on {
	margin-bottom: 16px;
}

.plugins__main-header {
	background: var( --color-surface );
	flex-direction: column;
	display: flex;
	margin: 9px 0;

	@include breakpoint-deprecated( '>480px' ) {
		flex-direction: row;
		margin: 17px 0;
	}
}

.plugins__main-header .section-nav {
	border: 1px solid color-mix( in srgb, var( --color-neutral-10 ) 50%, transparent );
	box-shadow: none;
	flex: auto;
	margin: 0;

	@include breakpoint-deprecated( '<660px' ) {
		border-width: 1px 0;
	}
}

.plugins__installed-header {
	margin-bottom: 1px;
}

.plugins__page-heading .formatted-header__subtitle {
	margin: 0;
}

.plugins__more-header {
	font-size: $font-body-small;
	line-height: 2;
	margin: 40px 0 20px;
	padding: 0 15px;

	@include breakpoint-deprecated( '>660px' ) {
		padding: 0;
	}
}

$layout-padding-top: 54px;
$calypso-header-height: 31px;
.plugin-details__layout {
	padding-top: $layout-padding-top;
	&:not( .is-logged-in ) {
		padding-top: calc( $layout-padding-top - $calypso-header-height );
	}

	@include display-grid;
	grid-template-columns: minmax( 380px, auto ) minmax( auto, 395px );
	grid-column-gap: 60px;
	grid-template-areas:
		'header actions'
		'content actions';
	grid-auto-rows: auto 1fr;

	@include breakpoint-deprecated( '<960px' ) {
		grid-template-areas:
			'header'
			'actions'
			'content';
		grid-template-columns: minmax( 0, 1fr );
		padding-top: 20px;
	}

	.plugin-details__header {
		grid-area: header;
	}

	.plugin-details__content {
		grid-area: content;
		padding-top: 40px;
	}

	.plugin-details__actions {
		position: relative;
		grid-area: actions;
		height: fit-content;

		@include breakpoint-deprecated( '<960px' ) {
			margin-top: 40px;
		}

		.plugin-details__sidebar {
			background-color: var( --studio-gray-0 );
			padding: 40px;

			@include breakpoint-deprecated( '<1280px' ) {
				padding: 30px;
			}

			@include breakpoint-deprecated( '<960px' ) {
				padding: 40px;
			}
		}

		.plugin-details-download-card {
			margin-top: 50px;
		}
	}

	.plugin-details__layout-col-left {
		position: relative;
		@include breakpoint-deprecated( '>1040px' ) {
			@include grid-column( 1, 2 );
		}
	}

	.plugin-details__layout-col-right {
		position: relative;
		@include breakpoint-deprecated( '>1040px' ) {
			@include grid-column( 3, 1 );
		}
	}

	.plugin-details__plugin-download {
		margin-top: 24px;
		gap: 16px;
		display: flex;
		font-size: $font-body-extra-small;

		@include breakpoint-deprecated( '<1280px' ) {
			flex-direction: column;
			gap: 10px;
		}

		.plugin-details__plugin-download-cta {
			a {
				font-size: $font-body-extra-small;
				padding: 6px 14px;
			}
		}
	}
}

.plugin-details__page {
	@media screen and ( max-width: 1040px ) {
		padding: 16px;
	}
}

.plugin-details__body {
	.plugin-sections {
		.section-nav {
			box-shadow: none;
		}

		.card {
			box-shadow: none;
			padding-left: 0;
			padding-right: 0;
		}
	}

	.section-nav-tabs__list {
		box-shadow: inset 0 -1px 0 var( --studio-gray-5 );
	}

	.section-nav-tab {
		border: none;

		&:first-child .section-nav-tab__link {
			padding-left: 0;
		}

		&.is-selected,
		&:hover:not( .is-selected ) {
			border-bottom-color: transparent;
		}

		.section-nav-tab__link {
			font-size: $font-body;
			color: var( --studio-gray-60 );
			padding: 8px 8px 12px;

			&:hover {
				background-color: transparent;
				color: var( --studio-gray-100 );
			}
		}

		&.is-selected .section-nav-tab__link {
			border-bottom: none;
			color: var( --studio-gray-100 );

			&:hover {
				color: var( --studio-gray-100 );
			}

			.section-nav-tab__text {
				padding-bottom: 10px;
				border-bottom: 1.5px solid var( --studio-gray-100 );
			}
		}
	}

	.plugin-details__layout-col-right {
		margin-top: 100px;

		.title {
			color: var( --studio-gray-60 );
			font-size: $font-body-extra-small;
		}

		.value {
			color: var( --studio-gray-90 );
			font-size: $font-body-small;
			padding-bottom: 16px;

			&.plugin-details__active-installs-value {
				font-size: $font-body;
			}
		}
	}

	@media screen and ( max-width: 1040px ) {
		display: flex;
		flex-direction: column;

		.plugin-details__layout-col-left {
			order: 2;
		}

		.plugin-details__layout-col-right {
			order: 1;
			margin-top: 0;
			padding: 0;
			display: flex;
			flex-direction: column;
			border-bottom: 1px solid var( --studio-gray-5 );
		}
	}

	@media screen and ( min-width: 481px ) {
		.section-nav-tab:first-child .section-nav-tab__link {
			padding-left: 0;
		}
	}
}

.plugin-details__sites-list-background + .plugin-details__body {
	border-top: none;
}

.plugin-details__sites-list-background {
	background-color: var( --studio-gray-0 );
	padding-top: 20px;
	padding-bottom: 60px;
	position: relative;
	transform: translateX( -50% );
	left: 50%;
	width: calc( 100vw - var( --sidebar-width-max ) + 1px );

	@media screen and ( max-width: 782px ) {
		width: 100vw;
	}
}

.plugin-details__sites-list {
	max-width: 1040px;
	margin: auto;

	@media screen and ( max-width: 1400px ) {
		padding: 0 40px;
	}

	@media screen and ( max-width: 1040px ) {
		padding: 0 48px;
	}

	@media screen and ( max-width: 660px ) {
		padding: 0 24px;
	}
}

body.is-section-plugins header .select-dropdown__item {
	padding: 0 0 0 16px !important;
}

body.is-section-plugins .is-logged-in .navigation-header {
	padding-block: 16px;
}

body.is-section-plugins #primary {
	.search-box-header::before {
		box-sizing: border-box;
		content: '';
		background-color: #fdfdfd;
		position: absolute;
		height: 100%;
		width: 200vw;
		left: -100vw;
		z-index: -1;
	}

	.is-logged-out .search-box-header::before {
		background: #e5f4ff;
		top: 0;
	}

	.categories__menu {
		.components-button {
			&:not( .is-pressed ):not( .is-selected ) {
				color: var( --studio-blue-90 );
			}
			&.is-pressed {
				&::before {
					background: var( --studio-blue-90 );
					border-radius: 4px;
				}
			}
		}
	}
}

.plugins__page-title {
	color: var( --studio-gray-80 );
	font-weight: 400;
	font-size: 2.25rem;
	line-height: 40px;
}
.plugins__page-subtitle {
	font-size: 0.875rem;
	color: var( --studio-gray-60 );
	margin-bottom: 8px;
}
.plugins__page-title-container {
	display: flex;
	flex-wrap: wrap;
	flex-direction: row;
	.plugins__header-left-content {
		display: none;
		@include breakpoint-deprecated( '>660px' ) {
			display: block;
			width: 100%;
		}
		@include break-xlarge {
			width: 45%;
		}
	}
	.plugins__header-right-content {
		width: 100%;
		margin: 12px 0;
		.button {
			height: 40px;
			display: inline-flex;
			&:not( :last-child ) {
				margin-inline-end: 8px;
			}
			.plugins__button-icon {
				margin-inline-end: 5px;
			}
			// Move button to next line if there are 3 buttons on devices <425px
			&:nth-child( 3 ) {
				margin-block-start: 12px;
				display: block;
				@media ( min-width: 425px ) {
					display: initial;
					margin-block-start: initial;
				}
			}
		}
		@include break-xlarge {
			width: 55%;
			text-align: right;
		}
	}
}

.plugins__main-updated {
	.plugins__main-header .section-nav {
		border-width: 1px;
		@include breakpoint-deprecated( '>660px' ) {
			border-width: 0;
		}
	}
	.plugins__main-header {
		margin: 9px 0;
		@include breakpoint-deprecated( '>660px' ) {
			margin: 0;
		}
	}
}
.plugins__top-container {
	padding: 0 16px;

	@media ( min-width: $break-small ) {
		padding: 0;
	}
}

.plugins__top-container-jc {
	margin: 0 -32px;
	padding: 4px 48px 0;

	@include break-large() {
		padding: 6px 48px 0;
	}
}

.plugin-management-wrapper {
	.plugins__top-container-jc {
		padding: 4px 0 0;

		@include break-large() {
			padding: 6px 0 0;
		}
	}
}

.plugins__content-wrapper {
	max-width: 1500px;
	margin: auto;
	@include break-large() {
		padding: 0;
	}
}

.plugins__main-content {
	margin: 0;
	padding: 0;
	flex: 1 1 100%;
	@media ( min-width: $break-small ) {
		padding: 16px 0;
		background: rgba( 255, 255, 255, 0.5 );
		margin-bottom: -32px;
	}
}

.plugins__search {
	height: 52px;
	box-shadow: 0 0 0 1px var( --color-neutral-5 );
	margin-block-end: 8px;
	@include breakpoint-deprecated( '>660px' ) {
		margin-block-end: 0;
	}
	.search.is-open {
		box-shadow: none;
		z-index: 0;
	}
}

.plugin-details__reviews {
	margin-bottom: 40px;

	@media screen and ( max-width: 1040px ) {
		padding: 16px;
	}
}

.plugin__header {
	border-bottom: none !important;
	background-color: var( --color-surface-backdrop ) !important;

	@include breakpoint-deprecated( '>660px' ) {
		inset-inline-start: 10px !important;
	}

	@media ( min-width: 782px ) {
		inset-inline-start: calc( var( --sidebar-width-min ) + 10px ) !important;
	}

	@include break-large {
		inset-inline-start: calc( var( --sidebar-width-min ) + 20px ) !important;
	}

	@include break-xlarge {
		> div {
			max-width: 1530px;
			margin: auto;
		}
	}
}

.banner.card.plugin-details__reviews-banner {
	&:hover {
		cursor: pointer;
		box-shadow:
			0 0 1px var( --color-neutral ),
			0 2px 4px var( --color-neutral-10 );
	}

	~ .plugin-details__page .plugin-details__layout {
		padding-top: calc( $layout-padding-top - 40px );
	}
}
