/* Support Chat widget styles. Scoped under #support-chat-root so a theme's
   global rules do not bleed in, and the widget does not bleed out.
   No color-mix()/:has()/container queries: works on 2019+ browsers. */

#support-chat-root.sc-root {
	--sc-accent: #1c1c1e;
	--sc-on-accent: #ffffff;
	--sc-off-x: 20px;
	--sc-off-y: 20px;
	--sc-bg: #ffffff;
	--sc-fg: #17181a;
	--sc-muted: #6b7280;
	--sc-them-bg: #f2f3f5;
	--sc-them-fg: #17181a;
	--sc-border: #e6e7ea;
	--sc-field-bg: #ffffff;
	--sc-shadow: 0 14px 44px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
	--sc-radius: 18px;
	--sc-green: #22c55e;
	--sc-danger: #b42318;
	position: fixed;
	bottom: var(--sc-off-y);
	bottom: calc(var(--sc-off-y) + env(safe-area-inset-bottom, 0px));
	z-index: 2147483000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14.5px;
	line-height: 1.45;
	color: var(--sc-fg);
	-webkit-font-smoothing: antialiased;
	-webkit-text-size-adjust: 100%;
}
#support-chat-root.sc-root[data-position="right"] { right: var(--sc-off-x); right: calc(var(--sc-off-x) + env(safe-area-inset-right, 0px)); }
#support-chat-root.sc-root[data-position="left"]  { left: var(--sc-off-x);  left: calc(var(--sc-off-x) + env(safe-area-inset-left, 0px)); }

#support-chat-root.sc-root[data-theme="dark"] {
	--sc-bg: #17191d;
	--sc-fg: #ececee;
	--sc-muted: #9aa1ab;
	--sc-them-bg: #24272e;
	--sc-them-fg: #ececee;
	--sc-border: #2e3239;
	--sc-field-bg: #1e2126;
	--sc-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
}

/* The one line that makes `hidden` work despite our display rules. */
#support-chat-root [hidden] { display: none !important; }

#support-chat-root *, #support-chat-root *::before, #support-chat-root *::after { box-sizing: border-box; }

/* ── Theme isolation ──────────────────────────────────────────────────────
   Themes (Flatsome, Astra, …) style bare `button`, `input` and `textarea`
   globally: uppercase, letter-spacing, min-height 2.5em, padding 0 1.2em,
   margins, inset box-shadows on hover. Neutralise all of it before our own
   component rules apply. */
#support-chat-root button {
	font: inherit;
	font-weight: inherit;
	line-height: 1.3;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	text-decoration: none;
	text-align: center;
	margin: 0;
	padding: 0;
	min-height: 0;
	min-width: 0;
	max-width: none;
	width: auto;
	height: auto;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: inherit;
	box-shadow: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: middle;
	position: relative;
	overflow: visible;
	transition: none;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
}
#support-chat-root button:hover, #support-chat-root button:focus, #support-chat-root button:active {
	box-shadow: none;
	opacity: 1;
	text-decoration: none;
	transform: none;
}
#support-chat-root button svg { display: block; width: auto; height: auto; max-width: none; flex: 0 0 auto; }
#support-chat-root input, #support-chat-root textarea {
	font: inherit;
	line-height: 1.35;
	letter-spacing: normal;
	text-transform: none;
	margin: 0;
	height: auto;
	min-height: 0;
	max-width: 100%;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
	outline: none;
}
#support-chat-root input:focus, #support-chat-root textarea:focus { box-shadow: none; }
#support-chat-root a { box-shadow: none; }
#support-chat-root div, #support-chat-root span, #support-chat-root small { margin: 0; }
#support-chat-root button:focus-visible, #support-chat-root .sc-field:focus-visible, #support-chat-root .sc-input:focus-visible {
	outline: 2px solid var(--sc-accent);
	outline-offset: 2px;
}

/* ── Launcher ─────────────────────────────────────────────────────────────── */
#support-chat-root .sc-launcher {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 52px;
	min-width: 52px;
	padding: 0 18px 0 16px;
	border: none;
	border-radius: 999px;
	background: var(--sc-accent);
	color: var(--sc-on-accent);
	cursor: pointer;
	box-shadow: var(--sc-shadow);
	font-weight: 600;
	font-size: 14px;
	letter-spacing: 0.01em;
	white-space: nowrap;
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.25s ease;
	opacity: 0;
	transform: translateY(6px);
}
#support-chat-root.sc-ready .sc-launcher { opacity: 1; transform: none; }
#support-chat-root.sc-root[data-launcher="circle"] .sc-launcher { width: 56px; height: 56px; padding: 0; justify-content: center; }
#support-chat-root .sc-launcher:hover { transform: translateY(-1px); box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.1); }
#support-chat-root .sc-launcher:active { transform: translateY(0) scale(0.98); }
#support-chat-root .sc-launcher svg { flex: 0 0 auto; }
#support-chat-root .sc-badge {
	position: absolute;
	top: -5px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 10px;
	background: #e5484d;
	color: #fff;
	font-size: 11.5px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
	box-shadow: 0 0 0 2px var(--sc-bg);
}
#support-chat-root .sc-launcher .sc-ic-close { display: none; }
#support-chat-root.sc-is-open .sc-launcher .sc-ic-chat { display: none; }
#support-chat-root.sc-is-open .sc-launcher .sc-ic-close { display: block; }
#support-chat-root.sc-is-open .sc-launcher .sc-launcher-label { display: none; }
#support-chat-root.sc-is-open .sc-launcher { width: 52px; min-width: 52px; padding: 0; justify-content: center; }
#support-chat-root.sc-is-open .sc-badge { display: none; }

/* ── Teaser bubble ─────────────────────────────────────────────────────────── */
#support-chat-root .sc-teaser {
	position: absolute;
	bottom: 64px;
	display: flex;
	align-items: center;
	gap: 4px;
	width: max-content;
	max-width: 300px;
	max-width: min(300px, calc(100vw - 40px));
	padding: 4px 4px 4px 0;
	background: var(--sc-bg);
	color: var(--sc-fg);
	border: 1px solid var(--sc-border);
	border-radius: 14px;
	box-shadow: var(--sc-shadow);
}
#support-chat-root.sc-root[data-position="right"] .sc-teaser { right: 0; }
#support-chat-root.sc-root[data-position="left"]  .sc-teaser { left: 0; }
#support-chat-root .sc-teaser-text {
	display: block;
	border: none;
	background: transparent;
	color: inherit;
	padding: 10px 6px 10px 14px;
	text-align: left;
	font-size: 14px;
	line-height: 1.35;
	cursor: pointer;
}
#support-chat-root .sc-teaser-close {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--sc-muted);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
#support-chat-root .sc-teaser-close:hover { background: var(--sc-them-bg); color: var(--sc-fg); }
#support-chat-root .sc-teaser.sc-in { animation: sc-pop 0.25s ease; }

/* ── Panel ─────────────────────────────────────────────────────────────────── */
#support-chat-root .sc-panel {
	position: absolute;
	bottom: 64px; /* above the launcher, which becomes the close toggle */
	width: 380px;
	max-width: calc(100vw - 2 * var(--sc-off-x));
	height: 620px;
	max-height: calc(100vh - var(--sc-off-y) - 88px);
	max-height: calc(100dvh - var(--sc-off-y) - 88px);
	background: var(--sc-bg);
	color: var(--sc-fg);
	border: 1px solid var(--sc-border);
	border-radius: var(--sc-radius);
	box-shadow: var(--sc-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: sc-open 0.2s ease;
}
#support-chat-root.sc-root[data-position="right"] .sc-panel { right: 0; }
#support-chat-root.sc-root[data-position="left"]  .sc-panel { left: 0; }

/* Header */
#support-chat-root .sc-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 12px 14px 16px;
	background: var(--sc-accent);
	color: var(--sc-on-accent);
	flex: 0 0 auto;
}
#support-chat-root .sc-htext { flex: 1 1 auto; min-width: 0; }
#support-chat-root .sc-title { font-weight: 650; font-size: 15.5px; line-height: 1.25; }
#support-chat-root .sc-subtitle { font-size: 12.5px; opacity: 0.82; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#support-chat-root .sc-close {
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	opacity: 0.85;
}
#support-chat-root .sc-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }

/* Avatar */
#support-chat-root .sc-avatar {
	position: relative;
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--sc-accent);
	color: var(--sc-on-accent);
	font-size: 12px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	align-self: flex-end;
	margin-bottom: 20px;
}
#support-chat-root .sc-avatar-lg {
	width: 40px;
	height: 40px;
	font-size: 16px;
	background: rgba(255, 255, 255, 0.16);
	border: 1px solid rgba(255, 255, 255, 0.25);
	align-self: center;
	margin-bottom: 0;
}
#support-chat-root .sc-online {
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: var(--sc-green);
	border: 2px solid var(--sc-accent);
}

/* Log */
#support-chat-root .sc-log {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 16px 14px 8px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--sc-bg);
}
#support-chat-root .sc-day { display: flex; justify-content: center; margin: 2px 0 4px; }
#support-chat-root .sc-day span { font-size: 11px; color: var(--sc-muted); background: var(--sc-them-bg); padding: 3px 10px; border-radius: 999px; }
#support-chat-root .sc-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
#support-chat-root .sc-row.sc-me { justify-content: flex-end; }
#support-chat-root .sc-row.sc-them { justify-content: flex-start; }
#support-chat-root .sc-col { display: flex; flex-direction: column; max-width: 82%; min-width: 0; }
#support-chat-root .sc-me .sc-col { align-items: flex-end; }
#support-chat-root .sc-bubble {
	padding: 9px 13px;
	border-radius: 16px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
	font-size: 14.5px;
}
#support-chat-root .sc-me .sc-bubble { background: var(--sc-accent); color: var(--sc-on-accent); border-bottom-right-radius: 5px; }
#support-chat-root .sc-them .sc-bubble { background: var(--sc-them-bg); color: var(--sc-them-fg); border-bottom-left-radius: 5px; }
#support-chat-root .sc-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
#support-chat-root .sc-meta { display: flex; gap: 6px; align-items: center; margin-top: 3px; padding: 0 4px; font-size: 10.5px; color: var(--sc-muted); }
#support-chat-root .sc-state:empty { display: none; }
#support-chat-root .sc-row.sc-failed .sc-bubble { opacity: 0.55; }
#support-chat-root .sc-retry { display: inline; border: none; background: transparent; color: var(--sc-danger); font-size: 11px; cursor: pointer; padding: 0; text-decoration: underline; }
#support-chat-root .sc-row.sc-in { animation: sc-pop 0.2s ease; }

/* Promo code box */
#support-chat-root .sc-code {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1px;
	margin: 10px 0 2px;
	padding: 9px 12px;
	width: 100%;
	border: 1.5px dashed var(--sc-accent);
	border-radius: 10px;
	background: var(--sc-bg);
	color: var(--sc-fg);
	cursor: pointer;
	letter-spacing: 0.12em;
	font-weight: 700;
	font-size: 16px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#support-chat-root .sc-code small { font-family: inherit; font-weight: 500; font-size: 10.5px; letter-spacing: 0.02em; color: var(--sc-muted); }

/* Typing indicator */
#support-chat-root .sc-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
#support-chat-root .sc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--sc-muted); opacity: 0.5; animation: sc-dots 1.2s infinite ease-in-out; }
#support-chat-root .sc-typing span:nth-child(2) { animation-delay: 0.15s; }
#support-chat-root .sc-typing span:nth-child(3) { animation-delay: 0.3s; }

/* Quick replies */
#support-chat-root .sc-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 10px; flex: 0 0 auto; }
#support-chat-root .sc-chip {
	display: inline-flex;
	border: 1px solid var(--sc-accent);
	background: transparent;
	color: var(--sc-fg);
	border-radius: 999px;
	padding: 7px 12px;
	font-size: 13px;
	cursor: pointer;
	transition: background 0.12s ease, color 0.12s ease;
}
#support-chat-root .sc-chip:hover { background: var(--sc-accent); color: var(--sc-on-accent); }

/* Cards (soft identity), gate, callback */
#support-chat-root .sc-card, #support-chat-root .sc-gate, #support-chat-root .sc-cb {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 12px 14px;
	border: 1px solid var(--sc-border);
	border-radius: 14px;
	background: var(--sc-bg);
	flex: 0 0 auto;
}
#support-chat-root .sc-gate, #support-chat-root .sc-cb { border-radius: 0; border-width: 1px 0 0; }
#support-chat-root .sc-card { margin: 4px 0 4px 34px; animation: sc-pop 0.2s ease; }
#support-chat-root .sc-card-title { font-weight: 600; font-size: 13.5px; }
#support-chat-root .sc-card-sub { font-size: 12px; color: var(--sc-muted); margin-top: -4px; }
#support-chat-root .sc-card-actions { display: flex; gap: 8px; margin-top: 2px; }
#support-chat-root .sc-field {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--sc-border);
	border-radius: 10px;
	background: var(--sc-field-bg);
	color: var(--sc-fg);
	font: inherit;
	font-size: 16px; /* ≥16px: iOS Safari does not zoom */
}
#support-chat-root .sc-field.sc-invalid { border-color: var(--sc-danger); }
#support-chat-root .sc-btn {
	display: inline-flex;
	padding: 10px 14px;
	border: none;
	border-radius: 10px;
	background: var(--sc-accent);
	color: var(--sc-on-accent);
	font-weight: 600;
	cursor: pointer;
	min-height: 40px;
}
#support-chat-root .sc-btn-ghost { background: transparent; color: var(--sc-muted); }
#support-chat-root .sc-btn-ghost:hover { color: var(--sc-fg); }

/* Status */
#support-chat-root .sc-status { padding: 7px 14px; color: var(--sc-danger); font-size: 12.5px; background: rgba(180, 35, 24, 0.08); flex: 0 0 auto; }

/* Composer */
#support-chat-root .sc-composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--sc-border);
	background: var(--sc-bg);
	flex: 0 0 auto;
}
#support-chat-root .sc-input {
	flex: 1 1 auto;
	min-height: 44px;
	max-height: 120px;
	resize: none;
	border: 1px solid var(--sc-border);
	border-radius: 14px;
	padding: 11px 14px;
	font: inherit;
	font-size: 16px; /* ≥16px: iOS Safari does not zoom */
	line-height: 1.35;
	background: var(--sc-field-bg);
	color: var(--sc-fg);
}
#support-chat-root .sc-input::placeholder { color: var(--sc-muted); }
#support-chat-root .sc-send {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: none;
	background: var(--sc-accent);
	color: var(--sc-on-accent);
	cursor: pointer;
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
#support-chat-root .sc-send:hover { filter: brightness(1.12); }
#support-chat-root .sc-footer { display: flex; justify-content: space-between; align-items: center; padding: 0 14px 8px; font-size: 11px; color: var(--sc-muted); flex: 0 0 auto; }
#support-chat-root .sc-link { display: inline; border: none; background: transparent; color: var(--sc-muted); font-size: 12px; cursor: pointer; padding: 0; text-decoration: underline; }
#support-chat-root .sc-powered { margin-left: auto; }

/* Exit-intent card */
#support-chat-root .sc-exit {
	position: fixed;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	width: 360px;
	max-width: calc(100vw - 32px);
	padding: 26px 24px 22px;
	background: var(--sc-bg);
	color: var(--sc-fg);
	border-radius: 18px;
	box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
	text-align: center;
	animation: sc-pop 0.25s ease;
}
#support-chat-root .sc-exit-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: none; background: transparent; color: var(--sc-muted); cursor: pointer; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
#support-chat-root .sc-exit-close:hover { background: var(--sc-them-bg); }
#support-chat-root .sc-exit-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
#support-chat-root .sc-exit-text { font-size: 14.5px; color: var(--sc-muted); margin-bottom: 16px; }
#support-chat-root .sc-exit-btn { width: 100%; font-size: 15px; min-height: 46px; }

/* Cart nudge (rendered by PHP on the cart page, outside the root) */
.sc-cart-nudge {
	display: inline-flex !important;
	align-items: center;
	gap: 8px;
	width: 100%;
	margin: 0 0 12px;
	padding: 10px 14px;
	border: 1px dashed currentColor;
	border-radius: 10px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 14px;
	cursor: pointer;
	text-align: left;
}
.sc-cart-nudge[hidden] { display: none !important; }

/* ── Tablet: floating panel, capped to the viewport ───────────────────────── */
@media (min-width: 768px) and (max-width: 1024px) {
	#support-chat-root .sc-panel { width: 380px; height: 600px; max-height: 80vh; max-height: 80dvh; }
}

/* ── Phone: full-screen sheet, keyboard-aware ─────────────────────────────── */
@media (max-width: 767px) {
	#support-chat-root.sc-root { --sc-off-x: 14px; --sc-off-y: 14px; }
	#support-chat-root .sc-launcher { height: 50px; font-size: 13.5px; padding: 0 16px 0 14px; }
	#support-chat-root .sc-teaser { bottom: 60px; max-width: calc(100vw - 28px); }
	#support-chat-root .sc-panel {
		position: fixed;
		left: 0;
		right: 0;
		top: var(--sc-vvtop, 0px);
		bottom: auto;
		width: 100%;
		max-width: 100%;
		height: 100vh;
		height: var(--sc-vvh, 100dvh);
		max-height: none;
		border-radius: 0;
		border: none;
		animation: sc-slide 0.22s ease;
	}
	#support-chat-root .sc-header { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
	#support-chat-root.sc-is-open .sc-launcher { display: none; }
	#support-chat-root .sc-col { max-width: 86%; }
	#support-chat-root .sc-exit { padding: 22px 18px 18px; }
}
html.sc-lock, html.sc-lock body { overflow: hidden !important; height: 100% !important; overscroll-behavior: none; }

/* ── Motion ───────────────────────────────────────────────────────────────── */
@keyframes sc-pop   { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes sc-open  { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes sc-slide { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes sc-dots  { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
	#support-chat-root .sc-row.sc-in, #support-chat-root .sc-panel, #support-chat-root .sc-teaser.sc-in, #support-chat-root .sc-exit, #support-chat-root .sc-card { animation: none; }
	#support-chat-root .sc-launcher { transition: none; }
	#support-chat-root .sc-typing span { animation: none; opacity: 0.6; }
}
