/* CF7 Apps — AI Form Generator (CF7 editor) */

/* Inline with “Add / Edit Contact Form” + “Add Contact Form” (before .wp-header-end) */
#wpcf7-contact-form-editor .cf7apps-ai-fg-wrap--page-title {
	display: inline-block;
	margin: -10px 0 0 10px;
	padding: 0;
	border: none;
	vertical-align: middle;
}

@media screen and (max-width: 782px) {
	#wpcf7-contact-form-editor .cf7apps-ai-fg-wrap--page-title {
		display: block;
		margin: 12px 0 0;
	}
}

.cf7apps-ai-fg-open.button.button-primary,
.cf7apps-ai-fg-open.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	font-size: 13px;
	font-weight: 600;
	height: auto;
	padding: 5px 10px;
	background: #0d2149 !important;
	border-color: #081633 !important;
	color: #fff !important;
	box-shadow: none !important;
	text-shadow: none !important;
}

.cf7apps-ai-fg-open.button:hover,
.cf7apps-ai-fg-open.button:focus {
	background: #152a5c !important;
	border-color: #0d2149 !important;
	color: #fff !important;
}

.cf7apps-ai-fg-open.button:focus {
	box-shadow: 0 0 0 1px #fff, 0 0 0 3px #0d2149 !important;
}

.cf7apps-ai-fg-open .cf7apps-ai-fg-sparkle-cluster {
	flex-shrink: 0;
	color: #fff;
}

.cf7apps-ai-fg-open__icon {
	display: block;
	flex-shrink: 0;
	width: 15px;
	height: 18px;
	object-fit: contain;
}

.cf7apps-ai-fg-open__label {
	line-height: 1.3;
}

/* ——— Modal backdrop ——— */
.cf7apps-ai-fg-backdrop {
	position: fixed;
	inset: 0;
	/* Frosted glass: blur page behind overlay (Safari + Chromium) */
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	z-index: 100050;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Browsers without backdrop-filter: keep readable dimming */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
	.cf7apps-ai-fg-backdrop {
		background: rgba(15, 23, 42, 0.55);
	}
}

.cf7apps-ai-fg-backdrop.is-open {
	display: flex;
}

/* Modal card: white, rounded, shadow */
.cf7apps-ai-fg-modal {
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.08);
	max-width: 640px;
	width: 100%;
	max-height: 92vh;
	overflow: auto;
	position: relative;
	-webkit-font-smoothing: antialiased;
}

.cf7apps-ai-fg-modal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 22px 24px 18px;
	border-bottom: none;
}

.cf7apps-ai-fg-modal__title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.3;
	display: flex;
	align-items: center;
	gap: 12px;
	color: #1e3a5c;
	letter-spacing: -0.02em;
}

.cf7apps-ai-fg-modal__title-text {
	flex: 1;
	min-width: 0;
}

.cf7apps-ai-fg-modal__title-sparkle {
	flex-shrink: 0;
	display: block;
	width: 22px;
	height: 26px;
	object-fit: contain;
}

.cf7apps-ai-fg-modal__close {
	background: transparent;
	border: none;
	padding: 6px 10px;
	margin: -6px -8px -6px 0;
	cursor: pointer;
	font-size: 1.5rem;
	line-height: 1;
	color: #787c82;
	border-radius: 4px;
	transition: color 0.15s, background 0.15s;
}

.cf7apps-ai-fg-modal__close:hover,
.cf7apps-ai-fg-modal__close:focus {
	color: #1d2327;
	outline: none;
}

.cf7apps-ai-fg-modal__body {
	padding: 0 24px 24px;
}

.cf7apps-ai-fg-modal__label {
	display: block;
	font-weight: 500;
	font-size: 14px;
	margin-bottom: 8px;
	color: #50575e;
}

.cf7apps-ai-fg-modal__prompt {
	width: 100%;
	min-height: 72px;
	max-height: 200px;
	box-sizing: border-box;
	margin: 0 0 16px;
	padding: 10px 12px;
	font-size: 14px;
	line-height: 1.45;
	color: #1d2327;
	border: 1px solid #d0d5dd;
	border-radius: 8px;
	resize: vertical;
	background: #fff;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.cf7apps-ai-fg-modal__prompt::placeholder {
	color: #9ca3af;
}

.cf7apps-ai-fg-modal__prompt:hover {
	border-color: #c3c4c7;
}

.cf7apps-ai-fg-modal__prompt:focus {
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
	outline: none;
}

.cf7apps-ai-fg-prompt-meta {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	margin: -8px 0 14px;
	font-size: 12px;
	line-height: 1.3;
}

.cf7apps-ai-fg-prompt-count {
	color: #6b7280;
}

.cf7apps-ai-fg-templates {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 14px;
	margin: 0 0 16px;
}

@media (max-width: 600px) {
	.cf7apps-ai-fg-templates {
		grid-template-columns: 1fr;
	}
}

/* Template cards: icon tile #CFCFCF + white icons; selected tile #208AAE; card #EAF5F9 */
.cf7apps-ai-fg-template {
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	gap: 14px;
	padding: 14px 16px;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	cursor: pointer;
	text-align: left;
	background: #fff;
	transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
	width: 100%;
	margin: 0;
	font: inherit;
	color: inherit;
	box-sizing: border-box;
}

.cf7apps-ai-fg-template:hover:not(.is-selected) {
	border-color: #208aae;
	background: #eaf5f9;
	box-shadow: 0 2px 8px rgba(32, 138, 174, 0.12);
}

.cf7apps-ai-fg-template.is-selected {
	border-color: #208aae;
	box-shadow: 0 0 0 1px #208aae;
	background: #eaf5f9;
}

.cf7apps-ai-fg-template.is-selected:hover {
	background: #dbeef4;
	border-color: #1a7392;
	box-shadow: 0 0 0 1px #1a7392;
}

.cf7apps-ai-fg-template:focus-visible {
	outline: 2px solid #208aae;
	outline-offset: 2px;
}

.cf7apps-ai-fg-template__icon {
	flex-shrink: 0;
}

.cf7apps-ai-fg-template__icon-box {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: 8px;
	background: #cfcfcf;
	color: #fff;
}

.cf7apps-ai-fg-template.is-selected .cf7apps-ai-fg-template__icon-box {
	background: #208aae;
	color: #fff;
}

.cf7apps-ai-fg-template__icon-box svg {
	display: block;
}

.cf7apps-ai-fg-template__img {
	display: block;
	width: 24px;
	height: 24px;
	object-fit: contain;
}

/* ai-sparkle.svg (job tab): tighter artboard, keep visible in tile */
.cf7apps-ai-fg-template__img--sparkle {
	width: 22px;
	height: 26px;
}

.cf7apps-ai-fg-template__content {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.cf7apps-ai-fg-template__title {
	display: block;
	font-weight: 700;
	font-size: 14px;
	line-height: 1.35;
	color: #1d2327;
}

.cf7apps-ai-fg-template__desc {
	display: block;
	font-size: 12px;
	line-height: 1.45;
	color: #6b7280;
}

/* Full-width teal CTA (match mock — not WP primary blue) */
.cf7apps-ai-fg-generate {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-top: 22px;
	padding: 14px 20px;
	min-height: 48px;
	box-sizing: border-box;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	color: #fff !important;
	background: #2a8eac !important;
	border: none !important;
	border-radius: 8px !important;
	cursor: pointer;
	box-shadow: none !important;
	text-shadow: none !important;
	transition: background 0.15s, transform 0.05s;
	-webkit-appearance: none;
	appearance: none;
}

.cf7apps-ai-fg-generate:hover,
.cf7apps-ai-fg-generate:focus {
	background: #248798 !important;
	color: #fff !important;
	outline: none;
	box-shadow: 0 2px 8px rgba(42, 142, 172, 0.35) !important;
}

.cf7apps-ai-fg-generate:active {
	transform: scale(0.99);
}

.cf7apps-ai-fg-generate:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	box-shadow: none !important;
}

.cf7apps-ai-fg-generate .cf7apps-ai-fg-sparkle-cluster {
	flex-shrink: 0;
	color: #fff;
}

.cf7apps-ai-fg-generate__spinner {
	display: none;
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: cf7apps-ai-fg-spin 0.7s linear infinite;
	flex-shrink: 0;
}

.cf7apps-ai-fg-generate__text {
	position: relative;
	top: 1px;
}

.cf7apps-ai-fg-error {
	margin-top: 14px;
	padding: 12px 14px;
	background: #fcf0f1;
	border-left: 4px solid #d63638;
	border-radius: 0 6px 6px 0;
	color: #3c434a;
	font-size: 13px;
	display: none;
	line-height: 1.45;
}

.cf7apps-ai-fg-error.is-visible {
	display: block;
}

.cf7apps-ai-fg-output {
	margin-top: 24px;
	display: none;
}

.cf7apps-ai-fg-output.is-visible {
	display: block;
}

.cf7apps-ai-fg-output__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 8px;
}

.cf7apps-ai-fg-output__title {
	font-weight: 600;
	margin: 0;
	font-size: 14px;
	color: #1d2327;
}

.cf7apps-ai-fg-output__actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.cf7apps-ai-fg-action-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: #fff;
	border: 1px solid #d0d5dd;
	border-radius: 6px;
	padding: 8px 14px;
	font-size: 14px;
	font-weight: 500;
	color: #1d2327;
	cursor: pointer;
	box-shadow: none;
	transition: border-color 0.15s, background 0.15s;
	font-family: inherit;
}

.cf7apps-ai-fg-action-btn:hover {
	border-color: #9ca3af;
	background: #f9fafb;
}

.cf7apps-ai-fg-action-btn:focus {
	outline: none;
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
}

.cf7apps-ai-fg-action-btn svg {
	flex-shrink: 0;
	color: #000;
}

.cf7apps-ai-fg-code {
	margin: 0;
	padding: 14px 16px;
	background: #1d2327;
	color: #f0f0f1;
	font-family: Consolas, Monaco, "Courier New", monospace;
	font-size: 13px;
	line-height: 1.5;
	border-radius: 8px;
	overflow: auto;
	max-height: 100px;
	white-space: pre-wrap;
	word-break: break-word;
}

.cf7apps-ai-fg-credits-bar {
	margin-bottom: 16px;
	padding: 12px 14px;
	background: #f0f6fc;
	border: 1px solid #c3d9ed;
	border-radius: 8px;
	font-size: 13px;
	color: #1d2327;
	display: none;
}

.cf7apps-ai-fg-credits-bar.is-visible {
	display: block;
}

.cf7apps-ai-fg-credits-bar--exhausted {
	background: #fcf0f1;
	border-color: #f0b0b5;
}

.cf7apps-ai-fg-credits-bar .button {
	margin-top: 8px;
}

.cf7apps-ai-fg-busy .cf7apps-ai-fg-generate {
	opacity: 0.75;
	pointer-events: none;
}

.cf7apps-ai-fg-busy .cf7apps-ai-fg-generate__spinner {
	display: inline-block;
}

@keyframes cf7apps-ai-fg-spin {
	to {
		transform: rotate(360deg);
	}
}