/* MKS Chatbot — fil de conversation dans le bloc assistant de la page contact.
   Palette du thème : navy #130090, orange #ff6e00, lavande #f1f2ff, texte #44404c. */

.mkscb {
	width: 100%;
	max-width: 860px;
	margin: 0 auto 16px;
	text-align: left;
}

.mkscb[hidden] {
	display: none;
}

/* sans API : seule la note reste visible */
.mkscb--down .mkscb__head,
.mkscb--down .mkscb__thread,
.mkscb--down .mkscb__alt {
	display: none;
}

.mkscb__notice {
	margin: 0 0 12px;
	padding: 10px 14px;
	border-radius: 10px;
	background: #f1f2ff;
	color: #130090;
	font-size: 14px;
	line-height: 1.3;
}

.mkscb__notice--error {
	background: #fff1e8;
	color: #b34a00;
}

.mkscb__notice--info {
	background: #f1f2ff;
	color: #130090;
}

.mkscb__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 0 0 8px;
}

.mkscb__badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border-radius: 48px;
	background: #130090;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
}

.mkscb__badge .material-symbols-outlined {
	font-size: 16px;
}

.mkscb__actions {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-left: auto;
}

/* actions en pictos seuls (libellés en aria-label / title) */
.mkscb__new,
.mkscb__history {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: #707682;
	cursor: pointer;
}

.mkscb__new:hover,
.mkscb__history:hover,
.mkscb__history.is-open {
	background: #f1f2ff;
	color: #130090;
}

.mkscb__new .material-symbols-outlined,
.mkscb__history .material-symbols-outlined {
	font-size: 20px;
	line-height: 1;
}

/* liste des conversations mémorisées (métadonnées locales uniquement) :
   panneau flottant sous le picto d'historique, ne décale pas le contenu */
.mkscb__list {
	position: absolute;
	top: 56px;
	right: 20px;
	z-index: 5;
	display: flex;
	flex-direction: column;
	gap: 4px;
	width: min(340px, calc(100% - 40px));
	max-height: 260px;
	margin: 0;
	padding: 8px;
	overflow-y: auto;
	border: 1px solid #e5e6ff;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 8px 24px rgba(19, 0, 144, .15);
}

/* état de base : le picto flotte à 12px du bord, le panneau s'aligne dessous */
.mksc__ask--chat:not(.mksc__ask--wide) .mkscb__list {
	top: 48px;
	right: 12px;
}

.mkscb__list[hidden] {
	display: none;
}

.mkscb__list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	padding: 8px 10px;
	border: 0;
	border-radius: 8px;
	background: none;
	color: #44404c;
	font-size: 14px;
	text-align: left;
	cursor: pointer;
}

.mkscb__list-item:hover {
	background: #f1f2ff;
}

.mkscb__list-item.is-active {
	background: #f1f2ff;
	color: #130090;
	font-weight: 600;
}

.mkscb__list-title {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mkscb__list-date {
	flex: none;
	color: #989898;
	font-size: 12px;
}

/* --- fil --------------------------------------------------------------- */
.mkscb__thread.is-empty {
	display: none;
}

/* …sauf quand il porte la bulle d'accueil de l'assistant (transparence IA) :
   affiché en entier — l'encart grandit avec la bulle (pas de hauteur max),
   et le fondu garde sa place sans déborder sur le message (marge négative
   annulée dans cet état) */
.mkscb__thread.is-empty:has(.mkscb__msg--welcome),
.mksc__ask--chat .mkscb__thread.is-empty:has(.mkscb__msg--welcome) {
	display: block;
	max-height: none;
}

.mksc__ask--chat .mkscb__thread.is-empty:has(.mkscb__msg--welcome)::before {
	margin-bottom: 0;
}

/* sans conversation : pas de bouton « Nouvelle conversation » */
.mkscb:not(.mkscb--has-conv) .mkscb__new {
	display: none;
}

.mkscb__thread {
	display: flex;
	flex-direction: column;
	gap: 14px;
	max-height: 420px;
	overflow-y: auto;
	padding: 16px;
	border: 1px solid #e5e6ff;
	border-radius: 16px;
	background: #fff;
	scroll-behavior: smooth;
}

.mkscb__msg {
	display: flex;
	flex-direction: column;
	max-width: 80%;
}

.mkscb__msg--user {
	align-self: flex-end;
	align-items: flex-end;
}

.mkscb__msg--assistant,
.mkscb__msg--agent {
	align-self: flex-start;
	align-items: flex-start;
}

.mkscb__bubble {
	padding: 10px 14px;
	border-radius: 14px;
	color: #44404c;
	font-size: 14px;
	line-height: 1.45;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.mkscb__msg--assistant .mkscb__bubble {
	background: #f1f2ff;
	border-bottom-left-radius: 4px;
}

.mkscb__msg--agent .mkscb__bubble {
	background: #fff;
	border: 1px solid #130090;
	border-bottom-left-radius: 4px;
}

.mkscb__msg--user .mkscb__bubble {
	background: #130090;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.mkscb__bubble a {
	color: inherit;
	text-decoration: underline;
}

.mkscb__bubble ul {
	margin: 6px 0;
	padding-left: 18px;
}

.mkscb__bubble li {
	list-style: disc;
}

/* notification du système dans le fil (« Votre demande est transmise… ») */
.mkscb__msg--system {
	align-self: stretch;
	max-width: none;
	padding: 8px 14px;
	border-radius: 10px;
	background: #fff6ea;
	border: 1px solid #ffe2c4;
	color: #b34a00;
	font-size: 13px;
	text-align: center;
}

/* prénom du conseiller au-dessus de sa bulle */
.mkscb__agent-nom {
	margin: 0 0 2px 6px;
	color: #130090;
	font-size: 12px;
	font-weight: 600;
}

.mkscb__msg--streaming .mkscb__body::after {
	content: '▍';
	margin-left: 2px;
	color: #ff6e00;
	animation: mkscb-blink 1s steps(2) infinite;
}

.mkscb__meta {
	margin-top: 4px;
	color: #989898;
	font-size: 11px;
}

/* choix rapides proposés par l'assistant */
.mkscb__choices {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
}

.mkscb__choice {
	padding: 6px 12px;
	border: 1px solid #130090;
	border-radius: 48px;
	background: #fff;
	color: #130090;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
}

.mkscb__choice:hover {
	background: #130090;
	color: #fff;
}

.mkscb__choice:disabled {
	opacity: .5;
	cursor: default;
}

.mkscb__choice.is-chosen {
	background: #130090;
	color: #fff;
	opacity: 1;
}

/* indicateur de frappe */
.mkscb__dots {
	display: inline-flex;
	gap: 4px;
	height: 14px;
	align-items: center;
}

.mkscb__dots i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #130090;
	animation: mkscb-bounce 1.2s infinite ease-in-out;
}

.mkscb__dots i:nth-child(2) { animation-delay: .15s; }
.mkscb__dots i:nth-child(3) { animation-delay: .3s; }

@keyframes mkscb-bounce {
	0%, 80%, 100% { transform: translateY(0); opacity: .4; }
	40% { transform: translateY(-4px); opacity: 1; }
}

@keyframes mkscb-blink {
	50% { opacity: 0; }
}

/* pièces jointes */
.mkscb__attachment {
	margin-top: 8px;
}

.mkscb__attachment img {
	display: block;
	max-width: 240px;
	max-height: 240px;
	border-radius: 10px;
}

.mkscb__file {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-weight: 600;
}

.mkscb__file .material-symbols-outlined {
	font-size: 20px;
}

/* --- sous le fil -------------------------------------------------------- */
.mkscb__status {
	/* le retrait bas compense le fondu blanc du composer (12px) qui recouvre
	   le bas du bloc précédent */
	margin: 8px 0 0;
	padding-bottom: 12px;
	color: #707682;
	font-size: 13px;
	font-style: italic;
}

.mkscb__alt {
	margin: 10px 0 0;
	font-size: 15px;
	text-align: center;
}

.mkscb__alt a {
	color: #464646;
	text-decoration: none;
}

.mkscb__alt a:hover {
	color: #130090;
	text-decoration: underline;
}

/* mention de transparence RGPD, au-dessus des raccourcis de conversation
   (même largeur que la zone de dialogue ; marge négative : la section
   assistant impose un gap flex de 36px, on le ramène à ~10px) */
.mkscb__rgpd {
	width: 100%;
	max-width: 860px;
	margin: -26px auto 0;
	color: #6b7280;
	font-size: 11px;
	line-height: 1.45;
	text-align: left;
}

.mkscb__rgpd a {
	color: #6b7280;
	text-decoration: underline;
}

.mkscb__rgpd a:hover {
	color: #130090;
}

/* en conversation plein écran le gap flex n'est plus que de 16px :
   la compensation se réduit d'autant pour garder ~10px visuels */
.mksc__assistant--chat .mkscb__rgpd {
	margin-top: -6px;
}

/* chat indisponible : la mention n'a pas lieu d'être */
.mkscb--down .mkscb__rgpd {
	display: none;
}

/* écran étroit : le gap de la section tombe à 24px (contact-v2.css), la
   compensation se réduit pour garder ~10px visuels, et une gouttière évite
   que le texte colle aux bords */
@media (max-width: 991px) {
	.mkscb__rgpd {
		margin-top: -14px;
		padding: 0 16px;
	}
}

/* sélecteur d'articles : hauteur bornée (au moins 5 lignes produits visibles,
   le fil reste accessible dessous) et replié en bandeau quand un message
   arrive — son titre le rouvre */
.mkscb__picker {
	margin: 12px 0 0;
	padding: 14px 16px;
	max-height: 380px;
	overflow-y: auto;
	border: 1px solid #e5e6ff;
	border-radius: 12px;
	background: #fff;
}

.mkscb__picker--replie .mkscb__picker-all,
.mkscb__picker--replie .mkscb__picker-row,
.mkscb__picker--replie .mkscb__picker-send {
	display: none;
}

.mkscb__picker-title {
	cursor: pointer;
}

.mkscb__picker--replie .mkscb__picker-title::after {
	content: ' — rouvrir';
	color: #ff6e00;
	font-weight: 600;
}

.mkscb__picker-title {
	margin: 0 0 8px;
	color: #130090;
	font-weight: 600;
}

.mkscb__picker-all,
.mkscb__picker-row {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 6px 0;
	font-size: 14px;
	cursor: pointer;
}

.mkscb__picker-row + .mkscb__picker-row {
	border-top: 1px solid #efeef0;
}

.mkscb__picker-lib {
	flex: 1;
}

.mkscb__picker-qty {
	width: 64px;
	padding: 4px 8px;
	border: 1px solid #dbdadd;
	border-radius: 8px;
}

.mkscb__picker-send {
	margin-top: 10px;
	padding: 8px 16px;
	border: 0;
	border-radius: 48px;
	background: #ff6e00;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.mkscb__picker-send:disabled {
	opacity: .6;
	cursor: default;
}

/* CSAT */
.mkscb__csat {
	margin: 12px 0 0;
	padding: 14px 16px;
	border-radius: 12px;
	background: #f1f2ff;
	text-align: center;
}

.mkscb__csat-title {
	margin: 0 0 8px;
	color: #130090;
	font-weight: 600;
}

.mkscb__stars {
	display: flex;
	justify-content: center;
	gap: 4px;
}

.mkscb__star {
	padding: 2px;
	border: 0;
	background: none;
	color: #c9c8d6;
	cursor: pointer;
}

.mkscb__star .material-symbols-outlined {
	font-size: 28px;
	font-variation-settings: 'FILL' 1;
}

.mkscb__star.is-on {
	color: #ff6e00;
}

.mkscb__csat-comment {
	width: 100%;
	max-width: 420px;
	margin: 10px auto 0;
	padding: 8px 12px;
	border: 1px solid #dbdadd;
	border-radius: 10px;
	font-size: 14px;
	resize: vertical;
}

.mkscb__csat-send {
	margin-top: 10px;
	padding: 8px 16px;
	border: 0;
	border-radius: 48px;
	background: #130090;
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

.mkscb__csat-send:disabled {
	opacity: .5;
	cursor: default;
}

/* --- chat monté dans l'encart de saisie ---------------------------------
   .mksc__ask (cadre navy) devient une colonne : fil de conversation en haut,
   barre de composition (textarea + pièce jointe + envoi) en bas */
.mksc__ask--chat {
	flex-direction: column;
	align-items: stretch;
	gap: 4px;
	min-height: 0;
}

/* sans conversation : l'encart garde la hauteur de la maquette, la saisie
   occupe toute la place au-dessus des boutons, le texte part du haut (le gap
   du bloc caché du fil est annulé pour coller au retrait de 20px) */
.mksc__ask--chat:not(.mksc__ask--wide) {
	gap: 0;
	min-height: 156px;
}

/* avec un historique, l'en-tête (pictos) flotte en haut à droite sans pousser
   la saisie vers le bas */
.mksc__ask--chat:not(.mksc__ask--wide) .mkscb__head {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 1;
	margin: 0;
}

.mksc__ask--chat:not(.mksc__ask--wide) .mkscb__composer {
	flex: 1;
}

.mksc__ask--chat:not(.mksc__ask--wide) .mksc__ask-input {
	align-self: stretch;
	height: auto;
}

.mksc__ask--chat .mkscb {
	max-width: none;
	margin: 0;
}

/* conversation démarrée : l'encart prend toute la largeur du conteneur et le
   fil gagne en hauteur */
.mksc__ask--chat {
	transition: max-width .3s ease;
}

/* conversation démarrée : l'encart occupe tout l'écran disponible —
   pleine largeur de la fenêtre et 100vh moins le header (hauteur exposée
   par custom.js dans --mks-header-height) et le disclaimer, avec une
   respiration d'environ 24px sur les quatre côtés */
.mksc__ask--wide {
	/* 64px de chaque côté : le widget Avis Vérifiés, fixé au bord droit,
	   ne recouvre pas l'encart */
	width: calc(100vw - 128px);
	max-width: none;
	margin-left: calc(50% - 50vw + 64px);
	margin-right: calc(50% - 50vw + 64px);
	height: calc(100vh - var(--mks-header-height, 232px) - 112px);
	min-height: 320px;
}

@media (max-width: 767px) {
	/* pas de widget avis en mobile : l'encart reprend toute la largeur,
	   et descend presque jusqu'en bas de l'écran (dvh : barre d'adresse
	   mobile prise en compte quand le navigateur le gère) */
	.mksc__ask--wide {
		width: calc(100vw - 32px);
		margin-left: calc(50% - 50vw + 16px);
		margin-right: calc(50% - 50vw + 16px);
		/* le header mobile n'est pas sticky : une fois en conversation il est
		   hors écran, l'encart peut donc occuper presque toute la hauteur */
		height: calc(100vh - 32px);
		height: calc(100dvh - 32px);
	}

	/* en-tête raccourci : « Assistant IA » */
	.mkscb__brand .mkscb__brand-nom {
		display: none;
	}
}

/* en conversation, l'habillage au-dessus de l'encart se resserre pour
   laisser le maximum de hauteur à la fenêtre de chat */
.mksc:has(.mksc__assistant--chat) {
	padding-top: 24px;
}

.mksc__assistant--chat {
	gap: 16px;
}

/* le module chat s'étire dans l'encart et le fil absorbe toute la place
   restante (l'en-tête et la barre de saisie gardent leur hauteur) */
.mksc__ask--wide .mkscb {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
}

.mksc__ask--wide .mkscb__thread {
	flex: 1 1 auto;
	height: auto;
	max-height: none;
	min-height: 0;
}

/* discussion lancée : le grand titre et les raccourcis disparaissent,
   l'en-tête de l'encart porte l'icône et le nom de l'assistant */
.mksc__assistant--chat .mksc__assistant-icon,
.mksc__assistant--chat .mksc__assistant-title,
.mksc__assistant--chat .mksc__chips {
	display: none;
}

.mkscb__brand {
	display: none;
	align-items: center;
	gap: 12px;
	color: #130090;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.2;
}

.mkscb__brand-ia {
	margin-left: -4px;
	padding: 4px 6px;
	border-radius: 6px;
	background: #ff6e00;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
}

.mkscb__brand img {
	display: block;
	width: 32px;
	height: 32px;
}

.mksc__ask--wide .mkscb__brand {
	display: inline-flex;
}

.mksc__ask--wide .mkscb__head {
	margin: 0;
	padding: 0 0 6px;
}

.mksc__ask--wide .mkscb__badge {
	margin-left: 4px;
}

.mksc__ask--chat .mkscb__thread.is-empty {
	display: none;
}

.mksc__ask--chat .mkscb__thread {
	/* de l'air à droite entre les messages et la barre de défilement,
	   et sous le dernier message pour qu'il ne passe pas sous le fondu */
	padding: 0 12px 12px 0;
	border: 0;
	border-radius: 0;
	scrollbar-gutter: stable;
}

/* pas de filet sous l'en-tête : les messages s'estompent en haut sous un
   dégradé blanc → transparent (pseudo-élément collant dans la zone qui défile) */
.mksc__ask--chat .mkscb__thread::before {
	content: '';
	position: sticky;
	top: 0;
	z-index: 1;
	display: block;
	flex: none;
	height: 16px;
	/* annule l'écart de 14px du fil : le premier message commence juste sous
	   le fondu (16px), sans passer dessous tant qu'on n'a pas défilé */
	margin-bottom: -14px;
	background: linear-gradient(to bottom, #fff 20%, rgba(255, 255, 255, 0));
	pointer-events: none;
}



.mksc__ask--chat .mkscb__head {
	margin-bottom: 4px;
}

.mkscb__composer {
	position: relative;
	display: flex;
	align-items: flex-end;
	gap: 12px;
	/* la zone de saisie reste délimitée du fil par un filet */
	padding-top: 8px;
	border-top: 1px solid #e5e6ff;
}

/* sans conversation : ni filet ni fondu au-dessus de la saisie…
   sauf si la bulle d'accueil est affichée : le filet sépare alors le
   message de la zone de saisie */
.mkscb:not(.mkscb--has-conv):has(.mkscb__msg--welcome) ~ .mkscb__composer {
	padding-top: 8px;
	border-top: 1px solid #e5e6ff;
}

.mkscb:not(.mkscb--has-conv):not(:has(.mkscb__msg--welcome)) ~ .mkscb__composer {
	padding-top: 0;
	border-top: 0;
}

.mkscb:not(.mkscb--has-conv) ~ .mkscb__composer::before {
	display: none;
}

/* fondu transparent → blanc en surimpression sur le bas du fil : aucun
   espace ajouté sous le dernier message */
.mkscb__composer::before {
	content: '';
	position: absolute;
	right: 0;
	/* juste au-dessus du filet (la zone de référence commence sous la bordure) */
	bottom: calc(100% + 1px);
	left: 0;
	/* ne recouvre que le retrait bas du fil : le dernier message reste lisible */
	height: 12px;
	background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff);
	pointer-events: none;
}

.mkscb__composer .mksc__ask-input {
	min-height: 44px;
}

.mkscb__attach {
	flex: none;
	align-self: flex-end;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	/* zone cliquable de 40px : le centre du picto s'aligne sur celui du bouton
	   d'envoi (26px), soit (40 - 26) / 2 = 7px plus bas */
	margin-bottom: -7px;
	margin-right: -8px;
	border: 0;
	border-radius: 50%;
	background: none;
	color: #130090;
	cursor: pointer;
}

.mkscb__attach .material-symbols-outlined {
	display: block;
	line-height: 1;
}

.mkscb__attach:hover {
	background: #f1f2ff;
}

.mkscb__attach .material-symbols-outlined {
	font-size: 24px;
}

.mkscb__pending {
	display: inline-flex;
	align-self: flex-start;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 4px 10px;
	border-radius: 48px;
	background: #f1f2ff;
	color: #130090;
	font-size: 13px;
}

.mkscb__pending-remove {
	display: inline-flex;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
}

.mkscb__pending .material-symbols-outlined {
	font-size: 18px;
}

.mkscb--busy .mksc__ask-send {
	opacity: .5;
	cursor: default;
}

@media (max-width: 991px) {
	.mksc__ask--chat:not(.mksc__ask--wide) {
		min-height: 100px;
	}
}

@media (max-width: 767px) {
	.mkscb__thread {
		max-height: 60vh;
		padding: 12px;
	}

	.mkscb__msg {
		max-width: 92%;
	}

	.mkscb__attachment img {
		max-width: 100%;
	}

	/* iOS zoome au focus d'un champ de moins de 16px */
	.mkscb__csat-comment {
		font-size: 16px;
	}
}
