:root{
	/* Charte Ville de Rimouski v1 — octobre 2026 */
	--ai-bg:#ffffff; /* Blanc — fond de page du site */
	--ai-fg:#101e27; /* Épave */
	--ai-muted:#758181; /* Roc */
	--ai-accent:#f69546; /* Orange */
	--ai-blue:#019cd8; /* Bleu */
	--ai-header:#00243d; /* Marine — bandes du site */
	--ai-soft:#ffffff; /* Blanc */
	--ai-border:#ebebeb; /* Gris neutre */
	--ai-bot:#cfefff; /* Ciel — cartes claires du site */
	--ai-user:#ebebeb; /* Gris neutre */
	--ai-link:#00243d; /* Marine : l’Orange #f69546 est trop clair pour du petit texte */
	--ai-font:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

@media (prefers-color-scheme: dark){
	:root{
		--ai-bg:#ffffff; /* Blanc — fond de page du site */
		--ai-fg:#101e27; /* Épave */
		--ai-muted:#758181; /* Roc */
		--ai-accent:#f69546; /* Orange */
		--ai-blue:#019cd8; /* Bleu */
		--ai-header:#00243d; /* Marine — bandes du site */
		--ai-soft:#ffffff; /* Blanc */
		--ai-border:#ebebeb; /* Gris neutre */
		--ai-bot:#cfefff; /* Ciel — cartes claires du site */
		--ai-user:#ebebeb; /* Gris neutre */
		--ai-link:#00243d; /* Marine */
		--ai-font:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
	}
}

/* Verrouillage du scroll quand le widget est ouvert */
html.ai-lock,
body.ai-lock{
	overflow:hidden;
	touch-action:none;
	overscroll-behavior:contain;
	height:100dvh;
}

/* =========================
   LANCEUR
   ========================= */

#ai-launcher{
	--ai-launcher-expanded: min(208px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
	position:fixed;
	right:max(12px, env(safe-area-inset-right, 0px));
	bottom:max(12px, env(safe-area-inset-bottom, 0px));
	z-index:9999;
	width:64px;
	max-width:calc(100vw - 24px);
	height:64px;
	padding:0;
	border:none;
	border-radius:999px;
	background:var(--ai-accent);
	color:var(--ai-fg);
	cursor:pointer;
	overflow:hidden;
	isolation:isolate;
	display:block;
	font-family:var(--ai-font);
	touch-action:manipulation;
	-webkit-tap-highlight-color:transparent;
	box-shadow:0 14px 28px rgba(246,149,70,.28), 0 8px 14px rgba(16,30,39,.10);
	transition:
		width .28s ease,
		transform .18s ease,
		box-shadow .18s ease,
		filter .18s ease;
}

#ai-launcher:not(.is-open).is-nudge{
	width:var(--ai-launcher-expanded);
	transform:translateY(-1px);
	box-shadow:0 16px 32px rgba(246,149,70,.30), 0 10px 18px rgba(16,30,39,.14);
	filter:brightness(1.03);
}

@media (hover:hover) and (pointer:fine){
	#ai-launcher:not(.is-open):hover{
		width:var(--ai-launcher-expanded);
		transform:translateY(-1px);
		box-shadow:0 16px 32px rgba(246,149,70,.30), 0 10px 18px rgba(16,30,39,.14);
		filter:brightness(1.03);
	}
}

#ai-launcher:active{
	transform:translateY(1px);
}

#ai-launcher:focus-visible,
.ai-icon:focus-visible,
.ai-send:focus-visible,
.ai-suggestion:focus-visible{
	outline:2px solid var(--ai-blue);
	outline-offset:2px;
}

#ai-launcher .ai-launcher-icon{
	position:absolute;
	inset:auto;
	display:flex;
	align-items:center;
	justify-content:center;
	transition:opacity .18s ease, transform .18s ease;
}

#ai-launcher .ai-launcher-logo{
	left:0;
	top:0;
	width:64px;
	height:64px;
	z-index:3;
	display:flex;
	align-items:center;
	justify-content:center;
	transition:transform .18s ease, opacity .18s ease;
}

#ai-launcher .ai-launcher-logo.ai-launcher-faicon{
	background:transparent;
	border:none;
	box-shadow:none;
	color:var(--ai-fg);
	font-size:28px;
	border-radius:50%;
}

#ai-launcher .ai-launcher-logo.ai-launcher-faicon i{
	display:flex;
	align-items:center;
	justify-content:center;
	width:100%;
	height:100%;
	line-height:1;
	margin:0;
	padding:0;
}

#ai-launcher .ai-launcher-logo img{
	width:52px;
	height:52px;
	display:block;
	object-fit:cover;
	border-radius:50%;
}

#ai-launcher .ai-launcher-help{
	position:absolute;
	left:62px;
	right:12px;
	top:50%;
	transform:translateY(-50%);
	font-family:"IBM Plex Sans", var(--ai-font);
	font-weight:700;
	font-size:17px;
	line-height:1.15;
	color:var(--ai-fg);
	white-space:nowrap;
	text-align:left;
	overflow:hidden;
	text-overflow:ellipsis;
	opacity:0;
	visibility:hidden;
	pointer-events:none;
	transition:opacity .18s ease, visibility .18s ease;
}

#ai-launcher:not(.is-open).is-nudge .ai-launcher-help{
	opacity:1;
	visibility:visible;
}

#ai-launcher:not(.is-open).is-nudge .ai-launcher-logo{
	transform:scale(1.04);
}

@media (hover:hover) and (pointer:fine){
	#ai-launcher:not(.is-open):hover .ai-launcher-help{
		opacity:1;
		visibility:visible;
	}

	#ai-launcher:not(.is-open):hover .ai-launcher-logo{
		transform:scale(1.04);
	}
}

#ai-launcher .ai-launcher-chevron{
	position:absolute;
	width:22px;
	height:22px;
	right:18px;
	top:50%;
	opacity:0;
	pointer-events:none;
	z-index:3;
	transform:translateY(-50%) scale(.9);
	transition:opacity .18s ease, transform .18s ease, left .18s ease, right .18s ease;
}

#ai-launcher.is-open .ai-launcher-chevron{
	left:50%;
	right:auto;
	top:50%;
	opacity:1;
	transform:translate(-50%, -50%) scale(1);
}

#ai-launcher.is-open{
	width:64px;
	display:block;
}

#ai-launcher.is-open .ai-launcher-help{
	display:none;
}

#ai-launcher.is-open .ai-launcher-logo{
	opacity:0;
	transform:scale(.85);
	pointer-events:none;
}

@media (prefers-reduced-motion: reduce){
	#ai-launcher,
	#ai-launcher .ai-launcher-help,
	#ai-launcher .ai-launcher-logo{
		transition:none;
	}
}

/* =========================
   FENÊTRE
   ========================= */

#ai-widget{
	position:fixed;
	right:18px;
	bottom:94px;
	left:auto;
	top:auto;
	margin:0;
	padding:0;
	border:none;
	background:transparent;
	max-width:none;
	max-height:none;
	width:auto;
	height:auto;
	z-index:9999;
}

#ai-widget:not([open]){
	display:none;
}

.ai-window{
	position:relative;
	width:min(468px, 92vw);
	height:min(620px, 75vh);
	background:var(--ai-bg);
	color:var(--ai-fg);
	border:1px solid var(--ai-border);
	border-radius:16px;
	overflow:hidden;
	box-shadow:0 18px 40px rgba(16,30,39,.12);
	display:flex;
	flex-direction:column;
	font-family:var(--ai-font);
	font-size-adjust:from-font;
	accent-color:var(--ai-accent);
}

/* =========================
   HEADER
   ========================= */

.ai-header{
	background:var(--ai-header);
	border-bottom:none;
	color:#ffffff;
	padding:10px 12px;
	height:56px;
	display:flex;
	align-items:center;
	justify-content:space-between;
	flex:0 0 56px;
}

.ai-header .ai-title strong,
.ai-header .ai-icon,
.ai-header #ai-reset.ai-icon{
	color:#ffffff;
}

.ai-header .ai-actions{
	background:rgba(255,255,255,.12);
}

.ai-header .ai-icon{
	opacity:1;
}

.ai-header .ai-icon:hover{
	background:rgba(255,255,255,.16);
}

.ai-brand{
	display:flex;
	align-items:center;
	gap:10px;
}

.ai-brand img{
	width:28px;
	height:28px;
	border-radius:6px;
	object-fit:contain;
}

.ai-title strong{
	display:block;
	line-height:1.1;
	font-weight:700;
	color:var(--ai-fg);
}

.ai-title span{
	display:block;
	font-size:12px;
	color:#003b27; /* Forêt */
}

.ai-dot{
	display:inline-block;
	width:7px;
	height:7px;
	background:#009d6c; /* Vert */
	border-radius:50%;
	margin-right:6px;
}

.ai-actions{
	display:flex;
	align-items:center;
	gap:2px;
	padding:2px;
	border-radius:12px;
	background:rgba(16,30,39,.05);
	flex:0 0 auto;
}

.ai-icon{
	width:34px;
	height:34px;
	border:none;
	background:transparent;
	cursor:pointer;
	color:var(--ai-fg);
	display:grid;
	place-items:center;
	border-radius:10px;
	opacity:.78;
}

.ai-icon:hover{
	background:rgba(16,30,39,.08);
	opacity:1;
}

.ai-close.ai-icon{
	width:38px;
	height:38px;
	opacity:.9;
}

.ai-close.ai-icon svg{
	width:20px;
	height:20px;
}

#ai-reset.ai-icon{
	color:var(--ai-fg);
}

.ai-refresh{
	transition:transform .35s ease, opacity .2s ease;
	will-change:transform;
}

#ai-reset.ai-icon:hover .ai-refresh{
	transform:rotate(90deg);
}

#ai-reset.ai-icon:active .ai-refresh{
	transform:rotate(360deg);
}

/* =========================
   MESSAGES
   ========================= */

.ai-messages{
	flex:1 1 auto;
	min-height:0;
	overflow:auto;
	padding:14px 14px 12px;
	gap:10px;
	display:flex;
	flex-direction:column;
	background:var(--ai-bg);
	scroll-padding-bottom:22px;
}

.ai-messages::after{
	content:"";
	display:block;
	height:6px;
	flex:0 0 6px;
}

.ai-row{
	display:flex;
	gap:8px;
}

.ai-row.user{
	justify-content:flex-end;
}

.ai-bubble{
	max-width:78%;
	padding:10px 12px;
	border-radius:14px;
	line-height:1.45;
	white-space:pre-wrap;
	word-wrap:break-word;
	box-shadow:0 1px 0 rgba(16,30,39,.03);
	border:1px solid var(--ai-border);
}

.ai-row.user .ai-bubble{
	background:var(--ai-user);
	color:var(--ai-fg);
	border-top-right-radius:6px;
}

.ai-row.bot .ai-bubble{
	background:var(--ai-bot);
	color:var(--ai-fg);
	border-color:transparent;
	border-top-left-radius:6px;
	position:relative;
}

.ai-avatar{
	width:28px;
	height:28px;
	border-radius:6px;
	object-fit:cover;
	background:none;
	flex:0 0 28px;
}

.ai-typing{
	display:inline-block;
	min-width:32px;
}

.ai-typing span{
	display:inline-block;
	width:6px;
	height:6px;
	margin:0 2px;
	background:var(--ai-blue);
	border-radius:50%;
	animation:blink 1.3s infinite;
}

.ai-typing span:nth-child(2){
	animation-delay:.2s;
}

.ai-typing span:nth-child(3){
	animation-delay:.4s;
}

@keyframes blink{
	0%,80%,100%{ opacity:.2; }
	40%{ opacity:1; }
}

.ai-bubble strong{
	font-weight:700;
}

.ai-bubble a{
	color:var(--ai-link);
	text-decoration:underline;
	word-break:break-word;
}

.ai-bubble a:hover{
	text-decoration:none;
}

/* =========================
   SUGGESTIONS
   ========================= */

.ai-sr-only{
	position:absolute;
	width:1px;
	height:1px;
	padding:0;
	margin:-1px;
	overflow:hidden;
	clip:rect(0,0,0,0);
	white-space:nowrap;
	border:0;
}

.ai-suggestions{
	display:flex;
	flex-wrap:nowrap;
	align-items:center;
	justify-content:space-between;
	gap:6px;
	padding:0;
	margin:0 12px 6px;
	background:var(--ai-bg);
	flex:0 0 auto;
	box-sizing:border-box;
}

.ai-suggestions[hidden]{
	display:none;
}

.ai-suggestion{
	box-sizing:border-box;
	flex:0 0 auto;
	appearance:none;
	border:1px solid rgb(117 129 129 / .4); /* Roc */
	background:#ffffff;
	color:var(--ai-fg);
	border-radius:999px;
	padding:7px 12px;
	font:500 13px/1.2 var(--ai-font);
	cursor:pointer;
	white-space:nowrap;
	transition:transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}

.ai-suggestion:hover{
	transform:translateY(-1px);
	box-shadow:0 6px 16px rgba(16,30,39,.06);
	border-color:#758181; /* Roc */
	background:#ebebeb; /* Gris neutre */
}

.ai-suggestion:active{
	transform:translateY(0);
}

/* =========================
   BARRE DE SAISIE
   ========================= */

.ai-inputbar{
	position:relative;
	display:flex;
	align-items:center;
	gap:6px;
	min-height:0;
	height:auto;
	margin:0 12px 4px;
	padding:3px 3px 3px 12px;
	border-radius:14px;
	background:#ebebeb; /* Gris neutre */
	border:1px solid transparent;
	box-shadow:none;
	overflow:visible;
	flex:0 0 auto;
	max-width: 95%;
}

.ai-inputbar:focus-within{
	background:#ffffff;
	border-color:var(--ai-accent);
	box-shadow:0 0 0 3px rgba(246,149,70,.16);
}

#ai-input{
	box-sizing:border-box;
	flex:1 1 auto;
	width:auto;
	line-height:20px;
	height:24px;
	min-height:24px;
	max-height:64px;
	overflow-y:hidden;
	resize:none;
	border:none;
	outline:none;
	background:transparent;
	margin:0;
	padding:2px 0;
	font:400 15px/20px var(--ai-font);
	color:var(--ai-fg);
	caret-color:var(--ai-fg);
	white-space:pre-wrap;
	word-break:break-word;
}

#ai-input::placeholder{
	color:var(--ai-muted);
	font-family:var(--ai-font);
	font-weight:400;
}

.ai-send{
	position:static;
	flex:0 0 32px;
	width:32px;
	height:32px;
	border-radius:9px;
	border:none;
	cursor:pointer;
	color:var(--ai-fg);
	background:var(--ai-accent);
	display:grid;
	place-items:center;
	box-shadow:none;
	transform:none;
}

.ai-send:disabled{
	opacity:.45;
	cursor:not-allowed;
}

.ai-send:hover:not(:disabled){
	filter:brightness(1.05);
}

/* Scrollbar discrète */
#ai-input::-webkit-scrollbar{
	width:8px;
}

#ai-input::-webkit-scrollbar-thumb{
	background:#9cd5cd; /* Turquoise */
	border-radius:8px;
}

#ai-input::-webkit-scrollbar-track{
	background:transparent;
}

/* =========================
   FOOTER
   ========================= */

.ai-footer{
	height:auto;
	min-height:28px;
	flex:0 0 auto;
	display:flex;
	align-items:center;
	justify-content:center;
	border-top:none;
	background:var(--ai-bg);
	padding:0 12px 8px;
}

.ai-footer small{
	display:block;
	width:100%;
	text-align:center;
	line-height:1.2;
}

.ai-footer a{
	color:var(--ai-muted);
	text-decoration:none;
	white-space:normal;
	word-break:break-word;
	font-size:11px;
}

.ai-footer a:hover{
	text-decoration:underline;
}

/* =========================
   CONFIRMATION SESSION
   ========================= */

.ai-confirm{
	position:absolute;
	inset:0;
	z-index:40;
	display:flex;
	align-items:center;
	justify-content:center;
	padding:20px;
	font-family:var(--ai-font);
}

.ai-confirm[hidden]{
	display:none !important;
}

.ai-confirm-backdrop{
	position:absolute;
	inset:0;
	background:rgba(0,36,61,.46);
}

.ai-confirm-panel{
	position:relative;
	z-index:1;
	width:min(100%, 320px);
	background:var(--ai-bg);
	color:var(--ai-fg);
	border:1px solid var(--ai-border);
	border-radius:14px;
	padding:18px 16px 14px;
	box-shadow:0 18px 36px rgba(16,30,39,.18);
}

.ai-confirm-title{
	display:block;
	font-size:16px;
	font-weight:700;
	line-height:1.25;
	color:var(--ai-header);
	margin:0 0 8px;
}

.ai-confirm-desc{
	margin:0 0 16px;
	font-size:14px;
	line-height:1.45;
	color:var(--ai-fg);
}

.ai-confirm-actions{
	display:flex;
	justify-content:flex-end;
	gap:8px;
}

.ai-confirm-btn{
	appearance:none;
	border:1px solid transparent;
	border-radius:10px;
	padding:9px 14px;
	font:500 14px/1.2 var(--ai-font);
	cursor:pointer;
	touch-action:manipulation;
	-webkit-tap-highlight-color:transparent;
	transition:background .15s ease, border-color .15s ease, filter .15s ease;
}

.ai-confirm-cancel{
	background:transparent;
	border-color:var(--ai-border);
	color:var(--ai-fg);
}

.ai-confirm-cancel:hover{
	background:#ebebeb;
	border-color:#758181;
}

.ai-confirm-ok{
	background:var(--ai-accent);
	color:var(--ai-fg);
}

.ai-confirm-ok:hover{
	filter:brightness(1.05);
}

.ai-confirm-btn:focus-visible{
	outline:2px solid var(--ai-blue);
	outline-offset:2px;
}

/* =========================
   MOBILE
   ========================= */

@media (max-width:640px){
	#ai-launcher{
		--ai-launcher-expanded: min(196px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
	}

	#ai-launcher .ai-launcher-help{
		left:58px;
		right:10px;
		font-size:15px;
	}

	#ai-launcher.is-open{
		display:none;
	}

	#ai-widget{
		top:0;
		right:0;
		bottom:0;
		left:0;
		position:fixed;
		margin:0;
	}

	.ai-window{
		width:100vw;
		height:100vh;
		height:100dvh;
		max-width:none;
		max-height:none;
		border-radius:0;
		border:0;
		box-shadow:none;
	}

	.ai-header{
		height:auto;
		min-height:56px;
		flex:0 0 auto;
		padding:8px 10px 8px 14px;
		padding-top:calc(8px + env(safe-area-inset-top));
	}

	.ai-actions{
		gap:4px;
		padding:3px;
		border-radius:14px;
		background:rgba(255,255,255,.12);
	}

	.ai-icon{
		width:42px;
		height:42px;
		border-radius:12px;
		opacity:.85;
	}

	.ai-icon svg{
		width:20px;
		height:20px;
	}

	.ai-close.ai-icon{
		width:46px;
		height:46px;
		opacity:1;
		background:transparent;
	}

	.ai-close.ai-icon svg{
		width:24px;
		height:24px;
	}

	.ai-suggestions{
		flex-wrap:wrap;
		justify-content:flex-start;
		margin:0 10px 6px;
	}

	.ai-suggestion{
		flex:0 0 auto;
		font-size:13px;
		padding:7px 12px;
	}

	.ai-inputbar{
		margin:0 10px 6px;
	}

	.ai-footer{
		padding-bottom:max(10px, env(safe-area-inset-bottom));
	}
}