/* Camp Mars — Assistant de chat
   Palette inspirée du désert de Douz au coucher du soleil :
   - fond nuit tombante (#22283D)
   - sable chaud (#F6EEDD)
   - cuivre / dune éclairée (#B5602E)
   - vert zellige tunisien, en contrepoint (#2F6E64)
*/

#campmars-chat-root {
	--cm-night: #22283d;
	--cm-night-soft: #2b3350;
	--cm-sand: #f6eedd;
	--cm-sand-deep: #ece0c8;
	--cm-copper: #b5602e;
	--cm-copper-hover: #9c4f24;
	--cm-teal: #2f6e64;
	--cm-ink: #2a2118;
	--cm-shadow: rgba(34, 24, 12, 0.28);

	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 999999;
	font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	color: var(--cm-ink);
}

#campmars-chat-root * {
	box-sizing: border-box;
}

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

.cm-launcher {
	width: 60px;
	height: 60px;
	border-radius: 30% 70% 65% 35% / 55% 40% 60% 45%;
	background: linear-gradient(150deg, var(--cm-copper) 0%, #d97f3f 100%);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 10px 26px var(--cm-shadow);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cm-launcher:hover {
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 14px 30px var(--cm-shadow);
}

.cm-launcher:focus-visible {
	outline: 3px solid var(--cm-teal);
	outline-offset: 3px;
}

.cm-launcher svg {
	width: 26px;
	height: 26px;
}

/* -------------------- Panneau de conversation -------------------- */

.cm-panel {
	position: absolute;
	right: 0;
	bottom: 76px;
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 520px;
	max-height: 70vh;
	background: var(--cm-sand);
	border-radius: 22px 22px 14px 14px;
	box-shadow: 0 20px 50px var(--cm-shadow);
	display: none;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--cm-sand-deep);
}

.cm-panel.cm-open {
	display: flex;
}

.cm-header {
	background: linear-gradient(160deg, var(--cm-night) 0%, var(--cm-night-soft) 100%);
	color: var(--cm-sand);
	padding: 16px 18px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}

.cm-header-title {
	font-family: 'Fraunces', Georgia, serif;
	font-size: 17px;
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1.2;
}

.cm-header-sub {
	font-size: 12px;
	color: #cbb896;
	margin-top: 2px;
}

.cm-close {
	background: none;
	border: none;
	color: var(--cm-sand);
	cursor: pointer;
	padding: 4px;
	opacity: 0.75;
	transition: opacity 0.15s ease;
}

.cm-close:hover {
	opacity: 1;
}

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

.cm-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.cm-msg {
	max-width: 82%;
	padding: 10px 13px;
	border-radius: 14px;
	font-size: 14.5px;
	line-height: 1.45;
	white-space: pre-wrap;
	word-wrap: break-word;
}

.cm-msg-bot {
	align-self: flex-start;
	background: var(--cm-sand-deep);
	color: var(--cm-ink);
	border-bottom-left-radius: 4px;
}

.cm-msg-user {
	align-self: flex-end;
	background: var(--cm-teal);
	color: #f4faf8;
	border-bottom-right-radius: 4px;
}

.cm-msg-error {
	align-self: flex-start;
	background: #f3d9ce;
	color: #7a3418;
	border-bottom-left-radius: 4px;
}

.cm-typing {
	align-self: flex-start;
	display: flex;
	gap: 4px;
	padding: 12px 14px;
	background: var(--cm-sand-deep);
	border-radius: 14px;
	border-bottom-left-radius: 4px;
}

.cm-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #a99873;
	animation: cm-bounce 1.2s infinite ease-in-out;
}

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

@keyframes cm-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
	30% { transform: translateY(-4px); opacity: 1; }
}

/* -------------------- Zone de saisie -------------------- */

.cm-input-row {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--cm-sand-deep);
	background: var(--cm-sand);
	flex-shrink: 0;
}

.cm-input {
	flex: 1;
	border: 1.5px solid var(--cm-sand-deep);
	background: #fffdf8;
	border-radius: 12px;
	padding: 10px 12px;
	font-size: 14.5px;
	font-family: inherit;
	color: var(--cm-ink);
	resize: none;
	max-height: 90px;
}

.cm-input:focus {
	outline: none;
	border-color: var(--cm-copper);
}

.cm-send {
	background: var(--cm-copper);
	border: none;
	color: white;
	width: 40px;
	height: 40px;
	border-radius: 12px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s ease;
}

.cm-send:hover {
	background: var(--cm-copper-hover);
}

.cm-send:disabled {
	background: #d8c9a8;
	cursor: not-allowed;
}

.cm-send svg {
	width: 17px;
	height: 17px;
}

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

@media (max-width: 420px) {
	#campmars-chat-root {
		right: 12px;
		bottom: 12px;
	}
	.cm-panel {
		width: calc(100vw - 24px);
		height: 65vh;
	}
}
