/* Citizen AI Chatbot — frontend widget */

#citizen-widget {
	--citizen-primary: #7c3aed;
	--citizen-bubble: #7c3aed;
	position: fixed;
	bottom: 20px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#citizen-widget.citizen-pos-bottom-right { right: 20px; }
#citizen-widget.citizen-pos-bottom-left { left: 20px; }

#citizen-bubble {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	border: none;
	background: var(--citizen-bubble);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0,0,0,.25);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .2s ease;
}
#citizen-bubble:hover { transform: scale(1.08); }
#citizen-bubble img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.citizen-bubble-emoji { font-size: 28px; line-height: 1; }

#citizen-window {
	position: absolute;
	bottom: 76px;
	width: 360px;
	max-width: calc(100vw - 40px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0,0,0,.3);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
#citizen-widget.citizen-pos-bottom-right #citizen-window { right: 0; }
#citizen-widget.citizen-pos-bottom-left #citizen-window { left: 0; }
#citizen-window.citizen-hidden { display: none; }

#citizen-header {
	background: var(--citizen-primary);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	gap: 10px;
}
.citizen-header-avatar { font-size: 22px; }
.citizen-header-avatar img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; vertical-align: middle; }
.citizen-header-name { font-weight: 600; flex: 1; }
#citizen-close { background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; line-height: 1; }

#citizen-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: #f7f7f9;
}

.citizen-msg {
	max-width: 80%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.4;
	animation: citizen-in .25s ease;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.citizen-msg.bot { background: #fff; color: #222; align-self: flex-start; border: 1px solid #e6e6ea; }
.citizen-msg.user { background: var(--citizen-primary); color: #fff; align-self: flex-end; }

@keyframes citizen-in {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

.citizen-typing { display: inline-flex; gap: 4px; align-self: flex-start; padding: 12px 14px; }
.citizen-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: var(--citizen-primary);
	animation: citizen-pulse 1.2s infinite ease-in-out;
}
.citizen-typing span:nth-child(2) { animation-delay: .2s; }
.citizen-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes citizen-pulse {
	0%, 60%, 100% { transform: scale(.6); opacity: .4; }
	30% { transform: scale(1); opacity: 1; }
}

#citizen-lead-form {
	padding: 14px 16px;
	border-top: 1px solid #eee;
	background: #fff;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
#citizen-lead-form.citizen-hidden { display: none; }
.citizen-lead-title { margin: 0 0 4px; font-weight: 600; font-size: 14px; }
#citizen-lead-form input {
	padding: 9px 12px;
	border: 1px solid #ddd;
	border-radius: 8px;
	font-size: 14px;
}
#citizen-lead-submit {
	background: var(--citizen-primary);
	color: #fff;
	border: none;
	padding: 10px;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 600;
}
.citizen-link { background: none; border: none; color: #888; cursor: pointer; font-size: 13px; text-decoration: underline; }

#citizen-input-bar {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #eee;
	background: #fff;
}
#citizen-input {
	flex: 1;
	resize: none;
	border: 1px solid #ddd;
	border-radius: 10px;
	padding: 9px 12px;
	font-size: 14px;
	max-height: 120px;
	font-family: inherit;
}
#citizen-send {
	background: var(--citizen-primary);
	color: #fff;
	border: none;
	width: 40px;
	height: 40px;
	border-radius: 10px;
	cursor: pointer;
	font-size: 16px;
	flex-shrink: 0;
}

/* Formulaires IA (shortcode) */
.citizen-aiform {
	max-width: 560px;
	border: 1px solid #e6e6ea;
	border-radius: 12px;
	padding: 20px;
	background: #fff;
}
.citizen-aiform-label { display: block; margin-bottom: 12px; font-weight: 600; }
.citizen-aiform-label input,
.citizen-aiform-label textarea,
.citizen-aiform-label select {
	display: block;
	width: 100%;
	margin-top: 4px;
	padding: 9px 12px;
	border: 1px solid #ddd;
	border-radius: 8px;
	font-weight: 400;
}
.citizen-aiform-submit {
	background: #7c3aed;
	color: #fff;
	border: none;
	padding: 11px 22px;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 600;
}
.citizen-aiform-result {
	margin-top: 16px;
	padding: 14px;
	background: #f3f0fd;
	border-radius: 8px;
}

@media (max-width: 480px) {
	#citizen-window {
		width: calc(100vw - 24px);
		height: calc(100vh - 100px);
	}
	#citizen-widget { bottom: 12px; }
	#citizen-widget.citizen-pos-bottom-right { right: 12px; }
	#citizen-widget.citizen-pos-bottom-left { left: 12px; }
}
