/*
 * Optimum Transfert : bulle WhatsApp.
 * Structure et comportement uniquement. Couleurs, tailles et positions
 * viennent des contrôles Elementor du widget (variables --optr-wa-*).
 */

.optr-wa {
	--optr-wa-launcher: 60px;
	--optr-wa-x: 24px;
	--optr-wa-y: 24px;
	--optr-wa-in: #fff;
	--optr-wa-out: #d9fdd3;
	position: fixed;
	bottom: calc(var(--optr-wa-y) + env(safe-area-inset-bottom, 0px));
	z-index: 9990;
	display: flex;
	flex-direction: column;
	gap: 14px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}

.optr-wa--right {
	right: var(--optr-wa-x);
	align-items: flex-end;
}

.optr-wa--left {
	left: var(--optr-wa-x);
	align-items: flex-start;
}

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

.optr-wa .optr-wa__launcher,
.optr-wa .optr-wa__launcher:hover,
.optr-wa .optr-wa__launcher:focus {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--optr-wa-launcher);
	height: var(--optr-wa-launcher);
	padding: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: transform 0.2s ease;
}

.optr-wa .optr-wa__launcher:hover {
	transform: scale(1.06);
}

.optr-wa__launcher:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}

.optr-wa__launcher-icon {
	position: absolute;
	display: inline-flex;
	transition: opacity 0.2s ease, transform 0.25s ease;
}

.optr-wa__launcher-icon svg {
	width: calc(var(--optr-wa-launcher) * 0.53);
	height: calc(var(--optr-wa-launcher) * 0.53);
}

.optr-wa__launcher-icon--close svg {
	width: calc(var(--optr-wa-launcher) * 0.4);
	height: calc(var(--optr-wa-launcher) * 0.4);
}

.optr-wa__launcher-icon--close,
.optr-wa.is-open .optr-wa__launcher-icon--open {
	opacity: 0;
	transform: rotate(-90deg) scale(0.6);
}

.optr-wa.is-open .optr-wa__launcher-icon--close {
	opacity: 1;
	transform: none;
}

.optr-wa__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	border: 2px solid #fff;
	border-radius: 10px;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	animation: optr-wa-pop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.optr-wa__badge[hidden] {
	display: none;
}

/* ---------- Fenêtre ---------- */

.optr-wa__panel {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	animation: optr-wa-open 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.optr-wa--left .optr-wa__panel {
	transform-origin: bottom left;
}

.optr-wa__panel[hidden] {
	display: none;
}

.optr-wa__header {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 12px;
	padding: 10px 8px 10px 14px;
}

.optr-wa .optr-wa__avatar {
	width: 40px;
	height: 40px;
	flex: 0 0 auto;
	border-radius: 100%;
	overflow: hidden;
	object-fit: cover;
	background: #fff;
}

.optr-wa__who {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
}

.optr-wa__name {
	overflow: hidden;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.25;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.optr-wa__status {
	font-size: 13px;
	line-height: 1.3;
	opacity: 0.85;
}

.optr-wa .optr-wa__close,
.optr-wa .optr-wa__close:hover,
.optr-wa .optr-wa__close:focus {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	color: inherit;
	background: transparent;
	cursor: pointer;
}

.optr-wa .optr-wa__close:hover {
	background: rgba(255, 255, 255, 0.15);
}

.optr-wa__close svg {
	width: 22px;
	height: 22px;
	fill: currentColor;
}

/* Conversation : fond avec motif discret, comme le papier peint de WhatsApp */
.optr-wa__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 4px;
	overflow-y: auto;
	padding: 12px 16px 16px;
	background-image:
		radial-gradient(rgba(0, 0, 0, 0.045) 1.2px, transparent 1.3px),
		radial-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1.1px);
	background-position: 0 0, 11px 11px;
	background-size: 22px 22px;
	overscroll-behavior: contain;
}

.optr-wa__day {
	align-self: center;
	margin: 0 0 10px;
	padding: 5px 12px;
	border-radius: 8px;
	background: #fff;
	font-size: 12px;
	line-height: 1.3;
	text-transform: uppercase;
	box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.optr-wa__msg {
	position: relative;
	max-width: 85%;
	padding: 6px 9px 8px;
	border-radius: 8px;
	font-size: 14.5px;
	line-height: 1.4;
	overflow-wrap: anywhere;
	box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
	animation: optr-wa-msg 0.25s ease-out;
}

/* Petite pointe de bulle (premier message d'une série) */
.optr-wa__msg::before {
	content: "";
	position: absolute;
	top: 0;
	width: 8px;
	height: 13px;
}

.optr-wa__msg--in {
	align-self: flex-start;
	border-top-left-radius: 0;
	background: var(--optr-wa-in);
}

.optr-wa__msg--in::before {
	left: -8px;
	background: var(--optr-wa-in);
	clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.optr-wa__msg--out {
	align-self: flex-end;
	margin-top: 6px;
	border-top-right-radius: 0;
	background: var(--optr-wa-out);
}

.optr-wa__msg--out::before {
	right: -8px;
	background: var(--optr-wa-out);
	clip-path: polygon(0 0, 100% 0, 0 100%);
}

/* L'heure flotte en bas à droite, dans la dernière ligne */
.optr-wa__meta {
	float: right;
	display: inline-flex;
	align-items: center;
	gap: 3px;
	margin: 6px 0 -4px 10px;
	font-size: 11px;
	line-height: 1;
	white-space: nowrap;
}

.optr-wa__ticks {
	width: 16px;
	height: 11px;
}

.optr-wa__typing {
	display: inline-flex;
	align-self: flex-start;
	gap: 4px;
	padding: 12px 14px;
	border-radius: 0 8px 8px;
	background: var(--optr-wa-in);
	box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

.optr-wa__typing[hidden] {
	display: none;
}

.optr-wa__typing span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #8696a0;
	animation: optr-wa-dot 1.2s infinite ease-in-out;
}

.optr-wa__typing span:nth-child(2) {
	animation-delay: 0.15s;
}

.optr-wa__typing span:nth-child(3) {
	animation-delay: 0.3s;
}

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

.optr-wa__form {
	display: flex;
	flex: 0 0 auto;
	align-items: flex-end;
	gap: 8px;
	margin: 0;
	padding: 8px 10px 6px;
}

.optr-wa .optr-wa__input {
	flex: 1;
	min-height: 42px;
	max-height: 120px;
	margin: 0;
	padding: 11px 14px;
	border: 0;
	border-radius: 21px;
	color: #111b21;
	font: inherit;
	font-size: 15px;
	line-height: 20px;
	resize: none;
	box-shadow: none;
}

.optr-wa .optr-wa__input:focus {
	outline: none;
	box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.35);
}

.optr-wa .optr-wa__send,
.optr-wa .optr-wa__send:hover,
.optr-wa .optr-wa__send:focus {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.optr-wa .optr-wa__send[disabled] {
	cursor: default;
	opacity: 0.45;
}

.optr-wa__send svg {
	width: 20px;
	height: 20px;
	margin-left: 3px;
	fill: currentColor;
}

.optr-wa__send:focus-visible {
	outline: 2px solid #111b21;
	outline-offset: 2px;
}

.optr-wa__note {
	flex: 0 0 auto;
	margin: 0;
	padding: 0 12px 10px;
	font-size: 11.5px;
	line-height: 1.3;
	text-align: center;
}

/* ---------- Animations ---------- */

@keyframes optr-wa-open {
	from { opacity: 0; transform: translateY(12px) scale(0.96); }
	to { opacity: 1; transform: none; }
}

@keyframes optr-wa-msg {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

@keyframes optr-wa-dot {
	0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

@keyframes optr-wa-pop {
	from { transform: scale(0); }
	to { transform: scale(1); }
}

@media (max-width: 767px) {
	/* 16px minimum : évite le zoom automatique d'iOS sur le champ */
	.optr-wa .optr-wa__input {
		font-size: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.optr-wa__panel,
	.optr-wa__msg,
	.optr-wa__badge,
	.optr-wa__typing span {
		animation: none;
	}

	.optr-wa__launcher,
	.optr-wa__launcher-icon {
		transition: none;
	}
}
