/* AideChat Frontend Widget */
.aidechat-widget {
	--aidechat-primary: #2563eb;
	--aidechat-radius: 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
	z-index: 999999;
	position: fixed;
	bottom: 24px;
	right: 24px;
}

.aidechat-widget.aidechat-pos-bottom-left {
	right: auto;
	left: 24px;
}

/* Bouton flottant */
.aidechat-toggle {
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--aidechat-primary);
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 20px rgba(0,0,0,0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	transition: transform 0.2s, box-shadow 0.2s;
}

.aidechat-toggle:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 28px rgba(0,0,0,0.3);
}

.aidechat-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	background: #e11d48;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	min-width: 20px;
	height: 20px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 5px;
}

/* Fenêtre */
.aidechat-window {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: var(--aidechat-radius);
	box-shadow: 0 12px 48px rgba(0,0,0,0.18);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.aidechat-pos-bottom-left .aidechat-window {
	right: auto;
	left: 0;
}

/* Header */
.aidechat-header {
	background: var(--aidechat-primary);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.aidechat-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 600;
	font-size: 15px;
}

.aidechat-status-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 3px rgba(74,222,128,0.3);
}

.aidechat-header-actions {
	display: flex;
	gap: 6px;
}

.aidechat-btn-icon {
	background: rgba(255,255,255,0.15);
	border: none;
	color: #fff;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s;
}

.aidechat-btn-icon:hover {
	background: rgba(255,255,255,0.3);
}

/* Messages */
.aidechat-body {
	flex: 1;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.aidechat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: #f8fafc;
}

.aidechat-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 14px;
	line-height: 1.45;
	word-wrap: break-word;
}

.aidechat-msg.bot,
.aidechat-msg.agent,
.aidechat-msg.system {
	align-self: flex-start;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-bottom-left-radius: 4px;
}

.aidechat-msg.visitor {
	align-self: flex-end;
	background: var(--aidechat-primary);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.aidechat-msg.system {
	background: #f1f5f9;
	color: #64748b;
	font-size: 13px;
	text-align: center;
	align-self: center;
	max-width: 95%;
}

.aidechat-msg-meta {
	font-size: 11px;
	opacity: 0.7;
	margin-bottom: 3px;
}

.aidechat-msg.visitor .aidechat-msg-meta {
	text-align: right;
}

/* Input */
.aidechat-input-area {
	display: flex;
	align-items: flex-end;
	padding: 12px;
	border-top: 1px solid #e2e8f0;
	background: #fff;
	gap: 8px;
}

#aidechat-input {
	flex: 1;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	padding: 10px 14px;
	font-size: 14px;
	resize: none;
	max-height: 100px;
	outline: none;
	font-family: inherit;
	transition: border-color 0.15s;
}

#aidechat-input:focus {
	border-color: var(--aidechat-primary);
}

.aidechat-send-btn {
	width: 42px;
	height: 42px;
	border-radius: 12px;
	background: var(--aidechat-primary);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: opacity 0.15s;
}

.aidechat-send-btn:hover {
	opacity: 0.9;
}

/* Formulaires */
.aidechat-ticket-form,
.aidechat-start-form,
.aidechat-gdpr {
	padding: 16px;
	overflow-y: auto;
	flex: 1;
	background: #f8fafc;
}

.aidechat-form-group {
	margin-bottom: 12px;
}

.aidechat-form-group input,
.aidechat-form-group select,
.aidechat-form-group textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	font-size: 14px;
	font-family: inherit;
	box-sizing: border-box;
}

.aidechat-form-group input:focus,
.aidechat-form-group select:focus,
.aidechat-form-group textarea:focus {
	outline: none;
	border-color: var(--aidechat-primary);
}

.aidechat-btn-primary {
	width: 100%;
	padding: 12px;
	background: var(--aidechat-primary);
	color: #fff;
	border: none;
	border-radius: 10px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	margin-bottom: 8px;
}

.aidechat-btn-primary:hover {
	opacity: 0.92;
}

.aidechat-btn-secondary {
	width: 100%;
	padding: 10px;
	background: transparent;
	color: #64748b;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	font-size: 13px;
	cursor: pointer;
}

.aidechat-gdpr p {
	font-size: 13px;
	color: #475569;
	line-height: 1.5;
	margin-bottom: 14px;
}

/* Responsive */
@media (max-width: 480px) {
	.aidechat-window {
		width: calc(100vw - 16px);
		height: calc(var(--aidechat-mobile-height, 58vh) - 10px);
		max-height: calc(var(--aidechat-mobile-height, 58vh) - 10px);
		bottom: 70px;
		right: 0;
		left: auto;
		border-radius: 16px 16px 0 0;
	}
	.aidechat-widget.aidechat-pos-bottom-left .aidechat-window {
		left: 0;
		right: auto;
	}
	.aidechat-widget {
		bottom: 16px;
		right: 16px;
	}
	.aidechat-widget.aidechat-full-mobile .aidechat-window {
		width: 100vw;
		right: 0;
		left: 0;
		border-radius: 16px 16px 0 0;
	}
}
/* Quick Replies */
.md-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 8px 12px;
	background: #fff;
	border-top: 1px solid #e2e8f0;
}
.md-quick-reply {
	background: #f1f5f9;
	border: 1px solid #e2e8f0;
	border-radius: 20px;
	padding: 6px 12px;
	font-size: 12px;
	cursor: pointer;
	transition: all 0.15s;
	color: #334155;
}
.md-quick-reply:hover {
	background: var(--aidechat-primary);
	color: #fff;
	border-color: var(--aidechat-primary);
}

/* Typing indicator */
.md-typing {
	display: flex;
	gap: 4px;
	align-items: center;
	padding: 12px 16px !important;
}
.md-typing span {
	width: 7px;
	height: 7px;
	background: #94a3b8;
	border-radius: 50%;
	animation: md-bounce 1.4s infinite ease-in-out both;
}
.md-typing span:nth-child(1) { animation-delay: -0.32s; }
.md-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes md-bounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
	40% { transform: scale(1); opacity: 1; }
}

/* Seen status */
.md-msg-status {
	font-size: 11px;
	text-align: right;
	margin-top: 2px;
	opacity: 0.7;
}
.md-seen { letter-spacing: -1px; }

/* CSAT */
.md-csat-box {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	padding: 16px;
	margin: 12px 0;
	text-align: center;
}
.md-csat-stars {
	font-size: 28px;
	margin: 10px 0;
	cursor: pointer;
}
.md-csat-star {
	color: #cbd5e1;
	transition: color 0.15s;
	padding: 0 2px;
}
.md-csat-star.active,
.md-csat-star:hover {
	color: #f59e0b;
}
.md-csat-box textarea {
	width: 100%;
	margin: 8px 0;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 8px;
	font-size: 13px;
	box-sizing: border-box;
}
.md-csat-thanks {
	color: #16a34a;
	font-weight: 600;
}

/* Attach button */
.aidechat-attach-btn {
	width: 36px;
	height: 36px;
	border: none;
	background: transparent;
	color: #64748b;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	flex-shrink: 0;
}
.aidechat-attach-btn:hover {
	background: #f1f5f9;
	color: var(--aidechat-primary);
}
.md-file-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	color: inherit;
	text-decoration: underline;
	font-size: 13px;
}

/* Avatar */
.aidechat-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(255,255,255,0.4);
	flex-shrink: 0;
}
.aidechat-avatar-fallback {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: rgba(255,255,255,0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	flex-shrink: 0;
}
.aidechat-header-text {
	display: flex;
	flex-direction: column;
	gap: 1px;
}
.aidechat-header-status {
	font-size: 11px;
	font-weight: 400;
	opacity: 0.9;
	display: flex;
	align-items: center;
	gap: 5px;
}
.aidechat-toggle-avatar {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
}

/* Emoji picker */
.md-emoji-picker {
	position: absolute;
	bottom: 60px;
	left: 8px;
	right: 8px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	box-shadow: 0 8px 24px rgba(0,0,0,0.12);
	padding: 10px;
	display: grid;
	grid-template-columns: repeat(8, 1fr);
	gap: 4px;
	max-height: 180px;
	overflow-y: auto;
	z-index: 10;
}
.md-emoji-picker span {
	font-size: 22px;
	cursor: pointer;
	text-align: center;
	padding: 4px;
	border-radius: 6px;
	line-height: 1.2;
	transition: background 0.12s;
}
.md-emoji-picker span:hover {
	background: #f1f5f9;
}
.aidechat-input-area {
	position: relative;
}

/* Micro */
.md-mic-active {
	background: #fee2e2 !important;
	color: #dc2626 !important;
	animation: md-pulse 1s infinite;
}
@keyframes md-pulse {
	0%, 100% { transform: scale(1); }
	50% { transform: scale(1.1); }
}

/* Proactive bubble */
.md-proactive-bubble {
	position: absolute;
	bottom: 76px;
	right: 0;
	width: 280px;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 8px 32px rgba(0,0,0,0.15);
	padding: 14px 16px;
	z-index: 5;
	animation: md-slide-up 0.3s ease;
}
.aidechat-pos-bottom-left .md-proactive-bubble {
	right: auto;
	left: 0;
}
@keyframes md-slide-up {
	from { opacity: 0; transform: translateY(12px); }
	to { opacity: 1; transform: translateY(0); }
}
.md-proactive-bubble p {
	margin: 0 0 10px;
	font-size: 14px;
	line-height: 1.4;
	color: #334155;
}
.md-proactive-close {
	position: absolute;
	top: 6px;
	right: 8px;
	border: none;
	background: transparent;
	font-size: 18px;
	cursor: pointer;
	color: #94a3b8;
	line-height: 1;
}
.md-proactive-open {
	width: 100%;
	padding: 8px !important;
	font-size: 13px !important;
}

/* Reactions */
.md-msg-reactions {
	display: flex;
	gap: 4px;
	margin-top: 4px;
	flex-wrap: wrap;
}
.md-reaction {
	background: #f1f5f9;
	border-radius: 12px;
	padding: 1px 6px;
	font-size: 14px;
	border: 1px solid #e2e8f0;
}
.md-react-picker {
	position: absolute;
	bottom: 100%;
	left: 0;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 20px;
	padding: 4px 8px;
	display: flex;
	gap: 6px;
	box-shadow: 0 4px 16px rgba(0,0,0,0.12);
	z-index: 5;
}
.md-react-picker span {
	cursor: pointer;
	font-size: 18px;
	padding: 2px;
}
.md-react-picker span:hover {
	transform: scale(1.2);
}

/* Labels under launcher – professional */
.md-launcher-labels {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 6px;
	margin-top: 10px;
	pointer-events: auto;
}
.aidechat-pos-bottom-left .md-launcher-labels {
	align-items: flex-start;
}
.md-launcher-label {
	border: none;
	cursor: pointer;
	font-family: inherit;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.02em;
	padding: 7px 14px;
	border-radius: 20px;
	box-shadow: 0 4px 14px rgba(0,0,0,0.12);
	transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
	white-space: nowrap;
	line-height: 1.2;
}
.md-launcher-label:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(0,0,0,0.16);
}
.md-label-chat {
	background: var(--aidechat-primary, #2563eb);
	color: #fff;
}
.md-label-ticket {
	background: #fff;
	color: #1e293b;
	border: 1px solid #e2e8f0;
}
.md-label-ticket:hover {
	border-color: var(--aidechat-primary, #2563eb);
	color: var(--aidechat-primary, #2563eb);
}

/* Style: pills (default) – already above */

/* Style: stack – same column, slightly larger */
.md-label-style-stack .md-launcher-label {
	min-width: 110px;
	text-align: center;
	border-radius: 10px;
	padding: 9px 14px;
}

/* Style: minimal – subtle text pills */
.md-label-style-minimal .md-launcher-label {
	background: rgba(15, 23, 42, 0.78);
	color: #fff;
	font-weight: 500;
	font-size: 11px;
	padding: 5px 10px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.md-label-style-minimal .md-label-ticket {
	background: rgba(255,255,255,0.92);
	color: #334155;
	border: none;
}

/* Hide labels when chat window is open */
.aidechat-widget.md-is-open .md-launcher-labels {
	opacity: 0;
	pointer-events: none;
	transform: translateY(6px);
	transition: opacity 0.2s, transform 0.2s;
}

@media (max-width: 480px) {
	.md-launcher-label {
		font-size: 11px;
		padding: 6px 12px;
	}
}

/* Google-style voice overlay */
.md-voice-overlay {
	position: absolute;
	left: 8px;
	right: 8px;
	bottom: 58px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 16px;
	box-shadow: 0 8px 28px rgba(0,0,0,0.12);
	padding: 16px;
	text-align: center;
	z-index: 20;
}
.md-voice-wave {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 5px;
	height: 36px;
	margin-bottom: 8px;
}
.md-voice-wave span {
	width: 4px;
	height: 12px;
	background: var(--aidechat-primary, #2563eb);
	border-radius: 4px;
	animation: md-wave 0.9s ease-in-out infinite;
}
.md-voice-wave span:nth-child(1) { animation-delay: 0s; }
.md-voice-wave span:nth-child(2) { animation-delay: 0.15s; height: 20px; }
.md-voice-wave span:nth-child(3) { animation-delay: 0.3s; height: 28px; }
.md-voice-wave span:nth-child(4) { animation-delay: 0.45s; height: 16px; }
@keyframes md-wave {
	0%, 100% { transform: scaleY(0.5); opacity: 0.6; }
	50% { transform: scaleY(1); opacity: 1; }
}
.md-voice-text {
	margin: 0 0 10px;
	font-size: 14px;
	color: #334155;
	min-height: 20px;
}
.md-voice-stop {
	border: none;
	background: #f1f5f9;
	color: #475569;
	padding: 6px 16px;
	border-radius: 20px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}
.md-voice-stop:hover {
	background: #e2e8f0;
}
.md-mic-btn.md-mic-active {
	background: #dbeafe !important;
	color: var(--aidechat-primary, #2563eb) !important;
}



/* Dark mode confortable (doux pour les yeux) */
.aidechat-widget.md-dark .aidechat-window {
	background: #1a1d23;
	color: #e8eaed;
	box-shadow: 0 12px 48px rgba(0,0,0,0.45);
}
.aidechat-widget.md-dark .aidechat-header {
	background: #2b5278;
}
.aidechat-widget.md-dark .aidechat-messages {
	background: #21242b;
}
.aidechat-widget.md-dark .aidechat-msg.bot,
.aidechat-widget.md-dark .aidechat-msg.agent {
	background: #2c3038;
	border-color: #3d4450;
	color: #e8eaed;
}
.aidechat-widget.md-dark .aidechat-msg.system {
	background: #2a2e36;
	border-color: #3d4450;
	color: #a0a8b4;
}
.aidechat-widget.md-dark .aidechat-msg.visitor {
	background: #3a7ab8;
	color: #fff;
}
.aidechat-widget.md-dark .aidechat-input-area {
	background: #1a1d23;
	border-color: #2c3038;
}
.aidechat-widget.md-dark #aidechat-input {
	background: #262a32;
	border-color: #3d4450;
	color: #e8eaed;
}
.aidechat-widget.md-dark #aidechat-input::placeholder {
	color: #8b93a0;
}
.aidechat-widget.md-dark .aidechat-attach-btn {
	color: #a0a8b4;
}
.aidechat-widget.md-dark .aidechat-attach-btn:hover {
	background: #2c3038;
	color: #e8eaed;
}
.aidechat-widget.md-dark .md-quick-replies {
	background: #1a1d23;
	border-color: #2c3038;
}
.aidechat-widget.md-dark .md-quick-reply {
	background: #2c3038;
	border-color: #3d4450;
	color: #d0d5dd;
}
.aidechat-widget.md-dark .md-quick-reply:hover {
	background: #3a7ab8;
	border-color: #3a7ab8;
	color: #fff;
}
.aidechat-widget.md-dark .aidechat-ticket-form,
.aidechat-widget.md-dark .aidechat-start-form,
.aidechat-widget.md-dark .aidechat-gdpr {
	background: #21242b;
}
.aidechat-widget.md-dark .aidechat-form-group input,
.aidechat-widget.md-dark .aidechat-form-group select,
.aidechat-widget.md-dark .aidechat-form-group textarea {
	background: #262a32;
	border-color: #3d4450;
	color: #e8eaed;
}
.aidechat-widget.md-dark .md-emoji-picker,
.aidechat-widget.md-dark .md-voice-overlay {
	background: #1a1d23;
	border-color: #3d4450;
	color: #e8eaed;
}
.aidechat-widget.md-dark .md-voice-text {
	color: #c5cad3;
}
.aidechat-widget.md-dark .md-proactive-bubble {
	background: #1a1d23;
	color: #e8eaed;
}
.aidechat-widget.md-dark .md-proactive-bubble p {
	color: #c5cad3;
}
.aidechat-widget.md-dark .md-label-ticket {
	background: #2c3038;
	color: #e8eaed;
	border-color: #3d4450;
}
