/**
 * Spiracle AI Sales Agent — Frontend widget styles.
 *
 * Matches the Next.js mockup (indigo/violet, rounded bubbles, recommendation
 * cards, summary card, typing indicator). Uses --sa-accent CSS variables
 * injected from settings for theming.
 *
 * All selectors are namespaced under .sa-root to avoid theme conflicts.
 * Font sizes/weights are tuned for readability inside a ~380px widget.
 */

/* ---------- Root + launcher ---------- */

.sa-root {
	--sa-indigo: var(--sa-accent, #4f46e5);
	--sa-violet: var(--sa-accent-2, #7c3aed);
	--sa-indigo-50: #eef2ff;
	--sa-indigo-100: #e0e7ff;
	--sa-slate-100: #f1f5f9;
	--sa-slate-200: #e2e8f0;
	--sa-slate-300: #cbd5e1;
	--sa-slate-400: #94a3b8;
	--sa-slate-500: #64748b;
	--sa-slate-600: #475569;
	--sa-slate-700: #334155;
	--sa-slate-800: #1e293b;
	--sa-slate-900: #0f172a;
	--sa-emerald-50: #ecfdf5;
	--sa-emerald-400: #34d399;
	--sa-emerald-500: #10b981;
	--sa-emerald-600: #059669;
	--sa-emerald-700: #047857;
	--sa-amber-50: #fffbeb;
	--sa-amber-200: #fde68a;
	--sa-amber-500: #f59e0b;
	--sa-amber-700: #b45309;
	--sa-white: #ffffff;
	--sa-radius: 18px;
	--sa-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.28);
	--sa-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
	--sa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-family: var(--sa-font);
	font-size: 14px;
	line-height: 1.5;
	color: var(--sa-slate-800);
	box-sizing: border-box;
}

.sa-root *,
.sa-root *::before,
.sa-root *::after {
	box-sizing: border-box;
}

.sa-root.sa-position-right {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99998;
}

.sa-root.sa-position-left {
	position: fixed;
	left: 20px;
	bottom: 20px;
	z-index: 99998;
}

.sa-root.sa-fullpage {
	position: relative;
	z-index: 1;
	max-width: 920px;
	margin: 24px auto;
}

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

.sa-launcher {
	position: relative;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: linear-gradient(135deg, var(--sa-indigo), var(--sa-violet));
	color: #fff;
	box-shadow: 0 12px 28px -6px rgba(79, 70, 229, 0.55);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
	padding: 0;
}

.sa-launcher:hover {
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 16px 32px -6px rgba(79, 70, 229, 0.65);
}

.sa-launcher:focus-visible {
	outline: 3px solid rgba(124, 58, 237, 0.45);
	outline-offset: 3px;
}

.sa-launcher-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.sa-launcher-icon.sa-launcher-close {
	display: none;
}

.sa-root.sa-open .sa-launcher-icon.sa-launcher-open {
	display: none;
}

.sa-root.sa-open .sa-launcher-icon.sa-launcher-close {
	display: inline-flex;
}

.sa-launcher-pulse {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--sa-indigo);
	opacity: 0;
	pointer-events: none;
}

.sa-root:not(.sa-open) .sa-launcher-pulse {
	animation: sa-pulse 2.4s ease-out infinite;
}

@keyframes sa-pulse {
	0% { transform: scale(1); opacity: 0.6; }
	100% { transform: scale(1.55); opacity: 0; }
}

/* ---------- Window ---------- */

.sa-window {
	position: absolute;
	bottom: 76px;
	width: 380px;
	max-width: calc(100vw - 40px);
	max-height: 620px;
	background: var(--sa-white);
	border-radius: var(--sa-radius);
	overflow: hidden;
	box-shadow: var(--sa-shadow);
	border: 1px solid var(--sa-slate-200);
	display: flex;
	flex-direction: column;
	transform-origin: bottom right;
	animation: sa-window-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.sa-position-left .sa-window {
	left: 0;
	transform-origin: bottom left;
}

.sa-position-right .sa-window {
	right: 0;
}

.sa-root.sa-fullpage .sa-window {
	position: relative;
	width: 100%;
	max-width: 920px;
	max-height: 80vh;
	bottom: auto;
	right: auto;
	left: auto;
	margin: 0 auto;
}

.sa-window[hidden] {
	display: none;
}

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

/* ---------- Header ---------- */

.sa-header {
	background: linear-gradient(to right, var(--sa-indigo), var(--sa-violet));
	padding: 14px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
	color: #fff;
	flex-shrink: 0;
}

.sa-avatar {
	position: relative;
	flex-shrink: 0;
}

.sa-avatar-circle {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: #fff;
	color: var(--sa-indigo);
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid rgba(255, 255, 255, 0.3);
	font-size: 18px;
}

.sa-online-dot {
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--sa-emerald-400);
	border: 2px solid #fff;
}

.sa-header-info {
	flex: 1;
	min-width: 0;
}

.sa-header-name {
	font-weight: 600;
	font-size: 15px;
	display: flex;
	align-items: center;
	gap: 6px;
}

.sa-header-badge {
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	border: none;
	font-size: 10px;
	font-weight: 500;
	padding: 1px 6px;
	border-radius: 4px;
	height: 16px;
	display: inline-flex;
	align-items: center;
	line-height: 1;
}

.sa-header-status {
	font-size: 12px;
	color: rgba(255, 255, 255, 0.85);
	margin-top: 1px;
}

.sa-header-pill {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 11px;
	font-weight: 500;
	color: rgba(255, 255, 255, 0.92);
	background: rgba(255, 255, 255, 0.1);
	padding: 6px 10px;
	border-radius: 999px;
	flex-shrink: 0;
}

.sa-header-pill svg {
	width: 12px;
	height: 12px;
}

/* ---------- Progress ---------- */

.sa-progress {
	padding: 11px 18px;
	border-bottom: 1px solid var(--sa-slate-100);
	background: rgba(241, 245, 249, 0.5);
	flex-shrink: 0;
}

.sa-progress-meta {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 6px;
}

.sa-progress-label {
	font-size: 12px;
	font-weight: 500;
	color: var(--sa-slate-600);
}

.sa-progress-time {
	font-size: 12px;
	color: var(--sa-slate-500);
}

.sa-progress-track {
	height: 6px;
	background: var(--sa-slate-200);
	border-radius: 999px;
	overflow: hidden;
}

.sa-progress-fill {
	height: 100%;
	background: linear-gradient(to right, var(--sa-indigo), var(--sa-violet));
	border-radius: 999px;
	transition: width 0.4s ease;
}

/* ---------- Messages ---------- */

.sa-messages {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	background: rgba(248, 250, 252, 0.4);
	scroll-behavior: smooth;
	min-height: 320px;
}

.sa-messages::-webkit-scrollbar {
	width: 8px;
}

.sa-messages::-webkit-scrollbar-thumb {
	background: var(--sa-slate-300);
	border-radius: 999px;
}

.sa-message-stack {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* Bubble row */

.sa-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.sa-row.sa-row-user {
	justify-content: flex-end;
}

.sa-bubble-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--sa-indigo-100);
	color: var(--sa-indigo);
	font-size: 12px;
	font-weight: 500;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.sa-bubble {
	max-width: 78%;
	padding: 10px 14px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.sa-row-agent .sa-bubble {
	background: var(--sa-white);
	border: 1px solid var(--sa-slate-200);
	color: var(--sa-slate-800);
	border-radius: 18px 18px 18px 4px;
	box-shadow: var(--sa-shadow-sm);
}

.sa-row-user .sa-bubble {
	background: var(--sa-indigo);
	color: #fff;
	border-radius: 18px 18px 4px 18px;
	box-shadow: var(--sa-shadow-sm);
}

/* Skip notice */

.sa-skip {
	display: flex;
	justify-content: center;
	margin: 4px 0;
}

.sa-skip-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 12px;
	border-radius: 999px;
	background: var(--sa-indigo-50);
	color: var(--sa-indigo);
	font-size: 12px;
	border: 1px solid var(--sa-indigo-100);
}

.sa-skip-pill svg {
	width: 12px;
	height: 12px;
}

/* Typing indicator */

.sa-typing {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.sa-typing .sa-typing-bubble {
	background: var(--sa-white);
	border: 1px solid var(--sa-slate-200);
	border-radius: 18px 18px 18px 4px;
	padding: 12px 14px;
	box-shadow: var(--sa-shadow-sm);
}

.sa-typing-dots {
	display: flex;
	gap: 4px;
}

.sa-typing-dots span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--sa-slate-300);
	animation: sa-bounce 1.2s infinite ease-in-out;
}

.sa-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.sa-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sa-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
	30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Recommendation card ---------- */

.sa-rec-wrap {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 92%;
}

.sa-rec-card {
	width: 100%;
	border: 1px solid var(--sa-indigo-100);
	border-radius: 14px;
	overflow: hidden;
	background: linear-gradient(135deg, var(--sa-indigo-50), #faf5ff);
	box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.sa-rec-header {
	background: linear-gradient(to right, var(--sa-indigo), var(--sa-violet));
	color: #fff;
	padding: 11px 16px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
}

.sa-rec-eyebrow {
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: rgba(255, 255, 255, 0.85);
	font-weight: 500;
}

.sa-rec-title {
	font-weight: 600;
	font-size: 15px;
	margin-top: 1px;
}

.sa-rec-price {
	text-align: right;
	flex-shrink: 0;
}

.sa-rec-price-value {
	font-weight: 700;
	font-size: 18px;
	line-height: 1.1;
}

.sa-rec-body {
	padding: 14px 16px;
}

.sa-rec-tagline {
	font-size: 13px;
	color: var(--sa-slate-700);
	font-style: italic;
	margin: 0 0 12px;
}

.sa-rec-section-label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--sa-slate-600);
	margin-bottom: 7px;
}

.sa-rec-list {
	list-style: none;
	margin: 0 0 12px;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.sa-rec-list-item {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 13px;
	color: var(--sa-slate-700);
}

.sa-rec-check {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	color: var(--sa-emerald-600);
	margin-top: 2px;
}

.sa-rec-timeline {
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 12px;
	color: var(--sa-slate-600);
	background: rgba(255, 255, 255, 0.6);
	padding: 7px 11px;
	border-radius: 8px;
	margin-bottom: 12px;
}

.sa-rec-timeline svg {
	width: 14px;
	height: 14px;
	color: var(--sa-indigo);
}

.sa-rec-not {
	list-style: none;
	margin: 0 0 12px;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.sa-rec-not-item {
	font-size: 12px;
	color: var(--sa-slate-500);
	display: flex;
	gap: 6px;
}

.sa-rec-not-item::before {
	content: '•';
	color: var(--sa-slate-400);
}

.sa-rec-why {
	background: rgba(224, 231, 255, 0.6);
	border: 1px solid var(--sa-indigo-100);
	border-radius: 8px;
	padding: 10px 12px;
	display: flex;
	gap: 8px;
	align-items: flex-start;
}

.sa-rec-why svg {
	width: 14px;
	height: 14px;
	color: var(--sa-indigo);
	flex-shrink: 0;
	margin-top: 2px;
}

.sa-rec-why-label {
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--sa-violet);
	margin-bottom: 2px;
}

.sa-rec-why-text {
	font-size: 12px;
	color: var(--sa-slate-700);
	line-height: 1.5;
}

/* Budget warning banner in recommendation card */
.sa-rec-budget-warning {
	background: #fef3cd;
	border: 1px solid #f5c049;
	border-radius: 8px;
	padding: 10px 12px;
	display: flex;
	gap: 8px;
	align-items: flex-start;
	margin-bottom: 10px;
}

.sa-rec-budget-icon {
	flex-shrink: 0;
	margin-top: 1px;
}

.sa-rec-budget-icon svg {
	width: 16px;
	height: 16px;
	color: #b45309;
}

.sa-rec-budget-text {
	font-size: 12px;
	color: #78350f;
	line-height: 1.55;
	font-weight: 500;
}

/* ---------- Theme cards ---------- */

.sa-theme-wrap {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 92%;
}

.sa-theme-card {
	background: var(--sa-white);
	border: 1px solid var(--sa-slate-200);
	border-radius: 14px;
	padding: 14px 16px;
	width: 100%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.sa-theme-detail-card {
	border: 2px solid var(--sa-indigo-100);
}

.sa-theme-header {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	margin-bottom: 6px;
}

.sa-theme-badges {
	display: flex;
	gap: 4px;
}

.sa-theme-badge {
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 2px 7px;
	border-radius: 4px;
}

.sa-theme-badge-cat {
	background: var(--sa-indigo-50);
	color: var(--sa-indigo);
}

.sa-theme-badge-free {
	background: #dcfce7;
	color: #15803d;
}

.sa-theme-badge-pro {
	background: #fef3c7;
	color: #b45309;
}

.sa-theme-name {
	font-size: 15px;
	font-weight: 700;
	color: var(--sa-slate-900);
	margin-left: 2px;
}

.sa-theme-name-lg {
	font-size: 17px;
	margin-bottom: 6px;
}

.sa-theme-desc {
	font-size: 12px;
	color: var(--sa-slate-600);
	line-height: 1.5;
	margin: 4px 0 8px;
}

.sa-theme-tags {
	display: flex;
	gap: 4px;
	flex-wrap: wrap;
	margin-bottom: 8px;
}

.sa-theme-tag {
	font-size: 10px;
	font-weight: 500;
	color: var(--sa-slate-500);
	background: var(--sa-slate-50);
	border: 1px solid var(--sa-slate-200);
	border-radius: 4px;
	padding: 1px 6px;
}

.sa-theme-actions {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	margin-top: 6px;
}

.sa-btn-sm {
	font-size: 11px;
	padding: 5px 12px;
}

.sa-btn-theme-detail {
	background: var(--sa-indigo);
	border-color: var(--sa-indigo);
	color: #fff;
}

.sa-btn-theme-detail:hover {
	background: #4338ca;
	border-color: #4338ca;
	color: #fff;
}

/* ---------- Summary card ---------- */

.sa-summary-wrap {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	max-width: 92%;
}

.sa-summary-card {
	width: 100%;
	border: 1px solid var(--sa-slate-200);
	border-radius: 14px;
	overflow: hidden;
	background: var(--sa-white);
	box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.sa-summary-header {
	background: var(--sa-slate-900);
	color: #fff;
	padding: 10px 14px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
}

.sa-summary-eyebrow {
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--sa-slate-400);
	font-weight: 500;
}

.sa-summary-title {
	font-weight: 600;
	font-size: 13px;
	color: #fff;
}

.sa-summary-icon {
	width: 16px;
	height: 16px;
	color: var(--sa-emerald-400);
	flex-shrink: 0;
}

.sa-pri-badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 10px;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 6px;
	border: 1px solid transparent;
	white-space: nowrap;
}

.sa-pri-badge .sa-pri-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
}

.sa-pri-high { background: var(--sa-emerald-50); color: var(--sa-emerald-700); border-color: rgba(16, 185, 129, 0.25); }
.sa-pri-high .sa-pri-dot { background: var(--sa-emerald-500); }

.sa-pri-medium { background: var(--sa-amber-50); color: var(--sa-amber-700); border-color: rgba(245, 158, 11, 0.25); }
.sa-pri-medium .sa-pri-dot { background: var(--sa-amber-500); }

.sa-pri-low { background: var(--sa-slate-100); color: var(--sa-slate-600); border-color: var(--sa-slate-200); }
.sa-pri-low .sa-pri-dot { background: var(--sa-slate-400); }

.sa-summary-grid {
	padding: 12px 14px;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px 12px;
}

.sa-summary-cell-label {
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--sa-slate-400);
	font-weight: 500;
	margin-bottom: 1px;
}

.sa-summary-cell-value {
	font-size: 12px;
	color: var(--sa-slate-700);
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sa-summary-footer {
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid var(--sa-slate-100);
	font-size: 10px;
	color: var(--sa-slate-500);
	display: flex;
	align-items: center;
	gap: 4px;
	grid-column: 1 / -1;
}

.sa-summary-footer svg {
	width: 12px;
	height: 12px;
	color: var(--sa-emerald-500);
}

/* ---------- Response area ---------- */

.sa-response {
	border-top: 1px solid var(--sa-slate-100);
	background: var(--sa-white);
	padding: 14px 18px;
	flex-shrink: 0;
}

.sa-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.sa-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--sa-white);
	border: 1px solid var(--sa-slate-300);
	color: var(--sa-slate-700);
	font-size: 13px;
	font-weight: 500;
	padding: 8px 16px;
	border-radius: 999px;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
	line-height: 1.2;
}

.sa-btn:hover {
	background: var(--sa-indigo-50);
	border-color: var(--sa-indigo);
	color: var(--sa-indigo);
}

.sa-btn:focus-visible {
	outline: 2px solid rgba(124, 58, 237, 0.5);
	outline-offset: 2px;
}

.sa-btn-primary {
	background: var(--sa-indigo);
	border-color: var(--sa-indigo);
	color: #fff;
}

.sa-btn-primary:hover {
	background: #4338ca;
	border-color: #4338ca;
	color: #fff;
}

.sa-btn svg {
	width: 14px;
	height: 14px;
}

.sa-btn-link {
	text-decoration: none;
}

.sa-btn-ext {
	display: inline-flex;
	margin-left: 2px;
	opacity: 0.6;
}

.sa-input-form {
	display: flex;
	gap: 8px;
}

.sa-input {
	flex: 1;
	padding: 10px 16px;
	border: 1px solid var(--sa-slate-300);
	border-radius: 999px;
	font-size: 14px;
	font-family: inherit;
	color: var(--sa-slate-800);
	background: var(--sa-white);
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	min-width: 0;
}

.sa-input:focus {
	border-color: var(--sa-indigo);
	box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.sa-send-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--sa-indigo);
	border: none;
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	padding: 10px 18px;
	border-radius: 999px;
	cursor: pointer;
	font-family: inherit;
	flex-shrink: 0;
	transition: background 0.15s ease;
}

.sa-send-btn:hover { background: #4338ca; }

.sa-send-btn svg { width: 14px; height: 14px; }

/* Free-text input shown below buttons in LLM mode */

.sa-input-freeform {
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px dashed var(--sa-slate-200);
}

.sa-input-freeform .sa-input {
	padding: 8px 14px;
	font-size: 13px;
}

.sa-input-freeform .sa-send-btn {
	padding: 8px 14px;
}

/* Error / disabled states */

.sa-error {
	padding: 10px 12px;
	border-radius: 8px;
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
	font-size: 12px;
	margin-bottom: 8px;
}

/* Mobile responsiveness */

@media (max-width: 480px) {
	.sa-root.sa-position-right,
	.sa-root.sa-position-left {
		right: 0;
		left: 0;
		bottom: 0;
	}

	.sa-launcher {
		position: absolute;
		right: 16px;
		bottom: 16px;
	}

	.sa-position-left .sa-launcher {
		left: 16px;
		right: auto;
	}
}

/* ---------- Body scroll lock ---------- */

body.sa-body-lock {
	overflow: hidden;
}

/* ---------- Full-page overlay ---------- */

.sa-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: linear-gradient(to bottom, #f8fafc, #ffffff);
	overflow-y: auto;
	animation: sa-overlay-in 0.25s ease;
}

.sa-overlay[hidden] {
	display: none;
}

@keyframes sa-overlay-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

/* Sticky header */

.sa-ov-header {
	position: sticky;
	top: 0;
	z-index: 10;
	background: rgba(255, 255, 255, 0.82);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid #e2e8f0;
}

.sa-ov-header-inner {
	max-width: 80rem;
	margin: 0 auto;
	padding: 0 1rem;
	height: 56px;
	display: flex;
	align-items: center;
	justify-content: flex-end;
}

.sa-brand {
	display: flex;
	align-items: center;
	gap: 8px;
}

.sa-brand-logo {
	width: 28px;
	height: 28px;
	border-radius: 8px;
	background: linear-gradient(to bottom right, var(--sa-indigo), var(--sa-violet));
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
}

.sa-brand-name {
	font-size: 14px;
	font-weight: 600;
	color: #0f172a;
	line-height: 1;
}

.sa-brand-sub {
	font-size: 10px;
	color: #64748b;
	line-height: 1;
	margin-top: 2px;
}

.sa-ov-close {
	width: 36px;
	height: 36px;
	border-radius: 8px;
	border: 1px solid #e2e8f0;
	background: #fff;
	color: #475569;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.sa-ov-close:hover {
	background: var(--sa-indigo-50);
	border-color: var(--sa-indigo);
	color: var(--sa-indigo);
}

/* Hero */

.sa-ov-hero {
	border-bottom: 1px solid #e2e8f0;
	background: linear-gradient(to right, #eef2ff, #ffffff, #f5f3ff);
	text-align: center;
	padding: 22px 1rem 22px;
}

.sa-ov-hero h1 {
	font-size: 22px;
	font-weight: 700;
	color: #0f172a;
	letter-spacing: -0.02em;
	margin: 0;
	line-height: 1.25;
}

.sa-beta-badge {
	display: inline-flex;
	align-items: center;
	vertical-align: middle;
	margin-left: 6px;
	padding: 1px 7px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: #92400e;
	background: linear-gradient(135deg, #fef3c7, #fde68a);
	border: 1px solid #f59e0b;
	border-radius: 4px;
	line-height: 1.4;
}

.sa-ov-hero p {
	margin: 8px auto 0;
	max-width: 42rem;
	font-size: 14px;
	color: #475569;
	line-height: 1.55;
}

.sa-ov-badges {
	margin-top: 12px;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
}

.sa-ov-badge {
	display: inline-flex;
	align-items: center;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	padding: 2px 8px;
	font-size: 11px;
	font-weight: 500;
	color: #475569;
	background: rgba(255, 255, 255, 0.6);
}

/* Body grid */

.sa-ov-body {
	max-width: 80rem;
	margin: 0 auto;
	padding: 22px 1rem;
	display: grid;
	grid-template-columns: 1fr;
	gap: 22px;
}

.sa-ov-chat-col {
	min-width: 0;
}

/* Override .sa-window when inside the overlay */

.sa-overlay .sa-window {
	position: relative;
	width: 100%;
	max-width: none;
	max-height: 720px;
	bottom: auto;
	right: auto;
	left: auto;
	border-radius: 16px;
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.18);
}

.sa-overlay .sa-messages {
	min-height: 420px;
}

/* Sidebar */

.sa-ov-sidebar {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* Insights card */

.sa-insights {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
}

.sa-insights-head {
	padding: 14px 16px;
	border-bottom: 1px solid #f1f5f9;
	background: rgba(248, 250, 252, 0.5);
	display: flex;
	align-items: flex-start;
	gap: 8px;
}

.sa-insights-head-icon {
	width: 16px;
	height: 16px;
	color: var(--sa-indigo);
	flex-shrink: 0;
	margin-top: 1px;
}

.sa-insights-title {
	font-size: 14px;
	font-weight: 600;
	color: #1e293b;
}

.sa-insights-desc {
	font-size: 12px;
	color: #64748b;
	margin-top: 2px;
}

.sa-insights-body {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.sa-insights-label {
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #64748b;
	font-weight: 600;
	margin-bottom: 6px;
}

.sa-insights-pri {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	border-radius: 8px;
	border: 1px solid #e2e8f0;
	background: #f1f5f9;
	color: #475569;
	font-size: 12px;
	font-weight: 600;
	transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.sa-insights-pri .sa-pri-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #94a3b8;
}

.sa-insights-pri.sa-pri-high {
	background: #ecfdf5;
	color: #047857;
	border-color: rgba(16, 185, 129, 0.25);
}
.sa-insights-pri.sa-pri-high .sa-pri-dot {
	background: #10b981;
	animation: sa-pri-pulse 1.5s ease-in-out infinite;
}

.sa-insights-pri.sa-pri-medium {
	background: #fffbeb;
	color: #b45309;
	border-color: rgba(245, 158, 11, 0.25);
}
.sa-insights-pri.sa-pri-medium .sa-pri-dot {
	background: #f59e0b;
}

.sa-insights-pri.sa-pri-low {
	background: #f1f5f9;
	color: #475569;
	border-color: #e2e8f0;
}
.sa-insights-pri.sa-pri-low .sa-pri-dot {
	background: #94a3b8;
}

@keyframes sa-pri-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.5; }
}

.sa-insights-divider {
	height: 1px;
	background: #f1f5f9;
	width: 100%;
}

.sa-insights-facts {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.sa-insights-fact {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 12px;
}

.sa-insights-fact-label {
	color: #64748b;
}

.sa-insights-fact-val {
	color: #1e293b;
	font-weight: 500;
	max-width: 60%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sa-insights-fact-val.sa-empty {
	color: #cbd5e1;
	font-style: italic;
	font-weight: 400;
}

/* Support card */

.sa-ov-support {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
}

.sa-ov-support-head {
	padding: 14px 16px;
	border-bottom: 1px solid #f1f5f9;
	background: rgba(248, 250, 252, 0.5);
	display: flex;
	align-items: flex-start;
	gap: 8px;
}

.sa-ov-support-icon {
	width: 16px;
	height: 16px;
	color: var(--sa-indigo);
	flex-shrink: 0;
	margin-top: 1px;
}

.sa-ov-support-title {
	font-size: 14px;
	font-weight: 600;
	color: #1e293b;
}

.sa-ov-support-desc {
	font-size: 12px;
	color: #64748b;
	margin-top: 2px;
}

.sa-ov-support-body {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.sa-ov-support-text {
	font-size: 12px;
	color: #64748b;
	margin: 0;
	line-height: 1.5;
}

.sa-ov-support-email {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 14px;
	border-radius: 10px;
	background: var(--sa-indigo, #4f46e5);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	transition: background 0.2s ease, transform 0.15s ease;
}

.sa-ov-support-email:hover {
	background: var(--sa-violet, #6d28d9);
	transform: translateY(-1px);
}

.sa-ov-support-email:active {
	transform: translateY(0);
}

/* Footer */

.sa-ov-footer {
	border-top: 1px solid #e2e8f0;
	background: #fff;
	padding: 22px 1rem;
	text-align: center;
}

.sa-ov-footer-main {
	font-size: 12px;
	color: #64748b;
	margin: 0;
}

.sa-ov-footer-sub {
	font-size: 11px;
	color: #94a3b8;
	margin: 4px 0 0;
}

/* ---------- Desktop layout for overlay ---------- */

@media (min-width: 1024px) {
	.sa-ov-body {
		grid-template-columns: 2fr 1fr;
	}

	.sa-ov-hero h1 {
		font-size: 30px;
	}

	.sa-ov-hero p {
		font-size: 16px;
	}
}

/* ---------- Mobile overlay adjustments ---------- */

@media (max-width: 1023px) {
	.sa-ov-sidebar {
		order: 2;
	}

	.sa-overlay .sa-window {
		max-height: 600px;
	}

	.sa-overlay .sa-messages {
		min-height: 300px;
	}
}

@media (max-width: 640px) {
	.sa-ov-header-inner {
		padding: 0 12px;
	}

	.sa-ov-hero {
		padding: 18px 12px;
	}

	.sa-ov-hero h1 {
		font-size: 20px;
	}

	.sa-ov-body {
		padding: 16px 12px;
	}

	.sa-overlay .sa-window {
		max-height: none;
	}

	.sa-overlay .sa-messages {
		min-height: 280px;
	}

	.sa-bubble { max-width: 85%; }
	.sa-rec-wrap, .sa-summary-wrap { max-width: 95%; }
}
