/* Chat assistant. Uses the theme's tokens; scoped to .sbc-chat so Elementor pages look the same. */

.sbc-chat {
	--chat-gap: 16px;
	position: fixed;
	right: max(var(--chat-gap), env(safe-area-inset-right));
	bottom: max(var(--chat-gap), env(safe-area-inset-bottom));
	z-index: 90;
	font-family: var(--body);
	color: var(--navy);
}
.sbc-chat *, .sbc-chat *::before, .sbc-chat *::after { box-sizing: border-box; }
.sbc-chat p { margin: 0; }
.sbc-chat button { font: inherit; }
.sbc-chat :focus-visible { outline: 3px solid var(--berry); outline-offset: 3px; }

/* Launcher */
.sbc-chat .chat-launcher {
	display: inline-flex; align-items: center; gap: 8px;
	min-height: 52px; padding: 0 22px 0 18px;
	border: 0; border-radius: 999px;
	background: var(--berry); color: var(--white);
	font: 500 15px/1 var(--body);
	box-shadow: 0 10px 28px var(--berry-a35), 0 2px 6px var(--ink-a10);
	cursor: pointer;
	transition: background-color .2s var(--ease), transform .15s var(--ease), opacity .2s var(--ease);
}
.sbc-chat .chat-launcher:hover { background: var(--berry-deep); }
.sbc-chat .chat-launcher:active { transform: scale(.96); }
.sbc-chat.is-open .chat-launcher { opacity: 0; transform: scale(.9); pointer-events: none; }

/* Panel */
.sbc-chat .chat-panel {
	position: absolute; right: 0; bottom: 0;
	display: flex; flex-direction: column;
	width: min(390px, calc(100vw - 2 * var(--chat-gap)));
	height: min(620px, calc(100vh - 2 * var(--chat-gap)));
	height: min(620px, calc(100dvh - 2 * var(--chat-gap)));
	overflow: hidden;
	border-radius: 22px;
	background: var(--blush);
	box-shadow: 0 24px 60px var(--ink-a25), 0 4px 14px var(--ink-a10);
	transform-origin: bottom right;
	animation: sbc-chat-in .28s var(--ease);
}
.sbc-chat .chat-panel[hidden] { display: none; }
@keyframes sbc-chat-in {
	from { opacity: 0; transform: translateY(12px) scale(.97); }
	to { opacity: 1; transform: none; }
}

.sbc-chat .chat-head {
	display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
	padding: 20px 18px 18px 22px;
	background: var(--navy); color: var(--white);
}
.sbc-chat .chat-title {
	margin: 0;
	font: 700 20px/1.15 var(--head); letter-spacing: -.01em; color: var(--white);
}
.sbc-chat .chat-sub { margin-top: 4px; font-size: 13px; line-height: 1.4; color: var(--white-a70); }
.sbc-chat .chat-close {
	display: grid; place-items: center; flex: none;
	width: 40px; height: 40px; margin: -6px -4px 0 0;
	border: 0; border-radius: 50%;
	background: transparent; color: var(--white);
	cursor: pointer;
	transition: background-color .2s var(--ease), transform .15s var(--ease);
}
.sbc-chat .chat-close:hover { background: var(--white-a14); }
.sbc-chat .chat-close:active { transform: scale(.92); }
.sbc-chat .chat-close:focus-visible { outline-color: var(--berry-tint); }

/* Messages */
.sbc-chat .chat-log {
	flex: 1; overflow-y: auto; overscroll-behavior: contain;
	display: flex; flex-direction: column; gap: 10px;
	padding: 20px 16px 12px;
}
.sbc-chat .chat-msg {
	max-width: 86%;
	padding: 11px 15px;
	border-radius: 18px;
	font-size: 15px; line-height: 1.55;
	white-space: pre-wrap; overflow-wrap: anywhere;
}
.sbc-chat .chat-msg--bot {
	align-self: flex-start;
	border-bottom-left-radius: 6px;
	background: var(--paper);
	box-shadow: 0 1px 2px var(--ink-a08);
}
.sbc-chat .chat-msg--user {
	align-self: flex-end;
	border-bottom-right-radius: 6px;
	background: var(--berry); color: var(--white);
}
.sbc-chat .chat-msg a { color: var(--berry); text-decoration: underline; text-underline-offset: 2px; }
.sbc-chat .chat-msg--user a { color: var(--white); }

.sbc-chat .chat-typing { display: inline-flex; gap: 5px; padding: 15px 16px; }
.sbc-chat .chat-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--ink-a35);
	animation: sbc-chat-dot 1.1s infinite ease-in-out;
}
.sbc-chat .chat-typing span:nth-child(2) { animation-delay: .15s; }
.sbc-chat .chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes sbc-chat-dot {
	0%, 80%, 100% { opacity: .35; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-3px); }
}

/* Suggested questions */
.sbc-chat .chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
.sbc-chat .chat-chips[hidden] { display: none; }
.sbc-chat .chat-chip {
	padding: 8px 14px;
	border: 1.5px solid var(--berry-a25); border-radius: 999px;
	background: var(--paper); color: var(--berry);
	font-size: 13px; line-height: 1.3; text-align: left;
	cursor: pointer;
	transition: background-color .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease);
}
.sbc-chat .chat-chip:hover { border-color: var(--berry); background: var(--plan-berry); }
.sbc-chat .chat-chip:active { transform: scale(.97); }

/* Composer */
.sbc-chat .chat-form {
	display: flex; align-items: flex-end; gap: 8px;
	margin: 0 12px; padding: 6px 6px 6px 16px;
	border: 1.5px solid var(--line); border-radius: 24px;
	background: var(--paper);
	transition: border-color .2s var(--ease);
}
.sbc-chat .chat-form:focus-within { border-color: var(--berry); }
.sbc-chat .chat-form textarea {
	flex: 1; min-width: 0; min-height: 40px; max-height: 120px;
	margin: 0; padding: 9px 0; border: 0; outline: 0; resize: none;
	background: transparent; color: var(--navy);
	font: 16px/1.4 var(--body); /* 16px keeps iOS from zooming in. */
}
.sbc-chat .chat-form textarea::placeholder { color: var(--muted); }
.sbc-chat .chat-send {
	display: grid; place-items: center; flex: none;
	width: 40px; height: 40px;
	border: 0; border-radius: 50%;
	background: var(--berry); color: var(--white);
	cursor: pointer;
	transition: background-color .2s var(--ease), transform .15s var(--ease), opacity .2s var(--ease);
}
.sbc-chat .chat-send:hover { background: var(--berry-deep); }
.sbc-chat .chat-send:active { transform: scale(.92); }
.sbc-chat .chat-form.is-busy .chat-send { opacity: .5; pointer-events: none; }

.sbc-chat .chat-foot {
	display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px;
	padding: 10px 18px 14px;
	font-size: 12px; line-height: 1.4; color: var(--muted);
}
.sbc-chat .chat-foot a { color: var(--berry); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; transition: color .2s var(--ease); }
.sbc-chat .chat-foot a:hover { color: var(--berry-deep); }

/* Phones: the panel takes the whole screen. */
@media (max-width: 599px) {
	.sbc-chat.is-open { inset: 0; }
	.sbc-chat .chat-panel {
		position: fixed; inset: 0;
		width: 100%; height: 100%;
		border-radius: 0;
		padding-bottom: env(safe-area-inset-bottom);
	}
	.sbc-chat .chat-head { padding-top: max(20px, env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
	.sbc-chat .chat-panel { animation: none; }
	.sbc-chat .chat-typing span { animation: none; opacity: .6; }
}
