/**
 * FAQ chatbot widget.
 *
 * @package PsychologiesV2
 */

.psy-chatbot {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 1200;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0.75rem;
	font-family: var(--psy-font-body);
}

.psy-chatbot[hidden] {
	display: none !important;
}

.psy-chatbot__teaser {
	position: relative;
	max-width: min(260px, calc(100vw - 6rem));
	padding: 0.85rem 2rem 0.85rem 1rem;
	background: var(--psy-surface);
	color: var(--psy-text);
	border: 1px solid var(--psy-card-border);
	border-radius: 16px 16px 4px 16px;
	box-shadow: var(--psy-shadow-md);
	animation: psy-chatbot-pop 280ms ease;
}

.psy-chatbot__teaser p {
	margin: 0;
	font-size: 0.875rem;
	line-height: 1.45;
	font-weight: 500;
}

.psy-chatbot__teaser-close {
	position: absolute;
	top: 0.35rem;
	right: 0.45rem;
	width: 1.5rem;
	height: 1.5rem;
	border: none;
	background: transparent;
	color: var(--psy-text-muted);
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
}

.psy-chatbot__launcher {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	min-height: 52px;
	padding: 0.7rem 1.05rem 0.7rem 0.85rem;
	border: none;
	border-radius: 999px;
	background: var(--psy-cta);
	color: #ffffff;
	box-shadow: 0 10px 28px rgba(205, 16, 19, 0.28);
	cursor: pointer;
	transition: transform var(--psy-transition-fast), background var(--psy-transition-fast);
}

.psy-chatbot__launcher:hover,
.psy-chatbot__launcher:focus-visible {
	background: var(--psy-cta-hover);
	transform: translateY(-2px);
	outline: none;
}

.psy-chatbot__launcher-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
}

.psy-chatbot__launcher-label {
	font-size: 0.875rem;
	font-weight: 600;
	white-space: nowrap;
}

.psy-chatbot__panel {
	width: min(360px, calc(100vw - 2rem));
	max-height: min(560px, calc(100vh - 6.5rem));
	display: flex;
	flex-direction: column;
	background: var(--psy-surface);
	color: var(--psy-text);
	border: 1px solid var(--psy-card-border);
	border-radius: 20px;
	box-shadow: var(--psy-shadow-md);
	overflow: hidden;
	animation: psy-chatbot-pop 220ms ease;
}

.psy-chatbot__panel[hidden] {
	display: none !important;
}

.psy-chatbot__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 1rem 1rem 0.85rem;
	background: var(--psy-surface-accent-soft);
	border-bottom: 1px solid var(--psy-card-border);
}

.psy-chatbot__eyebrow {
	margin: 0 0 0.2rem;
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--psy-cta);
}

.psy-chatbot__title {
	margin: 0;
	font-family: var(--psy-font-heading);
	font-size: 1.25rem;
	font-weight: 600;
	line-height: 1.2;
	color: var(--psy-text);
}

.psy-chatbot__close {
	width: 2rem;
	height: 2rem;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--psy-text-muted);
	font-size: 1.35rem;
	line-height: 1;
	cursor: pointer;
}

.psy-chatbot__close:hover,
.psy-chatbot__close:focus-visible {
	color: var(--psy-cta);
	outline: none;
}

.psy-chatbot__messages {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	background: var(--psy-background);
}

.psy-chatbot__bubble {
	max-width: 88%;
	padding: 0.75rem 0.9rem;
	border-radius: 14px;
	font-size: 0.875rem;
	line-height: 1.55;
	word-break: break-word;
}

.psy-chatbot__bubble a {
	color: var(--psy-cta);
	font-weight: 600;
	text-decoration: underline;
}

.psy-chatbot__bubble--bot {
	align-self: flex-start;
	background: var(--psy-surface-muted);
	color: var(--psy-text);
	border-bottom-left-radius: 4px;
}

.psy-chatbot__bubble--user {
	align-self: flex-end;
	background: var(--psy-cta);
	color: #ffffff;
	border-bottom-right-radius: 4px;
}

.psy-chatbot__bubble--typing {
	opacity: 0.75;
	font-style: italic;
}

.psy-chatbot__suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	padding: 0 1rem 0.75rem;
	background: var(--psy-background);
}

.psy-chatbot__suggestions button {
	padding: 0.4rem 0.7rem;
	border: 1px solid var(--psy-card-border);
	border-radius: 999px;
	background: var(--psy-surface);
	color: var(--psy-text);
	font-family: var(--psy-font-body);
	font-size: 0.75rem;
	font-weight: 600;
	cursor: pointer;
	transition: border-color var(--psy-transition-fast), color var(--psy-transition-fast);
}

.psy-chatbot__suggestions button:hover,
.psy-chatbot__suggestions button:focus-visible {
	border-color: var(--psy-cta);
	color: var(--psy-cta);
	outline: none;
}

.psy-chatbot__form {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.75rem 0.85rem 0.9rem;
	border-top: 1px solid var(--psy-card-border);
	background: var(--psy-surface);
}

.psy-chatbot__form input {
	flex: 1;
	min-width: 0;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--psy-input-border);
	border-radius: 999px;
	background: var(--psy-input-bg);
	color: var(--psy-text);
	font-family: var(--psy-font-body);
	font-size: 0.875rem;
}

.psy-chatbot__form input:focus,
.psy-chatbot__form input:focus-visible {
	outline: none;
	border-color: var(--psy-cta);
	box-shadow: 0 0 0 3px var(--psy-focus-ring);
}

.psy-chatbot__send {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border: none;
	border-radius: 50%;
	background: var(--psy-cta);
	color: #ffffff;
	cursor: pointer;
	transition: background var(--psy-transition-fast);
}

.psy-chatbot__send:hover,
.psy-chatbot__send:focus-visible {
	background: var(--psy-cta-hover);
	outline: none;
}

@keyframes psy-chatbot-pop {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@media (max-width: 575px) {
	.psy-chatbot {
		right: 0.85rem;
		bottom: 0.85rem;
	}

	.psy-chatbot__launcher-label {
		display: none;
	}

	.psy-chatbot__launcher {
		width: 54px;
		height: 54px;
		padding: 0;
		justify-content: center;
	}

	.psy-chatbot__launcher-icon {
		width: 100%;
		height: 100%;
		background: transparent;
	}

	.psy-chatbot__panel {
		width: calc(100vw - 1.7rem);
		max-height: min(70vh, 520px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.psy-chatbot__teaser,
	.psy-chatbot__panel,
	.psy-chatbot__launcher {
		animation: none;
		transition: none;
	}
}
