body {
	background-color: white;
}

h1,
#controls {
	text-align: center;
	margin: 1em;
}

main {
	width: 80%;
	min-height: 80vh;
	max-width: 800px;
	margin: auto;
	padding: 10px;
	border-radius: 15px;
	background: linear-gradient(
		90deg,
		rgb(239, 242, 247) 0%,
		7.60286%,
		rgb(237, 240, 249) 15.2057%,
		20.7513%,
		rgb(235, 239, 248) 26.297%,
		27.6386%,
		rgb(235, 239, 248) 28.9803%,
		38.2826%,
		rgb(231, 237, 249) 47.585%,
		48.1216%,
		rgb(230, 236, 250) 48.6583%,
		53.1306%,
		rgb(228, 236, 249) 57.6029%,
		61.5385%,
		rgb(227, 234, 250) 65.4741%,
		68.7835%,
		rgb(222, 234, 250) 72.093%,
		75.7603%,
		rgb(219, 230, 248) 79.4275%,
		82.8265%,
		rgb(216, 229, 248) 86.2254%,
		87.8354%,
		rgb(213, 228, 249) 89.4454%,
		91.8605%,
		rgb(210, 226, 249) 94.2755%,
		95.4383%,
		rgb(209, 225, 248) 96.6011%,
		98.3005%,
		rgb(208, 224, 247) 100%
	);
}

#chat {
	min-height: 350px;
	font-family: "Inter", sans-serif, Avenir, Helvetica, Arial;
	position: relative;
	overflow: hidden;
	padding: 10px;
	border-radius: 5px;
	margin-bottom: 5em;
}

#controls {
	margin: 0;
	position: fixed;
	bottom: 0px;
	display: flex;
	align-items: baseline;
	width: 82%;
	height: 110px;
	background-color: white;
	max-width: 820px;
	margin-left: -10px;
}

.hideControls #controls {
	height: 50px;
}

.hideControls #controls #input-container {
	opacity: 0;
	filter: alpha(opacity=0);
}
.hideControls #controls #send-button {
	opacity: 0;
	filter: alpha(opacity=0);
}

#input-container {
	width: 100%;
	background-color: rgb(255, 255, 255);
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 5px;
	margin-top: 0.8em;
	margin-bottom: 0.8em;
	box-shadow: rgba(149, 157, 165, 0.2) 0px 1px 12px;
	overflow-y: auto;
	max-height: 200px;
	height: 2em;
}

#user-input {
	outline: none;
	overflow-wrap: break-word;
	line-break: auto;
	text-align: left;
	padding: 5px;
	height: 1em;
}

.placeholder {
	color: gray;
}

[contenteditable="true"]:empty:before {
	content: attr(placeholder);
	color: grey;
	font-style: italic;
}

a,
a:visited {
	color: #551a8d !important;
	word-wrap: break-word;
}

button {
	height: 2em;
	margin-top: 0.8em;
	margin-bottom: 0.8em;
	margin-left: 10px;
}

.message {
	clear: both;
	margin-top: 10px;
	margin-bottom: 10px;
	padding: 10px;
	width: 80%;
	border-radius: 10px;
}

.user-message {
	box-shadow:
		rgba(0, 0, 0, 0.12) 0px 0.3px 0.9px,
		rgba(0, 0, 0, 0.16) 0px 1.6px 3.6px;
	color: rgb(255, 255, 255);
	background-color: rgb(0, 132, 255);
	float: right;
}

.user-message p {
	margin: 0px 5px;
}

.bot-message {
	float: left;
	margin-top: 10px;
	margin-bottom: 10px;
}
.bot-message .bot-message {
	margin-top: -20px;
	margin-bottom: 0px;
}

.bot-message > :first-child:before {
	content: "";
	margin-right: 15px;
	font-size: 2em;
	background-image: url("favicon.svg");
	background-size: 40px;
	width: 40px;
	height: 40px;
	display: inline-block;
	vertical-align: bottom;
}

.message > div > .admonition {
	margin-left: 3em;
}

.bot-message ul.messageOptions li {
	list-style-type: none;
}

.bot-message ul.messageOptions li > a {
	text-decoration: none;
	background-color: #ffffff3d;
	padding: 5px 10px;
	display: inline-block;
	color: black !important;
	border-radius: 12px;
	font-size: 0.95em;
	margin-left: -20px;
	text-align: left !important;
	border: 1px solid #666;
}

.bot-message ul.messageOptions li > a:hover {
	background-color: rgb(0, 132, 255);
	border-color: rgb(0, 132, 255);
	color: white !important;
}

footer {
	margin: auto;
	font-size: 0.9em;
	text-align: center;
	padding-top: 1em;
	position: fixed;
	bottom: 15px;
	left: 0;
	width: 100%;
}

footer a,
footer a:visited {
	color: black !important;
	text-decoration: underline #999;
}
footer a:hover {
	text-decoration: underline black;
}

#chat img {
	display: block;
	margin: 1em;
	max-width: 100%;
}

#chat li,
#chat li p {
	margin-top: 0.25em;
	margin-bottom: 0.25em;
}

pre {
	line-height: 1em;
	margin: 2.5em;
	border: 1px solid grey;
	padding: 20px;
	border-radius: 5px;
	width: fit-content;
	word-break: break-all;
	white-space: pre-wrap;
}

.admonition {
	margin-top: 1em;
	border: 1px solid black;
	border-radius: 5px;
	padding: 0.5em 1em;
	background-color: #eee;
}

.admonition.exemple {
	border-color: #02461f;
	background-color: rgb(250, 242, 209);
}
.admonition.resolution {
	border-color: #02461f;
	background-color: rgb(196, 237, 247);
}


.admonition.info,
.admonition.note,
.admonition.spoiler {
	border-color: #1505a1;
	background-color: rgb(194, 225, 235);
}
.admonition.tip,
.admonition.success {
	border-color: #02461f;
	background-color: rgb(207 235 194);
}
.admonition.warning,
.admonition.danger,
.admonition.bug {
	border-color: #b94a48;
	background-color: rgb(241 200 200);
}

.admonitionContent {
	font-size: 0.95em;
}

.admonitionTitle {
	font-weight: bold;
	font-size: 0.9em;
}

.admonitionTitle:before {
	font-weight: 300;
	margin-right: 0.5em;
	font-size: 1.15em;
}

.info .admonitionTitle,
.note .admonitionTitle,
.spoiler .admonitionTitle {
	color: #0b0258;
}
.info .admonitionTitle:before,
.note .admonitionTitle:before,
.spoiler .admonitionTitle:before {
	content: "ℹ️";
}
.warning .admonitionTitle:before,
.danger .admonitionTitle:before,
.bug .admonitionTitle:before {
	content: "⚠️";
}

.tip .admonitionTitle:before,
.success .admonitionTitle:before {
	content: "💡";
}

.tip .admonitionTitle,
.success .admonitionTitle {
	color: #012e14;
}
.warning .admonitionTitle,
.danger .admonitionTitle,
.bug .admonitionTitle {
	color: #470302;
}

.hidden {
	color: transparent;
	font-size: 0;
}

.message table:first-child,
.message pre:first-child {
	margin-left: 60px !important;
}
.message table:first-child:before,
.message pre:first-child:before {
	margin-left: -70px !important;
	position: absolute !important;
	margin-top: -20px !important;
}

@media screen and (max-width: 500px) {
	body {
		font-size: 1.05em !important;
	}
	main {
		width: initial !important;
		max-width: initial !important;
	}
	#controls {
		flex-direction: column;
		align-items: left;
		width: 100%;
		margin-left: -20px;
	}
	.hideControls #chat {
		margin-bottom: 2em !important;
	}
	.hideFooter #controls {
		height: 0px !important;
	}

	#input-container {
		width: 95%;
	}

	button {
		margin-top: 0;
	}
	footer {
		font-size: 0.7em;
		left: auto;
		right: 0;
		width: 200px;
	}
	.hideControls footer {
		left: 0;
		width: 90%;
	}

	#chat,
	.message {
		padding: 5px !important;
	}
	.bot-message {
		width: 90% !important;
	}
	ul {
		padding-left: 30px !important;
	}
	ul ul {
		padding-left: 25px !important;
	}
	pre {
		margin: 0em;
		width: 95%;
	}
	.message > div > .admonition {
		margin-left: 0.5em;
	}
	[contenteditable="true"]:empty:before {
		font-size: 0.9em;
	}
}

@media screen and (max-width: 400px) {
	[contenteditable="true"]:empty:before {
		font-size: 0.75em;
	}
}

/* Lien de retour vers le portail élève (ajouté par chatmd.js si data-portail) */
.retour-portail {
	position: sticky;
	top: 8px;
	z-index: 50;
	display: inline-block;
	margin: 12px 0 0 12px;
	padding: 6px 14px;
	border-radius: 999px;
	background: #6366f1;
	color: #fff !important;
	font-family: Arial, sans-serif;
	font-size: 14px;
	text-decoration: none;
	box-shadow: 0 3px 10px rgba(49, 46, 129, 0.25);
}

.retour-portail:hover,
.retour-portail:focus-visible {
	background: #4f46e5;
}

/* ===== Adaptation aux petits écrans : rien ne doit dépasser la bulle du message ===== */

/* Tableaux : jamais plus larges que la bulle ; défilement horizontal si nécessaire */
.message table {
	display: block;
	width: fit-content;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* Formules longues : défilement horizontal plutôt que débordement */
.message .katex-display {
	overflow-x: auto;
	overflow-y: hidden;
	padding: 0.1em 0;
}

.message .katex {
	display: inline-block;
	max-width: 100%;
	overflow-x: auto;
	overflow-y: hidden;
	vertical-align: middle;
	padding: 0.15em 0;
}

/* Encart affiché à la place d'une animation pendant l'effet « machine à écrire » (voir chatmd.js) */
.animation-attente {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	max-width: 380px;
	min-height: 140px;
	margin: 0.8em auto;
	border: 2px dashed #93c5fd;
	border-radius: 12px;
	background: #eef4ff;
	color: #1d4ed8;
	font-family: Arial, sans-serif;
	font-weight: bold;
}

.animation-attente-roue {
	width: 22px;
	height: 22px;
	border: 3px solid #bfdbfe;
	border-top-color: #1d4ed8;
	border-radius: 50%;
	animation: animation-attente-tourne 0.9s linear infinite;
}

@keyframes animation-attente-tourne {
	to {
		transform: rotate(360deg);
	}
}

/* Animations et images */
.message iframe,
.message img,
.message video {
	max-width: 100%;
}

/* Mots très longs (adresses…) : coupés seulement s'ils ne tiennent pas sur une ligne entière */
.message p {
	overflow-wrap: break-word;
}

/* Tableaux : on ne coupe jamais un mot ou un nombre au milieu (le tableau défile si besoin) */
.message td,
.message th {
	overflow-wrap: normal;
	word-break: normal;
	hyphens: manual;
}

@media screen and (max-width: 500px) {
	.message table:first-child,
	.message pre:first-child {
		margin-left: 0 !important;
	}

	.message table {
		font-size: 0.85em;
	}

	.message td,
	.message th {
		padding: 3px 5px !important;
	}

	.admonition {
		padding: 0.5em 0.6em;
	}

	.retour-portail {
		margin: 6px 0 0 6px;
		padding: 4px 10px;
		font-size: 13px;
		opacity: 0.92;
	}
}
