/**
 * Chatbot Wisteria — styles confinés sous #wsc-root.
 */

#wsc-root {
	--wsc-accent: #69c2ff;
	--wsc-on-accent: #10243a;
	--wsc-surface: #ffffff;
	--wsc-text: #1c1f23;
	--wsc-muted: #6b7280;
	--wsc-line: rgba( 0, 0, 0, 0.09 );

	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.55;
	color: var( --wsc-text );
}

#wsc-root *,
#wsc-root *::before,
#wsc-root *::after {
	box-sizing: border-box;
}

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

.wsc-bubble {
	position: relative; /* ancre le halo ::after */
	display: flex;
	align-items: center;
	justify-content: center;
	width: 58px;
	height: 58px;
	padding: 0;
	margin-left: auto;
	border: 0;
	border-radius: 50%;
	background: var( --wsc-accent );
	color: var( --wsc-on-accent );
	cursor: pointer;
	box-shadow: 0 8px 24px rgba( 0, 0, 0, 0.22 );
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

/**
 * Taille imposée à l'icône.
 *
 * Les attributs width/height du SVG ne suffisent pas : dans un conteneur flex,
 * un thème WordPress peut faire calculer une largeur de zéro, et l'icône
 * disparaît en laissant une pastille de couleur unie. On fige donc la taille et
 * on empêche le rétrécissement.
 */
#wsc-root .wsc-bubble .wsc-ico {
	display: block;
	width: 28px;
	height: 28px;
	min-width: 28px;
	flex: 0 0 28px;
	max-width: none;
	pointer-events: none; /* le clic atteint toujours le bouton */
}

.wsc-bubble:hover {
	transform: translateY( -2px );
	box-shadow: 0 12px 28px rgba( 0, 0, 0, 0.28 );
}

.wsc-bubble.is-open {
	transform: scale( 0.94 );
}

/* Halo discret pour signaler le chatbot, une fois au chargement. */
.wsc-bubble::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	border: 2px solid var( --wsc-accent );
	animation: wsc-pulse 2.4s ease-out 3;
	pointer-events: none;
}

.wsc-bubble.is-open::after {
	display: none;
}

@keyframes wsc-pulse {
	0% { opacity: 0.7; transform: scale( 1 ); }
	70%, 100% { opacity: 0; transform: scale( 1.6 ); }
}

@media ( prefers-reduced-motion: reduce ) {
	.wsc-bubble::after {
		animation: none;
		display: none;
	}
}

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

/* display: flex l'emporterait sur l'attribut hidden. */
.wsc-panel[hidden],
.wsc-form[hidden] {
	display: none;
}

.wsc-panel {
	display: flex;
	flex-direction: column;
	width: 380px;
	max-width: calc( 100vw - 32px );
	height: 580px;
	max-height: calc( 100vh - 120px );
	margin-bottom: 12px;
	overflow: hidden;
	border-radius: 16px;
	background: var( --wsc-surface );
	box-shadow: 0 24px 60px rgba( 0, 0, 0, 0.24 );
	animation: wsc-in 0.18s ease-out;
}

@keyframes wsc-in {
	from {
		opacity: 0;
		transform: translateY( 12px );
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.wsc-panel,
	.wsc-bubble {
		animation: none;
		transition: none;
	}
}

/* En-tête ---------------------------------------------------------------- */

.wsc-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 14px 16px;
	background: var( --wsc-accent );
	color: var( --wsc-on-accent );
}

.wsc-dot {
	flex: 0 0 auto;
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: #2fbf5f;
}

.wsc-title {
	flex: 1 1 auto;
	font-weight: 600;
}

.wsc-icon {
	flex: 0 0 auto;
	padding: 0 4px;
	border: 0;
	background: none;
	color: inherit;
	font-size: 18px;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	opacity: 0.8;
}

.wsc-icon:hover {
	opacity: 1;
}

.wsc-close {
	font-size: 24px;
}

/* Corps ------------------------------------------------------------------ */

.wsc-body {
	flex: 1 1 auto;
	padding: 16px;
	overflow-y: auto;
	background: #f6f8fa;
}

.wsc-msg {
	display: flex;
	margin-bottom: 10px;
}

.wsc-msg--user {
	justify-content: flex-end;
}

.wsc-msg-text {
	max-width: 85%;
	padding: 10px 13px;
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.06 );
	overflow-wrap: anywhere;
}

.wsc-msg--user .wsc-msg-text {
	background: var( --wsc-accent );
	color: var( --wsc-on-accent );
	box-shadow: none;
}

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

.wsc-link {
	display: inline-block;
	padding: 8px 13px;
	border: 1px solid var( --wsc-accent );
	border-radius: 999px;
	background: #fff;
	color: var( --wsc-text );
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}

.wsc-link:hover {
	background: var( --wsc-accent );
	color: var( --wsc-on-accent );
}

/* Suggestions ------------------------------------------------------------ */

.wsc-suggest {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 2px 0 12px;
}

.wsc-suggest-title {
	width: 100%;
	margin-bottom: 2px;
	color: var( --wsc-muted );
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.wsc-chip {
	padding: 8px 12px;
	border: 1px solid var( --wsc-line );
	border-radius: 999px;
	background: #fff;
	color: var( --wsc-text );
	font: inherit;
	font-size: 13.5px;
	text-align: left;
	text-decoration: none;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.wsc-chip:hover {
	border-color: var( --wsc-accent );
	background: #fff;
}

.wsc-chip--action {
	border-color: var( --wsc-accent );
	background: var( --wsc-accent );
	color: var( --wsc-on-accent );
	font-weight: 600;
}

/* Saisie en cours -------------------------------------------------------- */

.wsc-typing .wsc-msg-text {
	display: flex;
	gap: 4px;
	padding: 14px 13px;
}

.wsc-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var( --wsc-muted );
	animation: wsc-blink 1.2s infinite ease-in-out;
}

.wsc-typing span:nth-child( 2 ) { animation-delay: 0.15s; }
.wsc-typing span:nth-child( 3 ) { animation-delay: 0.3s; }

@keyframes wsc-blink {
	0%, 60%, 100% { opacity: 0.25; }
	30% { opacity: 1; }
}

/* Sélecteur de langue ---------------------------------------------------- */

.wsc-langs {
	padding: 28px 8px;
	text-align: center;
}

.wsc-langs-title {
	font-size: 17px;
	font-weight: 600;
}

.wsc-langs-sub {
	margin-bottom: 20px;
	color: var( --wsc-muted );
	font-size: 13px;
}

.wsc-langs-grid {
	display: grid;
	gap: 8px;
}

.wsc-lang {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px;
	border: 1px solid var( --wsc-line );
	border-radius: 10px;
	background: #fff;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.wsc-lang:hover {
	border-color: var( --wsc-accent );
	transform: translateY( -1px );
}

.wsc-flag {
	font-size: 18px;
}

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

.wsc-form {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var( --wsc-line );
	background: var( --wsc-surface );
}

.wsc-input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 11px 14px;
	border: 1px solid var( --wsc-line );
	border-radius: 999px;
	font: inherit;
	outline: none;
}

.wsc-input:focus {
	border-color: var( --wsc-accent );
}

.wsc-send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: var( --wsc-accent );
	color: var( --wsc-on-accent );
	font-size: 16px;
	cursor: pointer;
}

/* Arabe : lecture de droite à gauche ------------------------------------- */

.wsc-panel[dir="rtl"] .wsc-msg--user { justify-content: flex-start; }
.wsc-panel[dir="rtl"] .wsc-msg:not( .wsc-msg--user ) { justify-content: flex-end; }
.wsc-panel[dir="rtl"] .wsc-chip { text-align: right; }
.wsc-panel[dir="rtl"] .wsc-send { transform: scaleX( -1 ); }

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

@media ( max-width: 480px ) {
	#wsc-root {
		right: 12px;
		bottom: 12px;
	}

	.wsc-panel {
		width: calc( 100vw - 24px );
		height: calc( 100vh - 110px );
	}
}
