/* chatbot.css — Widget chatbot Brightway. Tokens du thème uniquement. */

#bw-chatbot-root {
	position: fixed;
	right: var(--space-5);
	bottom: var(--space-5);
	z-index: 9990;
	font-family: var(--font-body);
}

/* ── Launcher (bulle flottante) ──────────────────────────────────── */

.bw-chatbot__launcher {
	width: 56px;
	height: 56px;
	border-radius: 9999px;
	border: none;
	background: var(--accent);
	color: var(--bw-white);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--shadow-2);
	transition: transform var(--transition), background-color var(--transition);
	position: relative;
}

.bw-chatbot__launcher:hover {
	background: var(--accent-hover);
	transform: translateY(-2px);
}

.bw-chatbot__launcher:focus-visible {
	outline: 2px solid var(--bw-blue);
	outline-offset: 3px;
}

.bw-chatbot__launcher-icon {
	position: absolute;
	transition: opacity var(--transition), transform var(--transition);
}

.bw-chatbot__launcher-icon--close {
	opacity: 0;
	transform: rotate(-90deg);
}

.bw-chatbot__launcher--open .bw-chatbot__launcher-icon:not(.bw-chatbot__launcher-icon--close) {
	opacity: 0;
	transform: rotate(90deg);
}

.bw-chatbot__launcher--open .bw-chatbot__launcher-icon--close {
	opacity: 1;
	transform: rotate(0);
}

/* ── Window (fenêtre de chat) ────────────────────────────────────── */

.bw-chatbot__window {
	position: absolute;
	bottom: calc(56px + var(--space-3));
	right: 0;
	width: 380px;
	max-width: calc(100vw - var(--space-8));
	height: 520px;
	max-height: calc(100vh - 120px);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-2);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	animation: bw-chatbot-in 200ms ease;
}

.bw-chatbot__window[hidden] {
	display: none;
}

@keyframes bw-chatbot-in {
	from { opacity: 0; transform: translateY(8px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	.bw-chatbot__window,
	.bw-chatbot__launcher,
	.bw-chatbot__launcher-icon {
		animation: none;
		transition: none;
	}
}

/* ── Header ──────────────────────────────────────────────────────── */

.bw-chatbot__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--space-3);
	padding: var(--space-4) var(--space-5);
	background: var(--accent);
	color: var(--bw-white);
}

.bw-chatbot__header-text {
	flex: 1;
	min-width: 0;
}

.bw-chatbot__title {
	margin: 0;
	font-size: var(--text-md);
	font-weight: var(--fw-semi);
	line-height: var(--lh-tight);
}

.bw-chatbot__subtitle {
	margin: var(--space-1) 0 0;
	font-size: var(--text-xs);
	opacity: 0.85;
	line-height: var(--lh-snug);
}

.bw-chatbot__close {
	background: transparent;
	border: none;
	color: inherit;
	cursor: pointer;
	padding: var(--space-1);
	border-radius: var(--radius-sm);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color var(--transition);
}

.bw-chatbot__close:hover {
	background: rgb(255 255 255 / 0.15);
}

.bw-chatbot__close:focus-visible {
	outline: 2px solid var(--bw-white);
	outline-offset: 2px;
}

/* ── Messages ────────────────────────────────────────────────────── */

.bw-chatbot__messages {
	flex: 1;
	overflow-y: auto;
	padding: var(--space-4);
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	background: var(--bg);
	scrollbar-width: thin;
	scrollbar-color: var(--border) transparent;
}

.bw-chatbot__messages::-webkit-scrollbar {
	width: 6px;
}

.bw-chatbot__messages::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 3px;
}

.bw-chatbot__msg {
	display: flex;
	max-width: 85%;
}

.bw-chatbot__msg--user {
	align-self: flex-end;
	justify-content: flex-end;
}

.bw-chatbot__msg--assistant {
	align-self: flex-start;
}

.bw-chatbot__bubble {
	padding: var(--space-3) var(--space-4);
	border-radius: var(--radius-lg);
	font-size: var(--text-sm);
	line-height: var(--lh-snug);
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.bw-chatbot__msg--user .bw-chatbot__bubble {
	background: var(--accent);
	color: var(--bw-white);
	border-bottom-right-radius: var(--radius-sm);
}

.bw-chatbot__msg--assistant .bw-chatbot__bubble {
	background: var(--surface);
	color: var(--fg);
	border-bottom-left-radius: var(--radius-sm);
}

.bw-chatbot__bubble p {
	margin: 0;
}

.bw-chatbot__bubble p + p {
	margin-top: var(--space-2);
}

.bw-chatbot__bubble a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.bw-chatbot__msg--user .bw-chatbot__bubble a {
	color: var(--bw-white);
}

/* ── Indicateur "thinking" ──────────────────────────────────────── */

.bw-chatbot__dots {
	display: inline-flex;
	gap: 4px;
	align-items: center;
	min-height: 1em;
}

.bw-chatbot__dots span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--fg-muted, var(--bw-gray-muted));
	animation: bw-chatbot-bounce 1.2s infinite ease-in-out both;
}

.bw-chatbot__dots span:nth-child(2) { animation-delay: 0.16s; }
.bw-chatbot__dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bw-chatbot-bounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
	40%           { transform: scale(1);   opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.bw-chatbot__dots span { animation: none; }
}

/* ── Form ────────────────────────────────────────────────────────── */

.bw-chatbot__form {
	display: flex;
	align-items: flex-end;
	gap: var(--space-2);
	padding: var(--space-3) var(--space-4);
	border-top: 1px solid var(--border);
	background: var(--bg);
}

.bw-chatbot__input {
	flex: 1;
	min-height: 40px;
	max-height: 120px;
	padding: var(--space-2) var(--space-3);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	background: var(--bg);
	color: var(--fg);
	font: inherit;
	font-size: var(--text-sm);
	line-height: var(--lh-normal);
	resize: none;
	overflow-y: auto;
	transition: border-color var(--transition);
}

.bw-chatbot__input:focus {
	outline: none;
	border-color: var(--accent);
}

.bw-chatbot__input:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.bw-chatbot__send {
	width: 40px;
	height: 40px;
	flex-shrink: 0;
	border: none;
	border-radius: var(--radius-md);
	background: var(--accent);
	color: var(--bw-white);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color var(--transition);
}

.bw-chatbot__send:hover:not(:disabled) {
	background: var(--accent-hover);
}

.bw-chatbot__send:focus-visible {
	outline: 2px solid var(--bw-blue);
	outline-offset: 2px;
}

.bw-chatbot__send:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* ── Disclaimer ──────────────────────────────────────────────────── */

.bw-chatbot__disclaimer {
	margin: 0;
	padding: var(--space-2) var(--space-4) var(--space-3);
	font-size: 11px;
	line-height: var(--lh-snug);
	color: var(--fg-muted, var(--bw-gray-muted));
	background: var(--bg);
	border-top: 1px solid var(--border);
	text-align: center;
}

/* ── Utilitaires ─────────────────────────────────────────────────── */

.bw-chatbot__sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ── Responsive — plein écran sous 480px ─────────────────────────── */

@media (max-width: 480px) {
	#bw-chatbot-root {
		right: var(--space-3);
		bottom: var(--space-3);
	}
	.bw-chatbot__window {
		position: fixed;
		bottom: calc(56px + var(--space-3));
		right: var(--space-3);
		left: var(--space-3);
		width: auto;
		max-width: none;
		height: calc(100vh - 56px - var(--space-8));
	}
}

/* ── Print : masquer ─────────────────────────────────────────────── */

@media print {
	#bw-chatbot-root { display: none; }
}
