/* Streamline chat widget. Uses the Streamline theme's variables when present. */

.sl-chat {
	--sl-chat-ink: var(--sl-charcoal, #15191d);
	--sl-chat-muted: var(--sl-steel, #56616b);
	--sl-chat-line: var(--sl-line, #dce3e7);
	--sl-chat-accent: var(--sl-cyan-deep, #0b6f96);
	margin-block: 2rem;
	font-size: 1rem;
}

.sl-chat .screen-reader-text,
.sl-chat__label {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
	white-space: nowrap;
}

.sl-chat__toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 48px;
	padding: 0.7rem 1.2rem;
	border: 0;
	border-radius: 999px;
	background: var(--sl-chat-ink);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 10px 30px -12px rgba(21, 25, 29, 0.6);
}

.sl-chat__toggle::before {
	content: "";
	width: 0.75rem;
	height: 0.75rem;
	border-radius: 50%;
	background: var(--sl-grad, linear-gradient(90deg, #2bb3e6, #e0762f));
}

.sl-chat__toggle:focus-visible,
.sl-chat button:focus-visible,
.sl-chat textarea:focus-visible,
.sl-chat a:focus-visible {
	outline: 3px solid var(--sl-chat-accent);
	outline-offset: 2px;
}

.sl-chat__panel {
	display: flex;
	flex-direction: column;
	width: min(24rem, calc(100vw - 2rem));
	max-height: min(38rem, calc(100vh - 8rem));
	max-height: min(38rem, calc(100dvh - 8rem)); /* Ignored where dvh is unsupported. */
	margin-top: 0.75rem;
	overflow: hidden;
	border: 1px solid var(--sl-chat-line);
	border-radius: 18px;
	background: #fff;
	box-shadow: 0 30px 60px -30px rgba(21, 25, 29, 0.55);
}

.sl-chat__panel[hidden] {
	display: none;
}

.sl-chat__head {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.75rem 0.75rem 0.75rem 1.25rem;
	background: var(--sl-chat-ink);
	color: #fff;
}

.sl-chat__head::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 2px;
	background: var(--sl-grad, linear-gradient(90deg, #2bb3e6, #e0762f));
}

.sl-chat .sl-chat__title {
	margin: 0;
	font-size: 1.125rem;
	color: #fff;
}

.sl-chat__close {
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: #fff;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
}

.sl-chat .sl-chat__new {
	margin-left: auto;
	min-height: 44px;
	padding: 0.4rem 0.75rem;
	border: 1px solid rgba(255, 255, 255, 0.45);
	border-radius: 10px;
	background: transparent;
	color: #fff;
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
}

.sl-chat__new[hidden],
.sl-chat__badge[hidden] {
	display: none;
}

.sl-chat__badge {
	margin-left: 0.25rem;
	padding: 0.1rem 0.5rem;
	border-radius: 999px;
	background: var(--sl-copper, #e0762f);
	color: #15191d;
	font-size: 0.8125rem;
}

.sl-chat__confirm {
	padding: 0.85rem 1rem;
	border: 1px solid var(--sl-chat-line);
	border-left: 4px solid var(--sl-chat-accent);
	border-radius: 12px;
	background: #fff;
}

.sl-chat__confirm p {
	margin: 0 0 0.5rem;
}

.sl-chat__confirm-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.sl-chat .sl-chat__secondary {
	min-height: 44px;
	padding: 0.5rem 0.9rem;
	border: 1.5px solid var(--sl-chat-ink);
	border-radius: 10px;
	background: #fff;
	color: var(--sl-chat-ink);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.sl-chat__intro,
.sl-chat__log {
	padding: 1rem 1.25rem;
	overflow-y: auto;
}

.sl-chat__intro[hidden],
.sl-chat__log[hidden],
.sl-chat__form[hidden] {
	display: none;
}

.sl-chat__intro p,
.sl-chat__msg p {
	margin: 0 0 0.75rem;
}

.sl-chat__privacy,
.sl-chat__fallback,
.sl-chat__note {
	font-size: 0.875rem;
	color: var(--sl-chat-muted);
}

.sl-chat__log {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.sl-chat__msg {
	max-width: 88%;
	padding: 0.6rem 0.85rem;
	border-radius: 14px;
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.sl-chat__msg p:last-child {
	margin-bottom: 0;
}

.sl-chat__msg--assistant {
	align-self: flex-start;
	background: var(--sl-mist, #eef2f4);
	color: var(--sl-chat-ink);
}

.sl-chat__msg--user {
	align-self: flex-end;
	background: var(--sl-chat-accent);
	color: #fff;
}

.sl-chat__msg--notice {
	align-self: stretch;
	max-width: none;
	background: #fdf3ec;
	color: var(--sl-chat-ink);
	font-size: 0.9375rem;
}

.sl-chat__msg--waiting {
	color: var(--sl-chat-muted);
	font-style: italic;
}

.sl-chat__handoff {
	padding: 0.85rem 1rem;
	border: 1px solid var(--sl-chat-line);
	border-left: 4px solid var(--sl-copper, #e0762f);
	border-radius: 12px;
	background: #fff;
}

.sl-chat__handoff-title {
	margin: 0 0 0.5rem;
	font-weight: 700;
}

.sl-chat__handoff dl {
	margin: 0 0 0.5rem;
	font-size: 0.9375rem;
}

.sl-chat__handoff dt {
	font-weight: 600;
	color: var(--sl-chat-muted);
}

.sl-chat__handoff dd {
	margin: 0 0 0.35rem;
	overflow-wrap: anywhere;
}

.sl-chat__missing {
	margin: 0 0 0.5rem;
	font-weight: 600;
	color: #a3290f;
}

.sl-chat__handoff form {
	margin: 0;
}

.sl-chat button.wp-element-button {
	min-height: 44px;
	border: 0;
	cursor: pointer;
}

.sl-chat__form {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	padding: 0.75rem;
	border-top: 1px solid var(--sl-chat-line);
}

.sl-chat__actions {
	display: flex;
	flex: 1 1 100%;
	justify-content: flex-end;
	gap: 0.5rem;
}

.sl-chat__speak,
.sl-chat__voice-cancel {
	min-height: 44px;
	min-width: 44px;
	padding: 0.5rem 0.9rem;
	border: 1.5px solid var(--sl-chat-ink);
	border-radius: 10px;
	background: #fff;
	color: var(--sl-chat-ink);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.sl-chat .sl-chat__send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	min-width: 44px;
	height: 44px;
	padding: 10px;
	flex-shrink: 0;
}

.sl-chat__send svg {
	display: block;
	flex-shrink: 0;
}

.sl-chat .sl-chat__send:disabled {
	opacity: 0.55;
	cursor: wait;
}

.sl-chat__voice-cancel {
	border-color: #c7d2d8;
	font-weight: 400;
}

.sl-chat__speak[disabled] {
	opacity: 0.55;
	cursor: not-allowed;
}

.sl-chat__speak.is-listening {
	border-color: #a3290f;
	color: #a3290f;
}

.sl-chat__speak.is-listening::before {
	content: "";
	display: inline-block;
	width: 0.6rem;
	height: 0.6rem;
	margin-right: 0.4rem;
	border-radius: 50%;
	background: #a3290f;
	animation: sl-chat-pulse 1.2s ease-in-out infinite;
}

@keyframes sl-chat-pulse {
	50% {
		opacity: 0.3;
	}
}

.sl-chat__voice-cancel[hidden] {
	display: none;
}

.sl-chat__voice-note,
.sl-chat__voice-status {
	flex: 1 1 100%;
	margin: 0;
	font-size: 0.8125rem;
	color: var(--sl-chat-muted);
}

.sl-chat__voice-status:empty {
	display: none;
}

.sl-chat__voice-status {
	color: var(--sl-chat-ink);
	font-weight: 600;
}

.sl-chat__form textarea {
	flex: 1 1 100%;
	min-height: 44px;
	padding: 0.6rem 0.75rem;
	border: 1.5px solid #c7d2d8;
	border-radius: 10px;
	font: inherit;
	resize: none;
}

/* Floating placement: bottom right, above the theme's mobile call bar. */
.sl-chat--floating {
	position: fixed;
	right: max(1rem, env(safe-area-inset-right));
	bottom: calc(1rem + env(safe-area-inset-bottom));
	z-index: 110; /* Keep the panel above the theme's sticky header (100). */
	margin: 0;
	display: flex;
	flex-direction: column-reverse;
	align-items: flex-end;
}

.sl-chat--floating .sl-chat__panel {
	margin: 0 0 0.75rem;
}

@media (max-width: 781px) {
	.sl-chat--floating {
		bottom: calc(5rem + env(safe-area-inset-bottom));
	}

	/* Leave room for the call bar below and the toggle button. */
	.sl-chat--floating .sl-chat__panel {
		max-height: calc(100vh - 11rem);
		max-height: calc(100dvh - 11rem);
	}
}

@media (prefers-reduced-motion: reduce) {
	.sl-chat * {
		animation: none !important;
		transition: none !important;
		scroll-behavior: auto !important;
	}
}
