/* ============================================================================
   ANaTT — Widget chatbot IA
   ----------------------------------------------------------------------------
   Charte graphique du portail ANaTT :
     · Montserrat (Regular / Medium / SemiBold / Bold)
     · Vert institutionnel #198754 — vert foncé #0C623B
     · Jaune #FEC929 — Rouge #ED242C — Encre #101913
     · Coins arrondis, ombres douces, surfaces blanches
   Toutes les classes sont préfixées « chatbot_ » pour ne rien écraser.
   Référence : ANaTT-DSI-SIMVeB-CHAT-001.
   ========================================================================== */

.chatbot {
	--cb-vert: #198754;
	--cb-vert-fonce: #0C623B;
	--cb-vert-clair: #B9E4CC;
	--cb-vert-xl: #E9F6EF;
	--cb-jaune: #FEC929;
	--cb-jaune-xl: #FFF8E1;
	--cb-rouge: #ED242C;
	--cb-rouge-xl: #FDEBEC;
	--cb-encre: #101913;
	--cb-encre-2: #17402C;
	--cb-texte: #292C33;
	--cb-muet: #6B7280;
	--cb-ligne: rgba(16, 25, 19, .10);
	--cb-g1: #F7FAF8;
	--cb-g2: #F1F5F4;
	--cb-g3: #E2E8E5;
	--cb-rayon: 1.25rem;
	--cb-rayon-sm: .75rem;
	--cb-ombre: 0 1px 2px rgba(16, 25, 19, .04), 0 8px 24px rgba(16, 25, 19, .06);
	--cb-ombre-lg: 0 2px 4px rgba(16, 25, 19, .05), 0 16px 40px rgba(16, 25, 19, .16);

	font-family: 'Montserrat-Regular', sans-serif;
	color: var(--cb-texte);
}

.chatbot *,
.chatbot *::before,
.chatbot *::after {
	box-sizing: border-box;
}

/* ── Bouton flottant (FAB) ──────────────────────────────────────────────── */
.chatbot_fab {
	position: fixed;
	right: 1.5rem;
	bottom: 1.5rem;
	width: 56px;
	height: 56px;
	border: 0;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, var(--cb-vert-fonce) 0%, var(--cb-vert) 100%);
	color: #fff;
	cursor: pointer;
	z-index: 9000;
	box-shadow: 0 4px 20px rgba(25, 135, 84, .42), 0 2px 6px rgba(0, 0, 0, .12);
	transition: transform .2s ease, box-shadow .2s ease;
}

.chatbot_fab:hover,
.chatbot_fab:focus-visible {
	transform: scale(1.07);
	box-shadow: 0 6px 28px rgba(25, 135, 84, .52), 0 2px 6px rgba(0, 0, 0, .14);
	outline: none;
}

.chatbot_fab:focus-visible {
	box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--cb-vert);
}

.chatbot_fab_icon {
	font-size: 22px;
	line-height: 1;
}

.chatbot_fab_icon--close {
	display: none;
}

.chatbot_fab.is-open .chatbot_fab_icon--open {
	display: none;
}

.chatbot_fab.is-open .chatbot_fab_icon--close {
	display: inline-block;
}

.chatbot_fab_badge {
	position: absolute;
	top: -3px;
	right: -3px;
	min-width: 18px;
	height: 18px;
	padding: 0 4px;
	border-radius: 9px;
	background: var(--cb-jaune);
	color: var(--cb-encre);
	border: 2px solid #fff;
	font-family: 'Montserrat-Bold', sans-serif;
	font-size: 9px;
	line-height: 14px;
	text-align: center;
}

/* ── Info-bulle d'accueil ───────────────────────────────────────────────── */
.chatbot_tooltip {
	position: fixed;
	right: 5.4rem;
	bottom: 2.1rem;
	background: var(--cb-encre);
	color: #fff;
	font-family: 'Montserrat-Medium', sans-serif;
	font-size: .72rem;
	padding: .45rem .85rem;
	border-radius: .5rem;
	white-space: nowrap;
	z-index: 9001;
	box-shadow: var(--cb-ombre-lg);
	animation: chatbot_fade_in .2s ease;
}

.chatbot_tooltip::after {
	content: '';
	position: absolute;
	right: -6px;
	top: 50%;
	transform: translateY(-50%);
	border: 6px solid transparent;
	border-left-color: var(--cb-encre);
	border-right: 0;
}

@keyframes chatbot_fade_in {
	from { opacity: 0; transform: translateX(6px); }
	to { opacity: 1; transform: none; }
}

/* ── Panneau ────────────────────────────────────────────────────────────── */
.chatbot_panel {
	position: fixed;
	right: 1.5rem;
	bottom: 5.5rem;
	width: 400px;
	height: min(600px, calc(100dvh - 7rem));
	display: flex;
	flex-direction: column;
	background: #fff;
	border: 1px solid var(--cb-ligne);
	border-radius: var(--cb-rayon);
	box-shadow: var(--cb-ombre-lg);
	overflow: hidden;
	z-index: 8999;
	opacity: 0;
	transform: scale(.94) translateY(14px);
	transform-origin: bottom right;
	transition: opacity .28s cubic-bezier(.4, 0, .2, 1), transform .28s cubic-bezier(.4, 0, .2, 1);
}

.chatbot_panel[hidden] {
	display: none;
}

.chatbot_panel.is-open {
	opacity: 1;
	transform: none;
}

/* Barre drapeau du Bénin */
.chatbot_flag {
	display: flex;
	height: 4px;
	flex-shrink: 0;
}

.chatbot_flag span {
	flex: 1;
}

.chatbot_flag span:nth-child(1) { background: var(--cb-vert-fonce); }
.chatbot_flag span:nth-child(2) { background: var(--cb-jaune); }
.chatbot_flag span:nth-child(3) { background: var(--cb-rouge); }

/* En-tête */
.chatbot_header {
	display: flex;
	align-items: center;
	gap: .75rem;
	padding: 1rem 1.1rem;
	background: linear-gradient(135deg, var(--cb-vert-fonce) 0%, var(--cb-vert) 100%);
	color: #fff;
	flex-shrink: 0;
}

.chatbot_avatar {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, .16);
	border: 2px solid rgba(255, 255, 255, .32);
	color: #fff;
	font-size: 18px;
	flex-shrink: 0;
}

.chatbot_identity {
	flex: 1;
	min-width: 0;
}

.chatbot_name {
	margin: 0;
	font-family: 'Montserrat-Bold', sans-serif !important;
	font-size: .875rem;
	line-height: 1.2;
	color: #fff;
}

.chatbot_status {
	margin: 1px 0 0;
	display: flex;
	align-items: center;
	gap: .35rem;
	font-family: 'Montserrat-Regular', sans-serif !important;
	font-size: .68rem;
	color: rgba(255, 255, 255, .82);
}

.chatbot_dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #7BE0A8;
	animation: chatbot_pulse 2s infinite;
}

@keyframes chatbot_pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: .45; }
}

.chatbot_header_actions {
	display: flex;
	gap: .4rem;
}

.chatbot_hbtn {
	width: 30px;
	height: 30px;
	border: 0;
	border-radius: .5rem;
	background: rgba(255, 255, 255, .14);
	color: rgba(255, 255, 255, .9);
	font-size: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background .13s;
}

.chatbot_hbtn:hover,
.chatbot_hbtn:focus-visible {
	background: rgba(255, 255, 255, .26);
	color: #fff;
	outline: none;
}

/* Onglets */
.chatbot_tabs {
	display: flex;
	background: var(--cb-g1);
	border-bottom: 1px solid var(--cb-ligne);
	flex-shrink: 0;
}

.chatbot_tab {
	flex: 1;
	padding: .6rem .4rem;
	border: 0;
	border-bottom: 2px solid transparent;
	background: transparent;
	color: var(--cb-muet);
	font-family: 'Montserrat-SemiBold', sans-serif;
	font-size: .76rem;
	cursor: pointer;
	transition: color .13s, background .13s, border-color .13s;
}

.chatbot_tab i {
	margin-right: .2rem;
}

.chatbot_tab:hover:not(.is-active) {
	color: var(--cb-texte);
	background: var(--cb-g2);
}

.chatbot_tab.is-active {
	color: var(--cb-vert-fonce);
	border-bottom-color: var(--cb-vert);
	background: #fff;
}

/* Panneaux d'onglets */
.chatbot_tabpanel {
	display: none;
	flex: 1;
	flex-direction: column;
	min-height: 0;
}

.chatbot_tabpanel.is-active {
	display: flex;
}

/* ── Fil de messages ────────────────────────────────────────────────────── */
.chatbot_messages {
	flex: 1;
	overflow-y: auto;
	padding: 1rem .9rem;
	display: flex;
	flex-direction: column;
	gap: .8rem;
	min-height: 0;
	scroll-behavior: smooth;
}

.chatbot_messages::-webkit-scrollbar { width: 5px; }
.chatbot_messages::-webkit-scrollbar-thumb {
	background: var(--cb-g3);
	border-radius: 3px;
}

.chatbot_msg {
	display: flex;
	align-items: flex-start;
	gap: .55rem;
}

.chatbot_msg.is-user {
	flex-direction: row-reverse;
}

.chatbot_msg_avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	flex-shrink: 0;
}

.chatbot_msg.is-bot .chatbot_msg_avatar {
	background: var(--cb-vert-xl);
	color: var(--cb-vert-fonce);
}

.chatbot_msg.is-user .chatbot_msg_avatar {
	background: radial-gradient(120% 140% at 0% 0%, var(--cb-encre-2) 0%, var(--cb-encre) 70%);
	color: #fff;
	font-family: 'Montserrat-Bold', sans-serif;
	font-size: .62rem;
}

.chatbot_msg_body {
	min-width: 0;
	max-width: 86%;
	display: flex;
	flex-direction: column;
}

.chatbot_msg.is-user .chatbot_msg_body {
	align-items: flex-end;
}

.chatbot_bubble {
	border-radius: 1rem;
	padding: .65rem .85rem;
	font-family: 'Montserrat-Regular', sans-serif;
	font-size: .8125rem;
	line-height: 1.5;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.chatbot_msg.is-bot .chatbot_bubble {
	background: var(--cb-g1);
	border: 1px solid var(--cb-ligne);
	border-top-left-radius: 4px;
	color: var(--cb-texte);
}

.chatbot_msg.is-user .chatbot_bubble {
	background: var(--cb-vert);
	border-top-right-radius: 4px;
	color: #fff;
}

.chatbot_bubble p {
	margin: 0 0 .4rem;
	font-size: inherit;
	line-height: inherit;
}

.chatbot_bubble p:last-child {
	margin-bottom: 0;
}

.chatbot_bubble strong {
	font-family: 'Montserrat-SemiBold', sans-serif;
}

.chatbot_msg_time {
	margin-top: 3px;
	font-size: .625rem;
	color: var(--cb-muet);
}

/* Suggestions rapides */
.chatbot_suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: .4rem;
	margin-top: .45rem;
}

.chatbot_chip {
	padding: .3rem .75rem;
	border-radius: 20px;
	border: 1.5px solid var(--cb-vert-clair);
	background: var(--cb-vert-xl);
	color: var(--cb-vert-fonce);
	font-family: 'Montserrat-Medium', sans-serif;
	font-size: .72rem;
	cursor: pointer;
	transition: background .13s, color .13s;
	text-align: left;
}

.chatbot_chip:hover,
.chatbot_chip:focus-visible {
	background: var(--cb-vert-clair);
	color: var(--cb-encre);
	outline: none;
}

/* Carte action */
.chatbot_card {
	margin-top: .5rem;
	border: 1px solid var(--cb-ligne);
	border-radius: var(--cb-rayon-sm);
	overflow: hidden;
	background: #fff;
	box-shadow: var(--cb-ombre);
}

.chatbot_card_header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
	padding: .55rem .8rem;
	background: linear-gradient(135deg, var(--cb-vert-fonce) 0%, var(--cb-vert) 100%);
	color: #fff;
}

.chatbot_card_title {
	margin: 0;
	font-family: 'Montserrat-SemiBold', sans-serif !important;
	font-size: .78rem;
	line-height: 1.25;
	color: #fff;
}

.chatbot_card_badge {
	flex-shrink: 0;
	padding: 2px 8px;
	border-radius: 10px;
	font-family: 'Montserrat-Bold', sans-serif;
	font-size: .6rem;
	background: rgba(255, 255, 255, .22);
	color: #fff;
	white-space: nowrap;
}

.chatbot_card_body {
	padding: .65rem .8rem;
	display: flex;
	flex-direction: column;
	gap: .45rem;
}

.chatbot_card_row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	font-size: .74rem;
}

.chatbot_card_lbl {
	color: var(--cb-muet);
	flex-shrink: 0;
}

.chatbot_card_val {
	font-family: 'Montserrat-SemiBold', sans-serif;
	color: var(--cb-texte);
	text-align: right;
}

.chatbot_card_list {
	margin: 0;
	padding-left: 1.1rem;
	display: flex;
	flex-direction: column;
	gap: .3rem;
	font-size: .74rem;
	line-height: 1.4;
}

.chatbot_tag {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 10px;
	font-family: 'Montserrat-Bold', sans-serif;
	font-size: .62rem;
}

.chatbot_tag.is-ok { background: var(--cb-vert-xl); color: var(--cb-vert-fonce); }
.chatbot_tag.is-warn { background: var(--cb-jaune-xl); color: #8a5a00; }
.chatbot_tag.is-danger { background: var(--cb-rouge-xl); color: var(--cb-rouge); }
.chatbot_tag.is-info { background: var(--cb-vert-xl); color: var(--cb-vert-fonce); }

.chatbot_gauge {
	display: flex;
	align-items: center;
	gap: .6rem;
}

.chatbot_gauge_track {
	flex: 1;
	height: 6px;
	border-radius: 3px;
	background: var(--cb-g3);
	overflow: hidden;
}

.chatbot_gauge_fill {
	height: 100%;
	border-radius: 3px;
	background: var(--cb-vert);
	transition: width .6s ease;
}

.chatbot_card_footer {
	display: flex;
	flex-wrap: wrap;
	gap: .4rem;
	padding: .55rem .8rem;
	border-top: 1px solid var(--cb-ligne);
	background: var(--cb-g1);
}

.chatbot_card_btn {
	padding: .32rem .7rem;
	border-radius: .5rem;
	border: 1px solid var(--cb-ligne);
	background: #fff;
	color: var(--cb-texte);
	font-family: 'Montserrat-SemiBold', sans-serif;
	font-size: .68rem;
	cursor: pointer;
	transition: background .13s, color .13s, border-color .13s;
}

.chatbot_card_btn.is-primary {
	background: var(--cb-vert);
	border-color: var(--cb-vert);
	color: #fff;
}

.chatbot_card_btn:hover,
.chatbot_card_btn:focus-visible {
	border-color: var(--cb-vert);
	color: var(--cb-vert-fonce);
	outline: none;
}

.chatbot_card_btn.is-primary:hover,
.chatbot_card_btn.is-primary:focus-visible {
	background: var(--cb-vert-fonce);
	color: #fff;
}

/* Indicateur de frappe */
.chatbot_typing {
	display: flex;
	gap: 4px;
	align-items: center;
	padding: .5rem .65rem;
}

.chatbot_typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--cb-vert-clair);
	animation: chatbot_bounce .9s infinite;
}

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

@keyframes chatbot_bounce {
	0%, 80%, 100% { transform: translateY(0); }
	40% { transform: translateY(-5px); }
}

/* Avis de sécurité (escalade) */
.chatbot_notice {
	margin-top: .45rem;
	padding: .5rem .7rem;
	border-radius: .6rem;
	border: 1px solid var(--cb-rouge);
	background: var(--cb-rouge-xl);
	color: #9b1c21;
	font-size: .72rem;
	line-height: 1.4;
}

/* ── Zone de saisie ─────────────────────────────────────────────────────── */
.chatbot_input {
	border-top: 1px solid var(--cb-ligne);
	padding: .7rem .9rem .75rem;
	flex-shrink: 0;
	background: #fff;
}

.chatbot_input_row {
	display: flex;
	align-items: flex-end;
	gap: .5rem;
}

.chatbot_field {
	flex: 1;
	min-height: 42px;
	max-height: 100px;
	padding: .6rem .8rem;
	border: 1.5px solid var(--cb-g3);
	border-radius: var(--cb-rayon-sm);
	background: var(--cb-g1);
	color: var(--cb-texte);
	font-family: 'Montserrat-Regular', sans-serif;
	font-size: .8125rem;
	line-height: 1.4;
	resize: none;
	outline: none;
	transition: border-color .13s, background .13s;
}

.chatbot_field:focus {
	border-color: var(--cb-vert);
	background: #fff;
}

.chatbot_field::placeholder {
	color: var(--cb-muet);
}

.chatbot_send {
	width: 42px;
	height: 42px;
	flex-shrink: 0;
	border: 0;
	border-radius: .65rem;
	background: var(--cb-vert);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background .13s;
}

.chatbot_send:hover:not(:disabled),
.chatbot_send:focus-visible {
	background: var(--cb-vert-fonce);
	outline: none;
}

.chatbot_send:disabled {
	background: var(--cb-g3);
	color: var(--cb-muet);
	cursor: not-allowed;
}

.chatbot_tools {
	display: flex;
	flex-wrap: wrap;
	gap: .35rem;
	margin-top: .45rem;
}

.chatbot_tool {
	padding: .2rem .55rem;
	border: 1px solid var(--cb-g3);
	border-radius: .5rem;
	background: transparent;
	color: var(--cb-muet);
	font-family: 'Montserrat-Medium', sans-serif;
	font-size: .66rem;
	cursor: pointer;
	transition: background .12s, color .12s, border-color .12s;
}

.chatbot_tool:hover,
.chatbot_tool:focus-visible {
	background: var(--cb-vert-xl);
	border-color: var(--cb-vert-clair);
	color: var(--cb-vert-fonce);
	outline: none;
}

/* ── Onglet Historique ──────────────────────────────────────────────────── */
.chatbot_history {
	flex: 1;
	overflow-y: auto;
	padding: .8rem;
	display: flex;
	flex-direction: column;
	gap: .5rem;
}

.chatbot_history_empty {
	margin: 1.5rem 0;
	text-align: center;
	color: var(--cb-muet);
	font-size: .75rem;
}

.chatbot_hist_item {
	width: 100%;
	padding: .6rem .8rem;
	border: 1px solid var(--cb-ligne);
	border-radius: .65rem;
	background: var(--cb-g1);
	text-align: left;
	cursor: pointer;
	transition: background .13s, border-color .13s;
}

.chatbot_hist_item:hover,
.chatbot_hist_item:focus-visible {
	background: var(--cb-vert-xl);
	border-color: var(--cb-vert-clair);
	outline: none;
}

.chatbot_hist_q {
	display: block;
	font-family: 'Montserrat-Medium', sans-serif;
	font-size: .75rem;
	color: var(--cb-texte);
}

.chatbot_hist_t {
	display: block;
	margin-top: 2px;
	font-size: .65rem;
	color: var(--cb-muet);
}

.chatbot_panel_footer {
	padding: .6rem .8rem;
	border-top: 1px solid var(--cb-ligne);
	background: var(--cb-g1);
}

.chatbot_link {
	border: 0;
	background: transparent;
	color: var(--cb-vert-fonce);
	font-family: 'Montserrat-Medium', sans-serif;
	font-size: .72rem;
	cursor: pointer;
	padding: .2rem .1rem;
}

.chatbot_link:hover {
	text-decoration: underline;
}

/* ── Onglet Aide ────────────────────────────────────────────────────────── */
.chatbot_help {
	flex: 1;
	overflow-y: auto;
	padding: .8rem;
	display: flex;
	flex-direction: column;
	gap: .4rem;
}

.chatbot_help_cat {
	margin: .35rem 0 .1rem;
	font-family: 'Montserrat-Bold', sans-serif !important;
	font-size: .66rem;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--cb-vert-fonce);
}

.chatbot_help_item {
	display: flex;
	align-items: center;
	gap: .5rem;
	width: 100%;
	padding: .55rem .8rem;
	border: 1px solid var(--cb-ligne);
	border-radius: .65rem;
	background: var(--cb-g1);
	color: var(--cb-texte);
	font-family: 'Montserrat-Regular', sans-serif;
	font-size: .75rem;
	text-align: left;
	cursor: pointer;
	transition: background .13s, color .13s, border-color .13s;
}

.chatbot_help_item i {
	color: var(--cb-vert);
}

.chatbot_help_item:hover,
.chatbot_help_item:focus-visible {
	background: var(--cb-vert-xl);
	border-color: var(--cb-vert-clair);
	color: var(--cb-vert-fonce);
	outline: none;
}

/* ── Responsive mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
	.chatbot_fab {
		right: 1rem;
		bottom: 1rem;
	}

	.chatbot_panel {
		right: 0;
		bottom: 0;
		width: 100vw;
		height: 100dvh;
		max-height: 100dvh;
		border: 0;
		border-radius: 0;
	}

	.chatbot_tooltip {
		right: 4.8rem;
		bottom: 1.6rem;
	}
}

/* ── Accessibilité : mouvement réduit ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.chatbot_fab,
	.chatbot_panel,
	.chatbot_field {
		transition: none;
	}

	.chatbot_dot,
	.chatbot_typing span {
		animation: none;
	}
}

/* ── Retour utilisateur (👍 / 👎) ─────────────────────────────────── */
.chatbot_feedback {
	display: flex;
	gap: 6px;
	margin-top: 8px;
}

.chatbot_fb {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: 1px solid rgba(16, 25, 19, 0.12);
	border-radius: 8px;
	background: #fff;
	color: #6b7280;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chatbot_fb:hover {
	background: rgba(25, 135, 84, 0.08);
	color: #198754;
	border-color: rgba(25, 135, 84, 0.35);
}

.chatbot_feedback.is-done .chatbot_fb {
	cursor: default;
	opacity: 0.55;
}

.chatbot_feedback.is-done .chatbot_fb.is-active {
	opacity: 1;
	background: #198754;
	border-color: #198754;
	color: #fff;
}
