/* ==========================================================================
   Sassy AI Concierge — widget styles
   Scoped entirely under #sac-root so it can't leak into (or be broken by)
   the host theme. --sac-primary is set inline from the admin color setting;
   everything else is defined here with safe fallbacks.
   ========================================================================== */

#sac-root {
	--sac-primary: #8b5cf6;
	--sac-bg: #15111f;
	--sac-bg-2: #1e1830;
	--sac-accent: #ffc857;
	--sac-text: #f5f2fa;
	--sac-muted: #b7aecb;
	--sac-radius: 18px;
	--sac-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-family: var(--sac-font);
	color: var(--sac-text);
}

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

.sac-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* ---------- Trigger button ---------- */

#sac-trigger {
	position: fixed;
	right: 24px;
	bottom: 24px;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--sac-primary); /* fallback for browsers without color-mix() */
	background: linear-gradient(145deg, var(--sac-primary), color-mix(in srgb, var(--sac-primary) 65%, #1e1830));
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
	color: #fff;
	z-index: 999998;
	transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

#sac-trigger:hover {
	transform: translateY(-3px) scale(1.05);
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

#sac-trigger:focus-visible {
	outline: 2px solid var(--sac-accent);
	outline-offset: 3px;
}

#sac-trigger svg {
	width: 26px;
	height: 26px;
	position: relative;
	z-index: 1;
}

.sac-trigger-pulse {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var(--sac-primary);
	animation: sac-trigger-pulse 2.6s ease-out infinite;
}

@keyframes sac-trigger-pulse {
	0% { transform: scale(1); opacity: 0.55; }
	100% { transform: scale(1.55); opacity: 0; }
}

#sac-root[data-open="true"] #sac-trigger {
	transform: scale(0.85);
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
}

/* ---------- Overlay: the translucent graying backdrop ---------- */

#sac-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.35s ease, visibility 0.35s ease;
}

#sac-overlay.sac-active {
	visibility: visible;
	opacity: 1;
}

#sac-overlay-bg {
	position: absolute;
	inset: 0;
	background: rgba(15, 12, 20, 0.72);
	-webkit-backdrop-filter: blur(9px) saturate(120%);
	backdrop-filter: blur(9px) saturate(120%);
}

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

#sac-panel {
	position: relative;
	width: 100%;
	max-width: 560px;
	max-height: 88vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	background: linear-gradient(180deg, var(--sac-bg-2), var(--sac-bg));
	border-radius: 28px;
	padding: 44px 28px 20px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
	transform: translateY(18px) scale(0.97);
	opacity: 0;
	transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

#sac-overlay.sac-active #sac-panel {
	transform: translateY(0) scale(1);
	opacity: 1;
}

#sac-close {
	position: absolute;
	top: 16px;
	right: 16px;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.06);
	color: var(--sac-muted);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease, color 0.2s ease;
}

#sac-close:hover {
	background: rgba(255, 255, 255, 0.12);
	color: var(--sac-text);
}

#sac-close svg {
	width: 16px;
	height: 16px;
}

/* ---------- The orb: signature "AI voice" element ---------- */

#sac-orb-wrap {
	position: relative;
	width: 108px;
	height: 108px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 22px;
}

#sac-orb {
	width: 76px;
	height: 76px;
	border-radius: 50%;
	background: var(--sac-primary); /* fallback for browsers without color-mix() */
	background: radial-gradient(circle at 34% 30%, color-mix(in srgb, var(--sac-primary) 85%, #fff), var(--sac-primary) 55%, #150f22 100%);
	box-shadow: 0 0 34px rgba(139, 92, 246, 0.5); /* fallback */
	box-shadow: 0 0 34px color-mix(in srgb, var(--sac-primary) 55%, transparent);
	animation: sac-breathe 3.2s ease-in-out infinite;
}

.sac-ring {
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 1.5px solid color-mix(in srgb, var(--sac-primary) 60%, transparent);
	opacity: 0;
}

/* Rings only animate while the orb is actively speaking or thinking. */
#sac-orb-wrap.sac-speaking .sac-ring-1 { animation: sac-ring-out 1.4s ease-out infinite; }
#sac-orb-wrap.sac-speaking .sac-ring-2 { animation: sac-ring-out 1.4s ease-out infinite 0.5s; }
#sac-orb-wrap.sac-speaking #sac-orb { animation: sac-speak 0.55s ease-in-out infinite alternate; }

#sac-orb-wrap.sac-thinking #sac-orb {
	animation: sac-think 1.1s linear infinite;
}

@keyframes sac-breathe {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.06); }
}

@keyframes sac-speak {
	from { transform: scale(1); }
	to { transform: scale(1.1); }
}

@keyframes sac-think {
	0% { transform: rotate(0deg) scale(1); }
	50% { transform: rotate(180deg) scale(0.94); }
	100% { transform: rotate(360deg) scale(1); }
}

@keyframes sac-ring-out {
	0% { transform: scale(0.7); opacity: 0.6; }
	100% { transform: scale(1.9); opacity: 0; }
}

/* ---------- Transcript ---------- */

#sac-transcript {
	width: 100%;
	flex: 1 1 auto;
	min-height: 60px;
	max-height: 38vh;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 4px 4px 12px;
	scrollbar-width: thin;
	scrollbar-color: color-mix(in srgb, var(--sac-primary) 50%, transparent) transparent;
}

#sac-transcript::-webkit-scrollbar { width: 6px; }
#sac-transcript::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--sac-primary) 50%, transparent); border-radius: 4px; }

.sac-bubble {
	line-height: 1.45;
	animation: sac-bubble-in 0.3s ease both;
}

.sac-bubble-assistant {
	font-size: clamp(1.05rem, 2.4vw, 1.28rem);
	font-weight: 600;
	letter-spacing: -0.01em;
	color: var(--sac-text);
	text-align: center;
	max-width: 46ch;
	margin: 0 auto;
}

.sac-bubble-user {
	font-size: 0.92rem;
	color: var(--sac-muted);
	text-align: right;
	align-self: flex-end;
	max-width: 80%;
}

.sac-bubble-user::before {
	content: "You: ";
	opacity: 0.6;
}

.sac-bubble.sac-thinking-dots {
	text-align: center;
	color: var(--sac-muted);
	font-size: 1rem;
}

@keyframes sac-bubble-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}

/* ---------- Consultation CTA ---------- */

#sac-cta-wrap {
	width: 100%;
	max-height: 0;
	overflow: hidden;
	opacity: 0;
	transform: translateY(6px);
	transition: max-height 0.5s ease, opacity 0.4s ease, transform 0.4s ease, margin 0.4s ease;
}

#sac-cta-wrap.sac-visible {
	max-height: 80px;
	opacity: 1;
	transform: translateY(0);
	margin: 6px 0 14px;
}

#sac-cta {
	display: block;
	text-align: center;
	text-decoration: none;
	padding: 13px 20px;
	border-radius: 999px;
	font-weight: 700;
	font-size: 0.95rem;
	color: #1c1420;
	background: var(--sac-accent); /* fallback for browsers without color-mix() */
	background: linear-gradient(120deg, var(--sac-accent), color-mix(in srgb, var(--sac-accent) 70%, #fff));
	box-shadow: 0 8px 20px rgba(255, 200, 87, 0.4); /* fallback */
	box-shadow: 0 8px 20px color-mix(in srgb, var(--sac-accent) 40%, transparent);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sac-cta:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 26px color-mix(in srgb, var(--sac-accent) 50%, transparent);
}

/* ---------- Input row ---------- */

#sac-input-row {
	width: 100%;
	display: flex;
	align-items: center;
	gap: 8px;
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 999px;
	padding: 6px 6px 6px 18px;
}

#sac-input {
	flex: 1 1 auto;
	background: transparent;
	border: none;
	outline: none;
	color: var(--sac-text);
	font-size: 0.95rem;
	font-family: var(--sac-font);
	min-width: 0;
}

#sac-input::placeholder {
	color: var(--sac-muted);
}

#sac-mic,
#sac-send {
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, background 0.2s ease;
}

#sac-mic {
	background: transparent;
	color: var(--sac-muted);
}

#sac-mic:hover { color: var(--sac-text); }

#sac-mic.sac-listening {
	color: #fff;
	background: var(--sac-primary); /* fallback for browsers without color-mix() */
	background: color-mix(in srgb, var(--sac-primary) 70%, transparent);
	animation: sac-mic-pulse 1.2s ease-in-out infinite;
}

@keyframes sac-mic-pulse {
	0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--sac-primary) 45%, transparent); }
	50% { box-shadow: 0 0 0 8px transparent; }
}

#sac-send {
	background: var(--sac-primary);
	color: #fff;
}

#sac-send:hover { transform: scale(1.06); }
#sac-send svg, #sac-mic svg { width: 17px; height: 17px; }

/* ---------- Motion & small-screen accommodations ---------- */

@media (max-width: 480px) {
	#sac-panel {
		padding: 36px 18px 16px;
		border-radius: 22px;
		max-height: 92vh;
	}
	#sac-orb-wrap { width: 88px; height: 88px; margin-bottom: 16px; }
	#sac-orb { width: 62px; height: 62px; }
	#sac-trigger { right: 16px; bottom: 16px; width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
	#sac-root * {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}
