// ==========================================================================
// UTM apply / reset confirmation dialog (two states: confirm, then result).
// Portaled to <body>, so root-level rules.
//
// Centred layout to the agreed final design: big title, the affected-URL count
// in its own tinted panel, and the result counts as one tinted ledger.
// ==========================================================================
$utmc-text: #131b2e;
$utmc-panel: #f0f4ff;
$utmc-panel-border: #dfe7ff;
$utmc-blue: #2961ff;
$utmc-blue-dark: #1a3fd0;
$utmc-green: #34a853;
$utmc-red: #ef4444;

.bl-utmc {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 440px;
	max-width: calc(100vw - 40px);
	padding: 32px 32px 26px;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 24px 60px rgba(15, 20, 30, 0.25);
	text-align: center;
	color: $utmc-text;

	* {
		box-sizing: border-box;
	}

	// The result dialog is narrower — it carries no wide count panel.
	&--success {
		width: 420px;
		padding-top: 30px;
	}

	&__close {
		position: absolute;
		top: 14px;
		right: 14px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 30px;
		height: 30px;
		padding: 0;
		border: none;
		border-radius: 9px;
		background: transparent;
		color: #98a2b3;
		cursor: pointer;
		transition: background 0.15s ease, color 0.15s ease;

		&:hover {
			background: #f4f5f7;
			color: $utmc-text;
		}
	}

	&__mark {
		display: flex;
		justify-content: center;
		margin-bottom: 18px;

		svg {
			display: block;
			filter: drop-shadow(0 6px 16px rgba($utmc-green, 0.28));
		}
	}

	&__title {
		margin: 0;
		padding: 0;
		font-family: inherit;
		font-size: 20px;
		font-weight: 700;
		line-height: 1.3;
		letter-spacing: -0.005em;
		text-align: center;
		color: $utmc-text;
	}

	&__desc {
		margin: 8px 0 0;
		max-width: 330px;
		font-size: 14px;
		line-height: 1.55;
		color: #55607a;
	}

	// The affected-URL count, called out so the number is unmissable before a
	// bulk write.
	&__count {
		width: 100%;
		margin-top: 14px;
		padding: 13px 18px;
		border-radius: 10px;
		background: $utmc-panel;
		font-size: 19px;
		font-weight: 700;
		line-height: 1.2;
		color: $utmc-blue;
	}

	&__note {
		margin: 14px 0 0;
		max-width: 330px;
		font-size: 13px;
		line-height: 1.55;
		color: #55607a;
	}

	// ---- Result ledger -----------------------------------------------------
	&__stats {
		width: 100%;
		margin: 18px 0 0;
		padding: 14px 18px;
		border: 1px solid $utmc-panel-border;
		border-radius: 10px;
		background: $utmc-panel;
		list-style: none;
		text-align: left;
	}
	&__stat {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 16px;
		margin: 0;
		padding: 5px 0;

		&--total {
			margin-top: 8px;
			padding-top: 12px;
			border-top: 1px solid $utmc-panel-border;

			.bl-utmc__stat-label {
				font-size: 14px;
				font-weight: 600;
			}
			.bl-utmc__stat-value {
				font-size: 15px;
				font-weight: 700;
			}
		}
	}
	&__stat-label {
		font-size: 14px;
		font-weight: 500;
		color: #4b5565;
	}
	&__stat-value {
		font-size: 14px;
		font-weight: 600;
		font-variant-numeric: tabular-nums;
		color: $utmc-blue;
	}

	// ---- Actions -----------------------------------------------------------
	&__actions {
		display: flex;
		justify-content: center;
		gap: 12px;
		margin-top: 24px;
	}
	&__btn {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 96px;
		height: 46px;
		padding: 0 20px;
		border: 1px solid transparent;
		border-radius: 10px;
		font-size: 14px;
		font-weight: 600;
		cursor: pointer;
		transition: all 0.15s ease;

		&:disabled {
			opacity: 0.6;
			cursor: not-allowed;
			box-shadow: none;
		}
		&--ghost {
			background: #fff;
			border-color: rgba($utmc-blue, 0.55);
			color: $utmc-blue;

			&:hover:not(:disabled) {
				background: $utmc-panel;
				border-color: $utmc-blue;
			}
		}
		&--primary {
			background: linear-gradient(180deg, $utmc-blue 0%, $utmc-blue-dark 100%);
			border-color: $utmc-blue-dark;
			color: #fff;
			box-shadow: 0 8px 18px rgba($utmc-blue, 0.26);

			&:hover:not(:disabled) {
				background: linear-gradient(180deg, darken($utmc-blue, 4%) 0%, darken($utmc-blue-dark, 4%) 100%);
				color: #fff;
			}
		}
		&--danger {
			background: $utmc-red;
			border-color: $utmc-red;
			color: #fff;
			box-shadow: 0 8px 18px rgba($utmc-red, 0.26);

			&:hover:not(:disabled) {
				background: darken($utmc-red, 7%);
				border-color: darken($utmc-red, 7%);
				color: #fff;
			}
		}
	}

	@media screen and (max-width: 600px) {
		padding: 26px 20px 22px;

		&__title {
			font-size: 18px;
		}
		&__count {
			font-size: 17px;
		}
		&__actions {
			flex-direction: column-reverse;
			width: 100%;
		}
		&__btn {
			width: 100%;
		}
	}
}

// ---- Dark mode -------------------------------------------------------------
body.betterlinks-dark-mode .bl-utmc {
	background: #2c3650;
	color: #e5e9f2;

	.bl-utmc__title {
		color: #e5e9f2;
	}
	.bl-utmc__desc,
	.bl-utmc__note,
	.bl-utmc__stat-label {
		color: #b6c0d4;
	}
	.bl-utmc__count,
	.bl-utmc__stats {
		background: #252f47;
		border-color: #36405a;
	}
	.bl-utmc__count,
	.bl-utmc__stat-value {
		color: #8ba9ff;
	}
	.bl-utmc__stat--total {
		border-top-color: #36405a;
	}
	.bl-utmc__close {
		color: #9aa5bd;

		&:hover {
			background: #36405a;
			color: #e5e9f2;
		}
	}
	.bl-utmc__btn--ghost {
		background: transparent;
		border-color: rgba(139, 169, 255, 0.6);
		color: #8ba9ff;

		&:hover:not(:disabled) {
			background: #36405a;
		}
	}
}
