/* SmartChat widget — all styles scoped under #sc-root.
   Spacing scale: 4 / 8 / 12 / 16 / 20. Nothing touches a border.

   Specificity contract: the reset below is (1,0,0) via :where() so it can
   never beat a component rule. Every component rule is #sc-root + class
   (1,1,0) and therefore always wins over the reset and over host-theme
   rules that target bare classes. */

#sc-root {
	--sc-accent: #0e63ff;
	--sc-accent-rgb: 14, 99, 255; /* JS syncs this with --sc-accent */
	--sc-accent-dark: #0b4fc4;
	--sc-ink: #1c2330;
	--sc-muted: #667085;
	--sc-line: #c6cfdd;
	--sc-line-strong: #aab7cb;
	--sc-bg: #eef1f6;
	--sc-card: #ffffff;
	--sc-radius: 18px;
	--sc-z: 2147483000;
	--sc-space: 20px;
	position: fixed;
	z-index: var(--sc-z);
	right: var(--sc-space);
	bottom: var(--sc-space);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--sc-ink);
	text-align: left;
}

#sc-root.sc-pos-left { right: auto; left: var(--sc-space); }

/* Reset — margin/padding zeroing is wrapped in :where() (zero specificity)
   so component paddings below always apply. box-sizing is unconditional. */
#sc-root,
#sc-root *,
#sc-root *::before,
#sc-root *::after { box-sizing: border-box; }
#sc-root :where(*),
#sc-root :where(*::before),
#sc-root :where(*::after) { margin: 0; padding: 0; }

#sc-root[hidden] { display: none; }
#sc-root [hidden] { display: none !important; }

/* ---------------------------------------------------------------- Bubble */
#sc-root .sc-bubble {
	position: relative;
	width: 60px;
	height: 60px;
	border: 0;
	border-radius: 50%;
	background: var(--sc-accent);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(16, 24, 40, .28);
	transition: transform .2s cubic-bezier(.2, .8, .3, 1.2), box-shadow .2s ease, background .2s ease;
	-webkit-tap-highlight-color: transparent;
}
#sc-root .sc-bubble:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 12px 28px rgba(16, 24, 40, .32); }
#sc-root .sc-bubble:active { transform: translateY(-1px) scale(.97); }
#sc-root .sc-bubble:focus-visible { outline: 3px solid rgba(0,0,0,.25); outline-offset: 2px; }

#sc-root .sc-bubble-icon { width: 27px; height: 27px; display: block; }
#sc-root .sc-bubble-icon svg { width: 100%; height: 100%; display: block; transition: transform .25s cubic-bezier(.2, .8, .3, 1.2), opacity .2s ease; }

#sc-root .sc-bubble-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border-radius: 10px;
	background: #e5484d;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
	box-shadow: 0 2px 6px rgba(0,0,0,.25);
	animation: sc-badge-pop .35s cubic-bezier(.2, .8, .3, 1.4);
}

/* Open state: white circle with a rotating X */
#sc-root.sc-open .sc-bubble { background: #ffffff; color: #3a4250; box-shadow: 0 6px 20px rgba(16,24,40,.22); }
#sc-root.sc-open .sc-bubble .sc-bubble-icon svg { transform: rotate(90deg); }

@keyframes sc-badge-pop {
	from { transform: scale(0); }
	to   { transform: scale(1); }
}

/* ---------------------------------------------------------------- Teaser */
#sc-root .sc-teaser {
	position: absolute;
	bottom: 74px;
	right: 0;
	max-width: 264px;
	background: var(--sc-card);
	border: 1px solid var(--sc-line-strong);
	border-radius: 14px;
	border-bottom-right-radius: 4px;
	padding: 12px 32px 12px 16px;
	box-shadow: 0 10px 30px rgba(16, 24, 40, .18);
	cursor: pointer;
	animation: sc-rise .32s cubic-bezier(.2, .8, .3, 1.1);
}
#sc-root.sc-pos-left .sc-teaser { right: auto; left: 0; border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
#sc-root .sc-teaser-text { font-size: 13.5px; }
#sc-root .sc-teaser-close {
	position: absolute;
	top: 4px;
	right: 6px;
	border: 0;
	background: none;
	color: var(--sc-muted);
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	padding: 4px;
}

@keyframes sc-rise {
	from { opacity: 0; transform: translateY(10px) scale(.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------------------------------------------------------- Panel */
#sc-root .sc-panel {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 566px;
	max-height: calc(100vh - 120px - var(--sc-space));
	background: var(--sc-card);
	border: 1px solid #d9dfe9;
	border-radius: var(--sc-radius);
	box-shadow: 0 24px 64px rgba(16, 24, 40, .3), 0 2px 8px rgba(16, 24, 40, .08);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
}
#sc-root.sc-pos-left .sc-panel { right: auto; left: 0; transform-origin: bottom left; }

/* Open / close animations */
#sc-root .sc-panel.sc-opening { animation: sc-panel-in .3s cubic-bezier(.2, .9, .3, 1.08); }
#sc-root .sc-panel.sc-closing { animation: sc-panel-out .2s ease forwards; pointer-events: none; }

@keyframes sc-panel-in {
	from { opacity: 0; transform: translateY(14px) scale(.96); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sc-panel-out {
	from { opacity: 1; transform: translateY(0) scale(1); }
	to   { opacity: 0; transform: translateY(10px) scale(.97); }
}

/* Header */
#sc-root .sc-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px;
	background: var(--sc-accent);
	color: #fff;
	flex: 0 0 auto;
}
#sc-root .sc-head-avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255,255,255,.18);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	flex: 0 0 auto;
	overflow: hidden;
}
#sc-root .sc-head-avatar img { width: 100%; height: 100%; object-fit: cover; }
#sc-root .sc-head-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
#sc-root .sc-head-name { font-weight: 700; font-size: 15px; }
#sc-root .sc-head-role { font-size: 11.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sc-root .sc-head-close {
	border: 0;
	background: rgba(255,255,255,.16);
	color: #fff;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	flex: 0 0 auto;
	transition: background .15s ease, transform .15s ease;
}
#sc-root .sc-head-close:hover { background: rgba(255,255,255,.3); transform: rotate(90deg); }

/* Body / messages */
#sc-root .sc-body {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: var(--sc-bg);
}
#sc-root .sc-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 16px 12px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scrollbar-width: thin;
	scrollbar-color: #c3ccda transparent;
}
#sc-root .sc-messages::-webkit-scrollbar { width: 6px; }
#sc-root .sc-messages::-webkit-scrollbar-track { background: transparent; }
#sc-root .sc-messages::-webkit-scrollbar-thumb { background: #c3ccda; border-radius: 3px; }
#sc-root .sc-messages::-webkit-scrollbar-thumb:hover { background: #aab7cb; }

#sc-root .sc-msg {
	max-width: 85%;
	padding: 11px 14px;
	border-radius: 16px;
	font-size: 14px;
	white-space: pre-line;
	word-wrap: break-word;
	animation: sc-msg-in .24s cubic-bezier(.2, .8, .3, 1.1);
}
#sc-root .sc-msg-bot {
	align-self: flex-start;
	background: var(--sc-card);
	border: 1.5px solid #aeb9cc;
	border-bottom-left-radius: 6px;
	color: var(--sc-ink);
	box-shadow: 0 2px 5px rgba(16, 24, 40, .08);
}
#sc-root .sc-msg-user {
	align-self: flex-end;
	background: var(--sc-accent);
	color: #fff;
	border-bottom-right-radius: 6px;
}

#sc-root .sc-msg-typing {
	align-self: flex-start;
	background: var(--sc-card);
	border: 1.5px solid #aeb9cc;
	border-bottom-left-radius: 6px;
	padding: 14px 16px;
	display: flex;
	gap: 5px;
	align-items: center;
	animation: sc-msg-in .24s ease;
}
#sc-root .sc-msg-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #a9b2c0;
	animation: sc-blink 1.1s infinite;
}
#sc-root .sc-msg-typing span:nth-child(2) { animation-delay: .18s; }
#sc-root .sc-msg-typing span:nth-child(3) { animation-delay: .36s; }

@keyframes sc-msg-in {
	from { opacity: 0; transform: translateY(6px) scale(.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sc-blink {
	0%, 80%, 100% { opacity: .3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-2px); }
}

/* Answer link buttons — sized like a bubble, never edge-to-edge */
#sc-root .sc-links {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-width: 85%;
	align-self: flex-start;
	animation: sc-msg-in .24s ease;
}
#sc-root .sc-link {
	display: inline-flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 14px;
	background: #ffffff;
	border: 1.5px solid rgba(var(--sc-accent-rgb), .5);
	border-radius: 12px;
	color: var(--sc-accent-dark);
	font-size: 13.5px;
	font-weight: 600;
	text-decoration: none;
	transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
#sc-root .sc-link:hover { background: rgba(var(--sc-accent-rgb), .07); border-color: rgba(var(--sc-accent-rgb), .9); transform: translateX(2px); }
#sc-root .sc-link-arrow { flex: 0 0 auto; opacity: .7; font-weight: 400; }

/* Chips — a structured footer zone with clearly tappable pills */
#sc-root .sc-chips {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	padding: 12px 16px 14px;
	background: #ffffff;
	border-top: 1px solid #e3e8f0;
	animation: sc-rise .25s ease;
}
#sc-root .sc-chip {
	border: 1.5px solid var(--sc-accent);
	background: rgba(var(--sc-accent-rgb), .13);
	color: var(--sc-accent-dark);
	border-radius: 999px;
	padding: 10px 16px;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.3;
	cursor: pointer;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
#sc-root .sc-chip:hover { border-color: var(--sc-accent); background: rgba(var(--sc-accent-rgb), .16); transform: translateY(-1px); }
#sc-root .sc-chip:active { transform: translateY(0); }
#sc-root .sc-chip-contact {
	border-color: var(--sc-accent);
	background: var(--sc-accent);
	color: #fff;
}
#sc-root .sc-chip-contact:hover { background: var(--sc-accent-dark); color: #fff; }

/* In-chat lead form card */
#sc-root .sc-formcard {
	max-width: 92%;
	align-self: flex-start;
	padding: 16px;
	background: var(--sc-card);
	border: 1.5px solid #aeb9cc;
	border-bottom-left-radius: 6px;
	border-radius: 16px;
	box-shadow: 0 6px 20px rgba(16, 24, 40, .12);
}
#sc-root .sc-form-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
#sc-root .sc-form-sub { font-size: 12.5px; color: var(--sc-muted); margin-bottom: 12px; }
#sc-root .sc-form { display: flex; flex-direction: column; gap: 8px; }
#sc-root .sc-field {
	width: 100%;
	height: 42px;
	padding: 0 13px;
	border: 1.5px solid #cfd8e4;
	border-radius: 10px;
	font-size: 14px;
	font-family: inherit;
	color: var(--sc-ink);
	background: #fbfcfe;
	outline: none;
	transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
#sc-root .sc-field::placeholder { color: #98a2b3; }
#sc-root .sc-field:focus { border-color: var(--sc-accent); background: #fff; box-shadow: 0 0 0 3px rgba(var(--sc-accent-rgb), .13); }
#sc-root .sc-field.sc-invalid { border-color: #e5484d; background: #fff8f8; }
#sc-root .sc-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
#sc-root .sc-form-btn {
	height: 44px;
	margin-top: 2px;
	border: 0;
	border-radius: 10px;
	background: var(--sc-accent);
	color: #fff;
	font-size: 14.5px;
	font-weight: 700;
	font-family: inherit;
	cursor: pointer;
	transition: background .15s ease, transform .15s ease;
}
#sc-root .sc-form-btn:hover { background: var(--sc-accent-dark); transform: translateY(-1px); }
#sc-root .sc-form-btn:active { transform: translateY(0); }
#sc-root .sc-form-btn[disabled] { opacity: .6; cursor: default; transform: none; }
#sc-root .sc-form-consent { font-size: 11px; color: var(--sc-muted); text-align: center; }
#sc-root .sc-form-error {
	color: #c62a2f;
	font-size: 12.5px;
	font-weight: 600;
	background: #fdecec;
	border-radius: 8px;
	padding: 8px 10px;
	animation: sc-shake .3s ease;
}
@keyframes sc-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-3px); }
	75% { transform: translateX(3px); }
}

/* Input row */
#sc-root .sc-inputrow {
	flex: 0 0 auto;
	display: flex;
	gap: 8px;
	padding: 12px 14px;
	border-top: 1px solid var(--sc-line);
	background: var(--sc-card);
}
#sc-root .sc-input {
	flex: 1 1 auto;
	height: 44px;
	border: 1.5px solid #cfd8e4;
	border-radius: 11px;
	padding: 0 14px;
	font-size: 14px;
	font-family: inherit;
	color: var(--sc-ink);
	outline: none;
	min-width: 0;
	background: #fbfcfe;
	transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
#sc-root .sc-input:focus { border-color: var(--sc-accent); background: #fff; box-shadow: 0 0 0 3px rgba(var(--sc-accent-rgb), .13); }
#sc-root .sc-send {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 11px;
	background: var(--sc-accent);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s ease, transform .15s ease;
}
#sc-root .sc-send:hover { background: var(--sc-accent-dark); transform: translateY(-1px); }
#sc-root .sc-send:active { transform: translateY(0); }
#sc-root .sc-send[disabled] { opacity: .55; cursor: default; transform: none; }

/* Footnote */
#sc-root .sc-footnote {
	flex: 0 0 auto;
	text-align: center;
	font-size: 11px;
	color: var(--sc-muted);
	padding: 0 14px 10px;
	background: var(--sc-card);
}

/* ------------------------------------------------------------- Mobile */
@media (max-width: 480px) {
	#sc-root { --sc-space: 14px; }
	#sc-root .sc-panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-width: none;
		max-height: none;
		border-radius: 0;
	}
	#sc-root .sc-panel.sc-opening { animation: none; }
	#sc-root .sc-panel.sc-closing { animation: sc-fade-out .18s ease forwards; }
	#sc-root .sc-teaser { max-width: 220px; }
	#sc-root .sc-messages { padding: 16px 14px 12px; }
}

@keyframes sc-fade-out {
	from { opacity: 1; }
	to   { opacity: 0; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	#sc-root *, .sc-teaser, .sc-panel, .sc-msg { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
