.scb-widget {
	--scb-accent: #1f7a5c;
	--scb-ink: #17211f;
	--scb-muted: #6b7471;
	--scb-panel: #ffffff;
	--scb-soft: #eef7f3;
	--scb-border: #d9e4df;
	position: fixed;
	z-index: 99990;
	right: 20px;
	bottom: 30px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	color: var(--scb-ink);
}

.scb-widget--left {
	right: auto;
	left: 20px;
}

.scb-launcher {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 58px;
	max-width: min(320px, calc(100vw - 40px));
	padding: 10px 18px 10px 12px;
	border: 0;
	border-radius: 999px;
	background: var(--scb-accent);
	color: #fff;
	box-shadow: 0 12px 30px rgba(14, 31, 27, 0.22);
	cursor: pointer;
	font: inherit;
	font-weight: 700;
	line-height: 1.2;
	transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
}

.scb-launcher[aria-expanded="true"] {
	opacity: 0;
	transform: scale(0.8) translateY(20px);
	visibility: hidden;
	pointer-events: none;
}

.scb-launcher__label:empty {
	display: none;
}

.scb-launcher__icon {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	flex: 0 0 auto;
	animation: scb-pulse-icon 2s infinite;
}

@keyframes scb-pulse-icon {
	0% {
		box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
	}
	70% {
		box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
	}
}

.scb-launcher__label {
	overflow-wrap: anywhere;
}

.scb-panel {
	position: absolute;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	width: min(390px, calc(100vw - 32px));
	height: min(620px, calc(100vh - 40px));
	overflow: hidden;
	border: 1px solid var(--scb-border);
	border-radius: 8px;
	background: var(--scb-panel);
	box-shadow: 0 24px 70px rgba(18, 31, 28, 0.24);
	/* Animate open: opacity + slight upward slide. */
	transition: opacity 0.22s ease, transform 0.22s ease;
}

.scb-widget--left .scb-panel {
	right: auto;
	left: 0;
}

/*
 * Hidden state: invisible and slid down slightly.
 * The delayed visibility transition ensures the element only becomes
 * truly invisible AFTER the opacity/transform animation finishes
 * (so the closing animation is visible). On open, visibility is
 * restored immediately (no transition on the base .scb-panel rule).
 */
.scb-panel--closed {
	visibility: hidden;
	opacity: 0;
	transform: translateY(12px);
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}

.scb-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 14px;
	background: var(--scb-accent);
	color: #fff;
}

.scb-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.scb-avatar {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: #fff;
	color: var(--scb-accent);
	font-weight: 800;
	flex: 0 0 auto;
	overflow: hidden;
}

.scb-avatar img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.scb-brand h2 {
	margin: 0;
	color: inherit;
	font-size: 16px;
	line-height: 1.2;
	overflow-wrap: anywhere;
}

.scb-brand p {
	margin: 2px 0 0;
	color: rgba(255, 255, 255, 0.82);
	font-size: 12px;
	line-height: 1.2;
}

.scb-header-actions {
	display: flex;
	gap: 6px;
	flex: 0 0 auto;
}

.scb-icon-button,
.scb-nav-button {
	border: 0;
	cursor: pointer;
	font: inherit;
}

.scb-icon-button {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
	font-size: 22px;
	line-height: 1;
}

.scb-nav {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--scb-border);
	background: #f1f4f8;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
	flex: 0 0 auto;
}

.scb-nav-button {
	flex: 1 1 0;
	min-height: 32px;
	padding: 6px 11px;
	border: 1px solid #8a96a8;
	border-radius: 8px;
	background: #fff;
	color: #2f3a49;
	font-size: 13px;
	font-weight: 700;
	transition: all 0.2s ease;
}

.scb-nav-button:hover:not(:disabled) {
	background: #f1f5f9;
	border-color: #475569;
	color: #0f172a;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
	transform: translateY(-1px);
}

.scb-nav-button:active:not(:disabled) {
	background: #e2e8f0;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
	transform: translateY(1px);
}

.scb-nav-button:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.scb-scroll {
	flex: 1;
	overflow-y: auto;
	background: #f6faf8;
}

.scb-messages {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 16px 14px 18px;
}

.scb-bubble {
	display: flex;
	max-width: 86%;
}

.scb-bubble--bot {
	align-self: flex-start;
}

.scb-bubble--user {
	align-self: flex-end;
}

.scb-bubble__text {
	padding: 10px 12px;
	border-radius: 8px;
	background: #fff;
	border: 1px solid var(--scb-border);
	box-shadow: 0 5px 14px rgba(26, 50, 43, 0.08);
	font-size: 14px;
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.scb-bubble--user .scb-bubble__text {
	background: var(--scb-accent);
	border-color: var(--scb-accent);
	color: #fff;
}

.scb-bubble__text a {
	color: inherit;
	text-decoration: underline;
}

.scb-option {
	align-self: flex-end;
	max-width: 86%;
	padding: 10px 13px;
	border: 1px solid rgba(31, 122, 92, 0.25);
	border-radius: 8px;
	background: #fff;
	color: var(--scb-accent);
	box-shadow: 0 5px 14px rgba(26, 50, 43, 0.08);
	cursor: pointer;
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	text-align: left;
	overflow-wrap: anywhere;
}

.scb-option:hover,
.scb-option:focus {
	background: var(--scb-soft);
	outline: 2px solid rgba(31, 122, 92, 0.18);
	outline-offset: 2px;
}

.scb-typing {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-width: 38px;
}

.scb-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--scb-muted);
	animation: scbTyping 1s infinite ease-in-out;
}

.scb-typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.scb-typing span:nth-child(3) {
	animation-delay: 0.3s;
}

@keyframes scbTyping {
	0%,
	80%,
	100% {
		transform: translateY(0);
		opacity: 0.45;
	}
	40% {
		transform: translateY(-4px);
		opacity: 1;
	}
}

@media (min-width: 782px) {
	.scb-widget--mobile-only {
		display: none;
	}
}

@media (max-width: 781px) {
	.scb-widget--desktop-only {
		display: none;
	}
}

@media (max-width: 480px) {
	/*
	 * On mobile each widget is anchored to its own side, not stretched
	 * full-width. The panel switches to position:fixed so it can span
	 * the full viewport width independently of the narrow widget container.
	 */
	.scb-widget {
		right: 10px;
		left: auto;
		bottom: 15px;
	}

	.scb-widget--left {
		left: 10px;
		right: auto;
		bottom: 15px;
	}

	.scb-launcher {
		max-width: calc(100vw - 20px);
	}

	/*
	 * Panel breaks out of the widget stacking context and becomes
	 * viewport-relative so it is always full-width on small screens,
	 * regardless of whether the launcher is on the left or right side.
	 * z-index is one above the widget (99990) to render on top.
	 */
	.scb-panel,
	.scb-widget--left .scb-panel {
		position: fixed;
		z-index: 99991;
		right: 10px;
		left: 10px;
		bottom: 15px;
		width: auto;
		height: min(620px, calc(100vh - 20px));
	}
}

/* Notification Bubble */
.scb-notification {
	position: absolute;
	bottom: 100%;
	right: 0;
	margin-bottom: 16px;
	background: #fff;
	border: 1px solid var(--scb-border);
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
	border-radius: 12px;
	padding: 12px 16px;
	padding-right: 36px;
	font-size: 14px;
	color: #111827;
	cursor: pointer;
	white-space: nowrap;
	opacity: 0;
	transform: translateY(10px) scale(0.95);
	transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
	transform-origin: bottom right;
	pointer-events: none;
}

.scb-widget--left .scb-notification {
	right: auto;
	left: 0;
	transform-origin: bottom left;
}

.scb-notification--pop {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.scb-notification::after {
	content: '';
	position: absolute;
	bottom: -6px;
	right: 20px;
	width: 12px;
	height: 12px;
	background: #fff;
	border-right: 1px solid var(--scb-border);
	border-bottom: 1px solid var(--scb-border);
	transform: rotate(45deg);
}

.scb-widget--left .scb-notification::after {
	right: auto;
	left: 20px;
}

.scb-notification__close {
	position: absolute;
	top: 50%;
	right: 8px;
	transform: translateY(-50%);
	background: transparent;
	border: none;
	width: 24px;
	height: 24px;
	padding: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #9ca3af;
	cursor: pointer;
	border-radius: 50%;
	transition: background-color 0.2s, color 0.2s;
}

.scb-notification__close:hover {
	background-color: #f3f4f6;
	color: #4b5563;
}
