/* ==========================================================================
   Custom Form Builder — Frontend + Admin styles
   ========================================================================== */

.cfb-form-wrapper {
	--cfb-primary: #2271b1;
	--cfb-radius: 4px;
	max-width: 100%;
}

.cfb-form-wrapper .cfb-field-row {
	margin-bottom: 18px;
	display: block;
}

.cfb-form-wrapper.cfb-label-left .cfb-field-row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.cfb-form-wrapper.cfb-label-left .cfb-field-row label {
	flex: 0 0 140px;
}

.cfb-form-wrapper.cfb-label-left .cfb-input-wrap {
	flex: 1 1 auto;
}

.cfb-form-wrapper.cfb-label-hidden label {
	display: none;
}

.cfb-form-wrapper label {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
}

.cfb-required {
	color: #d63638;
}

.cfb-input-wrap {
	position: relative;
	width: 100%;
}

.cfb-form-wrapper input[type="text"],
.cfb-form-wrapper input[type="email"],
.cfb-form-wrapper input[type="number"],
.cfb-form-wrapper input[type="tel"],
.cfb-form-wrapper input[type="url"],
.cfb-form-wrapper input[type="date"],
.cfb-form-wrapper textarea,
.cfb-form-wrapper select {
	width: 100%;
	box-sizing: border-box;
	padding: 10px 14px;
	border: 1px solid #ccd0d4;
	border-radius: var(--cfb-radius);
	font-size: 15px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cfb-form-wrapper input:focus,
.cfb-form-wrapper textarea:focus,
.cfb-form-wrapper select:focus {
	outline: none;
	border-color: var(--cfb-primary);
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

/* Icon support (left/right positioned inside the input) */
.cfb-field-icon {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	left: 12px;
	display: inline-flex;
	align-items: center;
	pointer-events: none;
	color: var(--cfb-primary);
	line-height: 1;
	z-index: 2;
}

.cfb-field-icon svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

.cfb-has-icon input,
.cfb-has-icon textarea {
	padding-left: 40px;
}

/* Right-positioned icon: flip the icon to the right edge and give the
   input right-side breathing room instead of left. Inline styles from
   the Elementor "Icon Margin/Padding" and "Input Padding" controls will
   still win over these defaults since inline CSS has higher specificity. */
.cfb-icon-right .cfb-field-icon {
	left: auto;
	right: 12px;
}

.cfb-icon-right input,
.cfb-icon-right textarea {
	padding-left: 14px;
	padding-right: 40px;
}

.cfb-choice-group {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 20px;
}

.cfb-choice-label {
	font-weight: normal;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.cfb-submit-btn {
	background: var(--cfb-primary);
	color: #fff;
	border: none;
	border-radius: var(--cfb-radius);
	padding: 12px 28px;
	font-size: 15px;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

.cfb-submit-btn:hover {
	opacity: 0.9;
}

.cfb-submit-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.cfb-response-message {
	margin-top: 16px;
	padding: 12px 16px;
	border-radius: var(--cfb-radius);
}

.cfb-response-message.cfb-success {
	background: #edf7ed;
	color: #1e4620;
	border: 1px solid #b6dfb8;
}

.cfb-response-message.cfb-error {
	background: #fdeded;
	color: #611a15;
	border: 1px solid #f5c2c0;
}

.cfb-field-row.cfb-field-error input,
.cfb-field-row.cfb-field-error textarea,
.cfb-field-row.cfb-field-error select {
	border-color: #d63638;
}

/* ==========================================================================
   Multi-step progress — screenshot-matched, theme-safe
   The step indicators intentionally use DIV elements, not BUTTON elements,
   so WordPress/Elementor/theme button styles cannot turn the whole step red.
   ========================================================================== */
.cfb-form-wrapper .cfb-step-progress {
	position: relative;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	width: 100%;
	margin: 0 0 34px;
	padding: 0;
	border: 0;
	background: transparent !important;
	box-shadow: none !important;
}

.cfb-form-wrapper .cfb-step-progress::before {
	content: "";
	position: absolute;
	z-index: 0;
	top: 20px;
	left: calc(100% / (2 * var(--cfb-step-count, 3)));
	right: calc(100% / (2 * var(--cfb-step-count, 3)));
	height: 4px;
	border: 0;
	border-radius: 999px;
	background: #f0f1f3 !important;
}

.cfb-form-wrapper .cfb-step-dot {
	position: relative;
	z-index: 1;
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	gap: 9px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0 !important;
	border-radius: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	color: #111318 !important;
	cursor: pointer;
	font: inherit;
	line-height: 1.2;
	text-align: center;
	text-decoration: none !important;
}

.cfb-form-wrapper .cfb-step-dot:hover,
.cfb-form-wrapper .cfb-step-dot:active,
.cfb-form-wrapper .cfb-step-dot:visited {
	background: transparent !important;
	box-shadow: none !important;
	color: #111318 !important;
}

.cfb-form-wrapper .cfb-step-dot:focus-visible {
	outline: 2px solid #C90F16;
	outline-offset: 5px;
	border-radius: 6px !important;
}

.cfb-form-wrapper .cfb-step-number {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 42px;
	width: 42px !important;
	height: 42px !important;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	border: 2px solid #f0f1f3 !important;
	border-radius: 50% !important;
	background: #fff !important;
	color: #111318 !important;
	font-size: 16px;
	font-weight: 700;
	line-height: 1;
	box-shadow: none !important;
	transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.cfb-form-wrapper .cfb-step-label {
	display: block;
	max-width: 140px;
	margin: 0;
	padding: 0;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.25;
	color: #111318 !important;
	white-space: normal;
}

.cfb-form-wrapper .cfb-step-dot.is-active .cfb-step-number,
.cfb-form-wrapper .cfb-step-dot.is-active:hover .cfb-step-number {
	border-color: #C90F16 !important;
	background: #C90F16 !important;
	color: #fff !important;
	box-shadow: none !important;
}

.cfb-form-wrapper .cfb-step-dot:not(.is-active):hover .cfb-step-number {
	border-color: #d9dce0 !important;
	background: #fff !important;
	color: #111318 !important;
}

.cfb-form-wrapper .cfb-form-step {
	display: none !important;
	visibility: hidden;
}

.cfb-form-wrapper .cfb-form-step:not(.is-active) .cfb-submit-btn,
.cfb-form-wrapper .cfb-form-step:not(.is-active) .cfb-step-next,
.cfb-form-wrapper .cfb-form-step:not(.is-active) .cfb-step-prev {
	display: none !important;
}

.cfb-form-wrapper .cfb-form-step.is-active {
	display: block !important;
	visibility: visible;
}

.cfb-form-wrapper .cfb-step-actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	margin-top: 22px;
}

/* The action order is intentional: Next/Submit is on the LEFT and Back
 * is on the RIGHT whenever both controls exist. This also prevents
 * Elementor/theme float or text-align rules from reversing the layout. */
.cfb-form-wrapper .cfb-step-actions .cfb-step-next,
.cfb-form-wrapper .cfb-step-actions .cfb-submit-btn {
	order: 1;
	margin: 0 !important;
}

.cfb-form-wrapper .cfb-step-actions .cfb-step-prev {
	order: 2;
	margin: 0 0 0 auto !important;
}

.cfb-form-wrapper .cfb-step-actions button {
	border: 1px solid var(--cfb-primary, #C90F16);
	background: var(--cfb-primary, #C90F16);
	color: #fff;
	border-radius: var(--cfb-radius, 4px);
	padding: 11px 18px;
	cursor: pointer;
	float: none !important;
	text-align: center;
}

.cfb-form-wrapper .cfb-step-actions .cfb-step-prev {
	background: #fff;
	color: #111318;
}

.cfb-input-invalid {
	border-color: #d63638 !important;
	box-shadow: 0 0 0 1px #d63638 !important;
}

.cfb-field-type-file input[type=file] {
	height: auto;
}

/* ==========================================================================
   Frontend file upload control
   Keep long selected filenames inside their own field and clamp the visible
   filename to two lines so it cannot overlap adjacent fields.
   ========================================================================== */

.cfb-file-upload-control {
	position: relative;
	width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

.cfb-file-select {
	position: relative;
	display: inline-flex;
	align-items: center;
	max-width: 100%;
	margin: 0;
	cursor: pointer;
}

.cfb-file-input {
	position: absolute !important;
	inset: 0;
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
	opacity: 0 !important;
	cursor: pointer;
	z-index: 2;
}

.cfb-file-select-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: 38px;
	padding: 8px 14px;
	border: 1px solid #ccd0d4;
	border-radius: var(--cfb-radius);
	background: #f6f7f7;
	color: #111318;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.25;
	white-space: nowrap;
	transition: background-color .15s ease, border-color .15s ease;
}

.cfb-file-select:hover .cfb-file-select-button {
	background: #eef0f2;
	border-color: #b8bec5;
}

.cfb-file-select:focus-within .cfb-file-select-button {
	outline: 2px solid var(--cfb-primary);
	outline-offset: 2px;
}

/*
 * The filename is intentionally a separate block. This prevents the
 * browser's native file-name text from expanding the input horizontally.
 */
.cfb-file-name {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
	margin-top: 7px;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.4;
	color: #50575e;
	word-break: break-word;
	overflow-wrap: anywhere;
}

@media (max-width: 767px) {
	.cfb-file-name {
		font-size: 12px;
	}
}

@media (max-width: 767px) {
	.cfb-form-wrapper .cfb-step-progress {
		margin-bottom: 28px;
	}

	.cfb-form-wrapper .cfb-step-progress::before {
		top: 19px;
		left: calc(100% / (2 * var(--cfb-step-count, 3)));
		right: calc(100% / (2 * var(--cfb-step-count, 3)));
		height: 3px;
	}

	.cfb-form-wrapper .cfb-step-number {
		flex-basis: 40px;
		width: 40px !important;
		height: 40px !important;
		font-size: 15px;
	}

	.cfb-form-wrapper .cfb-step-label {
		font-size: 12px;
		max-width: 100px;
	}

	.cfb-form-wrapper .cfb-step-actions {
		justify-content: stretch;
	}

	.cfb-form-wrapper .cfb-step-actions button {
		flex: 1 1 0;
	}
}

/* ==========================================================================
   Main Service + Related Services picker
   ========================================================================== */

.cfb-service-picker .cfb-service-main-wrap {
	margin-bottom: 12px;
}

.cfb-service-related-group {
	border: 1px solid #e2e4e7;
	border-radius: var(--cfb-radius);
	padding: 12px;
	margin-bottom: 12px;
	background: #fafafa;
}

.cfb-service-search-wrap {
	margin-bottom: 10px;
}

.cfb-service-search {
	width: 100%;
	box-sizing: border-box;
	padding: 8px 12px;
	border: 1px solid #ccd0d4;
	border-radius: var(--cfb-radius);
	font-size: 14px;
}

.cfb-service-checklist {
	max-height: 220px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding-right: 4px;
}

.cfb-service-checkbox-label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: normal;
	margin: 0;
	padding: 6px 8px;
	border-radius: 4px;
	transition: background 0.15s ease;
}

.cfb-service-checkbox-label:hover {
	background: #f0f0f1;
}

.cfb-service-checkbox-label.cfb-service-hidden {
	display: none;
}

.cfb-service-empty {
	color: #757575;
	font-size: 13px;
	margin: 0;
}

.cfb-service-selected-wrap {
	margin-top: 8px;
}

.cfb-service-selected-label {
	font-weight: 600;
	font-size: 13px;
	margin-bottom: 8px;
}

.cfb-service-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.cfb-service-chips-empty {
	color: #757575;
	font-size: 13px;
}

.cfb-service-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--cfb-primary);
	color: #fff;
	padding: 6px 10px;
	border-radius: 999px;
	font-size: 13px;
	line-height: 1;
}

.cfb-service-chip-remove {
	cursor: pointer;
	font-weight: bold;
	opacity: 0.85;
	line-height: 1;
}

.cfb-service-chip-remove:hover {
	opacity: 1;
}

/* Responsive tweaks: on small screens, let the checklist take a bit less
   vertical room and stack chips more tightly. */
@media (max-width: 767px) {
	.cfb-service-checklist {
		max-height: 180px;
	}

	.cfb-service-picker .cfb-field-row,
	.cfb-service-related-group {
		padding: 10px;
	}

	.cfb-form-wrapper.cfb-label-left .cfb-service-picker {
		display: block;
	}

	.cfb-form-wrapper.cfb-label-left .cfb-service-picker label {
		flex: none;
	}
}

/* ==========================================================================
   Admin: field repeater builder
   ========================================================================== */

#cfb-fields-list .cfb-field-row {
	border: 1px solid #dcdcde;
	background: #fff;
	margin-bottom: 10px;
	border-radius: 4px;
}

.cfb-field-row-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: #f6f7f7;
	border-bottom: 1px solid #dcdcde;
	cursor: move;
}

.cfb-field-row-header .cfb-field-title {
	flex: 1;
}

.cfb-remove-field {
	color: #d63638;
	font-size: 20px;
	line-height: 1;
	text-decoration: none;
}

.cfb-field-row-body {
	padding: 14px;
}

.cfb-dimensions-row::after {
	content: "";
	display: block;
	clear: both;
}

/* ==========================================================================
   Admin: Email Notifications repeater
   ========================================================================== */

#cfb-notifications-list .cfb-notification-row {
	border: 1px solid #dcdcde;
	background: #fff;
	margin-bottom: 12px;
	border-radius: 4px;
}

.cfb-notification-row-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: #f6f7f7;
	border-bottom: 1px solid #dcdcde;
	cursor: move;
}

.cfb-notification-row-header .cfb-notification-title {
	flex: 1;
}

.cfb-remove-notification {
	color: #d63638;
	font-size: 20px;
	line-height: 1;
	text-decoration: none;
}

.cfb-notification-row-body {
	padding: 14px;
}

.cfb-notification-tabs {
	display: flex;
	gap: 2px;
	border-bottom: 1px solid #dcdcde;
	margin-bottom: 14px;
}

.cfb-tab-btn {
	background: none;
	border: none;
	border-bottom: 2px solid transparent;
	padding: 8px 14px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	color: #646970;
	cursor: pointer;
}

.cfb-tab-btn:hover {
	color: #2271b1;
}

.cfb-tab-btn.active {
	color: #2271b1;
	border-bottom-color: #2271b1;
}

.cfb-mode-toggle label {
	margin-right: 16px;
	font-weight: 600;
}

.cfb-insert-field-select {
	float: right;
	max-width: 220px;
	font-size: 12px;
}

.cfb-routing-rules,
.cfb-conditions-rules {
	border-collapse: collapse;
	margin: 8px 0;
}

.cfb-routing-rules th,
.cfb-conditions-rules th {
	text-align: left;
	font-size: 12px;
	padding: 6px 8px;
}

.cfb-routing-rules td,
.cfb-conditions-rules td {
	padding: 4px 8px;
	vertical-align: middle;
}

.cfb-remove-routing-rule,
.cfb-remove-condition {
	color: #d63638;
	font-size: 18px;
	line-height: 1;
	text-decoration: none;
}

.cfb-test-mail-row {
	margin-top: 16px;
	padding-top: 14px;
	border-top: 1px solid #dcdcde;
}

/* ==========================================================================
   Admin: Body field Visual/Code rich-text editor
   ========================================================================== */

.cfb-richtext-wrap {
	border: 1px solid #dcdcde;
	border-radius: 4px;
	background: #fff;
	overflow: hidden;
}

.cfb-richtext-toolbar {
	display: flex;
	align-items: center;
	gap: 2px;
	padding: 6px 8px;
	background: #f6f7f7;
	border-bottom: 1px solid #dcdcde;
}

.cfb-rt-tab {
	background: transparent;
	border: none;
	padding: 6px 12px;
	font-size: 13px;
	font-weight: 600;
	color: #50575e;
	cursor: pointer;
	border-radius: 3px;
}

.cfb-rt-tab.active {
	background: #fff;
	color: #1d2327;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.cfb-rt-divider {
	width: 1px;
	height: 20px;
	background: #dcdcde;
	margin: 0 6px;
}

.cfb-rt-btn {
	background: transparent;
	border: none;
	min-width: 30px;
	height: 30px;
	padding: 0 8px;
	font-size: 13px;
	color: #1d2327;
	cursor: pointer;
	border-radius: 3px;
}

.cfb-rt-btn:hover {
	background: #e9eaeb;
}

.cfb-richtext-visual {
	min-height: 150px;
	max-height: 400px;
	overflow-y: auto;
	padding: 10px 12px;
	font-size: 14px;
	line-height: 1.6;
}

.cfb-richtext-visual:focus {
	outline: none;
}

.cfb-richtext-visual ul,
.cfb-richtext-visual ol {
	margin: 0 0 1em 1.5em;
}

.cfb-richtext-visual a {
	color: #2271b1;
}

.cfb-richtext-code {
	width: 100%;
	box-sizing: border-box;
	border: none;
	padding: 10px 12px;
	font-family: Consolas, Monaco, monospace;
	font-size: 13px;
	min-height: 150px;
	resize: vertical;
}

.cfb-richtext-code:focus {
	outline: none;
}


/* Admin multi-step builder */
#cfb-steps-list .cfb-step-row{display:grid;grid-template-columns:28px minmax(220px,1fr) minmax(110px,150px) minmax(110px,150px) 30px;gap:8px;align-items:center;padding:10px;border:1px solid #dcdcde;background:#fff;margin-bottom:8px;border-radius:4px}
#cfb-steps-list .cfb-step-number-admin{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50%;background:#C90F16;color:#fff;font-weight:700}
#cfb-steps-list .cfb-step-row .cfb-step-id{width:70px}
#cfb-steps-list .cfb-step-row .cfb-drag-handle{cursor:move}
@media(max-width:782px){#cfb-steps-list .cfb-step-row{grid-template-columns:28px 1fr;gap:8px}.cfb-step-row .cfb-step-title{grid-column:2}.cfb-step-row input[name*=next_text],.cfb-step-row input[name*=prev_text]{grid-column:2}.cfb-step-row .cfb-remove-step{grid-column:2;justify-self:end}}

/* Form appearance: values are configured per form in WordPress admin. */
.cfb-form-wrapper, .cfb-form-wrapper * { font-family: var(--cfb-font, "Montserrat", sans-serif); }
.cfb-form-wrapper input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
.cfb-form-wrapper select, .cfb-form-wrapper textarea {
    border-color: var(--cfb-input-border, #111318);
    color: var(--cfb-input-text, #000000);
}
.cfb-form-wrapper input::placeholder, .cfb-form-wrapper textarea::placeholder {
    color: var(--cfb-placeholder, #000000); opacity: 1;
}
.cfb-form-wrapper .cfb-validation-text { display:block; margin-top:6px; font-size:13px; line-height:1.5; color:var(--cfb-error-color,#C90F16); background:none; border:0; }
.cfb-form-wrapper .cfb-response-message.cfb-error { background:transparent; border:0; padding:0; color:var(--cfb-error-color,#C90F16); }
.cfb-form-wrapper .cfb-field-row.cfb-field-error input,
.cfb-form-wrapper .cfb-field-row.cfb-field-error textarea,
.cfb-form-wrapper .cfb-field-row.cfb-field-error select,
.cfb-form-wrapper .cfb-input-invalid { border-color:var(--cfb-error-color,#C90F16) !important; }

/* Validation text remains visible even inside grid/column field layouts. */
.cfb-form-wrapper .cfb-field-row > .cfb-validation-text {
    display: block !important;
    width: 100%;
    grid-column: 1 / -1;
    margin: 6px 0 0;
    padding: 0;
    background: transparent !important;
    border: 0 !important;
    color: var(--cfb-error-color, #C90F16) !important;
    font-family: var(--cfb-font, Montserrat, sans-serif);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
}

/* 1.5.18: visible, accessible validation feedback */
.cfb-form-wrapper .cfb-step-error-summary { display:block!important; color:#C90F16!important; font-family:Montserrat,sans-serif; font-size:14px; line-height:1.5; margin:14px 0; }
.cfb-form-wrapper .cfb-field-row .cfb-validation-text { display:block!important; position:static!important; visibility:visible!important; opacity:1!important; color:#C90F16!important; font-family:Montserrat,sans-serif; font-size:13px; margin:6px 0 0; }
