/*
 * Smart Client Contact Hub — frontend widget.
 *
 * Every visual value reads from a custom property with a fallback baked into
 * the var() call. The plugin emits a property only for values the site
 * actually customized, so the fallbacks below are the shipped design and an
 * untouched install produces almost no generated CSS.
 */

.scch-root {
	position: fixed;
	bottom: var(--scch-btn-margin, 24px);
	z-index: var(--scch-z, 99990);
	font-family: var(--scch-font, inherit);
	font-size: var(--scch-fs-base, 15px);
	line-height: var(--scch-lh, 1.5);
	letter-spacing: var(--scch-tracking, 0);

	/* Light palette. The plugin overrides these per install. */
	--scch-surface: #ffffff;
	--scch-text: #111827;
	--scch-muted: #6b7280;
	--scch-line: #e5e7eb;
	--scch-error: #dc2626;
	--scch-success: #16a34a;
}

.scch-pos-right { right: var(--scch-btn-margin, 24px); }
.scch-pos-left  { left: var(--scch-btn-margin, 24px); }

/* ---------- Launcher ---------- */

.scch-launcher {
	position: relative;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--scch-btn-size, 60px);
	height: var(--scch-btn-size, 60px);
	border: var(--scch-border, 0);
	border-radius: var(--scch-btn-radius, 50%);
	background: var(--scch-btn-bg, #2563eb);
	color: var(--scch-icon-color, #fff);
	box-shadow: var(--scch-shadow, 0 8px 24px rgba(0, 0, 0, .22));
	cursor: pointer;
	padding: 0;
	transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
}

.scch-launcher:hover,
.scch-launcher:focus-visible {
	transform: translateY(-2px) scale(1.04);
	background: var(--scch-btn-hover-bg, var(--scch-btn-bg, #2563eb));
	color: var(--scch-icon-hover-color, var(--scch-icon-color, #fff));
}

.scch-launcher:focus-visible,
.scch-panel :focus-visible {
	outline: 3px solid var(--scch-focus, var(--scch-primary, #2563eb));
	outline-offset: 2px;
}

.scch-launcher-icon {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.scch-launcher-icon svg,
.scch-custom-icon {
	width: var(--scch-icon-size, 28px);
	height: var(--scch-icon-size, 28px);
	display: block;
}

.scch-launcher-icon[hidden] { display: none !important; }

/* Launcher animations */
@keyframes scch-fade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes scch-scale  { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes scch-bounce {
	0%, 100% { transform: translateY(0); }
	30%      { transform: translateY(-10px); }
	60%      { transform: translateY(-4px); }
}
@keyframes scch-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, .45); }
	70%  { box-shadow: 0 0 0 16px rgba(37, 99, 235, 0); }
	100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.scch-anim-fade   { animation: scch-fade .5s ease both; }
.scch-anim-scale  { animation: scch-scale .35s cubic-bezier(.34, 1.56, .64, 1) both; }
.scch-anim-bounce { animation: scch-bounce 1.6s ease .4s 3; }
.scch-anim-pulse  { animation: scch-pulse 2.2s ease-out infinite; }

/* ---------- Overlay ---------- */

.scch-overlay {
	position: fixed;
	inset: 0;
	background: var(--scch-overlay-bg, rgba(17, 24, 39, .35));
	backdrop-filter: blur(var(--scch-overlay-blur, 2px));
	z-index: -1;
}

/* ---------- Panel ---------- */

.scch-panel {
	position: absolute;
	bottom: calc(var(--scch-btn-size, 60px) + 16px);
	width: min(var(--scch-popup-width, 380px), calc(100vw - 32px));
	max-height: min(72vh, 640px);
	overflow-y: auto;
	background: var(--scch-surface);
	color: var(--scch-text);
	border: var(--scch-panel-border, 0);
	border-radius: var(--scch-popup-radius, 16px);
	box-shadow: var(--scch-panel-shadow, 0 20px 50px rgba(0, 0, 0, .25));
	animation: scch-panel-in .22s ease both;
}

.scch-pos-right .scch-panel { right: 0; }
.scch-pos-left  .scch-panel { left: 0; }

@keyframes scch-panel-in {
	from { opacity: 0; transform: translateY(12px) scale(.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.scch-panel-header {
	position: relative;
	padding: var(--scch-heading-pad-y, 22px) calc(var(--scch-heading-pad-x, 22px) + 30px) calc(var(--scch-heading-pad-y, 22px) * .7) var(--scch-heading-pad-x, 22px);
	background: var(--scch-heading-bg, var(--scch-gradient, linear-gradient(135deg, var(--scch-primary, #2563eb), var(--scch-secondary, #7c3aed))));
	color: var(--scch-heading-text, #fff);
}

.scch-panel-title {
	margin: 0 0 4px;
	font-family: var(--scch-font-heading, var(--scch-font, inherit));
	font-size: var(--scch-title-size, 18px);
	font-weight: var(--scch-title-weight, 700);
	line-height: 1.3;
	color: var(--scch-heading-text, #fff);
}

.scch-panel-intro {
	margin: 0;
	font-size: var(--scch-intro-size, 13px);
	color: var(--scch-intro-color, inherit);
	/* Softened only while it inherits the header color. The plugin emits
	   --scch-intro-opacity:1 as soon as an explicit intro color is set, so a
	   chosen color renders exactly as chosen. */
	opacity: var(--scch-intro-opacity, .9);
}

.scch-close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: var(--scch-close-size, 32px);
	height: var(--scch-close-size, 32px);
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--scch-close-bg, rgba(255, 255, 255, .18));
	border: 0;
	border-radius: var(--scch-close-radius, 50%);
	color: var(--scch-close-color, #fff);
	cursor: pointer;
	transition: background .15s ease;
}
.scch-close svg { width: 50%; height: 50%; }
.scch-close:hover { background: var(--scch-close-hover-bg, rgba(255, 255, 255, .3)); }

.scch-view { padding: var(--scch-view-pad-y, 18px) var(--scch-view-pad-x, 22px) calc(var(--scch-view-pad-y, 18px) + 4px); }

/* ---------- Channel buttons ---------- */

.scch-channel {
	display: flex;
	align-items: center;
	gap: 14px;
	width: 100%;
	margin: 0 0 var(--scch-channel-gap, 10px);
	padding: var(--scch-channel-pad-y, 14px) var(--scch-channel-pad-x, 16px);
	background: var(--scch-channel-bg, var(--scch-surface));
	border: var(--scch-channel-bw, 1px) solid var(--scch-channel-bc, var(--scch-line));
	border-radius: var(--scch-channel-radius, 12px);
	color: var(--scch-channel-text, var(--scch-text));
	font-size: var(--scch-channel-fs, 15px);
	font-weight: var(--scch-channel-fw, 600);
	text-decoration: none;
	cursor: pointer;
	transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease, background .15s ease;
	box-sizing: border-box;
}

.scch-channel:last-child { margin-bottom: 0; }

.scch-channel:hover,
.scch-channel:focus-visible {
	background: var(--scch-channel-hover-bg, var(--scch-channel-bg, var(--scch-surface)));
	border-color: var(--scch-channel-hover-bc, var(--scch-primary, #2563eb));
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(0, 0, 0, .08);
}

.scch-channel-icon {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--scch-cicon-box, 40px);
	height: var(--scch-cicon-box, 40px);
	border-radius: var(--scch-cicon-radius, 10px);
	background: var(--scch-cicon-bg, var(--scch-gradient, linear-gradient(135deg, var(--scch-primary, #2563eb), var(--scch-secondary, #7c3aed))));
	color: var(--scch-cicon-color, #fff);
}
.scch-channel-icon svg { width: var(--scch-cicon-size, 20px); height: var(--scch-cicon-size, 20px); }

/* ---------- Form ---------- */

.scch-back {
	background: none;
	border: 0;
	padding: 0 0 10px;
	color: var(--scch-back-color, var(--scch-primary, #2563eb));
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.scch-form-title {
	margin: 0 0 14px;
	font-family: var(--scch-font-heading, var(--scch-font, inherit));
	font-size: var(--scch-form-title-size, 16px);
	font-weight: var(--scch-form-title-weight, 700);
	color: var(--scch-text);
}

.scch-field { margin-bottom: var(--scch-field-gap, 14px); }

.scch-field label {
	display: block;
	margin-bottom: 5px;
	font-size: var(--scch-label-size, 13px);
	font-weight: var(--scch-label-weight, 600);
	color: var(--scch-label-color, var(--scch-text));
}

.scch-req { color: var(--scch-error); margin-left: 2px; }

.scch-field input,
.scch-field select,
.scch-field textarea {
	width: 100%;
	box-sizing: border-box;
	padding: var(--scch-input-pad-y, 10px) var(--scch-input-pad-x, 12px);
	font-size: var(--scch-input-fs, 14px);
	font-family: inherit;
	line-height: inherit;
	color: var(--scch-input-text, var(--scch-text));
	background: var(--scch-input-bg, var(--scch-surface));
	border: var(--scch-input-bw, 1px) solid var(--scch-input-bc, var(--scch-line));
	border-radius: var(--scch-input-radius, 9px);
	transition: border-color .15s ease, box-shadow .15s ease;
}

.scch-field input::placeholder,
.scch-field textarea::placeholder { color: var(--scch-placeholder, var(--scch-muted)); opacity: 1; }

.scch-field input:focus,
.scch-field select:focus,
.scch-field textarea:focus {
	border-color: var(--scch-focus, var(--scch-primary, #2563eb));
	/* Static ring first so browsers without color-mix() still show one. */
	box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--scch-focus, var(--scch-primary, #2563eb)) 22%, transparent);
	outline: none;
}

.scch-field.scch-invalid input,
.scch-field.scch-invalid select,
.scch-field.scch-invalid textarea { border-color: var(--scch-error); }

.scch-field-error {
	margin: 5px 0 0;
	font-size: 12px;
	color: var(--scch-error);
}

/* CAPTCHA */
.scch-captcha-row { display: flex; align-items: center; gap: 10px; }
.scch-captcha-question {
	flex: 0 0 auto;
	padding: var(--scch-input-pad-y, 10px) calc(var(--scch-input-pad-x, 12px) + 2px);
	background: var(--scch-captcha-bg, var(--scch-line));
	color: var(--scch-captcha-text, var(--scch-text));
	border-radius: var(--scch-input-radius, 9px);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}
.scch-captcha-row input { flex: 1 1 auto; width: auto; }
.scch-captcha-refresh {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	background: none;
	border: var(--scch-input-bw, 1px) solid var(--scch-input-bc, var(--scch-line));
	border-radius: var(--scch-input-radius, 9px);
	color: var(--scch-muted);
	cursor: pointer;
}
.scch-captcha-refresh svg { width: 16px; height: 16px; }
.scch-captcha-refresh:hover {
	color: var(--scch-focus, var(--scch-primary));
	border-color: var(--scch-focus, var(--scch-primary));
}

/* Honeypot: pulled off-screen, not display:none, to look real to bots. */
.scch-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.scch-form-feedback { font-size: 13px; margin: 0 0 10px; color: var(--scch-error); }

.scch-submit {
	width: 100%;
	padding: var(--scch-submit-pad, 13px);
	border: var(--scch-submit-bw, 0) solid var(--scch-submit-bc, transparent);
	border-radius: var(--scch-submit-radius, 10px);
	background: var(--scch-submit-bg, var(--scch-gradient, linear-gradient(135deg, var(--scch-primary, #2563eb), var(--scch-secondary, #7c3aed))));
	color: var(--scch-submit-text, #fff);
	font-family: inherit;
	font-size: var(--scch-submit-fs, 15px);
	font-weight: var(--scch-submit-fw, 700);
	cursor: pointer;
	transition: filter .15s ease, transform .15s ease;
}
.scch-submit:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.scch-submit:disabled { opacity: .65; cursor: wait; }

/* Success */
.scch-view-success { text-align: center; padding: 40px 24px; }
.scch-success-icon {
	width: var(--scch-success-box, 56px);
	height: var(--scch-success-box, 56px);
	margin: 0 auto 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--scch-success);
	color: var(--scch-success-icon-color, #fff);
	font-size: calc(var(--scch-success-box, 56px) * .46);
	font-weight: 700;
}
.scch-success-message { font-size: var(--scch-success-fs, 15px); color: var(--scch-text); }

/* ---------- Dark mode ---------- */

@media (prefers-color-scheme: dark) {
	.scch-root:not([data-forced-light]) {
		--scch-surface: #1f2937;
		--scch-text: #f9fafb;
		--scch-muted: #9ca3af;
		--scch-line: #374151;
	}
}

/* ---------- Mobile ---------- */

@media (max-width: 480px) {
	.scch-panel {
		position: fixed;
		left: 16px !important;
		right: 16px !important;
		bottom: calc(var(--scch-btn-margin, 24px) + var(--scch-btn-size, 60px) + 12px);
		width: auto;
	}
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.scch-launcher,
	.scch-panel,
	.scch-channel,
	.scch-submit { animation: none !important; transition: none !important; }
}

/* Hidden field labels: removed visually, kept for screen readers. */
.scch-label-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Dialog container receives focus on external-trigger open; no visible ring. */
.scch-panel:focus { outline: none; }
