/* CTM Connector – front end. All design settings arrive as CSS custom properties.
 * Defaults live on :root so they are only a fallback: values set on an ancestor
 * (the saved design inlined by PHP, or the admin live-preview frame) always win. */
:root {
	--ctmc-primary: #2563eb; --ctmc-btn-text: #fff; --ctmc-bg: #fff; --ctmc-text: #111827;
	--ctmc-radius: 16px; --ctmc-overlay: rgba(0, 0, 0, .55); --ctmc-logo-height: 48px; --ctmc-logo-width: auto; --ctmc-font: inherit;
	--ctmc-header-from: #7c3aed; --ctmc-header-to: #4c1d95; --ctmc-header-text: #fff;
}
.ctmc-lock { overflow: hidden; }

/* Popup */
.ctmc-overlay { position: fixed; inset: 0; z-index: 999999; display: flex; align-items: center; justify-content: center; padding: 16px; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: var(--ctmc-overlay); }
.ctmc-overlay[hidden] { display: none; }
.ctmc-dialog { position: relative; width: 100%; max-width: 420px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); /* dvh = visible area on iOS/Android */ overflow-y: auto; overscroll-behavior: contain; --ctmc-pad-t: 32px; --ctmc-pad-x: 24px; padding: var(--ctmc-pad-t) var(--ctmc-pad-x) 24px; border-radius: var(--ctmc-radius); background: var(--ctmc-bg); color: var(--ctmc-text); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); font-family: var(--ctmc-font); font-size: 16px; line-height: 1.5; box-sizing: border-box; }
.ctmc-close { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; padding: 0; border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }
.ctmc-close:hover { opacity: 1; }

/* Inline (embedded) */
.ctmc-inline { --ctmc-pad-t: 28px; --ctmc-pad-x: 24px; max-width: 480px; padding: var(--ctmc-pad-t) var(--ctmc-pad-x); overflow: hidden; border-radius: var(--ctmc-radius); background: var(--ctmc-bg); color: var(--ctmc-text); font-family: var(--ctmc-font); box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); box-sizing: border-box; }

/* Form */
.ctmc-form { margin: 0; }
.ctmc-form [hidden] { display: none !important; }
.ctmc-logo { text-align: center; margin-bottom: 16px; }
/* Width/height come from the dashboard (auto keeps the aspect ratio; both set = fit inside the box). */
.ctmc-logo img { display: inline-block; width: var(--ctmc-logo-width); height: var(--ctmc-logo-height); max-width: 100%; max-height: 240px; object-fit: contain; vertical-align: middle; }
.ctmc-title { margin: 0 0 8px; font-size: 1.4rem; line-height: 1.25; text-align: center; color: inherit; font-family: inherit; }
.ctmc-subtext { margin: 0 0 20px; text-align: center; opacity: .8; }
.ctmc-field { margin: 0 0 14px; }
.ctmc-label { display: block; margin: 0 0 6px; font-weight: 600; font-size: .9rem; }
.ctmc-input { display: block; width: 100%; box-sizing: border-box; min-height: 48px; margin: 0; padding: 10px 14px; border: 1px solid rgba(127, 127, 127, .45); border-radius: calc(var(--ctmc-radius) * .6); background: #fff; color: #111827; font-size: 17px; /* ≥16px prevents iOS zoom */ font-family: inherit; }
.ctmc-input:focus { outline: 2px solid var(--ctmc-primary); outline-offset: 1px; }
/* Phone + optional country selector (a native <select> layered invisibly over a compact flag/code label). */
.ctmc-phone { display: flex; gap: 8px; }
.ctmc-phone .ctmc-input { flex: 1; min-width: 0; }
.ctmc-country { position: relative; flex: none; display: flex; align-items: center; min-height: 48px; padding: 0 30px 0 12px; border: 1px solid rgba(127, 127, 127, .45); border-radius: calc(var(--ctmc-radius) * .6); background: #fff; color: #111827; font-size: 17px; box-sizing: border-box; }
.ctmc-country::after { content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -6px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); opacity: .6; pointer-events: none; }
.ctmc-country:focus-within { outline: 2px solid var(--ctmc-primary); outline-offset: 1px; }
.ctmc-country-display { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; pointer-events: none; }
.ctmc-country-flag { font-size: 1.2em; line-height: 1; }
.ctmc-country-select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; font-size: 16px; appearance: none; }
.ctmc-consent { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; font-size: .8rem; line-height: 1.4; opacity: .9; }
.ctmc-consent input { margin: 2px 0 0; width: 18px; height: 18px; flex: none; accent-color: var(--ctmc-primary); }
.ctmc-consent a { color: inherit; text-decoration: underline; }
.ctmc-cta, .ctmc-button { display: block; width: 100%; min-height: 52px; padding: 0 20px; border: 0; border-radius: max(8px, var(--ctmc-radius)); background: var(--ctmc-primary); color: var(--ctmc-btn-text); font-size: 1.05rem; font-weight: 700; font-family: inherit; cursor: pointer; transition: filter .15s; }
.ctmc-button { display: inline-block; width: auto; }
.ctmc-cta:hover, .ctmc-button:hover { filter: brightness(1.08); }
.ctmc-cta:disabled { opacity: .6; cursor: progress; }
.ctmc-status { margin-top: 12px; font-size: .95rem; text-align: center; }
.ctmc-status:empty { display: none; }
/* Inline, fixable errors (bad number, missing consent…): readable on light and dark backgrounds. */
.ctmc-status.is-error { padding: 10px 12px; border: 1px solid rgba(239, 68, 68, .45); border-radius: calc(var(--ctmc-radius) * .5); background: rgba(239, 68, 68, .12); text-align: left; font-size: .9rem; }
.ctmc-status.is-error::before { content: "!"; display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 8px; border-radius: 50%; background: #ef4444; color: #fff; font-size: 12px; font-weight: 800; vertical-align: -3px; }

/* Button loading state. */
.ctmc-cta { position: relative; }
.ctmc-spinner { display: none; width: 20px; height: 20px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ctmc-spin .7s linear infinite; }
.ctmc-cta.is-loading { opacity: 1; cursor: progress; }
.ctmc-cta.is-loading .ctmc-cta-label { visibility: hidden; }
.ctmc-cta.is-loading .ctmc-spinner { display: block; position: absolute; left: 50%; top: 50%; margin: -10px 0 0 -10px; }
@keyframes ctmc-spin { to { transform: rotate(360deg); } }

/* Result screens (success / after hours / error) replace the form after submitting. */
.ctmc-form.is-result .ctmc-title, .ctmc-form.is-result .ctmc-subtext, .ctmc-form.is-result .ctmc-fields, .ctmc-form.is-result .ctmc-consent,
.ctmc-form.is-result .ctmc-cta, .ctmc-form.is-result .ctmc-status, .ctmc-form.is-result .cf-turnstile { display: none; }
.ctmc-result { padding: 6px 0 2px; text-align: center; }
.ctmc-result-icon { position: relative; display: grid; place-items: center; width: 76px; height: 76px; margin: 4px auto 18px; border-radius: 50%; background: var(--ctmc-primary); color: var(--ctmc-btn-text); }
.ctmc-result-icon svg { position: relative; z-index: 1; }
.ctmc-result.is-after_hours .ctmc-result-icon { background: rgba(127, 127, 127, .16); background: color-mix(in srgb, var(--ctmc-primary) 16%, transparent); color: var(--ctmc-primary); }
.ctmc-result.is-error .ctmc-result-icon { background: rgba(239, 68, 68, .14); color: #ef4444; }
.ctmc-ring { position: absolute; inset: 0; border: 2px solid var(--ctmc-primary); border-radius: 50%; opacity: 0; }
.ctmc-result-title { margin: 0 0 8px; font-size: 1.4rem; line-height: 1.25; color: inherit; font-family: inherit; }
.ctmc-result-title:focus { outline: none; }
.ctmc-result-number { display: inline-block; margin: 0 0 12px; padding: 5px 14px; border-radius: 999px; background: rgba(127, 127, 127, .14); background: color-mix(in srgb, var(--ctmc-primary) 14%, transparent); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.ctmc-result-number[hidden], .ctmc-result-number:empty { display: none; }
.ctmc-result-text { max-width: 34ch; margin: 0 auto 22px; opacity: .8; }
.ctmc-result-actions { display: flex; flex-direction: column; gap: 10px; }
.ctmc-result-call { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px; border-radius: max(8px, var(--ctmc-radius)); background: var(--ctmc-primary); color: var(--ctmc-btn-text); font-weight: 700; text-decoration: none; }
.ctmc-result-call:hover { filter: brightness(1.08); color: var(--ctmc-btn-text); }
.ctmc-result-link { min-height: 46px; padding: 0 20px; border: 1px solid rgba(127, 127, 127, .35); border-radius: max(8px, var(--ctmc-radius)); background: none; color: inherit; font: 600 1rem/1 var(--ctmc-font); cursor: pointer; }
.ctmc-result-link:hover { border-color: currentColor; }
.ctmc-result-help { margin: 16px 0 0; font-size: .85rem; opacity: .75; }
.ctmc-result-help a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.ctmc-inline .ctmc-result [data-ctmc-close] { display: none; } /* Nothing to close for embedded forms. */
.ctmc-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cf-turnstile { margin: 0 0 14px; }

/* Floating launcher */
.ctmc-launcher { position: fixed; bottom: 20px; z-index: 999998; display: inline-flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 22px 0 18px; border: 0; border-radius: 999px; background: var(--ctmc-primary); color: var(--ctmc-btn-text); font: 700 16px/1 var(--ctmc-font); box-shadow: 0 8px 24px rgba(0, 0, 0, .22); cursor: pointer; }
.ctmc-launcher[hidden] { display: none; }
.ctmc-launcher.is-right { right: 20px; } .ctmc-launcher.is-left { left: 20px; }
.ctmc-launcher.is-circle { width: 60px; height: 60px; padding: 0; justify-content: center; }
.ctmc-launcher.is-circle .ctmc-launcher-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ctmc-launcher-icon { flex: none; }
.ctmc-launcher { transition: transform .2s ease, box-shadow .2s ease; }
.ctmc-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 0, 0, .26); }
.ctmc-launcher:focus-visible { outline: 3px solid var(--ctmc-primary); outline-offset: 4px; }
/* Attention waves: two soft rings in the button's own shape (pill or circle). */
.ctmc-launcher.is-pulse::before, .ctmc-launcher.is-pulse::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }

@media (prefers-reduced-motion: no-preference) {
	.ctmc-overlay:not([hidden]) .ctmc-dialog { animation: ctmc-in .22s ease-out; }
	.ctmc-launcher .ctmc-launcher-icon { animation: ctmc-ring 3s ease-in-out 2s infinite; }
	.ctmc-launcher.is-pulse::before { animation: ctmc-wave 4s ease-out 1.5s infinite; }
	.ctmc-launcher.is-pulse::after { animation: ctmc-wave 4s ease-out 2.1s infinite; }
	.ctmc-launcher.is-pulse:hover::before, .ctmc-launcher.is-pulse:hover::after { animation-play-state: paused; opacity: 0; }
	/* Ripple out over ~1.6 s, then rest until the next cycle. */
	@keyframes ctmc-wave {
		0% { box-shadow: 0 0 0 0 rgba(0, 0, 0, .18); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ctmc-primary) 55%, transparent); }
		40%, 100% { box-shadow: 0 0 0 18px rgba(0, 0, 0, 0); box-shadow: 0 0 0 18px color-mix(in srgb, var(--ctmc-primary) 0%, transparent); }
	}
	@keyframes ctmc-in { from { transform: translateY(12px); opacity: 0; } }
	.ctmc-result:not([hidden]) { animation: ctmc-in .3s ease-out; }
	.ctmc-result.is-success .ctmc-ring { animation: ctmc-pulse 2s ease-out infinite; }
	.ctmc-result.is-success .ctmc-ring + .ctmc-ring { animation-delay: 1s; }
	.ctmc-result.is-success .ctmc-result-icon svg { animation: ctmc-shake 1.8s ease-in-out infinite; }
	@keyframes ctmc-pulse { from { transform: scale(1); opacity: .55; } to { transform: scale(1.75); opacity: 0; } }
	@keyframes ctmc-shake { 0%, 50%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-12deg); } 20%, 40% { transform: rotate(12deg); } }
	@keyframes ctmc-ring { 0%, 90%, 100% { transform: rotate(0); } 92% { transform: rotate(-14deg); } 96% { transform: rotate(14deg); } }
}
@media (max-width: 480px) {
	/* Default: centered card. */
	.ctmc-dialog { --ctmc-pad-t: 28px; --ctmc-pad-x: 20px; padding-bottom: 20px; }
	/* Optional bottom sheet (Display → Popup on phones). */
	.ctmc-overlay.is-mobile-sheet { align-items: flex-end; padding: 0; }
	.ctmc-overlay.is-mobile-sheet .ctmc-dialog { max-width: none; max-height: 92dvh; border-radius: var(--ctmc-radius) var(--ctmc-radius) 0 0; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

/* ---------- Gradient header style (Design → Header) ----------
   Colored band with the logo + headline, and the form in a card that overlaps it. */
.ctmc-form.is-header-gradient .ctmc-header { margin: calc(-1 * var(--ctmc-pad-t, 32px)) calc(-1 * var(--ctmc-pad-x, 24px)) 0; padding: calc(var(--ctmc-pad-t, 32px) + 6px) calc(var(--ctmc-pad-x, 24px) + 6px) 60px; background: var(--ctmc-header-from); background: linear-gradient(160deg, var(--ctmc-header-from) 0%, var(--ctmc-header-to) 100%); color: var(--ctmc-header-text); text-align: left; }
.ctmc-form.is-header-gradient .ctmc-logo { text-align: left; margin-bottom: 22px; }
.ctmc-form.is-header-gradient .ctmc-title { text-align: left; margin-bottom: 6px; font-size: 1.75rem; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; color: inherit; }
.ctmc-form.is-header-gradient .ctmc-subtext { text-align: left; margin: 0; opacity: .88; }
.ctmc-form.is-header-gradient .ctmc-body { position: relative; margin-top: -38px; padding: 20px 18px 18px; border-radius: max(12px, calc(var(--ctmc-radius) * .9)); background: var(--ctmc-bg); box-shadow: 0 12px 32px rgba(17, 24, 39, .14), 0 1px 3px rgba(17, 24, 39, .08); }
.ctmc-form.is-header-gradient.is-result .ctmc-header { padding-bottom: 54px; }
/* Soft page behind the card, white X on the gradient. */
.ctmc-dialog:has(.is-header-gradient), .ctmc-inline:has(.is-header-gradient) { background: #f5f5f7; background: color-mix(in srgb, var(--ctmc-bg) 94%, var(--ctmc-text)); }
.ctmc-dialog:has(.is-header-gradient) > .ctmc-close { z-index: 2; color: var(--ctmc-header-text); opacity: .9; }
/* Floating button follows the gradient. */
.ctmc-launcher.is-gradient { background: var(--ctmc-header-from); background: linear-gradient(135deg, var(--ctmc-header-from), var(--ctmc-header-to)); color: var(--ctmc-header-text); }
.ctmc-launcher.is-gradient.is-pulse::before, .ctmc-launcher.is-gradient.is-pulse::after { --ctmc-primary: var(--ctmc-header-from); }
