/**
 * CF7 Mate — AI Form Generator modal.
 *
 * Minimal, two-state (input / result), design-token-aligned.
 *
 * @package CF7_Mate
 * @since 3.0.5
 */

/* ── trigger button (page-title-action) ──────────────────────────── */
/* Visually distinct from WP's gray "Add Contact Form" button so the two
 * actions don't get confused. Same display/sizing as .page-title-action;
 * only colors and the icon span change. */
.cf7m-ai-btn.page-title-action {
	background: #3044d7;
	border-color: #3044d7;
	color: #fff;
}
.cf7m-ai-btn.page-title-action:hover,
.cf7m-ai-btn.page-title-action:focus {
	background: #253ab8;
	border-color: #253ab8;
	color: #fff;
	box-shadow: 0 0 0 1px #253ab8;
}
.cf7m-ai-btn.page-title-action:active {
	background: #1e2f99;
	border-color: #1e2f99;
	color: #fff;
}
.cf7m-ai-btn__icon {
	display: inline-block;
	width: 14px;
	height: 14px;
	margin-right: 5px;
	vertical-align: text-bottom;
	line-height: 0;
	color: #fff;
}
.cf7m-ai-btn__icon svg {
	width: 14px;
	height: 14px;
	display: inline-block;
	vertical-align: top;
	stroke: currentColor;
}

/* ── overlay ─────────────────────────────────────────────────────── */
.cf7m-ai-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: rgba(15, 23, 42, 0.45);
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
	overflow-y: auto;
}
.cf7m-ai-overlay.is-open {
	display: flex;
}

/* ── modal shell ─────────────────────────────────────────────────── */
.cf7m-ai-modal {
	width: 100%;
	max-width: 640px;
	background: #fff;
	border-radius: 14px;
	box-shadow:
		0 1px 3px rgba(0, 0, 0, 0.05),
		0 10px 40px rgba(15, 23, 42, 0.18);
	overflow: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: #0f172a;
	line-height: 1.5;
}

/* ── header ──────────────────────────────────────────────────────── */
.cf7m-ai-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 18px;
	border-bottom: 1px solid #f1f5f9;
}
.cf7m-ai-title {
	font-size: 14px;
	font-weight: 600;
	color: #0f172a;
	margin: 0;
	letter-spacing: -0.005em;
}
.cf7m-ai-provider {
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: #64748b;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	padding: 3px 10px;
	border-radius: 999px;
	text-decoration: none;
}
.cf7m-ai-provider a {
	color: #3044d7;
	text-decoration: none;
	margin-left: 4px;
}
.cf7m-ai-provider a:hover {
	text-decoration: underline;
}
.cf7m-ai-provider--missing {
	color: #b45309;
	background: #fef3c7;
	border-color: #fde68a;
	cursor: pointer;
}
.cf7m-ai-provider--missing:hover {
	background: #fde68a;
}
.cf7m-ai-close {
	border: 0;
	background: transparent;
	font-size: 22px;
	line-height: 1;
	color: #64748b;
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 6px;
}
.cf7m-ai-close:hover {
	color: #0f172a;
	background: #f1f5f9;
}

/* ── view container ──────────────────────────────────────────────── */
.cf7m-ai-view {
	padding: 18px;
}

/* ── textarea + code ─────────────────────────────────────────────── */
.cf7m-ai-textarea,
.cf7m-ai-code {
	width: 100%;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	padding: 12px 14px;
	font-size: 13px;
	line-height: 1.55;
	font-family: inherit;
	color: #0f172a;
	background: #fff;
	resize: vertical;
	box-sizing: border-box;
	transition: border-color 0.12s, box-shadow 0.12s;
}
.cf7m-ai-textarea:focus,
.cf7m-ai-code:focus {
	outline: 0;
	border-color: #3044d7;
	box-shadow: 0 0 0 3px rgba(48, 68, 215, 0.12);
}
.cf7m-ai-textarea.is-dragover {
	border-color: #3044d7;
	background: #eef1ff;
}
.cf7m-ai-code {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
	font-size: 12.5px;
	line-height: 1.6;
	min-height: 240px;
}

/* ── image preview ───────────────────────────────────────────────── */
.cf7m-ai-image {
	position: relative;
	display: inline-block;
	margin-top: 10px;
}
.cf7m-ai-image__thumb {
	display: block;
	max-width: 120px;
	max-height: 80px;
	border-radius: 8px;
	border: 1px solid #e2e8f0;
}
.cf7m-ai-image__clear {
	position: absolute;
	top: -8px;
	right: -8px;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 1px solid #e2e8f0;
	background: #fff;
	color: #475569;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.cf7m-ai-image__clear:hover {
	color: #0f172a;
	border-color: #cbd5e1;
}

/* ── error ───────────────────────────────────────────────────────── */
.cf7m-ai-error {
	margin: 10px 0 0;
	padding: 9px 12px;
	border-radius: 8px;
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
	font-size: 12.5px;
}

/* ── action row ──────────────────────────────────────────────────── */
.cf7m-ai-actions {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 12px;
	flex-wrap: wrap;
}
.cf7m-ai-spacer {
	flex: 1;
}
.cf7m-ai-attach {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 12.5px;
	color: #475569;
	cursor: pointer;
	padding: 5px 8px;
	margin: 0;
	border-radius: 6px;
}
.cf7m-ai-attach:hover {
	color: #0f172a;
	background: #f1f5f9;
}
.cf7m-ai-shortcut {
	margin-left: auto;
	font-size: 11.5px;
	color: #94a3b8;
}

/* ── buttons ─────────────────────────────────────────────────────── */
.cf7m-ai-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border-radius: 8px;
	border: 1px solid transparent;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.12s, border-color 0.12s, color 0.12s;
	font-family: inherit;
	line-height: 1.2;
}
.cf7m-ai-btn--primary {
	background: #3044d7;
	color: #fff;
	border-color: #3044d7;
}
.cf7m-ai-btn--primary:hover:not([disabled]) {
	background: #253ab8;
	border-color: #253ab8;
}
.cf7m-ai-btn--primary[disabled] {
	opacity: 0.7;
	cursor: not-allowed;
}
.cf7m-ai-btn--ghost {
	background: #fff;
	border-color: #e2e8f0;
	color: #475569;
}
.cf7m-ai-btn--ghost:hover {
	color: #0f172a;
	border-color: #cbd5e1;
	background: #f8fafc;
}

/* ── presets ─────────────────────────────────────────────────────── */
.cf7m-ai-presets {
	margin-top: 18px;
	padding-top: 18px;
	border-top: 1px solid #f1f5f9;
}
.cf7m-ai-presets__label {
	font-size: 11.5px;
	font-weight: 600;
	color: #64748b;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	display: block;
	margin-bottom: 10px;
}
.cf7m-ai-presets__list {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
.cf7m-ai-preset {
	display: inline-flex;
	align-items: center;
	padding: 5px 12px;
	font-size: 12.5px;
	color: #334155;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 999px;
	cursor: pointer;
	transition: background 0.12s, border-color 0.12s, color 0.12s;
	font-family: inherit;
}
.cf7m-ai-preset:hover:not([disabled]) {
	background: #eef1ff;
	border-color: #3044d7;
	color: #3044d7;
}
.cf7m-ai-preset[disabled] {
	opacity: 0.6;
	cursor: not-allowed;
}

/* ── spinner ─────────────────────────────────────────────────────── */
.cf7m-ai-spinner {
	display: inline-block;
	width: 12px;
	height: 12px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: cf7m-ai-spin 0.7s linear infinite;
	margin-right: 6px;
	vertical-align: -2px;
}
@keyframes cf7m-ai-spin {
	to { transform: rotate(360deg); }
}

/* ── responsive ──────────────────────────────────────────────────── */
@media (max-width: 540px) {
	.cf7m-ai-modal {
		max-width: 100%;
		border-radius: 10px;
	}
	.cf7m-ai-head {
		padding: 12px 14px;
	}
	.cf7m-ai-view {
		padding: 14px;
	}
	.cf7m-ai-title {
		font-size: 13px;
	}
	.cf7m-ai-provider {
		display: none;
	}
	.cf7m-ai-shortcut {
		display: none;
	}
}

/* ── screen reader ───────────────────────────────────────────────── */
.cf7m-ai-view .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}
