/* MKS Chatbot — bulle de conversation flottante (toutes pages sauf contact).
   Palette du thème : navy #130090, orange #ff6e00, lavande #f1f2ff, texte #44404c.
   Design repris de la maquette chatbot-client/maquettes/chat_client.html. */

.mkscbb {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 100000;
	font-family: 'Poppins', sans-serif;
}

.mkscbb[hidden] {
	display: none;
}

/* --- lanceur ------------------------------------------------------------- */
.mkscbb__launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	padding: 0;
	border: 1px solid #e5e6ff;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 6px 24px rgba(19, 0, 144, .25);
	cursor: pointer;
	transition: transform .15s ease, box-shadow .15s ease;
}

.mkscbb__launcher:hover {
	transform: scale(1.06);
	box-shadow: 0 8px 28px rgba(19, 0, 144, .32);
}

.mkscbb__launcher img {
	display: block;
	width: 34px;
	height: 34px;
}

.mkscbb__launcher > .material-symbols-outlined {
	color: #130090;
	font-size: 28px;
}

/* panneau ouvert : le lanceur devient un bouton « réduire » */
.mkscbb__launcher-close {
	display: none;
	color: #130090;
	font-size: 30px;
}

.mkscbb--open .mkscbb__launcher img,
.mkscbb--open .mkscbb__launcher > .material-symbols-outlined:not(.mkscbb__launcher-close) {
	display: none;
}

.mkscbb--open .mkscbb__launcher-close {
	display: block;
}

/* pastille « nouveau message » (panneau réduit) */
.mkscbb__dot {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 14px;
	height: 14px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: #ff6e00;
}

.mkscbb__dot[hidden] {
	display: none;
}

/* --- panneau ------------------------------------------------------------- */
.mkscbb__panel {
	position: fixed;
	right: 24px;
	bottom: 96px;
	display: flex;
	flex-direction: column;
	width: 392px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 130px);
	max-height: calc(100dvh - 130px);
	overflow: hidden;
	border: 1px solid #e5e6ff;
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 12px 48px rgba(19, 0, 144, .25);
}

.mkscbb__panel[hidden] {
	display: none;
}

/* --- en-tête ------------------------------------------------------------- */
.mkscbb__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
	background: linear-gradient(135deg, #130090 0%, #2a1fd0 100%);
	color: #fff;
}

.mkscbb__head-icon {
	flex: none;
	width: 36px;
	height: 36px;
	padding: 4px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

.mkscbb__head-who {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.mkscbb__head-nom {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
}

.mkscbb__head-ia {
	padding: 3px 5px;
	border-radius: 5px;
	background: #ff6e00;
	font-size: 10px;
	font-weight: 600;
	line-height: 1;
}

.mkscbb__head-etat {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	opacity: .85;
}

/* hors horaires d'ouverture : pas de ligne d'état du tout */
.mkscbb__head-etat[hidden] {
	display: none;
}

.mkscbb__head-etat::before {
	content: '';
	flex: none;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #3ddc84;
	box-shadow: 0 0 0 3px rgba(61, 220, 132, .25);
}

/* API injoignable : plus de point vert */
.mkscbb--down .mkscbb__head-etat::before {
	background: #c9c8d6;
	box-shadow: none;
}

.mkscbb__head-actions {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	margin-left: auto;
}

.mkscbb__action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: #fff;
	opacity: .8;
	cursor: pointer;
}

.mkscbb__action:hover {
	background: rgba(255, 255, 255, .15);
	opacity: 1;
}

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

/* en desktop, la fermeture passe par le lanceur (chevron du bas) :
   pas de bouton « réduire » dans l'en-tête (réaffiché en mobile) */
.mkscbb__action--close {
	display: none;
}

/* badge conseiller, sous l'en-tête */
.mkscbb__badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	align-self: flex-start;
	margin: 10px 16px 0;
	padding: 4px 10px;
	border-radius: 48px;
	background: #130090;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
}

.mkscbb__badge[hidden] {
	display: none;
}

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

/* --- notices / statut ----------------------------------------------------- */
.mkscbb__notice {
	margin: 10px 16px 0;
	padding: 8px 12px;
	border-radius: 10px;
	background: #f1f2ff;
	color: #130090;
	font-size: 13px;
	line-height: 1.35;
}

.mkscbb__notice[hidden] {
	display: none;
}

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

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

.mkscbb__notice a {
	color: inherit;
	font-weight: 600;
	text-decoration: underline;
}

.mkscbb__status {
	margin: 0 16px 6px;
	color: #707682;
	font-size: 12px;
	font-style: italic;
}

.mkscbb__status[hidden] {
	display: none;
}

/* --- liste des conversations mémorisées ----------------------------------- */
.mkscbb__list {
	position: absolute;
	top: 64px;
	right: 12px;
	z-index: 5;
	display: flex;
	flex-direction: column;
	gap: 4px;
	width: min(320px, calc(100% - 24px));
	max-height: 240px;
	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);
}

.mkscbb__list[hidden] {
	display: none;
}

.mkscbb__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;
}

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

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

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

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

/* --- fil ------------------------------------------------------------------ */
.mkscbb__thread {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	gap: 12px;
	min-height: 0;
	padding: 16px;
	overflow-y: auto;
	background: #f7f7fd;
	scroll-behavior: smooth;
}

.mkscbb__msg {
	display: flex;
	flex-direction: column;
	max-width: 84%;
	animation: mkscbb-pop .25s ease;
}

@keyframes mkscbb-pop {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

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

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

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

.mkscbb__msg--assistant .mkscbb__bubble {
	background: #fff;
	border: 1px solid #e5e6ff;
	border-bottom-left-radius: 5px;
}

.mkscbb__msg--agent .mkscbb__bubble {
	background: #fff;
	border: 1px solid #130090;
	border-bottom-left-radius: 5px;
}

.mkscbb__msg--user .mkscbb__bubble {
	background: #130090;
	color: #fff;
	border-bottom-right-radius: 5px;
}

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

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

.mkscbb__bubble li {
	list-style: disc;
}

/* notification du système (« Votre demande est transmise… ») */
.mkscbb__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 */
.mkscbb__agent-nom {
	margin: 0 0 2px 6px;
	color: #130090;
	font-size: 12px;
	font-weight: 600;
}

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

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

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

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

.mkscbb__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;
}

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

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

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

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

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

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

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

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

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

/* --- sélecteur d'articles -------------------------------------------------- */
.mkscbb__picker {
	flex: none;
	margin: 0 16px 10px;
	padding: 12px 14px;
	max-height: 260px;
	overflow-y: auto;
	border: 1px solid #e5e6ff;
	border-radius: 12px;
	background: #fff;
}

.mkscbb__picker[hidden] {
	display: none;
}

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

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

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

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

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

.mkscbb__picker-lib {
	flex: 1;
}

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

.mkscbb__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;
}

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

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

.mkscbb__csat[hidden] {
	display: none;
}

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

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

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

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

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

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

.mkscbb__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;
}

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

/* --- raccourcis de conversation (dans le fil, sous l'accueil) -------------- */
.mkscbb__starters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-self: stretch;
	margin-top: 2px;
}

.mkscbb__starters[hidden] {
	display: none;
}

.mkscbb__chip {
	padding: 7px 14px;
	border: 1px solid #e5e6ff;
	border-radius: 48px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(19, 0, 144, .08);
	color: #44404c;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.2;
	cursor: pointer;
	transition: border-color .15s ease, box-shadow .15s ease, color .15s ease;
}

.mkscbb__chip:hover {
	border-color: #130090;
	box-shadow: 0 2px 6px rgba(19, 0, 144, .15);
	color: #130090;
}

.mkscbb--down .mkscbb__starters {
	display: none;
}

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

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

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

.mkscbb__composer {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	flex: none;
	margin: 0;
	padding: 10px 12px;
	border-top: 1px solid #e5e6ff;
	background: #fff;
}

/* le cadre arrondi est porté par le conteneur : son overflow hidden rogne
   l'ascenseur du textarea sous le border-radius */
.mkscbb__input-wrap {
	display: flex;
	flex: 1;
	min-width: 0;
	overflow: hidden;
	border: 1px solid #dbdadd;
	border-radius: 20px;
	background: #f7f7fd;
}

.mkscbb__input-wrap:focus-within {
	border-color: #130090;
	background: #fff;
}

.mkscbb__input {
	flex: 1;
	width: 100%;
	min-height: 38px;
	/* pas d'ascenseur jusqu'à 4 lignes : bubble.js borne la hauteur à 4 lignes
	   et ne rend l'ascenseur qu'au-delà */
	overflow-y: hidden;
	padding: 9px 14px;
	border: 0;
	background: transparent;
	color: #44404c;
	font-family: inherit;
	font-size: 16px; /* iOS zoome au focus d'un champ de moins de 16px */
	line-height: 1.4;
	resize: none;
}

.mkscbb__input:focus {
	outline: none;
}

/* ascenseur (à partir de 5 lignes) au bord du champ, rogné par l'arrondi */
.mkscbb__input {
	scrollbar-width: thin;              /* Firefox */
	scrollbar-color: #c9c8d6 transparent;
}

.mkscbb__input::-webkit-scrollbar {
	width: 10px;
}

.mkscbb__input::-webkit-scrollbar-track {
	background: transparent;
}

.mkscbb__input::-webkit-scrollbar-thumb {
	background-color: #c9c8d6;
	border-radius: 10px;
}

.mkscbb__input::-webkit-scrollbar-thumb:hover {
	background-color: #989898;
}

.mkscbb__attach {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: #130090;
	cursor: pointer;
}

.mkscbb__attach:hover {
	background: #f1f2ff;
}

.mkscbb__attach .material-symbols-outlined {
	font-size: 22px;
	line-height: 1;
}

.mkscbb__send {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #ff6e00;
	color: #fff;
	cursor: pointer;
	transition: background .15s ease;
}

.mkscbb__send:hover {
	background: #e06100;
}

.mkscbb__send:disabled,
.mkscbb--busy .mkscbb__send {
	opacity: .5;
	cursor: default;
}

.mkscbb__send .material-symbols-outlined {
	font-size: 22px;
	line-height: 1;
}

/* --- pied ------------------------------------------------------------------ */
.mkscbb__rgpd {
	flex: none;
	margin: 0;
	padding: 6px 14px 10px;
	background: #fff;
	color: #6b7280;
	font-size: 10px;
	line-height: 1.45;
	text-align: center;
}

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

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

/* --- API injoignable -------------------------------------------------------- */
.mkscbb--down .mkscbb__composer,
.mkscbb--down .mkscbb__rgpd {
	display: none;
}

/* --- mobile ----------------------------------------------------------------- */
@media (max-width: 520px) {
	.mkscbb {
		right: 16px;
		bottom: 16px;
	}

	.mkscbb__launcher {
		width: 56px;
		height: 56px;
	}

	/* panneau plein écran, le lanceur passe dessous (fermeture par l'en-tête) */
	.mkscbb__panel {
		right: 0;
		bottom: 0;
		left: 0;
		top: 0;
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: 100vh;
		max-height: 100dvh;
		border: 0;
		border-radius: 0;
	}

	.mkscbb--open .mkscbb__launcher {
		display: none;
	}

	/* le lanceur est masqué quand le panneau est ouvert : le bouton
	   « réduire » de l'en-tête reprend du service */
	.mkscbb__action--close {
		display: inline-flex;
	}

	.mkscbb__msg {
		max-width: 92%;
	}

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