/* Tous les sélecteurs passent par #ecb-root pour l'emporter sur les styles du thème (boutons, champs). */

#ecb-root, #ecb-root *, #ecb-root *::before, #ecb-root *::after { box-sizing: border-box; }

#ecb-root {
	--ecb-color: #2f6f4f;
	position: fixed; right: 20px; bottom: 20px; z-index: 99999;
	font-family: inherit; font-size: 15px; line-height: 1.45; color: #222;
	letter-spacing: normal; text-transform: none; text-align: left;
}

/* Remise à zéro des boutons et du champ : le thème ne doit plus rien leur imposer. */
#ecb-root button, #ecb-root input {
	all: unset;
	box-sizing: border-box;
	font-family: inherit;
	letter-spacing: normal !important;
	text-transform: none !important;
	text-shadow: none !important;
	box-shadow: none;
	margin: 0;
	min-width: 0 !important;
	min-height: 0 !important;
	cursor: pointer;
}

#ecb-root button:focus-visible, #ecb-root input:focus-visible { outline: 2px solid var(--ecb-color); outline-offset: 2px; }

/* Bulle d'ouverture */
#ecb-root .ecb-toggle {
	width: 58px !important; height: 58px !important; border-radius: 50%;
	background: var(--ecb-color); color: #fff;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
#ecb-root .ecb-toggle:hover { filter: brightness(1.1); }
#ecb-root .ecb-toggleimg { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid #fff; }
#ecb-root .ecb-toggle:focus-visible { outline-color: #fff; outline-offset: -5px; }
#ecb-root.ecb-open .ecb-toggle { display: none; }

/* Fenêtre */
#ecb-root .ecb-panel {
	width: 360px; max-width: calc(100vw - 24px); height: 520px; max-height: calc(100vh - 40px);
	background: #fff; color: #222; border-radius: 14px;
	box-shadow: 0 8px 30px rgba(0,0,0,.28);
	display: flex; flex-direction: column; overflow: hidden;
}
#ecb-root .ecb-panel[hidden] { display: none; }

#ecb-root .ecb-header { background: var(--ecb-color); color: #fff; padding: 10px 12px 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 0 0 auto; }
#ecb-root .ecb-headleft { display: flex; align-items: center; gap: 10px; min-width: 0; }
#ecb-root .ecb-headavatar { display: block; width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px; background: #fff; object-fit: cover; border: 2px solid rgba(255,255,255,.85); }
#ecb-root .ecb-titles { display: flex; flex-direction: column; min-width: 0; }
#ecb-root .ecb-title { font-weight: 700; font-size: 17px; line-height: 1.2; }
#ecb-root .ecb-subtitle { font-size: 12px; line-height: 1.3; opacity: .9; }

#ecb-root .ecb-close {
	flex: 0 0 auto; width: 32px !important; height: 32px !important;
	display: flex; align-items: center; justify-content: center;
	border-radius: 50%; background: transparent; color: #fff; font-size: 24px; line-height: 1;
}
#ecb-root .ecb-close:hover { background: rgba(255,255,255,.2); }
#ecb-root .ecb-close:focus-visible { outline-color: #fff; }

/* Messages */
#ecb-root .ecb-messages { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #f6f7f6; }
#ecb-root .ecb-msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; white-space: normal; word-wrap: break-word; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; }
#ecb-root .ecb-assistant { background: #fff; color: #222; border: 1px solid #e2e5e2; align-self: flex-start; border-bottom-left-radius: 3px; }
#ecb-root .ecb-user { background: var(--ecb-color); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
#ecb-root .ecb-msg a { color: var(--ecb-color); text-decoration: underline; }
#ecb-root .ecb-user a { color: #fff; }
#ecb-root .ecb-typing { opacity: .6; }

/* Paragraphes et puces dans les réponses */
#ecb-root .ecb-p { margin: 0 0 .65em; }
#ecb-root .ecb-li { position: relative; padding-left: 16px; margin: 0 0 .3em; }
#ecb-root .ecb-li::before { content: "•"; position: absolute; left: 3px; }
#ecb-root .ecb-msg > :last-child { margin-bottom: 0; }

/* Buste de Dédé au-dessus du message d'accueil */
#ecb-root .ecb-welcome { align-self: center; margin: 2px 0 0; }
#ecb-root .ecb-bust { display: block; width: 110px; height: 110px; border-radius: 18px; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,.15); }

/* Avatar à côté des messages du bot */
#ecb-root .ecb-row { display: flex; align-items: flex-start; gap: 8px; align-self: flex-start; max-width: 94%; }
#ecb-root .ecb-row .ecb-msg { max-width: calc(100% - 36px); }
#ecb-root .ecb-avatar { display: block; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; object-fit: cover; background: #fff; border: 1px solid #e2e5e2; }
#ecb-root.ecb-has-avatar a.ecb-linkbtn { margin-left: 36px; }

/* Bouton de lien sous une réponse */
#ecb-root a.ecb-linkbtn {
	align-self: flex-start; display: inline-block; max-width: 85%;
	background: var(--ecb-color); color: #fff !important; border: 0;
	border-radius: 16px; padding: 5px 12px;
	font-size: 13px; font-weight: 600; line-height: 1.3;
	text-decoration: none !important; text-transform: none !important; letter-spacing: normal !important;
}
#ecb-root a.ecb-linkbtn:hover, #ecb-root a.ecb-linkbtn:focus-visible { filter: brightness(1.12); }

/* Boutons de suggestion */
#ecb-root .ecb-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; align-self: stretch; }
#ecb-root .ecb-chip {
	display: inline-block; max-width: 100%;
	border: 1px solid var(--ecb-color); background: #fff; color: var(--ecb-color);
	border-radius: 16px; padding: 5px 11px;
	font-size: 13px; font-weight: 500; line-height: 1.3; text-align: left; white-space: normal;
}
#ecb-root .ecb-chip:hover, #ecb-root .ecb-chip:focus-visible { background: var(--ecb-color); color: #fff; }

/* Saisie */
#ecb-root .ecb-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e2e5e2; background: #fff; flex: 0 0 auto; }
#ecb-root .ecb-input {
	flex: 1 1 auto; width: 100%; min-width: 0;
	border: 1px solid #c9cec9; border-radius: 8px; padding: 9px 10px;
	font-size: 15px; line-height: 1.3; color: #222; background: #fff; cursor: text;
}
#ecb-root .ecb-input::placeholder { color: #767c76; opacity: 1; }
#ecb-root .ecb-input:focus { border-color: var(--ecb-color); outline: 2px solid var(--ecb-color); outline-offset: 0; }
#ecb-root .ecb-send {
	flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
	border-radius: 8px; background: var(--ecb-color); color: #fff; padding: 0 14px;
	font-size: 14px; font-weight: 600; line-height: 1;
}
#ecb-root .ecb-send:hover { filter: brightness(1.1); }
#ecb-root .ecb-send:disabled { opacity: .5; cursor: default; }

#ecb-root .ecb-note { padding: 0 12px 8px; font-size: 11px; line-height: 1.3; color: #6b716b; background: #fff; flex: 0 0 auto; }

@media (max-width: 480px) {
	#ecb-root { right: 12px; bottom: 12px; }
	#ecb-root.ecb-open { right: 0; bottom: 0; }
	#ecb-root.ecb-open .ecb-panel { width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
	/* 16 px minimum : évite le zoom automatique de Safari sur iPhone quand on touche le champ */
	#ecb-root .ecb-input { font-size: 16px; }
}

@media (prefers-reduced-motion: no-preference) {
	#ecb-root .ecb-panel { animation: ecb-in .18s ease-out; }
	@keyframes ecb-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
