/*
 * Aide en ligne des trois sites (lot R113, tâche Odoo #234 « chat bot »). Balisage : assets/lvdr-chatbot.js.
 *
 * Bulle « verre dépoli » en bas à droite (fond Alternate du kit à 60 %, flou d'arrière-plan), pastille verte (service
 * ouvert) ou orange (fermé) ; fenêtre de 380 px sur ordinateur, plein écran jusqu'à 480 px (téléphone, 375 px).
 * Couleurs : jetons du kit (--lvdr-kit-*, en tête de lvdr-editorial.css ; le sélecteur de mode les redéfinit la nuit),
 * avec leurs valeurs de www en repli. Exceptions hors kit, documentées : le vert « succès » (--lvdr-ok) et l'orange
 * « attente » de la pastille.
 * Sélecteurs ancrés sur #lvdr-chat : ils passent devant les styles de boutons et de champs du thème et du kit
 * Elementor (dont les :not() montent haut) ; calques ::before/::after des <button> du thème neutralisés.
 * Masquée pendant les fenêtres modales de nos extensions (bienvenue, redirection) ; remontée au-dessus de la pastille
 * « Aperçu visiteur » du mu-plugin lvdr-site-ferme.
 */

#lvdr-chat {
	--lvdr-chat-encre: var(--lvdr-kit-secondary, #1F1F1F);
	--lvdr-chat-texte: var(--lvdr-kit-text, #3E3E3E);
	--lvdr-chat-fond: var(--lvdr-kit-alt-bg, #FFFFFF);
	--lvdr-chat-doux: var(--lvdr-kit-bg, #F7F7F7);
	--lvdr-chat-filet: var(--lvdr-kit-border, #DADADA);
	--lvdr-chat-rouge: var(--lvdr-kit-primary, #CC3232);
	--lvdr-chat-sur-rouge: var(--lvdr-kit-on-primary, #FFFFFF);
	--lvdr-chat-discret: var(--lvdr-kit-muted, #3E3E3E);
	--lvdr-chat-ok: var(--lvdr-ok, #247232);
	--lvdr-chat-attente: #B26A00;
	--lvdr-chat-voile: rgba(255, 255, 255, .6);
	--lvdr-chat-ombre: 0 8px 28px rgba(0, 0, 0, .18);
	bottom: 20px;
	box-sizing: border-box;
	color: var(--lvdr-chat-texte);
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	position: fixed;
	right: 20px;
	z-index: 99990;
}

html.cmsmasters-mode-switcher-active #lvdr-chat {
	--lvdr-chat-ok: #47C98A;
	--lvdr-chat-attente: #F0A33A;
	--lvdr-chat-voile: rgba(30, 30, 30, .6);
	--lvdr-chat-ombre: 0 8px 28px rgba(0, 0, 0, .5);
}

@supports (color: color-mix(in srgb, red 50%, red)) {
	#lvdr-chat {
		--lvdr-chat-voile: color-mix(in srgb, var(--lvdr-chat-fond) 60%, transparent);
	}

	html.cmsmasters-mode-switcher-active #lvdr-chat {
		--lvdr-chat-voile: color-mix(in srgb, var(--lvdr-chat-fond) 60%, transparent);
	}
}

#lvdr-chat *,
#lvdr-chat *::before,
#lvdr-chat *::after {
	box-sizing: border-box;
}

/* Piège du thème : Glossier peint le remplissage des <button> dans un calque ::before/::after. */
#lvdr-chat button::before,
#lvdr-chat button::after {
	content: none !important;
	display: none !important;
}

/* Fenêtres modales de nos extensions ouvertes : la bulle s'efface. */
html.lvdr-bienvenue-ouverte #lvdr-chat,
html.lvdr-fenetre-bascule-ouverte #lvdr-chat {
	display: none;
}

/* Pastille « Aperçu visiteur » (lvdr-site-ferme, bas de page centré) : la bulle passe au-dessus. */
html:has(#lvdr-apercu) #lvdr-chat:not(.is-ouvert) {
	bottom: 64px;
}

/* ─── Boutons communs (remise à zéro face au thème) ───────────────────────── */

#lvdr-chat button {
	appearance: none;
	-webkit-appearance: none;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: inherit;
	cursor: pointer;
	font-family: inherit;
	font-size: inherit;
	font-style: normal;
	font-weight: 500;
	height: auto;
	letter-spacing: 0;
	line-height: 1.3;
	margin: 0;
	min-height: 0;
	min-width: 0;
	padding: 0;
	text-align: left;
	text-decoration: none;
	text-shadow: none;
	text-transform: none;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease;
	width: auto;
}

#lvdr-chat button:disabled {
	cursor: default;
}

#lvdr-chat button:focus-visible,
#lvdr-chat a:focus-visible,
#lvdr-chat .lvdr-chat-entree:focus-visible,
#lvdr-chat .lvdr-chat-saisie:focus-visible {
	outline: 3px solid var(--lvdr-chat-rouge);
	outline-offset: 2px;
}

#lvdr-chat a {
	color: inherit;
	text-decoration: underline;
}

/* ─── Bulle ────────────────────────────────────────────────────────────────── */

#lvdr-chat .lvdr-chat-bulle {
	-webkit-backdrop-filter: blur(14px) saturate(160%);
	align-items: center;
	backdrop-filter: blur(14px) saturate(160%);
	background: var(--lvdr-chat-voile);
	border: 1px solid var(--lvdr-chat-filet);
	border-radius: 999px;
	box-shadow: var(--lvdr-chat-ombre);
	color: var(--lvdr-chat-encre);
	display: flex;
	font-weight: 600;
	gap: 10px;
	height: 58px;
	padding: 0 20px 0 16px;
	position: relative;
}

#lvdr-chat .lvdr-chat-bulle:hover {
	background: var(--lvdr-chat-fond);
}

#lvdr-chat .lvdr-chat-bulle svg {
	flex: none;
}

#lvdr-chat .lvdr-chat-pastille {
	background: var(--lvdr-chat-attente);
	border: 2px solid var(--lvdr-chat-fond);
	border-radius: 50%;
	height: 12px;
	left: 36px;
	position: absolute;
	top: 9px;
	width: 12px;
}

#lvdr-chat .lvdr-chat-pastille.is-ouvert {
	background: var(--lvdr-chat-ok);
}

#lvdr-chat.is-ouvert .lvdr-chat-bulle {
	display: none;
}

/* ─── Fenêtre ──────────────────────────────────────────────────────────────── */

#lvdr-chat .lvdr-chat-panneau {
	background: var(--lvdr-chat-fond);
	border: 1px solid var(--lvdr-chat-filet);
	border-radius: 18px;
	box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
	display: flex;
	flex-direction: column;
	height: 600px;
	max-height: calc(100vh - 40px);
	max-height: calc(100dvh - 40px);
	max-width: calc(100vw - 24px);
	overflow: hidden;
	width: 380px;
}

#lvdr-chat .lvdr-chat-panneau[hidden] {
	display: none !important;
}

#lvdr-chat .lvdr-chat-tete {
	align-items: center;
	background: var(--lvdr-chat-encre);
	color: var(--lvdr-chat-fond);
	display: flex;
	flex: none;
	gap: 6px;
	padding: 12px 10px 12px 16px;
}

#lvdr-chat .lvdr-chat-tete-texte {
	flex: 1;
	min-width: 0;
}

#lvdr-chat .lvdr-chat-titre {
	color: inherit;
	font-family: inherit;
	font-size: 16px;
	font-weight: 700;
	letter-spacing: 0;
	line-height: 1.3;
	margin: 0;
	padding: 0;
	text-transform: none;
}

#lvdr-chat .lvdr-chat-statut {
	align-items: center;
	display: flex;
	font-size: 13px;
	gap: 6px;
	line-height: 1.35;
	margin: 2px 0 0;
	opacity: .85;
}

#lvdr-chat .lvdr-chat-statut i {
	background: var(--lvdr-chat-attente);
	border-radius: 50%;
	flex: none;
	height: 8px;
	width: 8px;
}

#lvdr-chat .lvdr-chat-statut i.is-ouvert {
	background: var(--lvdr-chat-ok);
}

#lvdr-chat .lvdr-chat-icone {
	align-items: center;
	border-radius: 50%;
	color: inherit;
	display: inline-flex;
	flex: none;
	height: 44px;
	justify-content: center;
	width: 44px;
}

#lvdr-chat .lvdr-chat-icone:hover {
	background: rgba(255, 255, 255, .14);
}

html.cmsmasters-mode-switcher-active #lvdr-chat .lvdr-chat-icone:hover {
	background: rgba(0, 0, 0, .12);
}

/* ─── Fil de la conversation ───────────────────────────────────────────────── */

#lvdr-chat .lvdr-chat-fil {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 10px;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px 14px 8px;
}

#lvdr-chat .lvdr-chat-msg {
	border-radius: 14px;
	max-width: 88%;
	overflow-wrap: anywhere;
	padding: 10px 13px;
}

#lvdr-chat .lvdr-chat-msg p,
#lvdr-chat .lvdr-chat-msg ul {
	color: inherit;
	font-size: 15px;
	line-height: 1.45;
	margin: 0;
}

#lvdr-chat .lvdr-chat-msg p + p,
#lvdr-chat .lvdr-chat-msg p + ul,
#lvdr-chat .lvdr-chat-msg ul + p {
	margin-top: 8px;
}

#lvdr-chat .lvdr-chat-msg ul {
	padding-left: 18px;
}

#lvdr-chat .lvdr-chat-msg li {
	margin: 2px 0;
}

#lvdr-chat .lvdr-chat-msg strong,
#lvdr-chat .lvdr-chat-fort {
	color: var(--lvdr-chat-encre);
	font-weight: 600;
}

#lvdr-chat .lvdr-chat-msg--robot {
	align-self: flex-start;
	background: var(--lvdr-chat-doux);
	border-bottom-left-radius: 4px;
}

#lvdr-chat .lvdr-chat-msg--visiteur {
	align-self: flex-end;
	background: var(--lvdr-chat-encre);
	border-bottom-right-radius: 4px;
	color: var(--lvdr-chat-fond);
	white-space: pre-wrap;
}

#lvdr-chat .lvdr-chat-note {
	align-self: stretch;
	background: var(--lvdr-chat-fond);
	border: 1px solid var(--lvdr-chat-filet);
	border-radius: 12px;
	font-size: 13px;
	line-height: 1.45;
	margin: 0;
	padding: 9px 12px;
}

#lvdr-chat .lvdr-chat-note--attente {
	border-color: var(--lvdr-chat-attente);
}

/* ─── Choix ────────────────────────────────────────────────────────────────── */

#lvdr-chat .lvdr-chat-choix {
	align-items: flex-start;
	display: flex;
	flex-direction: column;
	gap: 7px;
}

#lvdr-chat .lvdr-chat-choix--ligne {
	flex-direction: row;
	flex-wrap: wrap;
}

#lvdr-chat .lvdr-chat-bouton {
	background: var(--lvdr-chat-fond);
	border: 1.5px solid var(--lvdr-chat-encre);
	border-radius: 12px;
	color: var(--lvdr-chat-encre);
	font-size: 14px;
	max-width: 100%;
	min-height: 40px;
	padding: 8px 13px;
}

#lvdr-chat .lvdr-chat-bouton:hover:not(:disabled) {
	background: var(--lvdr-chat-encre);
	color: var(--lvdr-chat-fond);
}

#lvdr-chat .lvdr-chat-bouton--theme {
	padding: 11px 14px;
	width: 100%;
}

#lvdr-chat .lvdr-chat-bouton--theme strong {
	display: block;
	font-size: 15px;
	font-weight: 600;
}

#lvdr-chat .lvdr-chat-bouton--theme span {
	color: var(--lvdr-chat-discret);
	display: block;
	font-size: 13px;
	font-weight: 400;
	margin-top: 1px;
}

#lvdr-chat .lvdr-chat-bouton--theme:hover:not(:disabled) span {
	color: inherit;
}

#lvdr-chat .lvdr-chat-bouton--question,
#lvdr-chat .lvdr-chat-bouton--discret {
	border-color: var(--lvdr-chat-filet);
	border-width: 1px;
}

#lvdr-chat .lvdr-chat-bouton--discret {
	color: var(--lvdr-chat-discret);
}

#lvdr-chat .lvdr-chat-bouton--plein {
	background: var(--lvdr-chat-rouge);
	border-color: var(--lvdr-chat-rouge);
	color: var(--lvdr-chat-sur-rouge);
	font-weight: 600;
}

#lvdr-chat .lvdr-chat-bouton--plein:hover:not(:disabled) {
	background: var(--lvdr-primary-hover, var(--lvdr-chat-rouge));
	border-color: var(--lvdr-primary-hover, var(--lvdr-chat-rouge));
	color: var(--lvdr-chat-sur-rouge);
}

#lvdr-chat .lvdr-chat-choix.is-fait .lvdr-chat-bouton {
	opacity: .45;
}

/* ─── Formulaire ───────────────────────────────────────────────────────────── */

#lvdr-chat .lvdr-chat-form {
	align-self: stretch;
	background: var(--lvdr-chat-fond);
	border: 1px solid var(--lvdr-chat-filet);
	border-radius: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 14px;
	position: relative;
}

#lvdr-chat .lvdr-chat-form-titre {
	color: var(--lvdr-chat-encre);
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0;
	line-height: 1.3;
	margin: 0;
	text-transform: none;
}

#lvdr-chat .lvdr-chat-champ {
	color: var(--lvdr-chat-encre);
	display: flex;
	flex-direction: column;
	font-size: 13px;
	font-weight: 600;
	gap: 4px;
	margin: 0;
}

#lvdr-chat .lvdr-chat-champ small {
	color: var(--lvdr-chat-discret);
	font-size: 12px;
	font-weight: 400;
}

#lvdr-chat .lvdr-chat-entree,
#lvdr-chat .lvdr-chat-saisie {
	background: var(--lvdr-chat-fond);
	border: 1px solid var(--lvdr-kit-alt-accent, #A8A8A8);
	border-radius: 9px;
	box-shadow: none;
	color: var(--lvdr-chat-encre);
	font-family: inherit;
	font-size: 16px; /* 16 px : pas de zoom automatique d'iOS au toucher */
	font-weight: 400;
	height: auto;
	letter-spacing: 0;
	line-height: 1.4;
	margin: 0;
	max-width: 100%;
	min-height: 44px;
	padding: 9px 11px;
	width: 100%;
}

#lvdr-chat textarea.lvdr-chat-entree {
	min-height: 110px;
	resize: vertical;
}

#lvdr-chat .lvdr-chat-entree[aria-invalid="true"] {
	border-color: var(--lvdr-chat-rouge);
}

#lvdr-chat .lvdr-chat-erreur {
	color: var(--lvdr-chat-rouge);
	font-size: 13px;
	font-weight: 600;
	margin: 0;
}

#lvdr-chat .lvdr-chat-erreur:empty {
	display: none;
}

#lvdr-chat .lvdr-chat-legal {
	color: var(--lvdr-chat-discret);
	font-size: 12px;
	line-height: 1.45;
	margin: 0;
}

#lvdr-chat .lvdr-chat-soumettre {
	justify-content: center;
	min-height: 44px;
	text-align: center;
	width: 100%;
}

#lvdr-chat .lvdr-chat-piege,
#lvdr-chat .lvdr-chat-masque {
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	height: 1px;
	left: -9999px;
	overflow: hidden;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

/* ─── Barre de saisie, pied ────────────────────────────────────────────────── */

#lvdr-chat .lvdr-chat-barre {
	align-items: flex-end;
	background: var(--lvdr-chat-fond);
	border-top: 1px solid var(--lvdr-chat-filet);
	display: flex;
	flex: none;
	gap: 8px;
	margin: 0;
	padding: 10px 12px;
}

#lvdr-chat .lvdr-chat-saisie {
	border-radius: 12px;
	flex: 1;
	max-height: 110px;
	resize: none;
}

#lvdr-chat .lvdr-chat-saisie:disabled {
	background: var(--lvdr-chat-doux);
	border-color: var(--lvdr-chat-filet);
}

#lvdr-chat .lvdr-chat-envoi {
	align-items: center;
	background: var(--lvdr-chat-encre);
	border-radius: 50%;
	color: var(--lvdr-chat-fond);
	display: flex;
	flex: none;
	height: 44px;
	justify-content: center;
	width: 44px;
}

#lvdr-chat .lvdr-chat-envoi:disabled {
	opacity: .4;
}

#lvdr-chat .lvdr-chat-pied {
	background: var(--lvdr-chat-fond);
	color: var(--lvdr-chat-discret);
	flex: none;
	font-size: 12px;
	line-height: 1.4;
	margin: 0;
	padding: 0 12px 10px;
	text-align: center;
}

/* ─── Messages du coin bas droit (revue R113) ───────────────────────────────────
   Avis des favoris (.lvdr-titres-avis) et de la boutique (.lvdr-commerce-notice) : même coin que la bulle, z-index
   plus bas. Ils remontent au-dessus de la bulle (56 px + 20 px de marge + 12 px d'écart) tant qu'elle est là. */

body:has(> #lvdr-chat) .lvdr-titres-avis,
body:has(> #lvdr-chat) .lvdr-commerce-notice {
	bottom: 88px;
}

/* ─── Téléphone : bulle ronde, fenêtre plein écran ─────────────────────────── */

@media (max-width: 480px) {
	#lvdr-chat {
		bottom: 16px;
		right: 16px;
	}

	#lvdr-chat.is-ouvert {
		bottom: 0;
		left: 0;
		right: 0;
		top: 0;
	}

	#lvdr-chat .lvdr-chat-bulle {
		height: 56px;
		justify-content: center;
		padding: 0;
		width: 56px;
	}

	#lvdr-chat .lvdr-chat-bulle-texte {
		display: none;
	}

	#lvdr-chat .lvdr-chat-pastille {
		left: auto;
		right: 9px;
		top: 9px;
	}

	#lvdr-chat .lvdr-chat-panneau {
		border: 0;
		border-radius: 0;
		height: 100%;
		max-height: none;
		max-width: none;
		width: 100%;
	}

	html.lvdr-chat-ouvert,
	html.lvdr-chat-ouvert body {
		overflow: hidden;
	}

	body:has(> #lvdr-chat) .lvdr-titres-avis,
	body:has(> #lvdr-chat) .lvdr-commerce-notice {
		bottom: 84px;
	}
}

@media (prefers-reduced-motion: reduce) {
	#lvdr-chat button {
		transition: none;
	}
}
