/**
 * FormPilot — Smart Form Builder — admin styles.
 *
 * @package FormPilot
 */

.formpilot-wrap .formpilot-panel {
	max-width: 720px;
}

.formpilot-badge {
	padding: 1px 7px;
	font-size: 11px;
	font-weight: 600;
	color: #fff;
	background: #2271b1;
	border-radius: 9px;
}

.formpilot-entry-values td {
	word-break: break-word;
}

/* Target size, WCAG 2.2 AA (2.5.8).
   A dashicon is 20px, and WordPress's .button-link adds no padding, so every
   icon-only control in this plugin was a 20x20 target. These are the row
   actions, the condition and webhook removers and the saved filter chips: all
   of them small, adjacent to their neighbours, and the ones a person with an
   unsteady hand misses. 24x24 is the minimum the criterion allows. */
.formpilot-field__actions .button-link,
.formpilot-field__handle,
.formpilot-condition__remove,
.formpilot-webhook__remove,
.formpilot-saved-filter__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 24px;
	min-height: 24px;
}

/* The icons were #787c82 on #f6f7f7, which is 3.9:1 — enough for a graphic
   under 1.4.11 but not for something a reader would call text. #50575e is
   7.1:1 on the same background and is what core uses for the same purpose. */
.formpilot-field__actions .button-link,
.formpilot-condition__remove,
.formpilot-webhook__remove,
.formpilot-saved-filter__remove,
.formpilot-field__handle {
	color: #50575e;
}

/* Logs */

.formpilot-log-files {
	max-width: 900px;
	margin-bottom: 12px;
}

.formpilot-log-files__current td:first-child {
	font-weight: 600;
}

.formpilot-log-preview {
	max-width: 900px;
	max-height: 26em;
	padding: 10px 12px;
	overflow: auto;
	font-size: 12px;
	line-height: 1.6;
	background: #fff;
	border: 1px solid #c3c4c7;
	white-space: pre-wrap;
	word-break: break-word;
}

/* Settings import and export */

.formpilot-transfer {
	display: flex;
	flex-wrap: wrap;
	gap: 20px;
	align-items: flex-start;
}

.formpilot-transfer form {
	flex: 1 1 320px;
	padding: 12px 16px;
	background: #fff;
	border: 1px solid #c3c4c7;
}

.formpilot-transfer h3 {
	margin-top: 0;
}

/* Integrations */

.formpilot-integration {
	margin-bottom: 8px;
	background: #fff;
	border: 1px solid #c3c4c7;
}

.formpilot-integration__header {
	padding: 10px 14px;
	background: #f6f7f7;
}

.formpilot-integration.is-enabled .formpilot-integration__header {
	border-bottom: 1px solid #f0f0f1;
}

.formpilot-integration__body {
	padding: 0 14px 4px;
}

/* The settings of a service nobody switched on are noise. Hidden rather than
   removed, so switching one off and saving keeps its credentials for later. */
.formpilot-integration:not( .is-enabled ) .formpilot-integration__body {
	display: none;
}

.formpilot-integration__required {
	color: #b32d2e;
}

.formpilot-integration__script textarea {
	margin-top: 8px;
	font-size: 12px;
}

.formpilot-integration__result.is-ok {
	color: #007017;
}

.formpilot-integration__result.is-error {
	color: #b32d2e;
}

.formpilot-integration__result.is-pending {
	color: #646970;
}

.formpilot-integration__reply {
	max-height: 12em;
	padding: 8px 10px;
	overflow: auto;
	font-size: 12px;
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	white-space: pre-wrap;
	word-break: break-word;
}

/* Webhooks */

.formpilot-webhook {
	padding: 12px 16px;
	margin-bottom: 10px;
	background: #fff;
	border: 1px solid #c3c4c7;
}

.formpilot-webhook__header {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-bottom: 10px;
}

.formpilot-webhook__toggle {
	font-weight: 600;
}

.formpilot-webhook__remove {
	margin-inline-start: auto;
	text-decoration: none;
}

.formpilot-webhook__remove:hover {
	color: #b32d2e;
}

.formpilot-webhook__result {
	margin-inline-start: 8px;
}

.formpilot-webhook__result.is-ok {
	color: #007017;
}

.formpilot-webhook__result.is-error {
	color: #b32d2e;
}

.formpilot-webhook__result.is-pending {
	color: #646970;
}

.formpilot-webhooks__empty {
	color: #646970;
}

.formpilot-webhook-log__url {
	word-break: break-all;
}

.formpilot-webhook-status {
	font-weight: 600;
}

.formpilot-webhook-status--success {
	color: #007017;
}

.formpilot-webhook-status--pending {
	color: #996800;
}

.formpilot-webhook-status--failed {
	color: #b32d2e;
}

/* Entries filters */

.formpilot-entry-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	align-items: center;
}

.formpilot-entry-filters .formpilot-filter-date {
	width: 9.5em;
}

.formpilot-saved-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 12px;
	align-items: center;
	padding: 8px 12px;
	margin: 12px 0;
	background: #fff;
	border: 1px solid #c3c4c7;
}

.formpilot-saved-filters__label {
	font-weight: 600;
}

.formpilot-saved-filters__list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0;
}

.formpilot-saved-filter {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	padding: 2px 8px;
	margin: 0;
	background: #f0f0f1;
	border-radius: 11px;
}

.formpilot-saved-filter.is-current {
	color: #fff;
	background: #2271b1;
}

.formpilot-saved-filter.is-current a {
	color: inherit;
}

.formpilot-saved-filter a {
	text-decoration: none;
}

.formpilot-saved-filter__remove {
	line-height: 1;
}

.formpilot-saved-filter.is-current .formpilot-saved-filter__remove,
.formpilot-saved-filter__remove:hover {
	color: #b32d2e;
}

.formpilot-saved-filters__save {
	display: flex;
	gap: 4px;
	align-items: center;
	margin-inline-start: auto;
}

@media screen and ( max-width: 782px ) {
	.formpilot-saved-filters__save {
		margin-inline-start: 0;
	}

	.formpilot-entry-filters .formpilot-filter-date {
		width: 100%;
	}
}

/* Builder layout */

/* The palette filter and the collapsed cards both hide with the attribute, which
   loses to the display rules below without this. */
.formpilot-builder [hidden] {
	display: none !important;
}

.formpilot-builder {
	display: grid;
	grid-template-columns: 220px minmax(0, 1fr);
	gap: 20px;
	align-items: start;
	margin: 12px 0 20px;
}

.formpilot-builder__palette {
	padding: 12px;
	background: #fff;
	border: 1px solid #c3c4c7;
}

.formpilot-builder__palette h3 {
	margin-top: 0;
}

.formpilot-builder__search {
	width: 100%;
	margin-bottom: 8px;
}

.formpilot-builder__types {
	display: grid;
	grid-template-columns: 1fr;
	gap: 4px;
}

.formpilot-builder__palette .button {
	width: 100%;
	text-align: start;
}

.formpilot-builder__no-types {
	margin: 8px 0 0;
	color: #646970;
	font-size: 12px;
}

.formpilot-builder__main {
	min-width: 0;
}

.formpilot-builder__toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	margin-bottom: 10px;
}

.formpilot-builder__count {
	margin-inline-start: auto;
	color: #646970;
	font-size: 12px;
}

.formpilot-builder__empty {
	padding: 24px;
	color: #646970;
	text-align: center;
	background: #fff;
	border: 1px dashed #c3c4c7;
}

/* One column once the palette would squeeze the canvas, which is the same
   breakpoint the admin menu collapses at. */
@media screen and ( max-width: 960px ) {
	.formpilot-builder {
		grid-template-columns: 1fr;
	}

	.formpilot-builder__types {
		grid-template-columns: repeat( auto-fill, minmax( 130px, 1fr ) );
	}
}

@media screen and ( min-width: 961px ) {
	.formpilot-builder__palette {
		position: sticky;
		top: 46px;
		max-height: calc( 100vh - 80px );
		overflow-y: auto;
	}
}

/* Field card */

.formpilot-field {
	margin-bottom: 8px;
	background: #fff;
	border: 1px solid #c3c4c7;
}

.formpilot-field.is-dragging {
	opacity: 0.5;
	outline: 2px dashed #2271b1;
}

/* Dragging over a card must not start a text selection inside its settings. */
.formpilot-builder__canvas.is-sorting .formpilot-field__body {
	pointer-events: none;
}

.formpilot-field__header {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
	padding: 6px 10px;
	cursor: pointer;
	background: #f6f7f7;
	border-bottom: 1px solid #f0f0f1;
}

.formpilot-field.is-collapsed .formpilot-field__header {
	border-block-end-color: transparent;
}

.formpilot-field__handle {
	padding: 2px;
	cursor: grab;
	background: none;
	border: 0;
}

.formpilot-field__handle:active {
	cursor: grabbing;
}

.formpilot-field__handle:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 1px;
}

/* Editable in place: a text box that only looks like one when it matters. */
.formpilot-field input.formpilot-field__title {
	flex: 1 1 160px;
	min-width: 0;
	padding: 4px 6px;
	margin: 0;
	font-weight: 600;
	cursor: text;
	background: transparent;
	border: 1px solid transparent;
	box-shadow: none;
}

.formpilot-field input.formpilot-field__title:hover {
	background: #fff;
	border-color: #c3c4c7;
}

.formpilot-field input.formpilot-field__title:focus {
	background: #fff;
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
}

.formpilot-field__type {
	padding: 1px 8px;
	font-size: 11px;
	color: #50575e;
	white-space: nowrap;
	background: #f0f0f1;
	border-radius: 9px;
}

.formpilot-field__actions {
	display: flex;
	gap: 4px;
	align-items: center;
	margin-inline-start: auto;
}

.formpilot-field__actions .button-link {
	text-decoration: none;
}

.formpilot-field__actions .formpilot-field__remove:hover {
	color: #b32d2e;
}

.formpilot-field__toggle .dashicons {
	transition: transform 0.15s ease;
}

.formpilot-field:not( .is-collapsed ) .formpilot-field__toggle .dashicons {
	transform: rotate( 180deg );
}

@media ( prefers-reduced-motion: reduce ) {
	.formpilot-field__toggle .dashicons {
		transition: none;
	}
}

.formpilot-field__body {
	padding: 10px 14px;
}

.formpilot-field__body p {
	margin: 0 0 12px;
}

.formpilot-field__body input[type="text"],
.formpilot-field__body textarea,
.formpilot-field__body select {
	max-width: 100%;
}

/* Conditional logic */

.formpilot-logic {
	padding: 10px 12px;
	margin: 0 0 12px;
	border: 1px solid #dcdcde;
}

.formpilot-logic legend {
	padding: 0 4px;
	font-weight: 600;
}

.formpilot-logic__summary select {
	margin: 0 4px;
}

.formpilot-condition {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
	margin-bottom: 6px;
}

.formpilot-condition__field,
.formpilot-condition__value {
	flex: 1 1 140px;
	min-width: 0;
}

.formpilot-condition__remove {
	text-decoration: none;
}

.formpilot-condition__remove:hover {
	color: #b32d2e;
}

.formpilot-field__inline label {
	margin-inline-end: 4px;
}

.formpilot-field__inline input {
	margin-inline-end: 14px;
}
