/* ============================================================
   Miroiterie Brun - Assistant IA (widget de chat)
   Couleurs alignees sur la charte du site (Elementor).
   ============================================================ */

#mbchat-root {
	--mb-main:   #1E525F;
	--mb-main2:  #266D85;
	--mb-accent: #87A8A9;
	--mb-bg:     #ffffff;
	--mb-soft:   #F8F8F8;
	--mb-line:   #E3E8EA;
	--mb-text:   #2C2C2C;
	--mb-muted:  #6b7b80;
	font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
}
#mbchat-root *, #mbchat-root *::before, #mbchat-root *::after { box-sizing: border-box; }

/* Defenses contre les themes WP qui appliquent des regles globales agressives
   sur les <svg>, <img> et les icones FontAwesome du widget. */
#mbchat-root svg { display: inline-block !important; max-width: none !important; vertical-align: middle !important; }
#mbchat-root svg path { fill: inherit; }
#mbchat-root img { max-width: 100%; height: auto; display: block; }

/* Icones FontAwesome — on force la couleur, le display et on neutralise les
   eventuelles regles "::before content: none" de certains resets. */
#mbchat-root .mb-icon { display: inline-block !important; line-height: 1 !important; color: #fff !important; font-style: normal !important; }
#mbchat-root .mb-icon::before { color: #fff !important; }

/* ---------- Bulle fermee ---------- */
#mbchat-bubble {
	position: fixed;
	right: 22px;
	bottom: 22px;
	width: 62px;
	height: 62px;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	z-index: 999998;
	background: linear-gradient(135deg, var(--mb-main2), var(--mb-main));
	box-shadow: 0 10px 28px rgba(30,82,95,.38);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .2s ease, box-shadow .2s ease;
	animation: mb-pop .35s ease;
}
#mbchat-bubble:hover { transform: scale(1.06); box-shadow: 0 14px 34px rgba(30,82,95,.46); }
#mbchat-bubble svg { width: 30px !important; height: 30px !important; fill: #fff !important; display: block !important; }
#mbchat-bubble .mb-icon { font-size: 26px !important; }
#mbchat-bubble .mb-pulse {
	position: absolute; inset: 0; border-radius: 50%;
	box-shadow: 0 0 0 0 rgba(135,168,169,.55);
	animation: mb-pulse 2.4s infinite;
}
#mbchat-bubble .mb-badge {
	position: absolute; top: -3px; right: -3px;
	min-width: 20px; height: 20px; padding: 0 5px;
	background: #e2574c; color: #fff; border-radius: 10px;
	font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
	box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

@keyframes mb-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(135,168,169,.55); }
	70%  { box-shadow: 0 0 0 16px rgba(135,168,169,0); }
	100% { box-shadow: 0 0 0 0 rgba(135,168,169,0); }
}
@keyframes mb-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* ---------- Fenetre de chat ---------- */
#mbchat-panel {
	position: fixed;
	right: 22px;
	bottom: 22px;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 580px;
	max-height: calc(100vh - 40px);
	background: var(--mb-bg);
	border-radius: 18px;
	box-shadow: 0 18px 50px rgba(20,40,46,.32);
	z-index: 999999;
	display: none;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(16px) scale(.98);
	transition: opacity .22s ease, transform .22s ease;
}
#mbchat-panel.mb-open { display: flex; opacity: 1; transform: translateY(0) scale(1); }

/* En-tete */
#mbchat-head {
	background: linear-gradient(135deg, var(--mb-main2), var(--mb-main));
	color: #fff;
	padding: 16px 18px;
	display: flex;
	align-items: center;
	gap: 12px;
}
#mbchat-head .mb-ava {
	width: 42px; height: 42px; border-radius: 50%;
	background: rgba(255,255,255,.16);
	display: flex; align-items: center; justify-content: center; flex: none;
	overflow: hidden;
}
#mbchat-head .mb-ava img {
	width: 42px !important;
	height: 42px !important;
	border-radius: 50%;
	object-fit: cover;
	display: block !important;
	max-width: none !important;
}
#mbchat-head .mb-ava .mb-ava-initial {
	color: #fff; font-weight: 700; font-size: 17px;
	font-family: inherit; line-height: 1;
}
#mbchat-head .mb-ttl { flex: 1; min-width: 0; }
#mbchat-head .mb-ttl b { display: block; font-size: 15.5px; font-weight: 700; }
#mbchat-head .mb-ttl span { display: flex; align-items: center; gap: 6px; font-size: 12.5px; opacity: .9; }
#mbchat-head .mb-dot { width: 8px; height: 8px; border-radius: 50%; background: #67e08a; box-shadow: 0 0 0 3px rgba(103,224,138,.3); }
#mbchat-close {
	background: rgba(255,255,255,.12); border: none; color: #fff;
	width: 32px; height: 32px; border-radius: 9px; cursor: pointer; font-size: 18px;
	display: flex; align-items: center; justify-content: center; transition: background .15s;
}
#mbchat-close:hover { background: rgba(255,255,255,.26); }

/* Zone messages */
#mbchat-body {
	flex: 1; overflow-y: auto; padding: 18px 16px 6px;
	background: var(--mb-soft);
	display: flex; flex-direction: column; gap: 10px;
}
#mbchat-body::-webkit-scrollbar { width: 7px; }
#mbchat-body::-webkit-scrollbar-thumb { background: #cdd6d8; border-radius: 4px; }

.mb-msg { max-width: 84%; padding: 10px 13px; border-radius: 15px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; animation: mb-in .2s ease; }
.mb-msg a { color: var(--mb-main2); font-weight: 600; }
.mb-bot { align-self: flex-start; background: #fff; color: var(--mb-text); border: 1px solid var(--mb-line); border-bottom-left-radius: 5px; }
.mb-user { align-self: flex-end; background: linear-gradient(135deg, var(--mb-main2), var(--mb-main)); color: #fff; border-bottom-right-radius: 5px; }
.mb-user a { color: #fff; text-decoration: underline; }
@keyframes mb-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Actions rapides */
#mbchat-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 8px; }
.mb-chip {
	background: #fff; border: 1px solid var(--mb-accent); color: var(--mb-main);
	padding: 7px 12px; border-radius: 20px; font-size: 13px; font-weight: 600;
	cursor: pointer; transition: all .15s; font-family: inherit;
}
.mb-chip:hover { background: var(--mb-main); color: #fff; border-color: var(--mb-main); }

/* Indicateur de saisie */
.mb-typing { align-self: flex-start; background: #fff; border: 1px solid var(--mb-line); border-radius: 15px; border-bottom-left-radius: 5px; padding: 12px 14px; display: flex; gap: 4px; }
.mb-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--mb-accent); display: inline-block; animation: mb-bounce 1.2s infinite; }
.mb-typing i:nth-child(2) { animation-delay: .2s; }
.mb-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes mb-bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Saisie */
#mbchat-foot { border-top: 1px solid var(--mb-line); background: #fff; padding: 10px 12px; }
#mbchat-input-row { display: flex; align-items: flex-end; gap: 8px; }
#mbchat-input {
	flex: 1; resize: none; border: 1px solid var(--mb-line); border-radius: 12px;
	padding: 10px 12px; font-family: inherit; font-size: 14px; color: var(--mb-text);
	max-height: 96px; line-height: 1.4; outline: none; transition: border-color .15s;
}
#mbchat-input:focus { border-color: var(--mb-accent); }
#mbchat-send {
	flex: none; width: 42px; height: 42px; border: none; border-radius: 12px; cursor: pointer;
	background: linear-gradient(135deg, var(--mb-main2), var(--mb-main));
	display: flex; align-items: center; justify-content: center; transition: opacity .15s, transform .1s;
}
#mbchat-send:hover { transform: scale(1.05); }
#mbchat-send:disabled { opacity: .5; cursor: default; transform: none; }
#mbchat-send svg { width: 19px !important; height: 19px !important; fill: #fff !important; display: block !important; }
#mbchat-send .mb-icon { font-size: 17px !important; }
#mbchat-note { text-align: center; font-size: 11px; color: var(--mb-muted); margin: 7px 0 1px; }
#mbchat-note a { color: var(--mb-muted); }

/* Mobile */
@media (max-width: 480px) {
	#mbchat-panel { right: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
	#mbchat-bubble { right: 16px; bottom: 16px; }
}
