/* KD Chatbot widget. Everything is scoped under .kdcb and takes the site's font. */

.kdcb {
	--kdcb-primary: #2b5d8a;
	--kdcb-on-primary: #fff;
	--kdcb-bg: #fff;
	--kdcb-text: #23282d;
	--kdcb-muted: #5f6770;
	--kdcb-line: #dcdfe3;
	--kdcb-soft: #f2f3f5;
	--kdcb-danger: #b3261e;
	position: fixed;
	bottom: 20px;
	z-index: 99990;
	font-size: 16px;
	line-height: 1.45;
	color: var(--kdcb-text);
}

.kdcb--right {
	right: 30px;
}

.kdcb--left {
	left: 20px;
}

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

.kdcb [hidden] {
	display: none !important;
}

.kdcb button,
.kdcb input,
.kdcb textarea {
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	margin: 0;
}

.kdcb button {
	cursor: pointer;
}

.kdcb :focus-visible {
	outline: 0.5px solid var(--kdcb-primary);
}

/* Launcher */

.kdcb-launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	padding: 0;
	border: 2px solid var(--kdcb-on-primary);
	border-radius: 50%;
	background: var(--kdcb-primary);
	color: var(--kdcb-on-primary);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
	transition: transform 0.15s ease;
}

.kdcb--left .kdcb-launcher {
	margin-right: auto;
}

.kdcb--right .kdcb-launcher {
	margin-left: auto;
}

.kdcb-launcher:hover {
	transform: scale(1.06);
}

.kdcb-launcher:focus-visible {
	outline-color: var(--kdcb-text);
}

.kdcb-badge {
	position: absolute;
	top: 0;
	right: 0;
	width: 14px;
	height: 14px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: #d93025;
}

/* Panel */

.kdcb-panel {
	display: flex;
	flex-direction: column;
	width: 400px;
	max-width: calc(100vw - 40px);
	height: 700px;
	max-height: calc(100vh - 120px);
	margin-bottom: 12px;
	overflow: hidden;
	border-radius: 12px;
	background: var(--kdcb-bg);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
	animation: kdcb-in 0.18s ease-out;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-weight: 400;
}

@keyframes kdcb-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.kdcb-header {
	display: flex;
	align-items: center;
	gap: 4px;
	flex: 0 0 auto;
	padding: 12px 12px 12px 16px;
	background: var(--kdcb-primary);
	color: var(--kdcb-on-primary);
}

.kdcb .kdcb-title {
	flex: 1 1 auto;
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.3;
	color: inherit;
	text-transform: none;
}

.kdcb-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: inherit;
}

.kdcb-icon:hover {
	background: rgba(255, 255, 255, 0.18);
}

.kdcb-header :focus-visible {
	outline-color: var(--kdcb-on-primary);
}

/* Views */

.kdcb-view {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
}

.kdcb-view--center {
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 24px;
	text-align: center;
}

.kdcb-view--form {
	gap: 6px;
	padding: 16px;
	overflow-y: auto;
}

/* Messages */

.kdcb-messages {
	flex: 1 1 auto;
	min-height: 0;
	padding: 14px 14px 6px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.kdcb-msg {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	margin: 0 0 15px;
}

.kdcb-msg--user {
	align-items: flex-end;
}

.kdcb-bubble {
	max-width: 90%;
	padding: 10px 13px;
	border-radius: 14px 14px 14px 4px;
	background: var(--kdcb-soft);
	color: var(--kdcb-text);
	font-size: 14px;
	overflow-wrap: anywhere;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.kdcb-msg--user .kdcb-bubble {
	border-radius: 14px 14px 4px 14px;
	background: var(--kdcb-primary);
	color: var(--kdcb-on-primary);
	white-space: pre-wrap;
}

.kdcb-bubble a {
	color: inherit;
	font-weight: 600;
	text-decoration: underline;
}

.kdcb-disclaimer {
	margin: 0 0 15px;
	font-size: 13px;
	color: var(--kdcb-muted);
	text-align: center;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.kdcb-chips {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	margin: 0 0 12px;
}

.kdcb .kdcb-chip {
	padding: 7px 12px;
	border: 1px solid var(--kdcb-primary);
	border-radius: 16px;
	background: var(--kdcb-bg);
	color: var(--kdcb-primary);
	font-size: 13px;
	line-height: 1.3;
	text-align: left;
	margin-top: 15px;
}

.kdcb .kdcb-chip + .kdcb-chip {
	margin-top: 6px;
}

.kdcb .kdcb-chip:hover {
	background: var(--kdcb-primary);
	color: var(--kdcb-on-primary);
}

.kdcb-chip--offer {
	margin-top: 6px;
}

/* Typing indicator */

.kdcb-typing .kdcb-bubble {
	display: flex;
	gap: 4px;
	padding: 13px;
}

.kdcb-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--kdcb-muted);
	animation: kdcb-dot 1.2s infinite ease-in-out;
}

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

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

@keyframes kdcb-dot {
	0%,
	60%,
	100% {
		opacity: 0.3;
		transform: none;
	}
	30% {
		opacity: 1;
		transform: translateY(-3px);
	}
}

/* Composer */

.kdcb-warning {
	margin: 0;
	padding: 8px 14px;
	background: #fdecea;
	color: var(--kdcb-danger);
	font-size: 14px;
}

.kdcb-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex: 0 0 auto;
	margin: 0;
	padding: 10px 12px;
	border-top: 1px solid var(--kdcb-line);
}

.kdcb .kdcb-input,
.kdcb .kdcb-field {
	display: block;
	width: 100%;
	min-height: 0;
	padding: 11px 12px;
	border: 1px solid #8a9199;
	border-radius: 8px;
	background: #fff;
	color: var(--kdcb-text);
	font-size: 15px;
	line-height: 1.4;
	box-shadow: none;
}

.kdcb .kdcb-input {
	flex: 1 1 auto;
	min-height: 45px;
	max-height: 120px;
	resize: none;
}

.kdcb-hp {
	position: absolute !important;
	left: -9999px;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.kdcb-send {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 42px;
	width: 45px;
	height: 45px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: var(--kdcb-primary);
	color: var(--kdcb-on-primary);
}

.kdcb-send:disabled,
.kdcb-button:disabled {
	opacity: 0.5;
	cursor: default;
}

.kdcb-footer {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	flex: 0 0 auto;
	padding: 0 14px 10px;
}

.kdcb-footer .kdcb-link:only-child,
.kdcb-footer [hidden] + .kdcb-link {
	margin-left: auto;
}

.kdcb .kdcb-link {
	padding: 2px 0;
	border: 0;
	background: none;
	color: var(--kdcb-muted);
	font-size: 13px;
	text-decoration: underline;
}

.kdcb .kdcb-link:hover {
	color: var(--kdcb-text);
}

.kdcb .kdcb-button {
	padding: 10px 18px;
	border: 0;
	border-radius: 8px;
	background: var(--kdcb-primary);
	color: var(--kdcb-on-primary);
	font-size: 15px;
	font-weight: 600;
}

/* Rating */

.kdcb-fieldset {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.kdcb .kdcb-legend {
	width: auto;
	margin: 0 auto 8px;
	padding: 0;
	font-size: 17px;
	font-weight: 600;
	color: var(--kdcb-text);
}

.kdcb-stars {
	display: flex;
	justify-content: center;
	gap: 2px;
}

.kdcb-star-input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.kdcb .kdcb-star {
	margin: 0;
	padding: 0 3px;
	font-size: 34px;
	line-height: 1;
	color: #c5cad0;
	cursor: pointer;
}

.kdcb .kdcb-star.is-on {
	color: #e6a100;
}

.kdcb-star-input:focus-visible + .kdcb-star {
	outline: 3px solid var(--kdcb-primary);
	outline-offset: 2px;
	border-radius: 4px;
}

.kdcb-thanks {
	margin: 0;
	font-size: 17px;
}

.kdcb-thanks:focus {
	outline: none;
}

/* Leave a message */

.kdcb-intro {
	margin: 0 0 6px;
	font-size: 14px;
	color: var(--kdcb-muted);
}

.kdcb .kdcb-label {
	display: block;
	margin: 6px 0 0;
	font-size: 14px;
	font-weight: 600;
	color: var(--kdcb-text);
}

.kdcb-view--form .kdcb-warning {
	border-radius: 6px;
}

.kdcb-view--form .kdcb-button {
	margin-top: 10px;
}

.kdcb-view--form .kdcb-link {
	align-self: center;
	margin-top: 4px;
}

/* Small screens: a full-height sheet */

@media (max-width: 575.98px) {
	.kdcb {
		bottom: 14px;
	}

	.kdcb--right {
		right: 14px;
	}

	.kdcb--left {
		left: 14px;
	}

	.kdcb--open {
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
	}

	.kdcb--open .kdcb-panel {
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none;
		margin: 0;
		border-radius: 0;
	}

	.kdcb--open .kdcb-launcher {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.kdcb-panel,
	.kdcb-typing span {
		animation: none;
	}

	.kdcb-launcher {
		transition: none;
	}
}
