// Mapping screen (numbered object cards). Built by `npm run build` into build/mapping.css.
// Rules: @use only; logical properties; everything scoped under .cf7hs-ui; no :has().
@use "tokens" as *;
@use "components";

.cf7hs-ui {
	// Object cards, one under another; each heading starts with the object's number.
	// The form body's own gap separates the last card from "Add an object".
	&__step {
		margin-block-end: $grid-unit-20;
	}

	.cf7hs-objects > .cf7hs-ui__step:last-child {
		margin-block-end: 0;
	}

	.cf7hs-add-object {
		align-self: flex-start;
	}

	// Object card header: "#1 Contact" with Remove on the title line and "Associated with" under it.
	.cf7hs-object-card > .cf7hs-ui__card-header {
		flex-wrap: nowrap; // Remove stays on the title line, also on phones.
		align-items: flex-start;
	}

	.cf7hs-object-header-text {
		flex: 1 1 auto;
		min-width: 0;
	}

	.cf7hs-object-heading {
		display: flex;
		align-items: baseline;
		gap: 0.3em; // A word space: "#1 Contact".
	}

	// The object's number reads "#1", part of the title. The "#" is CSS, so objects-panel.js
	// renumbers the digits only.
	.cf7hs-object-number::before {
		content: "#";
	}

	.cf7hs-ui__connector {
		margin-block-start: 4px;
	}

	&__connector {
		font-size: 13px;
		color: $gray-700;

		// The label and its value flow as one line and wrap as a pair, never inside the label.
		table,
		tbody,
		tr {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			gap: 4px 8px;
		}

		th {
			padding: 0;
			font-weight: 400;
			text-align: start;
			white-space: nowrap;
		}

		td {
			padding: 0;
			min-width: 0;
		}

		// Three or more objects: "Associated with" becomes a compact select.
		select.cf7hs-object-link-select {
			max-width: 100%;
			min-height: 30px;
			padding-inline: 8px 28px;
			font-size: 13px;
		}
	}

	&__danger {
		color: #cc1818;

		&:hover,
		&:focus {
			color: #a00;
		}
	}

	.cf7hs-ui__card-body > * + * {
		margin-block-start: $grid-unit-15;
	}

	// Contact action and Attach files are both switch rows; no divider between them.
	.cf7hs-object-action-field {
		padding-block: $grid-unit-10 0;
	}

	.cf7hs-ui__toggle-text .cf7hs-ui__help {
		margin-block-start: 2px;
	}

	.cf7hs-object-attach-row {
		padding-block: $grid-unit-10 0;
	}

	.cf7hs-object-pipeline-status:empty {
		display: none;
	}

	select {
		min-height: $button-size-next-default-40px;
		max-width: 100%;
		border-color: $control-border;
		border-radius: $radius-small;
		font-size: 13px;
	}

	.cf7hs-object-mapping {
		width: 100%;
		margin-block-start: 12px;
		border: 0;
		border-collapse: collapse;

		thead th {
			padding: 8px 0;
			font-size: 13px;
			font-weight: 400;
			text-align: start;
			color: $gray-700;
		}

		td {
			padding: 8px 0;
			border-block-start: 1px solid $hairline;
			vertical-align: middle;
		}

		td:first-child {
			padding-inline-end: $grid-unit-20;
		}

		select {
			width: 100%;
		}
	}

	// The CF7 field name in the admin font, not a code face.
	.cf7hs-field-name {
		font-size: 13px;
		color: $gray-900;
		overflow-wrap: anywhere;
	}

	// "Not sent: …" — the fields this object leaves out, on a light amber band so it is not missed
	// (the "Not set up" badge colours). The white top border keeps it apart from the last row.
	.cf7hs-object-mapping .cf7hs-mapping-more td {
		box-sizing: border-box; // Phones make it a 100%-wide block.
		padding: 8px 12px;
		border-block-start: 8px solid $white;
		border-radius: 2px;
		background: #fef8ee;
		font-size: 13px;
		color: #614200; // 7.6:1 on the band.
	}

	.cf7hs-map-more {
		min-height: 24px;
		font-weight: 500;
	}

	@media (forced-colors: active) {
		.cf7hs-object-mapping .cf7hs-mapping-more td {
			outline: 1px solid CanvasText;
		}
	}

	&__sync {
		font-size: 13px;
		cursor: pointer;
	}

	.cf7hs-consent-intro {
		margin-block-start: 0;
	}

	.cf7hs-consent-types label {
		display: flex;
		align-items: center;
		gap: $grid-unit-10;
		min-height: 24px;

		input[type="checkbox"] {
			margin: 0;
		}
	}

	.cf7hs-legal-consent textarea {
		border-color: $control-border;
		border-radius: $radius-small;
	}

	@media (max-width: 782px) {
		// Mapping rows stack: the CF7 field name above its HubSpot select.
		.cf7hs-object-mapping {
			thead {
				display: none;
			}

			tr {
				display: block;
				padding-block: 10px;
				border-block-start: 1px solid $gray-100;
			}

			td {
				display: block;
				width: 100%;
				padding: 0;
				border: 0;
			}

			td + td {
				margin-block-start: 6px;
			}
		}

		.cf7hs-field-name {
			font-weight: 600;
		}

		.cf7hs-add-object {
			align-self: stretch;
			justify-content: center;
		}

		.cf7hs-consent-types label {
			min-height: 40px;
		}

		select {
			font-size: 16px;
		}
	}
}
