/* ============================================================
   Chatbot IA — Les Vétos Parisiens
   Styles intégrés au design system : vert forêt, sauge,
   Fraunces pour les titres, Instrument Sans pour le corps.
   ============================================================ */

/* ---------- Variables locales (héritent des tokens du site) ---------- */
:root {
	--chatbot-z: 9999;
	--chatbot-radius: 20px;
	--chatbot-radius-sm: 12px;
	--chatbot-accent: var(--green-deep);
}

/* ---------- Bouton lanceur (FAB) ---------- */
.chatbot-launcher {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: var(--chatbot-z);
	display: flex;
	align-items: center;
	gap: 0;
	width: 60px;
	height: 60px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--chatbot-accent);
	color: var(--white);
	cursor: pointer;
	box-shadow: var(--shadow-lift);
	transition: width 0.4s var(--ease-spring),
		gap 0.3s var(--ease-out),
		transform 0.3s var(--ease-spring),
		background 0.25s var(--ease-out);
	overflow: hidden;
}

.chatbot-launcher:hover {
	transform: scale(1.06);
	background: var(--green-muted);
}

.chatbot-launcher:active {
	transform: scale(0.96);
}
/* Le box-shadow décoratif du lanceur écraserait le liseré blanc de l'anneau. */
.chatbot-launcher:focus-visible {
	box-shadow: 0 0 0 2px var(--white), var(--shadow-lift);
}


.chatbot-launcher__icon {
	width: 30px;
	height: 30px;
	flex-shrink: 0;
	margin-left: 15px;
	/* L'encre de la bulle occupe y=2.5 à 23.7 dans un viewBox de 28 : son centre
	   est 0,9 unité au-dessus du centre géométrique. En pourcentage (0,9/28) le
	   recentrage suit automatiquement la taille du pictogramme. */
	transform: translateY(3.2%);
	transition: margin 0.3s var(--ease-out);
}

.chatbot-launcher__badge {
	font-family: var(--font-body);
	font-size: 13px;
	font-weight: 600;
	color: var(--ivory);
	white-space: nowrap;
	opacity: 0;
	max-width: 0;
	transition: opacity 0.3s var(--ease-out), max-width 0.4s var(--ease-out);
}

.chatbot-launcher.show-badge {
	width: 180px;
	gap: 8px;
	padding-right: 20px;
}

.chatbot-launcher.show-badge .chatbot-launcher__icon {
	margin-left: 18px;
}

.chatbot-launcher.show-badge .chatbot-launcher__badge {
	opacity: 1;
	max-width: 120px;
}

.chatbot-launcher.is-hidden {
	opacity: 0;
	pointer-events: none;
	transform: scale(0.5) translateY(20px);
}

.chatbot-launcher--left { left: 24px; right: auto; }
.chatbot-panel--left { left: 24px; right: auto; transform-origin: bottom left; }

/* ---------- Panneau ---------- */
.chatbot-panel {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: var(--chatbot-z);
	width: 400px;
	max-width: calc(100vw - 32px);
	max-height: min(640px, calc(100vh - 48px));
	display: flex;
	flex-direction: column;
	background: var(--ivory);
	border-radius: var(--chatbot-radius);
	box-shadow: var(--shadow-lift);
	overflow: hidden;
	opacity: 0;
	pointer-events: none;
	transform: translateY(24px) scale(0.96);
	transform-origin: bottom right;
	transition: opacity 0.3s var(--ease-out),
		transform 0.4s var(--ease-spring);
}

.chatbot-panel.is-open {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0) scale(1);
}

/* ---------- Header du panneau ---------- */
.chatbot-panel__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	background: var(--chatbot-accent);
	color: var(--ivory);
	flex-shrink: 0;
}

.chatbot-panel__avatar {
	width: 40px;
	height: 40px;
	flex-shrink: 0;
}

.chatbot-panel__avatar svg {
	width: 100%;
	height: 100%;
	display: block;
}

.chatbot-panel__heading {
	flex: 1;
	min-width: 0;
}

.chatbot-panel__title {
	margin: 0;
	font-family: var(--font-display);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--ivory);
}

.chatbot-panel__status {
	margin: 2px 0 0;
	font-family: var(--font-body);
	font-size: 11px;
	color: var(--on-dark-subtle);
	display: flex;
	align-items: center;
	gap: 6px;
}

.chatbot-panel__dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #6ec86e;
	box-shadow: 0 0 6px rgba(110, 200, 110, 0.6);
}

.chatbot-panel__close {
	position: relative;
	flex-shrink: 0;
	width: 32px;
	height: 32px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: var(--ivory);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s var(--ease-out);
}
/* Zone tactile portée à 44×44 sans grossir la pastille visible. */
.chatbot-panel__close::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 44px;
	height: 44px;
	transform: translate(-50%, -50%);
}

.chatbot-panel__close:hover {
	background: rgba(255, 255, 255, 0.22);
}

.chatbot-panel__close svg {
	width: 16px;
	height: 16px;
}

/* ---------- Corps des messages ---------- */
.chatbot-panel__body {
	flex: 1;
	overflow-y: auto;
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background: var(--ivory-deep);
	scroll-behavior: smooth;
}

.chatbot-panel__body::-webkit-scrollbar {
	width: 6px;
}

.chatbot-panel__body::-webkit-scrollbar-track {
	background: transparent;
}

.chatbot-panel__body::-webkit-scrollbar-thumb {
	background: var(--hairline);
	border-radius: 3px;
}

/* ---------- Bulles de message ---------- */
.chatbot-msg {
	display: flex;
	max-width: 88%;
	animation: chatbot-msg-in 0.35s var(--ease-spring) both;
}

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

.chatbot-msg--user {
	align-self: flex-end;
	justify-content: flex-end;
}

.chatbot-msg--bot {
	align-self: flex-start;
}

.chatbot-msg__bubble {
	padding: 12px 16px;
	font-family: var(--font-body);
	font-size: 14px;
	line-height: 1.55;
	border-radius: var(--chatbot-radius-sm);
	word-break: break-word;
}

.chatbot-msg--bot .chatbot-msg__bubble {
	background: var(--surface);
	color: var(--text-body);
	border: 1px solid var(--hairline);
	border-bottom-left-radius: 4px;
	box-shadow: var(--shadow-soft);
}

.chatbot-msg--user .chatbot-msg__bubble {
	background: var(--forest);
	color: var(--ivory);
	border-bottom-right-radius: 4px;
}

.chatbot-msg__bubble a {
	color: var(--green-muted);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.chatbot-msg--user .chatbot-msg__bubble a {
	color: var(--sage);
}

.chatbot-msg__bubble strong {
	font-weight: 700;
	color: var(--text-heading);
}

.chatbot-msg--user .chatbot-msg__bubble strong {
	color: var(--ivory);
}

.chatbot-msg__bubble ul {
	margin: 6px 0;
	padding-left: 16px;
	list-style: none;
}

.chatbot-msg__bubble li {
	position: relative;
	padding-left: 4px;
	margin: 2px 0;
}

.chatbot-msg__bubble li::before {
	content: "•";
	position: absolute;
	left: -10px;
	color: var(--green-soft);
	font-weight: 700;
}

/* ---------- Indicateur de frappe ---------- */
.chatbot-msg--typing .chatbot-msg__bubble {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 14px 18px;
}

.chatbot-typing-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--sage-deep);
	animation: chatbot-typing 1.3s infinite ease-in-out;
}

.chatbot-typing-dot:nth-child(2) {
	animation-delay: 0.2s;
}

.chatbot-typing-dot:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes chatbot-typing {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.4;
	}
	30% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

/* ---------- Suggestions ---------- */
.chatbot-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding-top: 2px;
}

.chatbot-suggestion {
	/* Padding vertical asymétrique = compensation optique (voir --cap-shift). */
	padding: calc(8px + var(--cap-shift)) 14px calc(8px - var(--cap-shift));
	font-family: var(--font-body);
	font-size: 12.5px;
	font-weight: 500;
	color: var(--green-muted);
	background: var(--surface);
	border: 1px solid var(--hairline);
	border-radius: 100px;
	cursor: pointer;
	transition: all 0.2s var(--ease-out);
	white-space: nowrap;
}

.chatbot-suggestion:hover {
	background: var(--sage);
	border-color: var(--sage-deep);
	color: var(--forest);
	transform: translateY(-1px);
}

/* ---------- Formulaire ---------- */
.chatbot-panel__form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 14px;
	background: var(--surface);
	border-top: 1px solid var(--hairline);
	flex-shrink: 0;
}

.chatbot-panel__input {
	flex: 1;
	padding: 10px 14px;
	font-family: var(--font-body);
	font-size: 14px;
	color: var(--text-body);
	background: var(--ivory-deep);
	border: 1px solid var(--hairline);
	border-radius: 100px;
	outline: none;
	transition: border-color 0.2s var(--ease-out),
		background 0.2s var(--ease-out);
}

.chatbot-panel__input::placeholder {
	color: var(--sage-deep);
}

.chatbot-panel__input:focus {
	border-color: var(--green-soft);
	background: var(--surface);
}
/* L'outline: none ci-dessus tuerait l'anneau générique : on le rétablit. */
.chatbot-panel__input:focus-visible {
	outline: 2px solid var(--forest);
	outline-offset: 2px;
	box-shadow: 0 0 0 2px var(--white);
}


.chatbot-panel__send {
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--forest);
	color: var(--sage);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s var(--ease-out),
		transform 0.2s var(--ease-spring),
		opacity 0.2s var(--ease-out);
}

.chatbot-panel__send:hover:not(:disabled) {
	background: var(--green-muted);
	transform: scale(1.08);
}

.chatbot-panel__send:active:not(:disabled) {
	transform: scale(0.94);
}

.chatbot-panel__send:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.chatbot-panel__send svg {
	width: 18px;
	height: 18px;
}

/* ---------- Disclaimer ---------- */
.chatbot-panel__disclaimer {
	margin: 0;
	padding: 8px 14px 12px;
	font-family: var(--font-body);
	font-size: 11px;
	line-height: 1.4;
	color: var(--sage-deep);
	text-align: center;
	background: var(--surface);
	flex-shrink: 0;
}

.chatbot-panel__disclaimer a {
	color: var(--green-muted);
	font-weight: 600;
	text-decoration: none;
}

.chatbot-panel__disclaimer a:hover {
	text-decoration: underline;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
	.chatbot-panel {
		bottom: 0;
		right: 0;
		width: 100vw;
		max-width: 100vw;
		max-height: 100vh;
		border-radius: 0;
	}

	.chatbot-panel.is-open {
		transform: translateY(0) scale(1);
	}

	.chatbot-launcher {
		bottom: 16px;
		right: 16px;
	}

	.chatbot-launcher.show-badge {
		width: 60px;
		padding-right: 0;
	}

	.chatbot-launcher.show-badge .chatbot-launcher__badge {
		opacity: 0;
		max-width: 0;
	}

	.chatbot-launcher.show-badge .chatbot-launcher__icon {
		margin-left: 15px;
	}
}

/* ---------- Cibles tactiles au doigt ---------- */
@media (max-width: 860px) {
	.chatbot-suggestion {
		display: inline-flex;
		align-items: center;
		min-height: 44px;
	}
	.chatbot-panel__send {
		width: 44px;
		height: 44px;
	}
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
	.chatbot-launcher,
	.chatbot-panel,
	.chatbot-msg,
	.chatbot-typing-dot,
	.chatbot-suggestion,
	.chatbot-panel__send {
		transition: none !important;
		animation: none !important;
	}
}
