/* MAC Assistant — bouton et fenêtre de conversation. */
.macas {
	--ma-accent: var(--mac-orange-btn, #c24f08);
	--ma-accent-dark: var(--mac-orange-dark, #9a3d05);
	--ma-soft: var(--mac-orange-soft, #fbeadf);
	--ma-ink: var(--mac-ink, #16120f);
	--ma-text: var(--mac-text, #2b2622);
	--ma-muted: var(--mac-muted, #6a635c);
	--ma-line: var(--mac-line, #e7e1d9);
	--ma-tint: var(--mac-tint, #f8f4ee);
	--ma-blue: var(--mac-blue, #004aad);
	--ma-font: var(--mac-body, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
	font-family: var(--ma-font);
	color: var(--ma-text);
	font-size: 15px;
	line-height: 1.5;
}
.macas[hidden],
.macas [hidden] { display: none !important; }
.macas *,
.macas *::before,
.macas *::after { box-sizing: border-box; }
.macas-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
.macas-ico { width: 22px; height: 22px; flex: none; }

/* ---------- Bouton d'ouverture ---------- */
.macas-launcher {
	position: fixed;
	right: 18px;
	bottom: 18px;
	z-index: 99980;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 52px;
	padding: 0 20px 0 16px;
	border: 0;
	border-radius: 999px;
	background: var(--ma-accent);
	color: #fff;
	font: 700 15px/1 var(--ma-font);
	box-shadow: 0 8px 24px rgba(22, 18, 15, 0.22);
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.15s ease;
}
.macas-launcher:hover { background: var(--ma-accent-dark); }
.macas-launcher:focus-visible { outline: 3px solid var(--ma-blue); outline-offset: 3px; }
.macas.has-conv .macas-launcher::after {
	content: "";
	position: absolute;
	top: 6px;
	right: 8px;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #2fb05c;
	border: 2px solid #fff;
}
.macas.is-open .macas-launcher { background: var(--ma-accent-dark); }

/* Le bouton WhatsApp du thème passe au-dessus. */
body.macas-on .mac-wa-float { bottom: 84px; }

/* ---------- Fenêtre ---------- */
.macas-panel {
	position: fixed;
	right: 18px;
	bottom: 84px;
	z-index: 99981;
	display: flex;
	flex-direction: column;
	width: 384px;
	height: min(620px, calc(100vh - 110px));
	height: min(620px, calc(100dvh - 110px));
	background: #fff;
	border: 1px solid var(--ma-line);
	border-radius: 20px;
	box-shadow: 0 18px 50px rgba(22, 18, 15, 0.22);
	overflow: hidden;
}
.macas-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 10px 12px 14px;
	background: var(--ma-accent-dark);
	color: #fff;
}
.macas-avatar {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	flex: none;
	border-radius: 50%;
	background: #fff;
	color: var(--ma-accent-dark);
	font: 700 12px/1 var(--mac-display, var(--ma-font));
	letter-spacing: 0.04em;
}
.macas-head-text { flex: 1; min-width: 0; }
.macas-title { margin: 0; font-weight: 700; font-size: 15px; line-height: 1.25; color: #fff; }
.macas-sub { margin: 0; font-size: 12.5px; opacity: 0.9; color: #fff; }
.macas-icon-btn {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	flex: none;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	cursor: pointer;
}
.macas-icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.macas-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.macas-test {
	margin: 0;
	padding: 6px 14px;
	background: #fff7d6;
	color: #5c4a00;
	font-size: 12.5px;
	border-bottom: 1px solid #f0e3a6;
}

/* ---------- Messages ---------- */
.macas-log {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 14px 14px 6px;
	background: var(--ma-tint);
}
.macas-log:focus { outline: none; }
.macas-msg { display: flex; flex-direction: column; margin: 0 0 12px; }
.macas-msg.is-me { align-items: flex-end; }
.macas-bubble {
	max-width: 88%;
	padding: 10px 13px;
	border-radius: 16px;
	background: #fff;
	color: var(--ma-text);
	border: 1px solid var(--ma-line);
	overflow-wrap: anywhere;
}
.macas-msg.is-bot .macas-bubble { border-top-left-radius: 6px; }
.macas-msg.is-me .macas-bubble {
	background: var(--ma-accent);
	border-color: var(--ma-accent);
	color: #fff;
	border-top-right-radius: 6px;
	white-space: pre-wrap;
}
.macas-msg.is-error .macas-bubble { border-color: #e9b4a0; }
.macas-bubble p { margin: 0 0 6px; }
.macas-bubble p:last-child { margin-bottom: 0; }
.macas-bubble ul { margin: 4px 0 6px; padding-left: 18px; }
.macas-bubble li { margin: 2px 0; }
.macas-bubble strong { color: var(--ma-ink); }

.macas-typing .macas-bubble { display: inline-flex; gap: 4px; padding: 14px 16px; }
.macas-typing i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #b9afa5;
	animation: macas-dot 1.2s infinite ease-in-out;
}
.macas-typing i:nth-child(3) { animation-delay: 0.15s; }
.macas-typing i:nth-child(4) { animation-delay: 0.3s; }
@keyframes macas-dot {
	0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Suggestions et actions ---------- */
.macas-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.macas-chip,
.macas-link {
	display: inline-flex;
	align-items: center;
	min-height: 40px;
	padding: 8px 14px;
	border: 1.5px solid var(--ma-accent);
	border-radius: 999px;
	background: #fff;
	color: var(--ma-accent-dark);
	font: 600 14px/1.2 var(--ma-font);
	text-decoration: none;
	cursor: pointer;
}
.macas-chip:hover,
.macas-link:hover { background: var(--ma-soft); color: var(--ma-accent-dark); }
.macas-chip:focus-visible,
.macas-link:focus-visible,
.macas-wa:focus-visible { outline: 3px solid var(--ma-blue); outline-offset: 2px; }
.macas-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; max-width: 100%; }
.macas-wa {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 40px;
	padding: 8px 16px;
	border-radius: 999px;
	background: #1a7f43;
	color: #fff;
	font: 700 14px/1.2 var(--ma-font);
	text-decoration: none;
}
.macas-wa:hover { background: #146536; color: #fff; }

/* Formulaire de rappel (MAC Publicité) dans la conversation. */
.macas-formbox {
	width: 100%;
	padding: 12px;
	background: #fff;
	border: 1px solid var(--ma-line);
	border-radius: 14px;
}
.macas-formbox .macpub-form { margin: 0; }
.macas-formbox .macpub-grid { grid-template-columns: 1fr; gap: 8px; }
.macas-formbox label { font-size: 13.5px; }
.macas-formbox input[type="text"],
.macas-formbox input[type="tel"],
.macas-formbox input[type="email"] { min-height: 42px; font-size: 16px; }
.macas-formbox .macpub-accord { font-size: 12.5px; }
.macas-formbox .macpub-btn,
.macas-formbox .macpub-submit { width: 100%; }
.macas-formbox .macpub-form-note { font-size: 12px; margin: 6px 0 0; }
.macas-formbox .macpub-done { padding: 4px; }
.macas-done { margin: 0; color: #2f5206; font-weight: 600; }

/* ---------- Saisie ---------- */
.macas-input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--ma-line);
	background: #fff;
}
.macas-input textarea {
	flex: 1;
	min-height: 44px;
	max-height: 120px;
	padding: 11px 12px;
	border: 1px solid #cfc6bb;
	border-radius: 12px;
	resize: none;
	font: 16px/1.35 var(--ma-font);
	color: var(--ma-ink);
	background: #fff;
}
.macas-input textarea:focus { outline: 2px solid var(--ma-blue); outline-offset: 0; border-color: transparent; }
.macas-input textarea:disabled { background: var(--ma-tint); }
.macas-send {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	flex: none;
	border: 0;
	border-radius: 50%;
	background: var(--ma-accent);
	color: #fff;
	cursor: pointer;
}
.macas-send:hover { background: var(--ma-accent-dark); }
.macas-send:disabled { background: #c9bfb4; cursor: default; }
.macas-send:focus-visible { outline: 3px solid var(--ma-blue); outline-offset: 2px; }
.macas-note {
	margin: 0;
	padding: 0 12px 10px;
	background: #fff;
	color: var(--ma-muted);
	font-size: 11.5px;
	line-height: 1.4;
}
.macas-note a { color: inherit; text-decoration: underline; }

/* ---------- Téléphone : plein écran ---------- */
@media (max-width: 640px) {
	.macas-launcher { right: 14px; bottom: 14px; width: 56px; min-height: 56px; padding: 0; justify-content: center; }
	.macas-launcher .macas-launcher-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
	.macas-launcher .macas-ico { width: 26px; height: 26px; }
	body.macas-on .mac-wa-float { bottom: 80px; right: 16px; }
	.macas-panel {
		inset: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 100%;
		border: 0;
		border-radius: 0;
	}
	html.macas-open,
	html.macas-open body { overflow: hidden; }
	html.macas-open .macas-launcher,
	html.macas-open .mac-wa-float { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.macas-typing i { animation: none; }
	.macas-launcher { transition: none; }
}

@media print {
	.macas { display: none !important; }
}
