/*
 * SF Chat — widget visiteur.
 * Palette bleu nuit / or, empruntée à l'identité du cabinet.
 * Aucune police distante n'est chargée : le widget hérite de celle du site.
 */

.sfchat-root {
	--sfchat-accent: #1b2a5c;
	--sfchat-gold: #c9a227;
	--sfchat-ink: #14182b;
	--sfchat-paper: #ffffff;
	--sfchat-veil: #f4f2ee;
	--sfchat-line: rgba( 20, 24, 43, 0.12 );
	--sfchat-muted: #6b7185;
	--sfchat-radius: 14px;
	--sfchat-shadow: 0 18px 48px -12px rgba( 20, 24, 43, 0.34 );

	position: fixed;
	inset: auto 0 0 auto;
	z-index: 99990;
	font-size: 15px;
	line-height: 1.5;
	color: var( --sfchat-ink );
	-webkit-font-smoothing: antialiased;
}

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

.sfchat-root--left {
	inset: auto auto 0 0;
}

/* ---------------------------------------------------------------- Bulle */

.sfchat-launcher {
	position: fixed;
	right: 22px;
	bottom: 22px;
	width: 60px;
	height: 60px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var( --sfchat-accent );
	color: #fff;
	cursor: pointer;
	box-shadow: var( --sfchat-shadow );
	transition: transform 0.24s ease, box-shadow 0.24s ease;
}

.sfchat-root--left .sfchat-launcher {
	right: auto;
	left: 22px;
}

.sfchat-launcher:hover {
	transform: translateY( -2px );
}

.sfchat-launcher:focus-visible {
	outline: 3px solid var( --sfchat-gold );
	outline-offset: 3px;
}

.sfchat-launcher svg {
	width: 26px;
	height: 26px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.6;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/*
 * Signature du widget : un halo qui se dilate sur un cycle de 5,5 s,
 * le rythme d'une respiration calme. Il ne bat que lorsque le cabinet répond
 * en direct — la disponibilité se lit avant même d'ouvrir le panneau.
 */
.sfchat-launcher::before {
	content: "";
	position: absolute;
	inset: -6px;
	border-radius: 50%;
	border: 1px solid var( --sfchat-gold );
	opacity: 0;
}

.sfchat-root--online .sfchat-launcher::before {
	animation: sfchat-breathe 5.5s ease-in-out infinite;
}

@keyframes sfchat-breathe {
	0%   { transform: scale( 0.94 ); opacity: 0; }
	28%  { opacity: 0.85; }
	55%  { transform: scale( 1.16 ); opacity: 0; }
	100% { transform: scale( 0.94 ); opacity: 0; }
}

.sfchat-badge {
	position: absolute;
	top: -3px;
	right: -3px;
	min-width: 21px;
	height: 21px;
	padding: 0 5px;
	display: none;
	place-items: center;
	border-radius: 11px;
	background: var( --sfchat-gold );
	color: #241d00;
	font-size: 12px;
	font-weight: 700;
}

.sfchat-badge.is-visible {
	display: grid;
}

/* -------------------------------------------------------------- Panneau */

.sfchat-panel {
	position: fixed;
	right: 22px;
	bottom: 94px;
	width: 372px;
	min-height: min( 420px, calc( 100vh - 130px ) );
	max-height: min( 620px, calc( 100vh - 130px ) );
	display: none;
	flex-direction: column;
	overflow: hidden;
	border-radius: var( --sfchat-radius );
	background: var( --sfchat-paper );
	box-shadow: var( --sfchat-shadow );
}

.sfchat-root--left .sfchat-panel {
	right: auto;
	left: 22px;
}

.sfchat-panel.is-open {
	display: flex;
	animation: sfchat-rise 0.26s cubic-bezier( 0.2, 0.8, 0.3, 1 );
}

@keyframes sfchat-rise {
	from { opacity: 0; transform: translateY( 12px ); }
	to   { opacity: 1; transform: none; }
}

.sfchat-header {
	padding: 16px 18px 14px;
	background: var( --sfchat-accent );
	color: #fff;
}

.sfchat-header-top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.sfchat-header h2 {
	margin: 0;
	font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
	font-size: 19px;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: #fff;
}

.sfchat-header p {
	margin: 2px 0 0;
	font-size: 13px;
	color: rgba( 255, 255, 255, 0.72 );
}

.sfchat-close {
	flex: none;
	width: 30px;
	height: 30px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba( 255, 255, 255, 0.12 );
	color: #fff;
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
}

.sfchat-close:hover {
	background: rgba( 255, 255, 255, 0.22 );
}

.sfchat-status {
	margin-top: 12px;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 4px 10px 4px 8px;
	border-radius: 999px;
	background: rgba( 255, 255, 255, 0.12 );
	font-size: 12.5px;
	letter-spacing: 0.02em;
	color: rgba( 255, 255, 255, 0.92 );
}

.sfchat-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var( --sfchat-gold );
}

.sfchat-root--offline .sfchat-dot {
	background: rgba( 255, 255, 255, 0.4 );
}

/* ---------------------------------------------------------------- Fil */

/*
 * Le fil absorbe seul la réduction de hauteur. Avec `min-height: 150px` et un
 * panneau en `overflow: hidden`, un écran court (téléphone en paysage, portable
 * avec beaucoup de barres) faisait passer le bouton Envoyer sous la découpe.
 */
.sfchat-body {
	flex: 1 1 auto;
	min-height: 0;
	max-height: 100%;
	padding: 16px 18px;
	overflow-y: auto;
	background: var( --sfchat-veil );
	overscroll-behavior: contain;
}

.sfchat-header,
.sfchat-agent-typing,
.sfchat-form {
	flex: 0 0 auto;
}

.sfchat-intro {
	margin: 0 0 14px;
	padding: 12px 14px;
	border-left: 2px solid var( --sfchat-gold );
	background: var( --sfchat-paper );
	border-radius: 0 10px 10px 0;
	font-size: 14px;
	color: var( --sfchat-ink );
}

.sfchat-intro span {
	display: block;
	margin-top: 6px;
	font-size: 13px;
	color: var( --sfchat-muted );
}

.sfchat-msg {
	max-width: 84%;
	margin-bottom: 10px;
	padding: 9px 13px;
	border-radius: 14px;
	font-size: 14.5px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.sfchat-msg--visitor {
	margin-left: auto;
	border-bottom-right-radius: 4px;
	background: var( --sfchat-accent );
	color: #fff;
}

.sfchat-msg--agent {
	margin-right: auto;
	border-bottom-left-radius: 4px;
	background: var( --sfchat-paper );
	border: 1px solid var( --sfchat-line );
}

/*
 * Séparateur de date et notice locale : discrets, centrés, sans bulle.
 * Le message automatique du serveur, lui, est un vrai message : il doit se
 * lire comme tel, sinon l'accusé de réception passe pour une date.
 */
.sfchat-msg--day,
.sfchat-msg--note {
	max-width: 100%;
	margin: 12px 0;
	padding: 0;
	background: none;
	text-align: center;
	font-size: 12.5px;
	color: var( --sfchat-muted );
}

.sfchat-msg--system {
	margin-right: auto;
	border-bottom-left-radius: 4px;
	border: 1px solid var( --sfchat-line );
	border-left: 3px solid var( --sfchat-gold );
	background: var( --sfchat-paper );
	color: var( --sfchat-ink );
}

.sfchat-msg a {
	color: inherit;
	text-decoration: underline;
}

.sfchat-time {
	display: block;
	margin-top: 4px;
	font-size: 11.5px;
	opacity: 0.62;
}

/* ------------------------------------------------------------ Formulaire */

.sfchat-form {
	padding: 12px 18px 16px;
	border-top: 1px solid var( --sfchat-line );
	background: var( --sfchat-paper );
}

.sfchat-identity {
	display: none;
	gap: 8px;
	flex-direction: column;
	margin-bottom: 10px;
}

.sfchat-identity.is-visible {
	display: flex;
}

.sfchat-field {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var( --sfchat-line );
	border-radius: 9px;
	background: #fff;
	font: inherit;
	font-size: 14px;
	color: var( --sfchat-ink );
}

.sfchat-field:focus {
	outline: 2px solid var( --sfchat-accent );
	outline-offset: -1px;
	border-color: transparent;
}

.sfchat-consent {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 12.5px;
	line-height: 1.45;
	color: var( --sfchat-muted );
}

.sfchat-consent input {
	margin-top: 2px;
	flex: none;
	accent-color: var( --sfchat-accent );
}

.sfchat-consent a {
	color: var( --sfchat-accent );
}

.sfchat-notice {
	margin: 0 0 10px;
	font-size: 12px;
	color: var( --sfchat-muted );
}

.sfchat-compose {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.sfchat-textarea {
	flex: 1;
	min-height: 42px;
	max-height: 132px;
	padding: 10px 12px;
	border: 1px solid var( --sfchat-line );
	border-radius: 10px;
	font: inherit;
	font-size: 14.5px;
	line-height: 1.45;
	resize: none;
	color: var( --sfchat-ink );
	background: #fff;
}

.sfchat-textarea:focus {
	outline: 2px solid var( --sfchat-accent );
	outline-offset: -1px;
	border-color: transparent;
}

.sfchat-send {
	flex: none;
	width: 42px;
	height: 42px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: var( --sfchat-accent );
	color: #fff;
	cursor: pointer;
	transition: opacity 0.2s ease;
}

.sfchat-send:disabled {
	opacity: 0.45;
	cursor: default;
}

.sfchat-send svg {
	width: 19px;
	height: 19px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.7;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.sfchat-error {
	display: none;
	margin: 8px 0 0;
	font-size: 13px;
	color: #a1201c;
}

.sfchat-error.is-visible {
	display: block;
}

.sfchat-resume {
	display: none;
	width: 100%;
	margin-top: 8px;
	padding: 8px;
	border: 1px dashed var( --sfchat-line );
	border-radius: 9px;
	background: none;
	font: inherit;
	font-size: 13px;
	color: var( --sfchat-muted );
	cursor: pointer;
}

.sfchat-resume.is-visible {
	display: block;
}

.sfchat-reset {
	display: none;
	margin: 8px auto 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 11.5px;
	color: var( --sfchat-muted );
	text-decoration: underline;
	cursor: pointer;
}

.sfchat-reset.is-visible {
	display: block;
}

/* Piège à robots : hors flux et hors lecteurs d'écran. */
.sfchat-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ------------------------------------------------------------- Mobile */

@media ( max-width: 520px ) {

	.sfchat-panel {
		right: 0;
		left: 0;
		bottom: 0;
		width: 100%;
		max-height: 100dvh;
		height: 100dvh;
		border-radius: 0;
	}

	.sfchat-root--left .sfchat-panel {
		left: 0;
	}

	.sfchat-launcher {
		right: 16px;
		bottom: 16px;
	}

	.sfchat-root--left .sfchat-launcher {
		left: 16px;
	}
}

@media ( prefers-reduced-motion: reduce ) {

	.sfchat-root--online .sfchat-launcher::before {
		animation: none;
		opacity: 0.5;
	}

	.sfchat-panel.is-open,
	.sfchat-launcher {
		animation: none;
		transition: none;
	}
}


/* ------------------------------------------------------ Pièces jointes */

.sfchat-clip {
	flex: none;
	width: 38px;
	height: 42px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	background: none;
	color: var( --sfchat-muted );
	cursor: pointer;
	border-radius: 8px;
}

.sfchat-clip:hover {
	color: var( --sfchat-accent );
	background: var( --sfchat-veil );
}

.sfchat-clip:disabled {
	opacity: 0.4;
	cursor: default;
}

.sfchat-clip svg {
	width: 19px;
	height: 19px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.7;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.sfchat-file {
	display: flex;
	align-items: center;
	gap: 9px;
	margin-bottom: 4px;
	padding: 7px 9px;
	border-radius: 9px;
	background: rgba( 255, 255, 255, 0.14 );
	color: inherit;
	text-decoration: none;
	font-size: 13.5px;
}

.sfchat-msg--agent .sfchat-file {
	background: var( --sfchat-veil );
}

.sfchat-file svg {
	flex: none;
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
	opacity: 0.8;
}

.sfchat-file span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sfchat-file em {
	display: block;
	font-style: normal;
	font-size: 11.5px;
	opacity: 0.7;
}

.sfchat-file--image {
	display: block;
	padding: 0;
	overflow: hidden;
	background: none;
}

.sfchat-file--image img {
	display: block;
	width: 100%;
	max-height: 190px;
	object-fit: cover;
	border-radius: 9px;
}

.sfchat-file--image span {
	display: block;
	padding: 4px 2px 0;
	font-size: 11.5px;
	opacity: 0.75;
}

.sfchat-panel.is-dropping {
	outline: 2px dashed var( --sfchat-gold );
	outline-offset: -6px;
}

.sfchat-file--audio {
	display: block;
	padding: 6px 0 0;
	background: none;
}

.sfchat-file--audio audio {
	width: 100%;
	height: 34px;
}

.sfchat-file--audio em {
	display: block;
	margin-top: 3px;
	font-style: normal;
	font-size: 11.5px;
	opacity: 0.75;
}

/* 1.5 — indicateur de frappe opérateur. */
.sfchat-agent-typing {
	min-height: 24px;
	padding: 3px 18px 0;
	background: var( --sfchat-paper );
	color: var( --sfchat-muted );
	font-size: 12px;
	font-style: italic;
}
.sfchat-agent-typing:not(.is-visible) { visibility: hidden; }

/* Nom réel de l'opérateur ayant envoyé la réponse. */
.sfchat-agent-name {
	display: block;
	margin-bottom: 3px;
	font-size: 11px;
	font-weight: 700;
	opacity: .78;
}


/* 1.8.6 — lecture vocale robuste sur téléphone. */
.sfchat-audio-fallback { display: inline-block; margin-top: 4px; font-size: 11.5px; }
@media ( max-width: 520px ) {
	.sfchat-file--audio { width: 100%; min-width: 0; }
	.sfchat-file--audio audio { display: block; width: 100%; min-width: 0; height: 44px; }
}


/*
 * 1.8.11 — vocal refusé par le lecteur du système (iOS notamment).
 * Le lecteur natif barré ne dit rien à l'utilisateur : on l'efface au profit
 * d'un lien de téléchargement explicite.
 */
/* Le lecteur reste en place : le masquer supprimait toute possibilité de
   réessayer, y compris quand l'échec n'était que passager. */

.sfchat-file--audio.is-unplayable::before {
	content: "Format non lisible par ce navigateur.";
	display: block;
	margin-bottom: 4px;
	font-size: 12px;
	opacity: 0.85;
}

.sfchat-file--audio.is-unplayable .sfchat-audio-fallback {
	display: inline-block;
	padding: 6px 10px;
	border: 1px solid currentColor;
	border-radius: 8px;
	font-size: 12.5px;
	text-decoration: none;
}
