/* Site Assistant — Widget Styles v4
   All CSS scoped under .sa-widget-root.
   Brand colours injected as CSS custom properties by widget.js. */

/* ════════════════════════════════════════════════════════════
   1. TOKENS
   ════════════════════════════════════════════════════════════ */
.sa-widget-root {
	/* Brand (overridden by JS) */
	--sa-primary:        #2563eb;
	--sa-primary-d:      #1d4ed8;
	--sa-contrast:       #ffffff;
	/* Surfaces */
	--sa-bg:             #ffffff;
	--sa-canvas:         #f7f8fc;
	--sa-surface:        #ffffff;
	--sa-surface-2:      #eef0f5;
	/* Text */
	--sa-text:           #0f172a;
	--sa-muted:          #64748b;
	/* Structure */
	--sa-border:         #e3e7ef;
	--sa-radius:         24px;
	--sa-radius-sm:      14px;
	--sa-radius-xs:      10px;
	--sa-shadow:         0 24px 64px -16px rgba(15,23,42,.35), 0 8px 24px -8px rgba(15,23,42,.18);
	--sa-shadow-sm:      0 1px 2px rgba(15,23,42,.06), 0 2px 8px rgba(15,23,42,.06);
	--sa-font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
	                     "Helvetica Neue", Arial, sans-serif;
	/* Motion */
	--sa-ease:           cubic-bezier(.22, 1, .36, 1);
	--sa-dur:            .26s;
	/* Layout */
	--sa-z:              99999;
	--sa-w:              400px;
	--sa-h:              640px;
}

/* ── Dark mode ─────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
	.sa-widget-root {
		--sa-bg:        #12131c;
		--sa-canvas:    #171925;
		--sa-surface:   #20222f;
		--sa-surface-2: #2a2d3d;
		--sa-text:      #eef0f6;
		--sa-muted:     #9aa3b5;
		--sa-border:    #2f3346;
		--sa-shadow:    0 24px 64px -16px rgba(0,0,0,.75), 0 8px 24px -8px rgba(0,0,0,.5);
		--sa-shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.25);
	}
	.sa-bubble--error { background: #3b0a0a; color: #fca5a5; border-color: #7f1d1d; }
	.sa-bubble--error .sa-retry-btn { background: #b91c1c; }
}

/* ════════════════════════════════════════════════════════════
   2. RESET (scoped)
   ════════════════════════════════════════════════════════════ */
.sa-widget-root *,
.sa-widget-root *::before,
.sa-widget-root *::after {
	box-sizing: border-box;
	margin: 0; padding: 0;
}
.sa-widget-root button,
.sa-widget-root textarea,
.sa-widget-root input {
	font-family: var(--sa-font);
	font-size: 14px;
	line-height: 1.5;
	-webkit-appearance: none;
	appearance: none;
}
.sa-widget-root button { outline: none; cursor: pointer; border: none; background: none; color: inherit; }
.sa-widget-root textarea { outline: none; resize: none; }
.sa-widget-root { font-family: var(--sa-font); font-size: 14px; line-height: 1.5; color: var(--sa-text); }

/* Screen-reader only — used on the textarea <label> */
.sa-widget-root .sa-sr-only,
.sa-widget-root .sa-visually-hidden {
	position: absolute;
	width: 1px; height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════
   3. FLOATING CONTAINER
   ════════════════════════════════════════════════════════════ */
.sa-floating {
	position: fixed;
	bottom: 24px; right: 24px;
	z-index: var(--sa-z);
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
}
.sa-floating.sa-pos-bottom-left { right: auto; left: 24px; align-items: flex-start; }

/* ════════════════════════════════════════════════════════════
   4. GREETING BUBBLE
   ════════════════════════════════════════════════════════════ */
.sa-greeting {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--sa-bg);
	border: 1px solid var(--sa-border);
	border-radius: 16px 16px 4px 16px;
	padding: 10px 10px 10px 16px;
	box-shadow: var(--sa-shadow);
	max-width: 260px;
	animation: sa-greet-in .45s var(--sa-ease) 1.4s both;
}
.sa-pos-bottom-left .sa-greeting { border-radius: 16px 16px 16px 4px; }
.sa-greeting-text {
	font-size: 13.5px; font-weight: 500; color: var(--sa-text);
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sa-greeting-dismiss {
	flex-shrink: 0;
	width: 24px; height: 24px;
	border-radius: 50%;
	display: flex; align-items: center; justify-content: center;
	font-size: 16px; line-height: 1; color: var(--sa-muted);
	transition: background .15s, color .15s;
}
.sa-greeting-dismiss:hover  { background: var(--sa-surface-2); color: var(--sa-text); }
.sa-greeting-dismiss:focus-visible { outline: 2px solid var(--sa-primary); }
@keyframes sa-greet-in {
	from { opacity: 0; transform: translateY(10px) scale(.92); }
	to   { opacity: 1; transform: translateY(0)  scale(1); }
}
.sa-greeting.sa-hidden { display: none; }

/* ════════════════════════════════════════════════════════════
   5. LAUNCHER BUTTON
   ════════════════════════════════════════════════════════════ */
.sa-launcher {
	position: relative;
	width: 62px; height: 62px;
	border-radius: 50%;
	background: linear-gradient(140deg, var(--sa-primary), var(--sa-primary-d, var(--sa-primary)));
	color: var(--sa-contrast);
	box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--sa-primary) 60%, transparent),
	            0 0 0 3px rgba(255,255,255,.65);
	transition: transform var(--sa-dur) var(--sa-ease), box-shadow var(--sa-dur) var(--sa-ease);
	flex-shrink: 0;
	display: flex; align-items: center; justify-content: center;
}
/* Soft pulse ring, shown a few times to draw attention, then still. */
.sa-launcher::after {
	content: "";
	position: absolute; inset: 0;
	border-radius: 50%;
	box-shadow: 0 0 0 0 color-mix(in srgb, var(--sa-primary) 55%, transparent);
	animation: sa-pulse 2.4s var(--sa-ease) 1s 3;
	pointer-events: none;
}
.sa-launcher[aria-expanded="true"]::after { animation: none; }
@keyframes sa-pulse {
	0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sa-primary) 55%, transparent); }
	70%  { box-shadow: 0 0 0 16px transparent; }
	100% { box-shadow: 0 0 0 0 transparent; }
}
.sa-launcher:hover  { transform: translateY(-2px) scale(1.04); }
.sa-launcher:focus-visible { outline: 3px solid var(--sa-primary); outline-offset: 4px; }
.sa-launcher:active { transform: scale(.95); }

/* Icon morph: chat ↔ close */
.sa-launcher .sa-ico {
	position: absolute;
	width: 28px; height: 28px;
	display: flex; align-items: center; justify-content: center;
	transition: opacity var(--sa-dur) var(--sa-ease), transform var(--sa-dur) var(--sa-ease);
}
.sa-launcher .sa-ico svg { width: 28px; height: 28px; }
.sa-launcher .sa-ico-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.sa-launcher[aria-expanded="true"] .sa-ico-chat  { opacity: 0; transform: rotate(90deg) scale(.6); }
.sa-launcher[aria-expanded="true"] .sa-ico-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* ════════════════════════════════════════════════════════════
   6. DIALOG PANEL
   ════════════════════════════════════════════════════════════ */
.sa-dialog {
	position: absolute;
	bottom: 78px; right: 0;
	width: var(--sa-w);
	max-width: calc(100vw - 32px);
	height: var(--sa-h);
	max-height: calc(100dvh - 120px);
	background: var(--sa-canvas);
	border: 1px solid var(--sa-border);
	border-radius: var(--sa-radius);
	box-shadow: var(--sa-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	/* visibility flips after the fade-out, so the closed panel leaves the
	   tab order and the accessibility tree instead of just turning transparent */
	transition: opacity var(--sa-dur) var(--sa-ease),
	            transform var(--sa-dur) var(--sa-ease),
	            visibility 0s linear var(--sa-dur);
	opacity: 0;
	visibility: hidden;
	transform: scale(.94) translateY(14px);
	pointer-events: none;
}
.sa-dialog.sa-is-open {
	opacity: 1;
	visibility: visible;
	transform: scale(1) translateY(0);
	pointer-events: auto;
	transition-delay: 0s;
}
.sa-pos-bottom-left .sa-dialog { right: auto; left: 0; transform-origin: bottom left; }

/* Inline: always visible, no animation, no launcher */
.sa-inline .sa-dialog {
	position: relative;
	bottom: auto; right: auto; left: auto;
	width: 100%; max-width: 100%;
	height: var(--sa-h);
	max-height: none;
	transform: none;
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	box-shadow: var(--sa-shadow-sm);
	border-radius: var(--sa-radius-sm);
}
.sa-inline .sa-launcher,
.sa-inline .sa-greeting { display: none; }

/* ════════════════════════════════════════════════════════════
   7. HEADER
   ════════════════════════════════════════════════════════════ */
.sa-hdr {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 18px 16px 18px 18px;
	background:
		radial-gradient(120% 140% at 0% 0%, rgba(255,255,255,.22) 0%, rgba(255,255,255,0) 55%),
		linear-gradient(135deg, var(--sa-primary) 0%, var(--sa-primary-d, var(--sa-primary)) 100%);
	color: var(--sa-contrast);
	flex-shrink: 0;
}

.sa-hdr-avatar {
	position: relative;
	width: 44px; height: 44px;
	border-radius: 14px;
	background: rgba(255,255,255,.22);
	border: 1px solid rgba(255,255,255,.45);
	display: flex; align-items: center; justify-content: center;
	font-size: 16px; font-weight: 700;
	flex-shrink: 0;
	overflow: visible;
}
.sa-hdr-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 13px; }
.sa-hdr-avatar svg { width: 24px; height: 24px; }

.sa-hdr::after {
	content: "";
	position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
	background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.45), rgba(255,255,255,0));
}
.sa-hdr-avatar { box-shadow: 0 6px 16px -6px rgba(0,0,0,.35); }
.sa-hdr-info { flex: 1; min-width: 0; }
.sa-hdr-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sa-hdr-name {
	font-size: 16px; font-weight: 700; letter-spacing: -.01em;
	display: block; line-height: 1.25; min-width: 0;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sa-hdr-badge {
	flex-shrink: 0;
	padding: 1px 7px;
	border-radius: 999px;
	font-size: 11px; font-weight: 700; letter-spacing: .04em;
	background: rgba(255,255,255,.22);
	border: 1px solid rgba(255,255,255,.4);
}
/* Padding gives the status dot's glow room inside the overflow:hidden box, so its left edge is not clipped. The negative margins keep the text where it was. */
.sa-hdr-status { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .92; margin: -1px 0 -5px -6px; padding: 5px 2px 5px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-status-dot {
	width: 8px; height: 8px; border-radius: 50%;
	background: #22c55e;
	box-shadow: 0 0 0 2px rgba(255,255,255,.55);
	flex-shrink: 0;
	animation: sa-live 2.4s ease-in-out infinite;
}
@keyframes sa-live {
	0%, 100% { box-shadow: 0 0 0 2px rgba(255,255,255,.55); }
	50%      { box-shadow: 0 0 0 5px rgba(34,197,94,.25); }
}

.sa-hdr-actions { display: flex; gap: 2px; flex-shrink: 0; }
.sa-icon-btn {
	width: 34px; height: 34px;
	border-radius: var(--sa-radius-xs);
	display: flex; align-items: center; justify-content: center;
	color: var(--sa-contrast); opacity: .85;
	transition: opacity .15s, background .15s;
}
.sa-icon-btn:hover { opacity: 1; background: rgba(255,255,255,.22); }
.sa-icon-btn:focus-visible { outline: 2px solid rgba(255,255,255,.85); outline-offset: 1px; }
.sa-icon-btn svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ════════════════════════════════════════════════════════════
   8. MESSAGES AREA
   ════════════════════════════════════════════════════════════ */
.sa-messages {
	flex: 1;
	background: var(--sa-chat-bg, transparent);
	overflow-y: auto;
	padding: 18px 16px 12px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	scroll-behavior: smooth;
	scrollbar-width: thin;
	scrollbar-color: var(--sa-border) transparent;
}
.sa-messages::-webkit-scrollbar { width: 6px; }
.sa-messages::-webkit-scrollbar-thumb { background: var(--sa-border); border-radius: 6px; }
.sa-messages:focus { outline: none; }

/* ════════════════════════════════════════════════════════════
   9. STARTER CHIPS (empty state)
   ════════════════════════════════════════════════════════════ */
.sa-welcome {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 8px;
	padding: 14px 6px 4px;
	animation: sa-msg-in .45s var(--sa-ease) both;
}
.sa-welcome-av {
	width: 58px; height: 58px;
	border-radius: 18px;
	display: flex; align-items: center; justify-content: center;
	overflow: hidden;
	color: var(--sa-contrast);
	background: linear-gradient(140deg, var(--sa-primary), var(--sa-primary-d, var(--sa-primary)));
	box-shadow: 0 12px 28px -10px color-mix(in srgb, var(--sa-primary) 70%, transparent),
	            0 0 0 6px color-mix(in srgb, var(--sa-primary) 12%, transparent);
	margin-bottom: 6px;
	transition: width var(--sa-dur) var(--sa-ease), height var(--sa-dur) var(--sa-ease);
}
.sa-welcome-av img { width: 100%; height: 100%; object-fit: cover; }
.sa-welcome-av svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 2; }
.sa-welcome-title {
	margin: 0;
	font-size: 17px; font-weight: 700; letter-spacing: -.015em;
	color: var(--sa-text);
	line-height: 1.3;
}
.sa-welcome-text {
	max-width: 300px;
	font-size: 13.5px; line-height: 1.6;
	color: var(--sa-muted);
	overflow-wrap: anywhere;
}
.sa-welcome-text a { color: var(--sa-primary); }
/* Once the visitor has asked something, the welcome stays as a compact header of the chat. */
.sa-started .sa-welcome { padding-top: 4px; gap: 4px; }
.sa-started .sa-welcome-av { width: 40px; height: 40px; border-radius: 13px; margin-bottom: 2px; }
.sa-started .sa-welcome-av svg { width: 20px; height: 20px; }
.sa-started .sa-welcome-title { font-size: 14.5px; }
.sa-started .sa-welcome-text { font-size: 12.5px; }

.sa-starters {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 8px;
	width: 100%;
	margin-top: 14px;
	text-align: left;
}
.sa-starters-label {
	margin: 0 2px 2px;
	font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
	color: var(--sa-muted);
}
.sa-chip {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	background: var(--sa-surface);
	border: 1px solid var(--sa-border);
	color: var(--sa-text);
	border-radius: 14px;
	padding: 11px 12px 11px 14px;
	font-size: 13.5px; font-weight: 500;
	cursor: pointer;
	line-height: 1.4;
	box-shadow: var(--sa-shadow-sm);
	transition: border-color var(--sa-dur), background var(--sa-dur), transform var(--sa-dur) var(--sa-ease), box-shadow var(--sa-dur);
	text-align: left;
	min-height: 44px;
}
.sa-chip-text { min-width: 0; overflow-wrap: anywhere; }
.sa-chip-arrow {
	flex-shrink: 0;
	width: 26px; height: 26px;
	border-radius: 8px;
	display: flex; align-items: center; justify-content: center;
	color: var(--sa-primary);
	background: color-mix(in srgb, var(--sa-primary) 10%, transparent);
	transition: transform var(--sa-dur) var(--sa-ease), background var(--sa-dur), color var(--sa-dur);
}
.sa-chip-arrow svg { width: 14px; height: 14px; }
.sa-chip:hover {
	border-color: color-mix(in srgb, var(--sa-primary) 55%, var(--sa-border));
	transform: translateY(-1px);
	box-shadow: 0 8px 20px -12px rgba(15,23,42,.35);
}
.sa-chip:hover .sa-chip-arrow { background: var(--sa-primary); color: var(--sa-contrast); transform: translateX(2px); }
.sa-chip:focus-visible { outline: 2px solid var(--sa-primary); outline-offset: 2px; }

/* ════════════════════════════════════════════════════════════
   10. MESSAGE ROWS
   ════════════════════════════════════════════════════════════ */
.sa-msg {
	display: flex;
	gap: 10px;
	align-items: flex-end;
	animation: sa-msg-in .28s var(--sa-ease) both;
}
.sa-msg--user { flex-direction: row-reverse; }

@keyframes sa-msg-in {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}

/* Avatar */
.sa-msg-av {
	width: 30px; height: 30px;
	border-radius: 10px;
	background: linear-gradient(140deg, var(--sa-primary), var(--sa-primary-d, var(--sa-primary)));
	color: var(--sa-contrast);
	display: flex; align-items: center; justify-content: center;
	flex-shrink: 0;
	overflow: hidden;
	align-self: flex-start;
}
.sa-msg-av img { width: 100%; height: 100%; object-fit: cover; }
.sa-msg-av svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.sa-msg--user .sa-msg-av { display: none; }

/* Body */
.sa-msg-body {
	display: flex;
	flex-direction: column;
	max-width: 84%;
	min-width: 0;
	gap: 4px;
}
.sa-msg--asst .sa-msg-body { flex: 1 1 auto; align-items: flex-start; }
.sa-msg--user .sa-msg-body { align-items: flex-end; }

/* Bubbles */
.sa-bubble {
	padding: 11px 15px;
	border-radius: 18px;
	font-size: 14px;
	line-height: 1.6;
	overflow-wrap: anywhere;
}
.sa-bubble--user {
	background: linear-gradient(140deg, var(--sa-primary), var(--sa-primary-d, var(--sa-primary)));
	color: var(--sa-contrast);
	border-bottom-right-radius: 6px;
	box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--sa-primary) 70%, transparent);
}
.sa-bubble--asst {
	background: var(--sa-surface);
	color: var(--sa-text);
	border: 1px solid var(--sa-border);
	border-top-left-radius: 6px;
	box-shadow: var(--sa-shadow-sm);
}
.sa-bubble--error {
	background: #fef2f2;
	color: #991b1b;
	border: 1px solid #fecaca;
	border-top-left-radius: 6px;
}
.sa-bubble--error .sa-retry-btn {
	display: inline-flex; align-items: center; gap: 5px;
	margin-top: 8px;
	background: #991b1b; color: #fff;
	border-radius: var(--sa-radius-xs);
	padding: 6px 14px; font-size: 12.5px; font-weight: 600;
}
.sa-bubble--error .sa-retry-btn:hover { background: #7f1d1d; }

/* Safe formatting inside bubbles */
.sa-bubble strong { font-weight: 650; }
.sa-bubble em     { font-style: italic; }
.sa-bubble code   { background: rgba(15,23,42,.07); padding: 1px 6px; border-radius: 6px; font-size: .88em; }
.sa-bubble a      { color: var(--sa-primary); text-decoration: underline; text-underline-offset: 2px; }
.sa-bubble--user a { color: inherit; }
@media (prefers-color-scheme: dark) {
	.sa-bubble code { background: rgba(255,255,255,.10); }
}

/* Timestamp (visible on hover) */
.sa-ts {
	font-size: 10.5px;
	color: var(--sa-muted);
	opacity: 0;
	transition: opacity .15s;
	padding: 0 4px;
}
.sa-msg:hover .sa-ts,
.sa-msg:focus-within .sa-ts { opacity: 1; }

/* ════════════════════════════════════════════════════════════
   11. SOURCES — full-width cards; titles wrap, never cut off
   ════════════════════════════════════════════════════════════ */
.sa-sources {
	display: flex;
	flex-direction: column;
	gap: 6px;
	width: 100%;
	margin-top: 6px;
}
.sa-sources-label {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--sa-muted);
	padding: 0 2px;
}
.sa-source-pill {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-width: 0;
	background: var(--sa-surface);
	border: 1px solid var(--sa-border);
	border-radius: 12px;
	padding: 8px 10px;
	color: var(--sa-text);
	text-decoration: none;
	box-shadow: var(--sa-shadow-sm);
	transition: border-color .15s, transform .15s var(--sa-ease), box-shadow .15s;
}
.sa-source-pill:hover {
	border-color: var(--sa-primary);
	transform: translateY(-1px);
	box-shadow: 0 6px 16px -10px rgba(15,23,42,.35);
}
.sa-source-icon {
	width: 28px; height: 28px;
	border-radius: 8px;
	flex-shrink: 0;
	display: flex; align-items: center; justify-content: center;
	background: color-mix(in srgb, var(--sa-primary) 14%, transparent);
	color: var(--sa-primary);
}
.sa-source-icon svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }
.sa-source-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sa-source-title {
	font-size: 13px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--sa-text);
	overflow-wrap: anywhere;
	/* Long titles wrap onto as many lines as they need: never cut off (touch screens have no tooltip). */
}
.sa-source-host {
	font-size: 11.5px;
	line-height: 1.3;
	color: var(--sa-muted);
	overflow-wrap: anywhere;
	margin-top: 1px;
}
.sa-source-arrow { flex-shrink: 0; color: var(--sa-muted); display: flex; transition: color .15s, transform .15s var(--sa-ease); }
.sa-source-arrow svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sa-source-pill:hover .sa-source-arrow { color: var(--sa-primary); transform: translate(1px, -1px); }

/* ════════════════════════════════════════════════════════════
   12. CONTACT BUTTON
   ════════════════════════════════════════════════════════════ */
.sa-contact-link {
	display: inline-flex; align-items: center; gap: 7px;
	margin-top: 6px;
	background: transparent;
	border: 1.5px solid var(--sa-primary);
	color: var(--sa-primary);
	border-radius: 999px;
	padding: 7px 16px;
	font-size: 13px; font-weight: 600;
	text-decoration: none;
	transition: background .15s, color .15s;
}
.sa-contact-link:hover { background: var(--sa-primary); color: var(--sa-contrast); }

/* ════════════════════════════════════════════════════════════
   13. TYPING INDICATOR
   ════════════════════════════════════════════════════════════ */
.sa-typing {
	display: flex; align-items: center; gap: 5px;
	background: var(--sa-surface);
	border: 1px solid var(--sa-border);
	border-radius: 18px; border-top-left-radius: 6px;
	padding: 13px 16px;
	align-self: flex-start;
	box-shadow: var(--sa-shadow-sm);
	animation: sa-msg-in .2s var(--sa-ease) both;
}
.sa-dot {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--sa-primary);
	opacity: .55;
	animation: sa-bounce 1.1s infinite ease-in-out;
}
.sa-dot:nth-child(2) { animation-delay: .16s; }
.sa-dot:nth-child(3) { animation-delay: .32s; }
@keyframes sa-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: .45; }
	40%           { transform: translateY(-5px); opacity: 1; }
}

/* ════════════════════════════════════════════════════════════
   14. SCROLL-TO-BOTTOM BUTTON
   ════════════════════════════════════════════════════════════ */
.sa-scroll-btn {
	position: absolute;
	bottom: 96px; right: 16px;
	width: 34px; height: 34px;
	border-radius: 50%;
	background: var(--sa-surface);
	border: 1px solid var(--sa-border);
	box-shadow: var(--sa-shadow-sm);
	display: flex; align-items: center; justify-content: center;
	color: var(--sa-muted);
	transition: opacity .2s, transform .2s;
}
.sa-scroll-btn:hover { color: var(--sa-text); }
.sa-scroll-btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2.5; fill: none; stroke-linecap: round; }
.sa-scroll-btn.sa-hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(6px); }

/* ════════════════════════════════════════════════════════════
   15. INPUT AREA
   ════════════════════════════════════════════════════════════ */
.sa-input-area {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 12px 14px 6px;
	background: var(--sa-footer, var(--sa-bg));
	border-top: 1px solid var(--sa-border);
	flex-shrink: 0;
}

.sa-input-pill {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	background: var(--sa-canvas);
	border: 1.5px solid var(--sa-border);
	border-radius: 18px;
	padding: 6px 6px 6px 16px;
	box-shadow: inset 0 1px 2px rgba(15,23,42,.04);
	transition: border-color var(--sa-dur), box-shadow var(--sa-dur), background var(--sa-dur);
}
.sa-input-pill:focus-within {
	border-color: var(--sa-primary);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--sa-primary) 16%, transparent);
	background: var(--sa-bg);
}

.sa-input {
	flex: 1;
	background: transparent;
	border: none;
	padding: 8px 0;
	font-size: 14px;
	line-height: 1.45;
	max-height: 96px; /* ~4 lines */
	color: var(--sa-text);
	overflow-y: auto;
}
.sa-input::placeholder { color: var(--sa-muted); }
/* The pill shows focus (border + glow); the text box itself gets no second ring.
   Beats the widget's global :focus-visible rule and theme textarea:focus styles. */
.sa-widget-root .sa-input:focus,
.sa-widget-root .sa-input:focus-visible {
	outline: none;
	border: none;
	box-shadow: none;
	background: transparent;
}

/* Send: 40px rounded square in brand colour */
.sa-send {
	width: 40px; height: 40px;
	border-radius: 13px;
	background: linear-gradient(140deg, var(--sa-primary), var(--sa-primary-d, var(--sa-primary)));
	color: var(--sa-contrast);
	display: flex; align-items: center; justify-content: center;
	flex-shrink: 0;
	transition: opacity .15s, transform .15s var(--sa-ease), background .15s;
}
.sa-send:not(:disabled) { box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--sa-primary) 75%, transparent); }
.sa-send:hover:not(:disabled)  { transform: translateY(-1px); }
.sa-send:active:not(:disabled) { transform: scale(.94); }
.sa-send:disabled { background: var(--sa-surface-2); color: var(--sa-muted); cursor: not-allowed; }
.sa-send:focus-visible { outline: 3px solid var(--sa-primary); outline-offset: 2px; }
.sa-send svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; transform: translate(-.5px, .5px); }

/* Char hint */
.sa-char-hint {
	font-size: 11px; color: var(--sa-muted);
	text-align: right;
	display: none; /* shown by JS when >80% full */
}
.sa-char-hint.sa-visible { display: block; }
.sa-char-hint.sa-near-limit { color: #d97706; }

/* ════════════════════════════════════════════════════════════
   16. DISCLOSURE FOOTER
   ════════════════════════════════════════════════════════════ */
.sa-disclosure {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	gap: 6px;
	padding: 2px 18px 10px;
	background: var(--sa-footer, var(--sa-bg));
	font-size: 10.5px;
	color: var(--sa-muted);
	text-align: left;
	line-height: 1.45;
}
.sa-disclosure-icon { flex-shrink: 0; display: flex; margin-top: 1px; opacity: .8; }
.sa-disclosure-icon svg { width: 12px; height: 12px; }
@media (prefers-color-scheme: dark) {
	.sa-disclosure { color: #9aa3b5; }
}

/* ════════════════════════════════════════════════════════════
   17. FOCUS RING (global inside widget)
   ════════════════════════════════════════════════════════════ */
.sa-widget-root :focus-visible {
	outline: 2px solid var(--sa-primary);
	outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════
   17b. TOUCH — readable input and finger-sized targets
   ════════════════════════════════════════════════════════════ */
/* iOS Safari zooms the page when focusing an input under 16px. */
@media (max-width: 480px), (pointer: coarse) {
	.sa-widget-root .sa-input { font-size: 16px; }
}
/* 44×44px touch targets (WCAG 2.5.5 / platform guidelines) on touch screens
   only; mouse layouts keep their compact sizes. */
@media (pointer: coarse) {
	.sa-widget-root .sa-send,
	.sa-widget-root .sa-icon-btn,
	.sa-widget-root .sa-greeting-dismiss { width: 44px; height: 44px; }
	.sa-widget-root .sa-chip,
	.sa-widget-root .sa-contact-link,
	.sa-bubble--error .sa-retry-btn { min-height: 44px; display: inline-flex; align-items: center; }
	.sa-widget-root .sa-sources { gap: 8px; }
	.sa-widget-root .sa-source-pill { min-height: 44px; }
}

/* Logged-in users: keep the panel below the WordPress admin bar (46px up to 782px wide, 32px above). */
@media (min-width: 481px) and (max-width: 782px) {
	.admin-bar .sa-floating .sa-dialog { max-height: calc(100dvh - 166px); }
}
@media (min-width: 783px) {
	.admin-bar .sa-floating .sa-dialog { max-height: calc(100dvh - 152px); }
}

/* ════════════════════════════════════════════════════════════
   18. MOBILE ≤ 480px — full-screen sheet
   ════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
	/* The full-screen sheet must cover the WordPress admin bar (z-index 99999, printed after the
	   widget), or a logged-in user cannot reach the Close button. */
	.sa-floating { bottom: 16px; right: 16px; z-index: 100000; }
	.sa-floating.sa-pos-bottom-left { left: 16px; right: auto; }

	.sa-dialog {
		bottom: 0 !important; right: 0 !important; left: 0 !important;
		width: 100vw !important; max-width: 100vw !important;
		height: 100dvh !important; max-height: 100dvh !important;
		border-radius: 0 !important;
		border: none !important;
		transform-origin: center bottom !important;
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}
	.sa-floating .sa-dialog { position: fixed !important; top: 0; }
	.sa-launcher {
		position: fixed !important;
		bottom: calc(16px + env(safe-area-inset-bottom, 0px));
		right: 16px;
	}
	.sa-floating.sa-pos-bottom-left .sa-launcher { right: auto; left: 16px; }
	/* The open sheet covers the screen; its own Close button closes it. */
	.sa-floating .sa-launcher[aria-expanded="true"] { display: none; }
	.sa-floating .sa-greeting { display: none; }
	.sa-msg-body { max-width: 88%; }
}

/* ════════════════════════════════════════════════════════════
   19. REDUCED MOTION
   ════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
	.sa-widget-root *,
	.sa-widget-root *::before,
	.sa-widget-root *::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
	}
}
