/**
 * Chirurgie Assistance - Chatbot
 * Palette alignée sur le thème : teal #0f766e, fonds #f8fcfb / #eef8f6.
 */

#chirurgie-chatbot-root {
	--cb-teal: #0f766e;
	--cb-teal-dark: #0b5d57;
	--cb-ink: #0f2b29;
	--cb-muted: #6b7280;
	--cb-border: #dbe5e7;
	--cb-bg-soft: #eef8f6;
}

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

.cb-bubble {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99998;
	width: 60px;
	height: 60px;
	border: none;
	border-radius: 50%;
	background: var(--cb-teal);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(15, 118, 110, 0.35);
	transition: transform 0.2s ease, background 0.2s ease;
}

.cb-bubble:hover,
.cb-bubble:focus-visible {
	background: var(--cb-teal-dark);
	transform: scale(1.06);
	outline: none;
}

.cb-bubble svg {
	width: 28px;
	height: 28px;
	pointer-events: none;
}

.cb-bubble.is-hidden {
	display: none;
}

/* Petite pulsation d'appel, une seule fois, jamais d'ouverture automatique. */
.cb-bubble.cb-attract::after {
	content: '';
	position: absolute;
	inset: -6px;
	border-radius: 50%;
	border: 2px solid var(--cb-teal);
	animation: cb-ping 1.8s ease-out 3;
}

@keyframes cb-ping {
	0%   { opacity: 0.7; transform: scale(0.9); }
	100% { opacity: 0;   transform: scale(1.35); }
}

/* ---------- Panneau ---------- */

.cb-panel {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 99999;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 620px;
	max-height: calc(100vh - 40px);
	display: none;
	flex-direction: column;
	overflow: hidden;
	background: #fff;
	border: 1px solid var(--cb-border);
	border-radius: 18px;
	box-shadow: 0 18px 50px rgba(15, 43, 41, 0.22);
	font-size: 0.95rem;
	line-height: 1.6;
	color: var(--cb-ink);
}

.cb-panel.is-open {
	display: flex;
	animation: cb-slide-in 0.22s ease-out;
}

@keyframes cb-slide-in {
	from { opacity: 0; transform: translateY(14px); }
	to   { opacity: 1; transform: translateY(0); }
}

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

.cb-header {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	background: var(--cb-teal);
	color: #fff;
}

.cb-header-text { flex: 1 1 auto; min-width: 0; }

.cb-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.3;
}

.cb-subtitle {
	margin: 2px 0 0;
	font-size: 0.78rem;
	opacity: 0.85;
}

.cb-close {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease;
}

.cb-close:hover,
.cb-close:focus-visible {
	background: rgba(255, 255, 255, 0.3);
	outline: none;
}

/* ---------- Fil de discussion ---------- */

.cb-log {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 18px 16px 8px;
	background: #f8fcfb;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.cb-msg {
	max-width: 88%;
	padding: 11px 14px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.cb-msg.bot {
	align-self: flex-start;
	background: #fff;
	border: 1px solid var(--cb-border);
	border-bottom-left-radius: 5px;
	box-shadow: 0 4px 12px rgba(15, 118, 110, 0.05);
}

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

.cb-msg a {
	color: var(--cb-teal);
	font-weight: 600;
}

.cb-msg.user a { color: #fff; }

.cb-msg.alert {
	background: #fff7ed;
	border-color: #fdba74;
}

/* Indicateur de frappe */
.cb-typing { display: flex; gap: 4px; align-items: center; padding: 14px; }

.cb-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--cb-muted);
	animation: cb-blink 1.2s infinite ease-in-out;
}

.cb-typing span:nth-child(2) { animation-delay: 0.18s; }
.cb-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes cb-blink {
	0%, 60%, 100% { opacity: 0.25; }
	30%           { opacity: 1; }
}

/* ---------- Réponses rapides ---------- */

.cb-quick {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 4px 2px 10px;
}

.cb-chip {
	border: 1px solid var(--cb-teal);
	background: #fff;
	color: var(--cb-teal);
	padding: 8px 14px;
	border-radius: 999px;
	font-size: 0.85rem;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.cb-chip:hover,
.cb-chip:focus-visible {
	background: var(--cb-teal);
	color: #fff;
	outline: none;
}

.cb-chip.primary {
	background: var(--cb-teal);
	color: #fff;
}

.cb-chip.primary:hover,
.cb-chip.primary:focus-visible { background: var(--cb-teal-dark); }

.cb-chip.whatsapp {
	border-color: #25d366;
	color: #128c3f;
}

.cb-chip.whatsapp:hover,
.cb-chip.whatsapp:focus-visible {
	background: #25d366;
	border-color: #25d366;
	color: #fff;
}

/* ---------- Consentement ---------- */

.cb-consent {
	display: flex;
	gap: 9px;
	align-items: flex-start;
	padding: 4px 2px 8px;
	font-size: 0.82rem;
	color: var(--cb-muted);
	line-height: 1.5;
}

.cb-consent input {
	flex: 0 0 auto;
	margin-top: 3px;
	width: 16px;
	height: 16px;
	accent-color: var(--cb-teal);
}

.cb-privacy {
	padding: 0 2px 10px;
	font-size: 0.75rem;
	color: var(--cb-muted);
	line-height: 1.5;
}

/* ---------- Saisie ---------- */

.cb-form {
	flex: 0 0 auto;
	display: flex;
	gap: 8px;
	padding: 12px;
	background: #fff;
	border-top: 1px solid var(--cb-border);
}

.cb-input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 11px 14px;
	border: 1px solid var(--cb-border);
	border-radius: 999px;
	font-family: inherit;
	font-size: 0.92rem;
	color: var(--cb-ink);
	background: #fff;
}

.cb-input:focus {
	outline: none;
	border-color: var(--cb-teal);
	box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.cb-send {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	border: none;
	border-radius: 50%;
	background: var(--cb-teal);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}

.cb-send:hover,
.cb-send:focus-visible {
	background: var(--cb-teal-dark);
	outline: none;
}

.cb-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.cb-send svg { width: 18px; height: 18px; pointer-events: none; }

/* ---------- Mobile ---------- */

@media (max-width: 480px) {
	.cb-panel {
		right: 8px;
		left: 8px;
		bottom: 8px;
		width: auto;
		max-width: none;
		height: calc(100vh - 16px);
		height: calc(100dvh - 16px);
		max-height: none;
		border-radius: 14px;
	}

	.cb-bubble {
		right: 14px;
		bottom: 14px;
		width: 54px;
		height: 54px;
	}

	.cb-msg { max-width: 92%; }
}

/* ---------- Accessibilité ---------- */

@media (prefers-reduced-motion: reduce) {
	.cb-panel.is-open,
	.cb-bubble,
	.cb-typing span,
	.cb-bubble.cb-attract::after {
		animation: none;
		transition: none;
	}
}

@media print {
	#chirurgie-chatbot-root { display: none !important; }
}
