/* TGL Chatbot : bulle flottante en bas à droite, fenêtre de discussion moderne, couleurs de la marque. */
.tglcb {
	--tglcb-green: #21a56e;
	--tglcb-green-dark: #178257;
	--tglcb-green-soft: #e9f6ef;
	--tglcb-ink: #1d2a24;
	--tglcb-muted: #6b7a72;
	--tglcb-line: #e6ece8;
	--tglcb-bot: #f2f5f3;
	--tglcb-radius: 20px;
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 99999;
	font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--tglcb-ink);
	-webkit-font-smoothing: antialiased;
}
.tglcb *, .tglcb *::before, .tglcb *::after { box-sizing: border-box; }
.tglcb button { font: inherit; margin: 0; }
.tglcb svg { display: block; }

/* ---------- Bouton flottant ---------- */
.tglcb__fab {
	position: relative;
	display: grid;
	place-items: center;
	width: 60px;
	height: 60px;
	margin-left: auto;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: linear-gradient(145deg, #2bb87b 0%, var(--tglcb-green) 55%, var(--tglcb-green-dark) 100%);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(23, 130, 87, 0.38), 0 2px 6px rgba(0, 0, 0, 0.12);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tglcb__fab:hover { transform: scale(1.06); box-shadow: 0 14px 34px rgba(23, 130, 87, 0.45), 0 2px 6px rgba(0, 0, 0, 0.12); }
.tglcb__fab:active { transform: scale(0.97); }
.tglcb__fab-icon {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	transition: opacity 0.2s ease, transform 0.25s ease;
}
.tglcb__fab-icon--close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.tglcb--open .tglcb__fab-icon--chat { opacity: 0; transform: rotate(90deg) scale(0.6); }
.tglcb--open .tglcb__fab-icon--close { opacity: 1; transform: none; }

/* ---------- Fenêtre ---------- */
.tglcb__panel {
	position: absolute;
	right: 0;
	bottom: 76px;
	display: flex;
	flex-direction: column;
	width: 384px;
	height: min(640px, calc(100vh - 120px));
	background: #fff;
	border-radius: var(--tglcb-radius);
	box-shadow: 0 24px 60px rgba(16, 38, 28, 0.22), 0 4px 14px rgba(16, 38, 28, 0.08);
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transform: translateY(14px) scale(0.97);
	transform-origin: bottom right;
	transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.26s;
}
.tglcb--open .tglcb__panel {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity 0.22s ease, transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s;
}

/* En-tête */
.tglcb__header {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 16px 12px 16px 18px;
	background: linear-gradient(135deg, var(--tglcb-green) 0%, var(--tglcb-green-dark) 100%);
	color: #fff;
}
.tglcb__who { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.tglcb__titles { min-width: 0; }
.tglcb__title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.tglcb__subtitle { font-size: 12.5px; opacity: 0.88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tglcb__badge {
	padding: 1px 8px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.22);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
}
.tglcb__icon-btn {
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	flex: none;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: inherit;
	cursor: pointer;
	transition: background-color 0.15s ease;
}
.tglcb__icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

/* Avatars */
.tglcb__avatar {
	position: relative;
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	flex: none;
	border-radius: 50%;
	background: var(--tglcb-green-soft);
	color: var(--tglcb-green-dark);
	overflow: visible;
}
.tglcb__avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.tglcb__avatar--ghost { visibility: hidden; }
.tglcb__avatar--lg { width: 42px; height: 42px; background: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35); }
.tglcb__avatar--lg svg { width: 20px; height: 20px; }
.tglcb__online {
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #4ade80;
	border: 2px solid var(--tglcb-green);
}

/* Conversation */
.tglcb__log {
	flex: 1;
	min-height: 0;
	padding: 18px 16px 8px;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: #fff;
	scroll-behavior: smooth;
}
.tglcb__msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; animation: tglcb-in 0.22s ease both; }
.tglcb__msg:first-child { margin-top: 0; }
.tglcb__msg--cont { margin-top: 4px; }
.tglcb__msg--user { justify-content: flex-end; }
.tglcb__bubble {
	max-width: 80%;
	padding: 10px 14px;
	border-radius: 18px;
	background: var(--tglcb-bot);
	overflow-wrap: anywhere;
}
.tglcb__msg--bot .tglcb__bubble { border-bottom-left-radius: 6px; }
.tglcb__msg--user .tglcb__bubble {
	background: var(--tglcb-green);
	color: #fff;
	border-bottom-right-radius: 6px;
}
.tglcb__p { margin: 0 0 8px; }
.tglcb__p:last-child { margin-bottom: 0; }
.tglcb__list { margin: 4px 0 8px; padding-left: 18px; }
.tglcb__list:last-child { margin-bottom: 0; }
.tglcb__list li { margin: 2px 0; }
.tglcb__bubble strong { font-weight: 700; }
.tglcb__link { color: var(--tglcb-green-dark); font-weight: 600; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
.tglcb__link:hover { color: var(--tglcb-green); }
.tglcb__msg--user .tglcb__link { color: #fff; }

/* Indicateur d'écriture */
.tglcb__typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px; }
.tglcb__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #9fb3a8;
	animation: tglcb-dot 1.2s infinite ease-in-out;
}
.tglcb__typing span:nth-child(2) { animation-delay: 0.15s; }
.tglcb__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tglcb-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes tglcb-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Contact (sous un message de repli ou à la demande) */
.tglcb__contact { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.tglcb__bubble > .tglcb__contact:first-child { margin-top: 0; }
.tglcb__contact-lead { width: 100%; font-size: 13.5px; margin-bottom: 2px; }
.tglcb__pill {
	display: inline-flex;
	align-items: center;
	padding: 6px 12px;
	border: 1px solid var(--tglcb-green);
	border-radius: 999px;
	background: #fff;
	color: var(--tglcb-green-dark) !important;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none !important;
	transition: background-color 0.15s ease, color 0.15s ease;
}
.tglcb__pill:hover { background: var(--tglcb-green); color: #fff !important; }

/* Saisie */
.tglcb__composer { padding: 10px 14px 8px; background: #fff; }
.tglcb__field {
	display: flex;
	align-items: flex-end;
	gap: 6px;
	padding: 6px 6px 6px 16px;
	border: 1px solid var(--tglcb-line);
	border-radius: 24px;
	background: #f8faf9;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.tglcb__field:focus-within { border-color: var(--tglcb-green); background: #fff; box-shadow: 0 0 0 3px rgba(33, 165, 110, 0.15); }
.tglcb__input {
	flex: 1;
	min-height: 36px;
	max-height: 120px;
	padding: 7px 0;
	border: 0 !important;
	outline: 0 !important;
	box-shadow: none !important;
	background: transparent !important;
	color: var(--tglcb-ink);
	font: inherit;
	font-size: 15px;
	line-height: 22px;
	resize: none;
}
.tglcb__input::placeholder { color: #93a39a; }
.tglcb__send {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	flex: none;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--tglcb-green);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}
.tglcb__send:hover:not(:disabled) { background: var(--tglcb-green-dark); transform: scale(1.05); }
.tglcb__send:disabled { background: #cfd9d3; cursor: default; }

/* Pied */
.tglcb__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 0 16px 12px;
	background: #fff;
}
.tglcb__legend { font-size: 11px; line-height: 1.35; color: var(--tglcb-muted); }
.tglcb__human {
	flex: none;
	padding: 0;
	border: 0;
	background: none;
	color: var(--tglcb-green-dark);
	font-size: 12px;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

/* Focus clavier */
.tglcb__fab:focus-visible, .tglcb__icon-btn:focus-visible, .tglcb__send:focus-visible, .tglcb__pill:focus-visible, .tglcb__human:focus-visible, .tglcb__link:focus-visible {
	outline: 3px solid #0d5c3a;
	outline-offset: 2px;
}
.tglcb__header .tglcb__icon-btn:focus-visible { outline-color: #fff; }

/* Mobile : plein écran */
@media (max-width: 520px) {
	.tglcb { right: 16px; bottom: 16px; }
	.tglcb__panel {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		height: 100dvh;
		border-radius: 0;
		transform: translateY(24px);
	}
	.tglcb--open .tglcb__fab { opacity: 0; pointer-events: none; }
	.tglcb__header { padding-top: max(16px, env(safe-area-inset-top)); }
	.tglcb__foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
	.tglcb__bubble { max-width: 85%; }
	.tglcb__input { font-size: 16px; } /* évite le zoom automatique d'iOS */
}
html.tglcb-lock, html.tglcb-lock body { overflow: hidden !important; }

@media (prefers-reduced-motion: reduce) {
	.tglcb__fab, .tglcb__fab-icon, .tglcb__panel, .tglcb__msg, .tglcb__typing span, .tglcb__send { transition: none !important; animation: none !important; }
	.tglcb__log { scroll-behavior: auto; }
}
