@import "~@wordpress/base-styles/colors";
@import "~@wordpress/base-styles/variables";
@import "~@wordpress/base-styles/mixins";
@import "~@wordpress/base-styles/breakpoints";
@import "~@wordpress/base-styles/animations";
@import "~@wordpress/base-styles/z-index";

@include wordpress-admin-schemes();

$branding-bar-height: 79px;

// Page reset.
body.simpay-template-explorer-open {
	@include break-huge() {
		overflow: hidden;
	}

	.simpay-admin-notice-top-of-page.simpay-notice,
	.notice,
	#screen-meta,
	#screen-meta-links,
	#poststuff,
	#wpfooter {
		display: none !important;
	}

	// <SearchControl /> compat for WordPress 5.6-5.8
	&.branch-5-6,
	&.branch-5-7,
	&.branch-5-8 {

		.components-search-control {
			position: relative;

			input[type="search"].components-search-control__input {
				@include input-control;
				display: block;
				padding: $grid-unit-20 $grid-unit-60 $grid-unit-20 $grid-unit-20;
				background: $gray-100;
				border: none;
				width: 100%;
				height: $grid-unit-60;

				/* Fonts smaller than 16px causes mobile safari to zoom. */
				font-size: $mobile-text-min-font-size;
				@include break-small {
					font-size: $default-font-size;
				}

				&:focus {
					background: $white;
					box-shadow: 0 0 0 $border-width-focus var(--wp-admin-theme-color);
				}

				&::placeholder {
					color: $gray-700;
				}

				&::-webkit-search-decoration,
				&::-webkit-search-cancel-button,
				&::-webkit-search-results-button,
				&::-webkit-search-results-decoration {
					-webkit-appearance: none;
				}
			}
		}

		.components-search-control__icon {
			position: absolute;
			top: 0;
			right: calc( ( $grid-unit-60 - $icon-size ) / 2 );
			bottom: 0;
			display: flex;
			align-items: center;

			> svg {
				margin: $grid-unit-10 0;
			}
		}

		.components-search-control__input-wrapper {
			position: relative;
		}
	}
}

#simpay-form-template-explorer {
	background: #fff;
	border: 1px solid #c3c4c7;
	box-shadow: 0 1px 1px rgb(0, 0, 0, 0.04);
	margin-top: 10px;

	&,
	* {
		box-sizing: border-box;
	}

	@include break-huge() {
		position: fixed;
		top: calc( $admin-bar-height + $branding-bar-height );
		right: 0;
		bottom: 0;
		left: $admin-sidebar-width;
		margin: 20px 22px;
		overflow-x: hidden;
		overflow-y: scroll;

		.folded & {
			left: $admin-sidebar-width-collapsed;
		}
	}

	#wpcontent {
		padding-left: 0;
	}

	#wpbody-content {
		padding-bottom: 0;
	}

}

// Container.
.simpay-form-template-explorer {
	padding: $grid-unit-30;

	@include break-huge() {
		height: 100%;
		overflow: auto;
		padding-top: 0;
	}
}

// Header.
.simpay-form-template-explorer-header {

	@include break-huge() {
		position: absolute;
		left: 0;
		right: 0;
		padding: $grid-unit-30 0 $grid-unit-30 $grid-unit-30;
		margin-right: $grid-unit-30;
		height: 100px;
		background: #fff;
		z-index: 2;
	}

	&__title {
		font-size: 22px;
		font-weight: 400;
		margin: 0;
	}

	&__subtitle {
		color: #555;
		font-size: 15px;
		margin: $grid-unit-10 0 0;
	}
}

// Main content.
.simpay-form-template-explorer-main {
	margin-top: $grid-unit-30;

	&__sidebar {
		margin-bottom: $grid-unit-30;
		padding: 2px;

		&-search {
			margin-bottom: $grid-unit-15;

			@include break-huge() {
				margin-bottom: $grid-unit-30;
			}
		}

		&-categories {

			@include break-huge() {
				display: flex;
				flex-direction: column;
			}

			.components-button.is-pressed {
				background-color: var(--wp-admin-theme-color);
			}
		}
	}

	&__content {
		display: grid;
		grid-gap: $grid-unit-30;
		grid-template-columns: repeat(1, 1fr);
		padding: 2px;

		&:not(.is-empty) {
			@include break-medium() {
				grid-template-columns: repeat(2, minmax(0, 1fr));
			}

			@include break-large() {
				grid-template-columns: repeat(3, minmax(0, 1fr));
			}
		}

		&-list-item {
			text-align: left;
			padding: $grid-unit-20;
			border-radius: 4px;
			border: 1px solid #ddd;
			position: relative;
			transition: all 0.15s ease-out;
			width: 100%;
			height: auto;
			min-height: 100px;
			flex-direction: column;
			align-items: flex-start;

			&:focus-within,
			&:focus,
			&:hover {
				border-color: #1e1e1e;
				box-shadow: 0 0 0 1px #1e1e1e;
				outline: none;

				.simpay-form-template-explorer-main__content-list-item__description {
					opacity: 0;
				}

				.simpay-form-template-explorer-main__content-list-item__actions {
					opacity: 1;
				}
			}
		}

		&-list-item__name {
			font-size: 16px;
			font-weight: 600;
			line-height: 21px;
			overflow: hidden;
			position: relative;
			text-overflow: ellipsis;
			white-space: nowrap;

			&--is-locked {
				padding-right: 30px;
			}
		}

		&-list-item__description {
			color: #777777;
			font-size: 14px;
			line-height: 18px;
			margin: 10px 0 0;
			max-height: 53px;
			overflow: hidden;
			opacity: 1;
		}

		&-list-item__actions {
			background-color: #ffffff;
			border-radius: 4px;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: $grid-unit-20;
			position: absolute;
			top: 0;
			right: 0;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 100%;
			opacity: 0;
			transition: all 0.15s ease-out;

			@include break-medium(){
				padding: 0 $grid-unit-20 $grid-unit-20;
				top: auto;
				height: auto;
			}

			.components-button {
				justify-content: center;
				flex: 1 1 48%;
			}
		}

		&-list-item__badge {
			background: #fff;
			padding: 4px;
			position: absolute;
			right: calc($grid-unit-20 - 6px);
			top: 14px;
			z-index: 2;

			svg {
				fill: #777;
			}
		}

		&-suggest {
			color: #1d2327;
			padding: $grid-unit-30;
			grid-column: 1 / -1;
			display: flex;
			align-items: flex-start;
			border: 1px solid #ddd;
			border-radius: 4px;
			box-shadow: 0 1px 2px rgb(0 0 0 / 6%);

			> div {
				margin-left: $grid-unit-20;
			}

			svg {
				fill: currentColor;
				flex: 1 0 auto;
				margin-top: -6px;
			}

			h4 {
				margin: 0;
				font-size: 20px;
			}

			p {
				color: #555;
				font-size: 14px;
			}
		}
	}

	@include break-huge() {
		margin-top: 100px;

		&__sidebar {
			top: 100px;
			bottom: 0;
			left: $grid-unit-30;
			overflow-x: hidden;
			overflow-y: auto;
			position: absolute;
			width: 280px;
		}

		&__content {
			overflow-x: hidden;
			overflow-y: auto;
			margin-left: 300px;
		}
	}
}

// Upgrade modal.
.simpay-form-template-explorer-upgrade {
	max-width: 600px;

	* {
		box-sizing: border-box;
	}

	&__content {
		text-align: center;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	&__title {
		font-size: 22px;
		line-height: 1.5;
		display: block;
		margin: $grid-unit-15 0 0;
	}

	&__description {
		color: #777;
		font-size: 16px;
		margin: $grid-unit-20 0 $grid-unit-30;

		strong {
			color: #1d2327;
		}
	}

	.components-button.is-primary {
		font-size: 16px;
		font-weight: bold;
		margin: 0 0 15px;
		padding: 15px 30px !important;
		height: auto;
	}

	&__purchased {
		color: #555;
		display: inline-block;
		margin: $grid-unit-10 0;
	}

	&__discount {
		font-size: 15px;
		text-align: center;
		margin: $grid-unit-30 calc($grid-unit-40 * -1) calc($grid-unit-30 * -1);
		padding: $grid-unit-40 $grid-unit-50 $grid-unit-30;
		border-bottom-left-radius: $radius-block-ui;
		border-bottom-right-radius: $radius-block-ui;
		background-color: #fcf9e8;
		position: relative;

		svg {
			background: #00a32a;
			fill: white;
			border-radius: 50%;
			border: 4px solid white;
			width: 32px;
			height: 32px;
			position: absolute;
			top: -16px;
			left: 50%;
			margin-left: -16px;
		}

		u {
			text-decoration: none;
			font-weight: bold;
			color: #00a32a;
		}

		a {
			text-decoration: none;
		}
	}
}