/* Papote — widget de chat. Styles isolés (préfixe papote-) pour ne pas casser
   la page hôte. Contrastes conformes WCAG AA, focus visibles, reduced-motion. */

.papote-toggle,
.papote-panel,
.papote-panel * {
	box-sizing: border-box;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Bouton bulle */
.papote-toggle {
	position: fixed;
	bottom: 1.25rem;
	right: 1.25rem;
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 50%;
	border: none;
	background: #3e6b4f;
	color: #fff;
	font-size: 1.5rem;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
	z-index: 99999;
}

.papote-toggle:hover {
	background: #2f5740;
}

/* Panneau */
.papote-panel {
	position: fixed;
	bottom: 5.25rem;
	right: 1.25rem;
	width: 360px;
	max-width: calc(100vw - 2rem);
	height: 520px;
	max-height: calc(100vh - 7rem);
	display: flex;
	flex-direction: column;
	background: #fff;
	color: #1a1a1a;
	border: 1px solid #c4c4c4;
	border-radius: 10px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
	overflow: hidden;
	z-index: 99999;
}

.papote-panel[hidden] {
	display: none;
}

.papote-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: #3e6b4f;
	color: #fff;
	padding: 0.75rem 1rem;
}

.papote-title {
	margin: 0;
	font-size: 1rem;
	line-height: 1.3;
	/* Force le blanc et la police du widget pour résister au style h2 du thème hôte. */
	color: #fff !important;
	font-family: inherit !important;
}

.papote-close {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 1.1rem;
	cursor: pointer;
	padding: 0.25rem 0.5rem;
	border-radius: 4px;
}

.papote-log {
	flex: 1;
	overflow-y: auto;
	padding: 0.75rem;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.papote-msg {
	max-width: 90%;
	padding: 0.5rem 0.7rem;
	border-radius: 8px;
	font-size: 0.95rem;
	line-height: 1.4;
}

.papote-msg-user {
	align-self: flex-end;
	background: #3e6b4f;
	color: #fff;
}

.papote-msg-assistant {
	align-self: flex-start;
	background: #eef1f6;
	color: #1a1a1a;
}

.papote-msg-fallback {
	background: #fff4e5;
	border: 1px solid #e0a85c;
}

.papote-msg-author {
	display: block;
	font-size: 0.72rem;
	font-weight: 700;
	opacity: 0.85;
	margin-bottom: 0.15rem;
}

.papote-msg-body {
	white-space: pre-wrap;
	word-wrap: break-word;
}

/* Rendu Markdown (gras, listes, paragraphes) une fois la réponse finalisée. */
.papote-msg-body.papote-rendered {
	white-space: normal;
}

.papote-msg-body.papote-rendered p {
	margin: 0 0 0.5rem;
}

.papote-msg-body.papote-rendered p:last-child {
	margin-bottom: 0;
}

.papote-msg-body.papote-rendered ul {
	margin: 0.25rem 0;
	padding-left: 1.2rem;
}

.papote-msg-body.papote-rendered li {
	margin: 0.1rem 0;
}

.papote-sources {
	margin-top: 0.4rem;
	font-size: 0.78rem;
}

.papote-sources-label {
	font-weight: 700;
	margin-right: 0.3rem;
}

.papote-source {
	display: inline-block;
	margin-right: 0.4rem;
	color: #2f5740;
}

.papote-consent,
.papote-form {
	padding: 0.75rem;
	border-top: 1px solid #e2e2e2;
}

.papote-consent-text,
.papote-pii {
	margin: 0 0 0.5rem;
	font-size: 0.82rem;
	color: #4a4a4a;
}

.papote-pii {
	color: #8a4b00;
}

.papote-input {
	width: 100%;
	resize: vertical;
	padding: 0.5rem;
	font-size: 0.95rem;
	border: 1px solid #9a9a9a;
	border-radius: 6px;
	margin-bottom: 0.5rem;
}

.papote-btn {
	background: #3e6b4f;
	color: #fff;
	border: none;
	border-radius: 6px;
	padding: 0.5rem 0.9rem;
	font-size: 0.9rem;
	cursor: pointer;
}

.papote-btn:hover {
	background: #2f5740;
}

.papote-btn:disabled {
	background: #8a9a90;
	cursor: not-allowed;
}

.papote-contact {
	padding: 0.6rem 0.75rem;
	border-top: 1px solid #e2e2e2;
	font-size: 0.82rem;
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
	background: #f7f8fa;
}

.papote-contact-link,
.papote-contact-phone {
	color: #2f5740;
	font-weight: 600;
}

/* Accessibilité : libellé masqué visuellement mais lu par les lecteurs d'écran */
.papote-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Focus visible homogène et contrasté */
.papote-toggle:focus-visible,
.papote-close:focus-visible,
.papote-btn:focus-visible,
.papote-input:focus-visible,
.papote-source:focus-visible,
.papote-contact-link:focus-visible,
.papote-contact-phone:focus-visible {
	outline: 3px solid #ffbf47;
	outline-offset: 2px;
}

.papote-noscript {
	position: fixed;
	bottom: 1.25rem;
	right: 1.25rem;
	background: #3e6b4f;
	color: #fff;
	padding: 0.6rem 0.9rem;
	border-radius: 6px;
	z-index: 99999;
}

@media (prefers-reduced-motion: no-preference) {
	.papote-toggle,
	.papote-btn {
		transition: background-color 0.2s ease;
	}
}
