/*
 * Assistant IA WordPress — widget de chat flottant.
 *
 * Tous les sélecteurs sont préfixés par #aiwp-root : les thèmes commerciaux
 * (WoodMart, Elementor…) stylent agressivement `button` et écrasaient sinon
 * la pastille, les icônes d'en-tête et le bouton d'envoi.
 */

#aiwp-root {
	/* L'accent suit la couleur du thème quand elle existe, sinon l'ambre CEFEL. */
	--aiwp-accent: var(--wd-primary-color, #fbb03b);
	--aiwp-primary: var(--wd-alternative-color, #09245f);
	--aiwp-primary-dark: #061a45;
	--aiwp-primary-light: #1c4494;
	--aiwp-radius: 18px;
	--aiwp-surface: #ffffff;
	--aiwp-text: #16181d;
	--aiwp-muted: #6b7280;
	--aiwp-bot-bg: #f2f4f8;

	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--aiwp-text);
	text-align: left;
	direction: ltr;
}

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

/* Remise à zéro : le thème applique ses styles de bouton à tout <button>. */
#aiwp-root button {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	min-width: 0;
	min-height: 0;
	width: auto;
	height: auto;
	line-height: 1;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

#aiwp-root img.aiwp-mark {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: contain;
	border-radius: 0;
	box-shadow: none;
	background: none;
}

#aiwp-root .aiwp-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* --- Pastille ------------------------------------------------------- */

#aiwp-root .aiwp-bubble {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	margin-left: auto;
	padding: 11px;
	border: 2px solid var(--aiwp-primary);
	border-radius: 50%;
	background: #fff;
	color: var(--aiwp-primary);
	box-shadow: 0 6px 22px rgba(9, 36, 95, .28);
	transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

#aiwp-root .aiwp-bubble:hover {
	transform: translateY(-3px) scale(1.06);
	border-color: var(--aiwp-accent);
	box-shadow: 0 12px 28px rgba(9, 36, 95, .34);
}

#aiwp-root .aiwp-bubble:focus-visible {
	outline: 3px solid var(--aiwp-accent);
	outline-offset: 3px;
}

#aiwp-root .aiwp-bubble:active {
	transform: scale(.96);
}

#aiwp-root .aiwp-bubble-icon {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}

/* Pastille de dialogue en incrustation : signale que c'est un chat. */
#aiwp-root .aiwp-badge {
	position: absolute;
	right: -9px;
	bottom: -7px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 23px;
	height: 23px;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--aiwp-accent);
	color: #fff;
}

#aiwp-root .aiwp-icon-close {
	display: none;
}

#aiwp-root[data-open="true"] .aiwp-bubble {
	border-color: var(--aiwp-primary);
	background: var(--aiwp-primary);
	color: #fff;
	padding: 0;
}

#aiwp-root[data-open="true"] .aiwp-icon-chat {
	display: none;
}

#aiwp-root[data-open="true"] .aiwp-icon-close {
	display: flex;
}

/* --- Bulle d'accroche ----------------------------------------------- */

#aiwp-root .aiwp-teaser {
	position: absolute;
	right: 76px;
	bottom: 12px;
	display: flex;
	align-items: flex-start;
	gap: 2px;
	width: max-content;
	max-width: 250px;
	padding: 11px 8px 11px 14px;
	border-radius: 16px 16px 4px 16px;
	background: #fff;
	color: var(--aiwp-primary);
	box-shadow: 0 8px 26px rgba(9, 36, 95, .26);
	opacity: 0;
	transform: translateX(10px) scale(.96);
	transform-origin: right bottom;
	transition: opacity .25s ease, transform .25s ease;
	pointer-events: none;
}

#aiwp-root .aiwp-teaser[hidden] {
	display: none;
}

#aiwp-root .aiwp-teaser[data-show="true"] {
	opacity: 1;
	transform: translateX(0) scale(1);
	pointer-events: auto;
}

/* Pointe dirigée vers la pastille. */
#aiwp-root .aiwp-teaser::after {
	content: "";
	position: absolute;
	right: -7px;
	bottom: 14px;
	width: 0;
	height: 0;
	border-top: 8px solid transparent;
	border-bottom: 8px solid transparent;
	border-left: 8px solid #fff;
}

#aiwp-root .aiwp-teaser-text {
	flex: 1 1 auto;
	padding: 0;
	background: none;
	color: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	text-align: left;
	border-bottom: 2px solid var(--aiwp-accent);
}

#aiwp-root .aiwp-teaser-close {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	margin-top: -3px;
	border-radius: 50%;
	color: var(--aiwp-muted);
	opacity: .6;
	transition: opacity .15s ease, background-color .15s ease;
}

#aiwp-root .aiwp-teaser-close:hover {
	background: #eef0f5;
	opacity: 1;
}

#aiwp-root .aiwp-teaser-close svg {
	display: block;
	fill: currentColor;
}

@media (max-width: 600px) {
	#aiwp-root .aiwp-teaser {
		right: 70px;
		max-width: calc(100vw - 110px);
	}
}

@media (prefers-reduced-motion: reduce) {
	#aiwp-root .aiwp-teaser {
		transition: none;
	}
}

/* --- Fenêtre -------------------------------------------------------- */

#aiwp-root .aiwp-panel {
	position: absolute;
	right: 0;
	bottom: 80px;
	display: flex;
	flex-direction: column;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 540px;
	max-height: calc(100vh - 130px);
	overflow: hidden;
	border-radius: var(--aiwp-radius);
	background: var(--aiwp-surface);
	box-shadow: 0 20px 55px rgba(9, 36, 95, .3);
	opacity: 0;
	transform: translateY(12px) scale(.98);
	transition: opacity .18s ease, transform .18s ease;
}

#aiwp-root .aiwp-panel[hidden] {
	display: none;
}

#aiwp-root[data-open="true"] .aiwp-panel {
	opacity: 1;
	transform: translateY(0) scale(1);
}

#aiwp-root .aiwp-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 13px 14px;
	background: var(--aiwp-primary);
	color: #fff;
	border-bottom: 3px solid var(--aiwp-accent);
}

#aiwp-root .aiwp-header-id {
	display: flex;
	align-items: center;
	gap: 11px;
	min-width: 0;
}

#aiwp-root .aiwp-avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	padding: 5px;
	border-radius: 50%;
	background: #fff;
	color: var(--aiwp-primary);
	font-weight: 700;
	text-transform: uppercase;
}

#aiwp-root .aiwp-title {
	margin: 0;
	padding: 0;
	font-size: 15px;
	font-weight: 600;
	color: #fff;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#aiwp-root .aiwp-status {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 2px 0 0;
	padding: 0;
	font-size: 12px;
	color: rgba(255, 255, 255, .8);
}

#aiwp-root .aiwp-status::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--aiwp-accent);
}

#aiwp-root .aiwp-header-actions {
	display: flex;
	gap: 2px;
}

#aiwp-root .aiwp-icon-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 9px;
	background: transparent;
	color: #fff;
	opacity: .85;
	transition: background-color .15s ease, opacity .15s ease;
}

#aiwp-root .aiwp-icon-btn:hover {
	background: rgba(255, 255, 255, .18);
	opacity: 1;
}

#aiwp-root .aiwp-icon-btn svg,
#aiwp-root .aiwp-bubble svg,
#aiwp-root .aiwp-send svg {
	display: block;
	fill: currentColor;
}

/* --- Messages ------------------------------------------------------- */

#aiwp-root .aiwp-messages {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px 14px 4px;
	background: #fbfbfd;
	-webkit-overflow-scrolling: touch;
}

#aiwp-root .aiwp-msg {
	display: flex;
	margin: 0 0 10px;
}

#aiwp-root .aiwp-msg-user {
	justify-content: flex-end;
}

#aiwp-root .aiwp-msg-has-quick {
	flex-direction: column;
	align-items: flex-start;
}

#aiwp-root .aiwp-bubble-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 16px;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
	font-size: 14.5px;
}

#aiwp-root .aiwp-msg-bot .aiwp-bubble-msg {
	border-bottom-left-radius: 5px;
	background: var(--aiwp-bot-bg);
	color: var(--aiwp-text);
}

#aiwp-root .aiwp-msg-user .aiwp-bubble-msg {
	border-bottom-right-radius: 5px;
	background: var(--aiwp-primary);
	color: #fff;
}

#aiwp-root .aiwp-msg-error .aiwp-bubble-msg {
	background: #fdecec;
	color: #a8071a;
}

#aiwp-root .aiwp-bubble-msg a {
	color: var(--aiwp-primary);
	text-decoration: underline;
	text-decoration-color: var(--aiwp-accent);
	text-underline-offset: 2px;
	font-weight: 600;
	box-shadow: none;
}

#aiwp-root .aiwp-bubble-msg a:hover {
	color: var(--aiwp-accent);
}

#aiwp-root .aiwp-msg-user .aiwp-bubble-msg a {
	color: #fff;
}

#aiwp-root .aiwp-bubble-msg strong {
	font-weight: 700;
}

/* Listes à puces des réponses. La bulle est en pre-wrap : les éléments
   repassent en white-space normal pour éviter les décalages d'indentation. */
#aiwp-root .aiwp-bubble-msg .aiwp-list {
	margin: 6px 0;
	padding: 0 0 0 18px;
	list-style: none;
}

#aiwp-root .aiwp-bubble-msg .aiwp-list li {
	position: relative;
	margin: 4px 0;
	padding: 0;
	white-space: normal;
	list-style: none;
}

#aiwp-root .aiwp-bubble-msg .aiwp-list li::before {
	content: "";
	position: absolute;
	top: .55em;
	left: -12px;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: var(--aiwp-primary);
}

/* --- Réponses rapides ---------------------------------------------- */

#aiwp-root .aiwp-quick-replies {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 7px;
	max-width: 94%;
	margin: 7px 0 2px 5px;
}

#aiwp-root .aiwp-quick-hint {
	flex: 0 0 100%;
	margin: 0 0 1px;
	color: var(--aiwp-muted);
	font-size: 11.5px;
	font-weight: 600;
	line-height: 1.35;
}

#aiwp-root button.aiwp-quick-reply {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 34px;
	padding: 8px 11px;
	border: 1px solid rgba(9, 36, 95, .28);
	border-radius: 999px;
	background: #fff;
	color: var(--aiwp-primary);
	font-size: 12.5px;
	font-weight: 650;
	line-height: 1.2;
	text-align: center;
	box-shadow: 0 2px 7px rgba(9, 36, 95, .08);
	transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

#aiwp-root button.aiwp-quick-reply:hover {
	border-color: var(--aiwp-primary);
	background: var(--aiwp-primary);
	color: #fff;
	transform: translateY(-1px);
}

#aiwp-root button.aiwp-quick-reply:focus-visible {
	outline: 3px solid rgba(251, 176, 59, .42);
	outline-offset: 2px;
}

#aiwp-root button.aiwp-quick-reply.is-selected,
#aiwp-root button.aiwp-quick-reply[aria-pressed="true"] {
	border-color: var(--aiwp-primary);
	background: var(--aiwp-primary);
	color: #fff;
	box-shadow: 0 3px 9px rgba(9, 36, 95, .2);
}

#aiwp-root button.aiwp-quick-reply[aria-pressed="true"]::before {
	content: "✓";
	margin-right: 5px;
	font-weight: 800;
}

#aiwp-root button.aiwp-quick-confirm {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 145px;
	min-height: 36px;
	padding: 8px 13px;
	border: 1px solid var(--aiwp-accent);
	border-radius: 999px;
	background: var(--aiwp-accent);
	color: #182033;
	font-size: 12.5px;
	font-weight: 750;
	line-height: 1.2;
	box-shadow: 0 3px 9px rgba(251, 176, 59, .2);
	transition: filter .15s ease, transform .15s ease, opacity .15s ease;
}

#aiwp-root button.aiwp-quick-confirm:hover:not(:disabled) {
	filter: brightness(.96);
	transform: translateY(-1px);
}

#aiwp-root button.aiwp-quick-confirm:focus-visible {
	outline: 3px solid rgba(251, 176, 59, .42);
	outline-offset: 2px;
}

#aiwp-root button.aiwp-quick-confirm:disabled {
	opacity: .45;
	cursor: not-allowed;
}

#aiwp-root button.aiwp-quick-reply-other {
	border-style: dashed;
	border-color: var(--aiwp-accent);
	color: var(--aiwp-primary);
}

/* --- Indicateur de frappe ------------------------------------------- */

#aiwp-root .aiwp-typing {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 2px 18px 9px;
	background: #fbfbfd;
	font-size: 12.5px;
	color: var(--aiwp-muted);
}

#aiwp-root .aiwp-typing[hidden] {
	display: none;
}

#aiwp-root .aiwp-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--aiwp-accent);
	animation: aiwp-blink 1.2s infinite ease-in-out;
}

#aiwp-root .aiwp-dot:nth-child(2) {
	animation-delay: .18s;
}

#aiwp-root .aiwp-dot:nth-child(3) {
	animation-delay: .36s;
}

#aiwp-root .aiwp-typing-label {
	margin-left: 4px;
}

@keyframes aiwp-blink {
	0%, 80%, 100% { opacity: .25; transform: translateY(0); }
	40%           { opacity: 1;   transform: translateY(-3px); }
}

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

#aiwp-root .aiwp-form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0;
	padding: 11px 12px;
	border-top: 1px solid #e6e8ee;
	background: #fff;
}

#aiwp-root .aiwp-input {
	flex: 1 1 auto;
	max-height: 110px;
	min-height: 42px;
	margin: 0;
	padding: 11px 13px;
	border: 1px solid #d8dbe3;
	border-radius: 12px;
	background: #fff;
	color: var(--aiwp-text);
	font: inherit;
	font-size: 14.5px;
	line-height: 1.4;
	resize: none;
	outline: none;
	box-shadow: none;
	transition: border-color .15s ease, box-shadow .15s ease;
}

#aiwp-root .aiwp-input:focus {
	border-color: var(--aiwp-primary);
	box-shadow: 0 0 0 3px rgba(9, 36, 95, .12);
}

#aiwp-root .aiwp-input:disabled {
	background: #f4f5f8;
	cursor: not-allowed;
}

#aiwp-root .aiwp-send {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: var(--aiwp-accent);
	color: #fff;
	transition: filter .15s ease, transform .15s ease;
}

#aiwp-root .aiwp-send:hover:not(:disabled) {
	filter: brightness(.93);
	transform: scale(1.06);
}

#aiwp-root .aiwp-send:disabled {
	opacity: .45;
	cursor: not-allowed;
}

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

@media (max-width: 600px) {
	#aiwp-root {
		right: 14px;
		bottom: 14px;
	}

	#aiwp-root .aiwp-panel {
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		width: 100%;
		max-width: 100%;
		height: 100dvh;
		max-height: 100dvh;
		border-radius: 0;
	}

	#aiwp-root .aiwp-bubble {
		width: 58px;
		height: 58px;
	}

	#aiwp-root .aiwp-input {
		font-size: 16px; /* Évite le zoom automatique sur iOS. */
	}
}

@media (prefers-reduced-motion: reduce) {
	#aiwp-root .aiwp-bubble,
	#aiwp-root .aiwp-panel,
	#aiwp-root .aiwp-send,
	#aiwp-root .aiwp-dot {
		transition: none;
		animation: none;
	}
}
