/* AsK Chat : widget de conversation, embarqué ou flottant.
 *
 * Le flottant vit dans un portail posé sous <body> (cicatrice Divi : un
 * transform sur un ancêtre piège les éléments fixed). Rouge club #E5221E.
 * `display:flex` écrase [hidden] : les états cachés passent par des
 * classes et des display:none explicites.
 */

.ask-chat-portal {
	--ask-chat-red: #E5221E;
	--ask-chat-dark: #1d1d1f;
	--ask-chat-z: 99999;
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: var(--ask-chat-z);
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
	font-family: inherit;
}

.ask-chat-root {
	--ask-chat-red: #E5221E;
	--ask-chat-dark: #1d1d1f;
}

/* ── Bulle et infobulle (flottant) ── */
.ask-chat-bubble {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	border: 3px solid var(--ask-chat-red);
	background: #fff;
	padding: 0;
	cursor: pointer;
	overflow: hidden;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
}
.ask-chat-bubble.is-hidden { display: none; }
.ask-chat-bubble-avatar {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.ask-chat-avatar-initial {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--ask-chat-red);
	color: #fff;
	font-weight: 700;
	font-size: 1.4em;
	width: 100%;
	height: 100%;
}
.ask-chat-tip {
	max-width: 280px;
	background: #fff;
	color: var(--ask-chat-dark);
	border-radius: 12px;
	padding: 12px 16px;
	font-size: 0.95em;
	line-height: 1.4;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	text-align: center;
}
/* Étiquette courte du téléphone, à gauche de l'avatar et centrée sur lui
   (1.0.5). Cachée ailleurs : l'ordinateur garde l'infobulle. */
.ask-chat-hint { display: none; }

/* ── Panneau ── */
.ask-chat-panel {
	display: flex;
	flex-direction: column;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
	overflow: hidden;
	color: var(--ask-chat-dark);
	font-size: 0.95em;
	line-height: 1.45;
}
.ask-chat-panel[data-mode="floating"] {
	display: none;
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 560px;
	max-height: calc(100vh - 100px);
}
.ask-chat-panel[data-mode="floating"].is-open { display: flex; }
.ask-chat-panel[data-mode="embedded"] {
	width: 100%;
	max-width: 720px;
	height: 520px;
	border: 1px solid #e3e3e3;
}

.ask-chat-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	background: var(--ask-chat-dark);
	color: #fff;
}
.ask-chat-header-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
	flex: 0 0 32px;
	display: block;
}
.ask-chat-header .ask-chat-avatar-initial {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	font-size: 1em;
	flex: 0 0 32px;
}
.ask-chat-title {
	flex: 1 1 auto;
	font-weight: 700;
	font-size: 1.05em;
}

.ask-chat-icon {
	background: transparent;
	border: 0;
	padding: 4px 6px;
	cursor: pointer;
	color: inherit;
	line-height: 1;
	font-size: 1.1em;
	border-radius: 6px;
}
.ask-chat-icon:hover,
.ask-chat-icon:focus-visible { background: rgba(255, 255, 255, 0.15); outline: none; }
.ask-chat-icon:disabled { opacity: 0.4; cursor: default; }
.ask-chat-glyph { pointer-events: none; }

.ask-chat-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 14px 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f5f5f5;
}

.ask-chat-msg { display: flex; }
.ask-chat-msg-assistant { justify-content: flex-start; }
.ask-chat-msg-user { justify-content: flex-end; }
.ask-chat-bubble-text {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
.ask-chat-msg-assistant .ask-chat-bubble-text {
	background: var(--ask-chat-dark);
	color: #fff;
	border-bottom-left-radius: 4px;
}
.ask-chat-msg-user .ask-chat-bubble-text {
	background: var(--ask-chat-red);
	color: #fff;
	border-bottom-right-radius: 4px;
	white-space: pre-wrap;
}
.ask-chat-msg-error .ask-chat-bubble-text {
	background: #fff;
	color: var(--ask-chat-red);
	border: 1px solid var(--ask-chat-red);
}
.ask-chat-pending .ask-chat-bubble-text {
	opacity: 0.7;
	font-style: italic;
}

.ask-chat-md p { margin: 0 0 8px; }
.ask-chat-md p:last-child { margin-bottom: 0; }
.ask-chat-md ul,
.ask-chat-md ol { margin: 0 0 8px 1.2em; padding: 0; }
.ask-chat-md li { margin: 2px 0; }
.ask-chat-md a { color: #ff8a86; text-decoration: underline; }
.ask-chat-md code {
	background: rgba(255, 255, 255, 0.15);
	padding: 1px 4px;
	border-radius: 4px;
	font-size: 0.92em;
}

.ask-chat-footer {
	border-top: 1px solid #e3e3e3;
	background: #fff;
	padding: 8px 10px;
}
.ask-chat-form { display: flex; flex-direction: column; gap: 6px; }
.ask-chat-input {
	width: 100%;
	box-sizing: border-box;
	resize: none;
	border: 1px solid #c9c9c9;
	border-radius: 8px;
	padding: 8px 10px;
	font: inherit;
	line-height: 1.4;
	min-height: 44px;
}
.ask-chat-input:focus { outline: 2px solid var(--ask-chat-red); outline-offset: 0; border-color: transparent; }
.ask-chat-input:disabled { background: #f0f0f0; }
.ask-chat-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 6px;
}
.ask-chat-actions .ask-chat-icon { color: var(--ask-chat-dark); font-size: 1.3em; }
.ask-chat-actions .ask-chat-icon:hover,
.ask-chat-actions .ask-chat-icon:focus-visible { background: #eee; }
.ask-chat-send { color: var(--ask-chat-red) !important; }
.ask-chat-mic { display: inline-flex; align-items: center; justify-content: center; }
.ask-chat-mic-icon { display: block; }
.ask-chat-mic.is-recording {
	background: var(--ask-chat-red) !important;
	color: #fff !important;
	animation: ask-chat-pulse 1.2s ease-in-out infinite;
}
@keyframes ask-chat-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(229, 34, 30, 0.45); }
	50% { box-shadow: 0 0 0 8px rgba(229, 34, 30, 0); }
}
.ask-chat-counter {
	margin-right: auto;
	font-size: 0.8em;
	color: #777;
}

/* ── Téléphone ──
 * Panneau ouvert en plein écran, donc calque le plus haut de la page : la
 * barre d'admin WordPress passait devant et cachait la fermeture (son
 * z-index est relevé sur le site au-delà des 99999 du cœur, on ne s'y
 * aligne pas). Hauteur en dvh : 100vh compte la zone
 * sous les barres du navigateur. Pas d'infobulle d'accueil : sur un écran
 * de téléphone, elle couvrait les boutons de la page (Mat, 19/10) ; une
 * étiquette courte « Une question ? » la remplace à côté de l'avatar.
 */
@media (max-width: 600px) {
	.ask-chat-portal { right: 10px; bottom: 10px; --ask-chat-z: 2147483000; }
	.ask-chat-panel[data-mode="floating"] {
		width: calc(100vw - 20px);
		max-width: none;
		height: calc(100vh - 20px);
		height: calc(100dvh - 20px);
		max-height: calc(100vh - 20px);
		max-height: calc(100dvh - 20px);
	}
	.ask-chat-tip { display: none; }
	.ask-chat-hint {
		display: block;
		position: absolute;
		right: 70px; /* bulle de 64 px, bordure comprise, plus 6 px */
		bottom: 32px; /* centre de la bulle */
		transform: translateY(50%);
		white-space: nowrap;
		background: #fff;
		color: var(--ask-chat-dark);
		font-size: 13px;
		line-height: 1.2;
		padding: 6px 10px;
		border-radius: 14px;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
		cursor: pointer;
	}
}
