/**
 * Softlance AI Chat Assistant
 */

/* ── Launcher + panel shell ── */
.slrc-chat {
	--slrc-chat-accent: #0ea5e9;
	--slrc-chat-accent-dark: #0284c7;
	--slrc-chat-bg: #ffffff;
	--slrc-chat-header: linear-gradient(135deg, #0a1128 0%, #1e3a8a 55%, #0284c7 100%);
	--slrc-chat-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 1000;
	font-family: 'Plus Jakarta Sans', Poppins, system-ui, sans-serif;
	font-size: 16px;
	line-height: 1.5;
	color: #0f172a;
	box-sizing: border-box;
}

.slrc-chat *,
.slrc-chat *::before,
.slrc-chat *::after {
	box-sizing: border-box;
}

.slrc-chat__launcher {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-width: 3.5rem;
	height: 3.5rem;
	padding: 0 1.125rem;
	border: none;
	border-radius: 999px;
	background: linear-gradient(135deg, var(--slrc-chat-accent-dark), var(--slrc-chat-accent));
	color: #fff;
	font-size: 0.9375rem;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 10px 32px rgba(14, 165, 233, 0.45);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.slrc-chat__launcher:hover {
	transform: translateY(-2px);
	box-shadow: 0 14px 40px rgba(14, 165, 233, 0.55);
}

.slrc-chat__launcher-icon {
	display: inline-flex;
	width: 1.375rem;
	height: 1.375rem;
}

.slrc-chat__launcher-label {
	display: none;
}

.slrc-chat.is-open .slrc-chat__launcher {
	display: none;
}

.slrc-chat__panel {
	position: absolute;
	right: 0;
	bottom: 0;
	width: min(400px, calc(100vw - 2rem));
	height: min(640px, calc(100vh - 2rem));
	max-height: calc(100dvh - 2rem);
	display: flex;
	flex-direction: column;
	background: var(--slrc-chat-bg);
	border-radius: 1.25rem;
	box-shadow: var(--slrc-chat-shadow);
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px) scale(0.96);
	transform-origin: bottom right;
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.slrc-chat.is-open .slrc-chat__panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

/* ── Header ── */
.slrc-chat__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 1rem 1.125rem;
	background: var(--slrc-chat-header);
	color: #fff;
	flex-shrink: 0;
}

.slrc-chat__header-info {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	min-width: 0;
}

.slrc-chat__avatar {
	width: 2.5rem;
	height: 2.5rem;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.15);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 1.125rem;
}

.slrc-chat__title {
	margin: 0;
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.2;
}

.slrc-chat__status {
	margin: 0.125rem 0 0;
	font-size: 0.75rem;
	color: rgba(255, 255, 255, 0.82);
	display: flex;
	align-items: center;
	gap: 0.375rem;
}

.slrc-chat__status-dot {
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
}

.slrc-chat__close {
	width: 2.75rem;
	height: 2.75rem;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.slrc-chat__close:hover {
	background: rgba(255, 255, 255, 0.22);
}

/* ── Messages ── */
.slrc-chat__body {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: #f8fafc;
}

.slrc-chat__messages {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	scroll-behavior: smooth;
}

.slrc-chat__msg {
	max-width: 88%;
	padding: 0.75rem 0.9375rem;
	border-radius: 1rem;
	font-size: 0.875rem;
	line-height: 1.55;
	word-break: break-word;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.22s ease, transform 0.22s ease;
}

.slrc-chat__msg.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.slrc-chat__msg--streaming {
	min-height: 2.5rem;
}

/* ── Pre-stream loader ── */
.slrc-chat__msg--loader {
	max-width: 92%;
	padding: 0.75rem 0.875rem;
	background: #fff;
	border: 1px solid #e2e8f0;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.slrc-chat__loader-inner {
	display: flex;
	align-items: center;
	gap: 0.625rem;
}

.slrc-chat__loader-avatar {
	width: 2rem;
	height: 2rem;
	border-radius: 50%;
	background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
	color: #0284c7;
	font-size: 0.875rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	position: relative;
}

.slrc-chat__loader-avatar::after {
	content: '';
	position: absolute;
	inset: -2px;
	border-radius: 50%;
	border: 2px solid transparent;
	border-top-color: var(--slrc-chat-accent);
	animation: slrc-chat-spin 0.85s linear infinite;
}

.slrc-chat__loader-body {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 0;
}

.slrc-chat__loader-dots {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	height: 0.5rem;
}

.slrc-chat__loader-dots span {
	width: 0.4375rem;
	height: 0.4375rem;
	border-radius: 50%;
	background: var(--slrc-chat-accent);
	animation: slrc-chat-bounce 1.2s infinite ease-in-out;
}

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

.slrc-chat__loader-text {
	font-size: 0.8125rem;
	color: #64748b;
	line-height: 1.35;
	animation: slrc-chat-loader-pulse 1.6s ease-in-out infinite;
}

@keyframes slrc-chat-spin {
	to { transform: rotate(360deg); }
}

@keyframes slrc-chat-loader-pulse {
	0%, 100% { opacity: 0.72; }
	50% { opacity: 1; }
}

.slrc-chat__cursor {
	display: inline-block;
	width: 2px;
	height: 1em;
	margin-left: 1px;
	vertical-align: text-bottom;
	background: var(--slrc-chat-accent);
	animation: slrc-chat-cursor 0.9s step-end infinite;
}

@keyframes slrc-chat-cursor {
	0%, 100% { opacity: 1; }
	50% { opacity: 0; }
}

.slrc-chat__msg--bot {
	align-self: flex-start;
	background: #fff;
	color: #334155;
	border: 1px solid #e2e8f0;
	border-bottom-left-radius: 0.25rem;
}

.slrc-chat__msg--bot a {
	color: #0284c7;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.slrc-chat__msg--bot a:hover {
	color: #0369a1;
}

.slrc-chat__msg--user {
	align-self: flex-end;
	background: linear-gradient(135deg, var(--slrc-chat-accent-dark), var(--slrc-chat-accent));
	color: #fff;
	border-bottom-right-radius: 0.25rem;
}

.slrc-chat__msg--typing {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	padding: 0.875rem 1rem;
}

.slrc-chat__typing-dot {
	width: 0.4375rem;
	height: 0.4375rem;
	border-radius: 50%;
	background: #94a3b8;
	animation: slrc-chat-bounce 1.2s infinite ease-in-out;
}

.slrc-chat__typing-dot:nth-child(2) { animation-delay: 0.15s; }
.slrc-chat__typing-dot:nth-child(3) { animation-delay: 0.3s; }

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

/* ── Quick replies ── */
.slrc-chat__quick {
	display: flex;
	flex-wrap: wrap;
	gap: 0.375rem;
	padding: 0 1rem 0.75rem;
	flex-shrink: 0;
}

.slrc-chat__quick-btn {
	padding: 0.625rem 0.75rem;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	border-radius: 999px;
	border: 1px solid #bae6fd;
	background: #fff;
	color: #0369a1;
	font-size: 0.75rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s;
}

.slrc-chat__quick-btn:hover {
	background: #e0f2fe;
	border-color: #0ea5e9;
}

/* ── Input area ── */
.slrc-chat__footer {
	padding: 0.75rem 1rem 0.875rem;
	background: #fff;
	border-top: 1px solid #e2e8f0;
	flex-shrink: 0;
}

.slrc-chat .slrc-chat__form {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	width: 100%;
	margin: 0;
	padding: 0;
	gap: 0.375rem;
}

.slrc-chat__composer {
	display: flex;
	flex-direction: row;
	align-items: flex-end;
	gap: 0.5rem;
	width: 100%;
	min-width: 0;
	padding: 0.375rem 0.375rem 0.375rem 0.875rem;
	border: 1px solid #e2e8f0;
	border-radius: 1rem;
	background: #f8fafc;
	box-sizing: border-box;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.slrc-chat__composer:focus-within {
	border-color: var(--slrc-chat-accent);
	box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
	background: #fff;
}

.slrc-chat .slrc-chat__input-hint {
	display: block;
	width: 100%;
	margin: 0;
	padding: 0 0.25rem;
	font-size: 0.6875rem;
	font-weight: 400;
	color: #94a3b8;
	line-height: 1.35;
	text-align: center;
}

.slrc-chat.is-sending .slrc-chat__input-hint {
	color: #64748b;
}

.slrc-chat .slrc-chat__footer p {
	margin: 0;
}

.slrc-chat .slrc-chat__input {
	display: block;
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
	min-height: 2.25rem;
	max-height: 6rem;
	margin: 0;
	padding: 0.5rem 0;
	border: none;
	border-radius: 0;
	font-size: 0.875rem;
	line-height: 1.45;
	resize: none;
	font-family: inherit;
	color: #0f172a;
	background: transparent;
	box-shadow: none;
	overflow-y: auto;
	appearance: none;
	-webkit-appearance: none;
}

.slrc-chat .slrc-chat__input:disabled {
	opacity: 0.72;
	cursor: wait;
}

.slrc-chat .slrc-chat__input:focus {
	outline: none;
	border: none;
	box-shadow: none;
	background: transparent;
}

.slrc-chat .slrc-chat__input::placeholder {
	color: #94a3b8;
}

.slrc-chat .slrc-chat__send {
	width: 2.5rem;
	height: 2.5rem;
	min-width: 2.5rem;
	min-height: 2.5rem;
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--slrc-chat-accent-dark), var(--slrc-chat-accent));
	color: #fff;
	cursor: pointer;
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.slrc-chat .slrc-chat__send svg {
	display: block;
	width: 1.125rem;
	height: 1.125rem;
}

.slrc-chat .slrc-chat__send:hover:not(:disabled) {
	transform: scale(1.05);
}

.slrc-chat .slrc-chat__send:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	transform: none;
}

.slrc-chat.is-sending .slrc-chat__send svg {
	animation: slrc-chat-send-pulse 1s ease-in-out infinite;
}

@keyframes slrc-chat-send-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.45; }
}

.slrc-chat__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.375rem;
	margin-top: 0.625rem;
	padding-top: 0.625rem;
	border-top: 1px solid #f1f5f9;
}

.slrc-chat__action-link {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	padding: 0.3125rem 0.625rem;
	border-radius: 999px;
	background: #f1f5f9;
	color: #475569;
	font-size: 0.6875rem;
	font-weight: 600;
	text-decoration: none;
}

.slrc-chat__action-link:hover {
	background: #e0f2fe;
	color: #0284c7;
}

/* ── Lead capture overlay ── */
.slrc-chat__lead {
	display: none;
	flex-direction: column;
	padding: 1rem;
	background: #fff;
	border-top: 1px solid #e2e8f0;
	flex-shrink: 0;
}

.slrc-chat__lead.is-visible {
	display: flex;
}

.slrc-chat__lead-title {
	margin: 0 0 0.375rem;
	font-size: 0.9375rem;
	font-weight: 700;
	color: #0f172a;
}

.slrc-chat__lead-desc {
	margin: 0 0 0.875rem;
	font-size: 0.8125rem;
	color: #64748b;
	line-height: 1.5;
}

.slrc-chat__lead-field {
	margin-bottom: 0.625rem;
}

.slrc-chat__lead-field label {
	display: block;
	margin-bottom: 0.25rem;
	font-size: 0.75rem;
	font-weight: 600;
	color: #475569;
}

.slrc-chat__lead-field input,
.slrc-chat__lead-field textarea,
.slrc-chat__lead-field select {
	width: 100%;
	padding: 0.5625rem 0.75rem;
	border: 1px solid #e2e8f0;
	border-radius: 0.625rem;
	font-size: 0.8125rem;
	font-family: inherit;
	color: #0f172a;
	background: #f8fafc;
}

.slrc-chat__lead-field input:focus,
.slrc-chat__lead-field textarea:focus,
.slrc-chat__lead-field select:focus {
	outline: none;
	border-color: var(--slrc-chat-accent);
	box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.slrc-chat__lead-field textarea {
	min-height: 4rem;
	resize: vertical;
}

.slrc-chat__lead-submit {
	width: 100%;
	margin-top: 0.375rem;
	padding: 0.75rem;
	border: none;
	border-radius: 0.75rem;
	background: linear-gradient(135deg, var(--slrc-chat-accent-dark), var(--slrc-chat-accent));
	color: #fff;
	font-size: 0.875rem;
	font-weight: 700;
	cursor: pointer;
	transition: opacity 0.15s;
}

.slrc-chat__lead-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.slrc-chat__lead-message {
	margin-top: 0.5rem;
	font-size: 0.8125rem;
	line-height: 1.45;
}

.slrc-chat__lead-message.is-success { color: #059669; }
.slrc-chat__lead-message.is-error { color: #dc2626; }

.slrc-chat__lead-cancel {
	margin-top: 0.5rem;
	padding: 0;
	border: none;
	background: none;
	color: #64748b;
	font-size: 0.75rem;
	cursor: pointer;
	text-decoration: underline;
}

/* ── Adjust floating CTA when chat is enabled ── */
body.slrc-chat-enabled .softlance-floating-cta {
	bottom: 5.25rem;
}

body.slrc-chat-open .softlance-floating-cta {
	opacity: 0 !important;
	pointer-events: none !important;
}

body.slrc-chat-open .sl-city-mobile-cta,
body.slrc-chat-open .sl-service-sticky-cta {
	display: none !important;
}

/* ── Responsive ── */
@media (min-width: 480px) {
	.slrc-chat__launcher-label {
		display: inline;
	}
}

@media (max-width: 480px) {
	.slrc-chat {
		right: 0.75rem;
		bottom: 0.75rem;
	}

	.slrc-chat__panel {
		width: calc(100vw - 1.5rem);
		height: calc(100dvh - 1.5rem);
		max-height: calc(100dvh - 1.5rem);
		border-radius: 1rem;
	}

	body.slrc-chat-enabled .softlance-floating-cta {
		bottom: 4.75rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.slrc-chat__panel,
	.slrc-chat__launcher,
	.slrc-chat__typing-dot,
	.slrc-chat__loader-dots span,
	.slrc-chat__loader-avatar::after,
	.slrc-chat__loader-text {
		transition: none;
		animation: none;
	}
}
