/**
 * Czat leadowy — design inspirowany komponentami chat shadcn/ui.
 * Wszystko w zakresie .sf-chat, żeby nie kolidowało z resztą motywu.
 */

.sf-chat {
	position: relative;
	isolation: isolate;
	display: flex;
	flex: 0 0 auto;
	flex-direction: column;
	width: 100%;
	min-width: 0;
	max-width: 560px;
	height: 680px;
	min-height: 680px;
	max-height: 680px;
	box-sizing: border-box;
	border: 1px solid #e2e4e8;
	border-radius: 18px;
	background: var(--sf-white);
	box-shadow: 0 24px 48px rgb(28 30 44 / 10%);
	overflow: hidden;
	font-family: var(--sf-font-body);
}

.sf-chat::before {
	position: absolute;
	inset: 0;
	z-index: 3;
	border: 2px solid transparent;
	border-image: conic-gradient(
			from var(--sf-contact-angle, 0deg),
			transparent 0deg 315deg,
			rgb(255 255 255 / 24%) 330deg,
			var(--sf-gold) 342deg,
			#fff 350deg,
			rgb(229 183 110 / 82%) 356deg,
			transparent 360deg
		)
		1;
	opacity: 0;
	filter: blur(0.8px);
	content: "";
	pointer-events: none;
	transition: opacity 0.85s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.sf-chat.is-engaged {
	animation: sf-contact-glow 4.2s ease-in-out 0.4s infinite;
}

.sf-chat.is-engaged::before {
	opacity: 1;
	animation: sf-contact-gradient-orbit 2.6s linear infinite;
	transition-duration: 0.7s;
}

.sf-chat__header {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 12px;
	padding: 14px 18px;
	border-bottom: 1px solid #ececee;
	background: var(--sf-white);
}
.sf-chat__avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: contain;
	border: 1px solid #ececee;
}
.sf-chat__meta {
	display: flex;
	flex-direction: column;
	gap: 1px;
}
.sf-chat__meta strong {
	font-size: 13.5px;
	font-weight: 600;
	color: var(--sf-ink);
}
.sf-chat__status {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--sf-muted);
	font-size: 11.5px;
}
.sf-chat__status i {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #22c55e;
	box-shadow: 0 0 0 3px rgb(34 197 94 / 15%);
}
.sf-chat__step {
	margin-left: auto;
	color: #9aa1ab;
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.02em;
}

.sf-chat__sound {
	display: grid;
	flex: 0 0 auto;
	place-items: center;
	width: 30px;
	height: 30px;
	padding: 0;
	border: 1px solid #e2e4e8;
	border-radius: 50%;
	background: var(--sf-white);
	color: #535b65;
	cursor: pointer;
	transition:
		color 0.15s ease,
		border-color 0.15s ease;
}

.sf-chat__sound .sf-icon {
	width: 15px;
	height: 15px;
}

.sf-chat__sound.is-muted .sf-icon--sound-on,
.sf-chat__sound:not(.is-muted) .sf-icon--sound-off {
	display: none;
}

.sf-chat__sound:hover {
	color: var(--sf-blue);
	border-color: var(--sf-blue);
}
.sf-chat__sound:focus-visible {
	outline: 2px solid var(--sf-pink);
	outline-offset: 2px;
}

.sf-chat__messages {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-height: 0;
	padding: 18px 16px 10px;
	overflow-y: auto;
	background: #f7f8fa;
	scrollbar-width: thin;
}

.sf-message-row {
	display: flex;
	width: 100%;
	align-items: flex-end;
	gap: 8px;
	max-width: 100%;
}
.sf-message-row--bot {
	justify-content: flex-start;
}
.sf-message-row--user {
	justify-content: flex-end;
}
.sf-message-row--user .sf-message__avatar {
	order: 2;
}
.sf-message__avatar {
	display: grid;
	width: 28px;
	height: 28px;
	flex: 0 0 28px;
	place-items: center;
	overflow: hidden;
	border: 1px solid #e2e4e8;
	border-radius: 50%;
	background: var(--sf-white);
	object-fit: cover;
}
.sf-message__avatar--user {
	border-color: #dbe8f5;
	background: #eaf2fa;
	color: var(--sf-blue);
	font-size: 9px;
	font-weight: 600;
}
.sf-bubble {
	max-width: calc(86% - 34px);
	padding: 11px 15px;
	font-size: 14px;
	line-height: 1.5;
	animation: sf-bubble-in 0.32s cubic-bezier(0.2, 0.8, 0.3, 1.1) both;
}
@keyframes sf-bubble-in {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.97);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
.sf-bubble--bot {
	background: var(--sf-white);
	border: 1px solid #e6e8ec;
	border-radius: 16px 16px 16px 5px;
	color: #2c2b30;
}
.sf-bubble--user {
	background: var(--sf-blue);
	border-radius: 16px 16px 5px 16px;
	color: var(--sf-white);
}
.sf-bubble--user strong {
	font-weight: 600;
}
.sf-bubble--typing {
	display: flex;
	gap: 5px;
	align-items: center;
	padding: 14px 16px;
}
.sf-bubble--typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #b9c1cc;
	animation: sf-typing 1.1s ease-in-out infinite;
}
.sf-bubble--typing span:nth-child(2) {
	animation-delay: 0.15s;
}
.sf-bubble--typing span:nth-child(3) {
	animation-delay: 0.3s;
}
@keyframes sf-typing {
	0%,
	60%,
	100% {
		transform: translateY(0);
		opacity: 0.55;
	}
	30% {
		transform: translateY(-5px);
		opacity: 1;
	}
}
.sf-bubble__row {
	display: flex;
	justify-content: space-between;
	gap: 18px;
	padding: 3px 0;
}
.sf-bubble__row + .sf-bubble__row {
	border-top: 1px solid #f0f1f3;
}
.sf-bubble__row span {
	color: var(--sf-muted);
}
.sf-bubble__row strong {
	font-weight: 500;
	text-align: right;
}

.sf-chat__chips {
	display: flex;
	flex: 0 0 auto;
	flex-wrap: wrap;
	gap: 8px;
	max-height: 160px;
	overflow-y: auto;
	padding: 10px 16px 4px;
	background: var(--sf-white);
}
.sf-chat__chips[hidden] {
	display: none;
}
.sf-chip {
	padding: 9px 15px;
	border: 1px solid #d9dce2;
	border-radius: 999px;
	background: var(--sf-white);
	color: #34363c;
	font-family: var(--sf-font-body);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition:
		border-color 0.16s ease,
		background-color 0.16s ease,
		color 0.16s ease,
		transform 0.16s ease;
}
.sf-chip:hover,
.sf-chip:focus-visible {
	border-color: var(--sf-blue);
	background: #eef4fb;
	color: var(--sf-blue);
}
.sf-chip:active {
	transform: scale(0.97);
}
.sf-chip--primary {
	border-color: var(--sf-blue);
	background: var(--sf-blue);
	color: var(--sf-white);
}
.sf-chip--primary:hover {
	border-color: var(--sf-blue-dark);
	background: var(--sf-blue-dark);
	color: var(--sf-white);
}

.sf-chat .sf-select {
	width: 100%;
	padding: 11px 38px 11px 14px;
	border: 1px solid #d9dce2;
	border-radius: 12px;
	background-color: var(--sf-white);
	color: #34363c;
	font-family: var(--sf-font-body);
	font-size: 13.5px;
	cursor: pointer;
}

.sf-chat__input {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 8px;
	padding: 10px 14px 12px;
	background: var(--sf-white);
}
.sf-chat__input[hidden] {
	display: none;
}
.sf-chat__field {
	flex: 1;
	padding: 11px 16px;
	border: 1px solid #d9dce2;
	border-radius: 999px;
	background: #f7f8fa;
	color: var(--sf-ink);
	font-family: var(--sf-font-body);
	font-size: 13.5px;
	transition:
		border-color 0.16s ease,
		box-shadow 0.16s ease;
}
.sf-chat__field:focus {
	outline: none;
	border-color: var(--sf-blue);
	box-shadow: 0 0 0 3px rgb(30 115 190 / 14%);
}
.sf-chat__field.is-invalid {
	border-color: var(--sf-pink);
	box-shadow: 0 0 0 3px rgb(255 45 123 / 14%);
}
.sf-chat__send {
	display: grid;
	width: 42px;
	height: 42px;
	place-items: center;
	flex: 0 0 auto;
	border: 0;
	border-radius: 50%;
	background: var(--sf-blue);
	color: var(--sf-white);
	cursor: pointer;
	transition:
		background-color 0.16s ease,
		transform 0.16s ease;
}
.sf-chat__send:hover {
	background: var(--sf-blue-dark);
}
.sf-chat__send:active {
	transform: scale(0.94);
}
.sf-chat__send .sf-icon {
	filter: brightness(0) invert(1);
}

.sf-chat__foot {
	flex: 0 0 auto;
	padding: 9px 16px;
	border-top: 1px solid #ececee;
	background: var(--sf-white);
	color: #9aa1ab;
	font-size: 11px;
	text-align: center;
}

@media (max-width: 1024px), (any-pointer: coarse) {
	.sf-chat__field,
	.sf-chat .sf-select {
		font-size: 16px;
	}
}

@media (max-width: 780px) {
	.sf-chat {
		width: 100%;
		max-width: 560px;
		height: 620px;
		min-height: 620px;
		max-height: 620px;
		margin-inline: auto;
	}
	.sf-chat__sound {
		width: 44px;
		height: 44px;
	}
	.sf-bubble {
		font-size: 13.5px;
	}
}

@media (max-width: 430px) {
	.sf-chat__header {
		gap: 8px;
		padding: 12px;
	}
	.sf-chat__avatar {
		width: 36px;
		height: 36px;
	}
	.sf-chat__meta {
		min-width: 0;
	}
	.sf-chat__step {
		flex: 0 0 auto;
		font-size: 10px;
		white-space: nowrap;
	}
	.sf-chat__sound {
		width: 44px;
		height: 44px;
	}
}
@media (max-width: 360px) {
	.sf-chat__header {
		display: grid;
		grid-template-columns: 36px minmax(0, 1fr) 44px;
		grid-template-areas: "avatar meta sound" "avatar step sound";
		gap: 3px 8px;
		padding: 10px 12px;
	}
	.sf-chat__avatar {
		grid-area: avatar;
	}
	.sf-chat__meta {
		grid-area: meta;
	}
	.sf-chat__meta strong {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.sf-chat__status {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.sf-chat__step {
		grid-area: step;
		margin-left: 0;
	}
	.sf-chat__sound {
		grid-area: sound;
		align-self: center;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sf-chat.is-engaged {
		animation: none;
		box-shadow:
			0 16px 42px -20px rgb(30 115 190 / 42%),
			0 24px 58px -28px rgb(229 183 110 / 32%);
	}
	.sf-chat.is-engaged::before {
		animation: none;
		opacity: 1;
	}
}


/* Consent checkbox inside the homepage chat summary. */
.sf-chat__consent {
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid #e6e8eb;
	color: #6d7275;
	font-size: 11px;
	line-height: 1.5;
	text-align: left;
}

.sf-chat__consent label {
	display: flex;
	align-items: flex-start;
	gap: 8px;
}

.sf-chat__consent input {
	flex: 0 0 15px;
	width: 15px;
	height: 15px;
	margin: 1px 0 0;
	accent-color: var(--sf-blue);
}

.sf-chat__consent a {
	color: var(--sf-blue);
	text-decoration: underline;
}

.sf-chip:disabled {
	cursor: not-allowed;
	opacity: 0.5;
}
@media (max-width: 360px) {
	.sf-chat__meta strong {
		overflow: visible;
		font-size: 12px;
		line-height: 1.25;
		white-space: normal;
	}

	.sf-chat__status {
		overflow: visible;
		white-space: normal;
		line-height: 1.3;
	}
}
