/*
 * Chatbot IA & Leads — styles front.
 * Toutes les classes sont préfixées .cil- pour éviter tout conflit avec Enfold.
 */

#cil-root {
	--cil-primary: #1f3b57;
	--cil-primary-text: #ffffff;
	--cil-bg: #ffffff;
	--cil-text: #1f2933;
	--cil-muted: #5f6b7a;
	--cil-border: #d9dee5;
	--cil-radius: 14px;
	--cil-shadow: 0 8px 30px rgba(15, 23, 42, 0.22);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	box-sizing: border-box;
}

#cil-root *,
#cil-root *::before,
#cil-root *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

/* ---------- Bouton flottant ---------- */

.cil-launcher {
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 999990;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	background: var(--cil-primary);
	color: var(--cil-primary-text);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 18px rgba(15, 23, 42, 0.3);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cil-launcher:hover,
.cil-launcher:focus-visible {
	transform: scale(1.06);
	box-shadow: 0 6px 22px rgba(15, 23, 42, 0.38);
}

.cil-launcher:focus-visible {
	outline: 3px solid #ffffff;
	outline-offset: 2px;
}

.cil-launcher svg {
	width: 28px;
	height: 28px;
	fill: currentColor;
	pointer-events: none;
}

/* ---------- Fenêtre de chat ---------- */

.cil-window {
	position: fixed;
	right: 22px;
	bottom: 96px;
	z-index: 999991;
	width: 380px;
	max-width: calc(100vw - 44px);
	height: 550px;
	max-height: calc(100vh - 130px);
	max-height: calc(100dvh - 130px);
	background: var(--cil-bg);
	border-radius: var(--cil-radius);
	box-shadow: var(--cil-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--cil-border);
}

.cil-window[hidden] {
	display: none;
}

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

.cil-header {
	background: var(--cil-primary);
	color: var(--cil-primary-text);
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.cil-header-title {
	font-size: 16px;
	font-weight: 600;
	color: inherit;
}

.cil-header-status {
	font-size: 12px;
	opacity: 0.85;
}

.cil-close {
	background: transparent;
	border: none;
	color: inherit;
	cursor: pointer;
	font-size: 22px;
	line-height: 1;
	padding: 4px 8px;
	border-radius: 6px;
}

.cil-close:hover,
.cil-close:focus-visible {
	background: rgba(255, 255, 255, 0.18);
}

.cil-close:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 1px;
}

/* ---------- Notice RGPD ---------- */

.cil-rgpd {
	background: #f2f5f8;
	color: var(--cil-muted);
	font-size: 11.5px;
	padding: 8px 14px;
	border-bottom: 1px solid var(--cil-border);
	flex-shrink: 0;
}

/* ---------- Zone de messages ---------- */

.cil-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #fafbfc;
	scroll-behavior: smooth;
}

.cil-msg {
	max-width: 85%;
	padding: 9px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: break-word;
	font-size: 14.5px;
}

.cil-msg-bot {
	align-self: flex-start;
	background: #e9edf2;
	color: var(--cil-text);
	border-bottom-left-radius: 4px;
}

.cil-msg-user {
	align-self: flex-end;
	background: var(--cil-primary);
	color: var(--cil-primary-text);
	border-bottom-right-radius: 4px;
}

.cil-msg-error {
	align-self: center;
	background: #fdeaea;
	color: #90322d;
	font-size: 13px;
	text-align: center;
}

/* ---------- Indicateur « en train d'écrire » ---------- */

.cil-typing {
	align-self: flex-start;
	background: #e9edf2;
	border-radius: 14px;
	border-bottom-left-radius: 4px;
	padding: 12px 16px;
	display: flex;
	gap: 5px;
	align-items: center;
}

.cil-typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #8a97a5;
	animation: cil-bounce 1.2s infinite ease-in-out;
}

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

@keyframes cil-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-5px); opacity: 1; }
}

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

/* ---------- Formulaire de saisie ---------- */

.cil-inputbar {
	display: flex;
	gap: 8px;
	padding: 10px;
	border-top: 1px solid var(--cil-border);
	background: var(--cil-bg);
	flex-shrink: 0;
}

.cil-input {
	flex: 1;
	border: 1px solid var(--cil-border);
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 14.5px;
	font-family: inherit;
	resize: none;
	max-height: 90px;
	color: var(--cil-text);
	background: #ffffff;
}

.cil-input:focus {
	outline: 2px solid var(--cil-primary);
	outline-offset: -1px;
}

.cil-send {
	background: var(--cil-primary);
	color: var(--cil-primary-text);
	border: none;
	border-radius: 10px;
	padding: 0 16px;
	cursor: pointer;
	font-size: 14.5px;
	font-weight: 600;
	font-family: inherit;
}

.cil-send:hover:not(:disabled) { filter: brightness(1.12); }
.cil-send:disabled { opacity: 0.5; cursor: not-allowed; }

.cil-send:focus-visible {
	outline: 2px solid var(--cil-text);
	outline-offset: 2px;
}

/* ---------- Honeypot (invisible pour les humains) ---------- */

.cil-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	opacity: 0;
}

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

.cil-leadform {
	align-self: stretch;
	background: #ffffff;
	border: 1px solid var(--cil-border);
	border-radius: 12px;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 9px;
}

.cil-leadform-title {
	font-weight: 600;
	font-size: 14.5px;
	color: var(--cil-text);
}

.cil-leadform label {
	font-size: 12.5px;
	color: var(--cil-muted);
	display: block;
	margin-bottom: 3px;
}

.cil-leadform input[type="text"],
.cil-leadform input[type="tel"],
.cil-leadform input[type="email"] {
	width: 100%;
	border: 1px solid var(--cil-border);
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 14px;
	font-family: inherit;
	color: var(--cil-text);
	background: #ffffff;
}

.cil-leadform input:focus {
	outline: 2px solid var(--cil-primary);
	outline-offset: -1px;
}

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

.cil-consent input[type="checkbox"] {
	margin-top: 2px;
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	accent-color: var(--cil-primary);
}

.cil-leadform-actions {
	display: flex;
	gap: 8px;
	margin-top: 2px;
}

.cil-btn-primary,
.cil-btn-secondary {
	border-radius: 8px;
	padding: 9px 14px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	flex: 1;
}

.cil-btn-primary {
	background: var(--cil-primary);
	color: var(--cil-primary-text);
	border: none;
}

.cil-btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.cil-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.cil-btn-secondary {
	background: transparent;
	color: var(--cil-muted);
	border: 1px solid var(--cil-border);
}

.cil-btn-secondary:hover { background: #f2f5f8; }

.cil-btn-primary:focus-visible,
.cil-btn-secondary:focus-visible {
	outline: 2px solid var(--cil-text);
	outline-offset: 2px;
}

.cil-field-error {
	color: #90322d;
	font-size: 12px;
}

/* ---------- Lien d'accessibilité ---------- */

.cil-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- Mobile : quasi plein écran ---------- */

@media (max-width: 640px) {
	.cil-window {
		right: 0;
		left: 0;
		bottom: 0;
		width: 100%;
		max-width: 100%;
		height: 100%;
		max-height: 100dvh;
		border-radius: 0;
		border: none;
	}

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