/* WWB V2 — Agent IA widget chat */

.wwb-ai {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 9999;
	font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Trigger button */
.wwb-ai__trigger {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	background: linear-gradient(135deg, #362C49, #241C34);
	color: #fff;
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	font-weight: 600;
	font-size: 14px;
	box-shadow: 0 8px 24px rgba(54, 44, 73, 0.35);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wwb-ai__trigger:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 32px rgba(54, 44, 73, 0.45);
}

.wwb-ai__trigger svg {
	stroke: #FF99DA;
}

/* Panel */
.wwb-ai__panel {
	position: absolute;
	bottom: calc(100% + 14px);
	right: 0;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 560px;
	max-height: calc(100vh - 100px);
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 20px 60px rgba(54, 44, 73, 0.25);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: wwb-ai-pop 0.2s ease-out;
}

/* Respect de l'attribut HTML [hidden] dans tout le widget — sans ça, les
   éléments en display:flex (confirmation, bandeau, formulaire) restent
   visibles quand on les masque (double affichage). */
.wwb-ai [hidden],
.wwb-ai__panel[hidden] {
	display: none !important;
}

@keyframes wwb-ai-pop {
	from { opacity: 0; transform: translateY(10px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

.wwb-ai__header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 18px;
	background: linear-gradient(135deg, #362C49, #241C34);
	color: #fff;
}

.wwb-ai__avatar {
	flex-shrink: 0;
	border-radius: 50%;
	overflow: hidden;
	background: linear-gradient(135deg, #FF99DA, #F47ABF);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 700;
	font-size: 15px;
	letter-spacing: 0.5px;
	border: 2px solid rgba(255,255,255,0.15);
	position: relative;
}

.wwb-ai__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Indicateur de dispo (pastille verte) */
.wwb-ai__avatar::after {
	content: '';
	position: absolute;
	bottom: 0;
	right: 0;
	width: 10px;
	height: 10px;
	background: #10B981;
	border-radius: 50%;
	border: 2px solid #241C34;
}

.wwb-ai__identity {
	flex: 1;
	min-width: 0;
}

.wwb-ai__title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	font-family: 'Playfair Display', Georgia, serif;
	line-height: 1.2;
	color: #fff; /* force le blanc : le h2 global du theme ecrasait la couleur heritee */
}

.wwb-ai__role {
	display: block;
	font-size: 11px;
	opacity: 0.7;
	margin-top: 1px;
}

.wwb-ai__quota {
	display: inline-block;
	font-size: 10px;
	padding: 2px 8px;
	background: rgba(255, 153, 218, 0.25);
	border-radius: 10px;
	margin-top: 4px;
	color: #FF99DA;
	font-weight: 500;
}

.wwb-ai__quota--empty {
	background: rgba(239, 68, 68, 0.2);
	color: #FCA5A5;
}

.wwb-ai__close {
	background: transparent;
	border: 0;
	color: #fff;
	opacity: 0.7;
	cursor: pointer;
	padding: 6px;
	border-radius: 6px;
	transition: opacity 0.15s, background 0.15s;
}

.wwb-ai__close:hover {
	opacity: 1;
	background: rgba(255,255,255,0.1);
}

/* Messages area */
.wwb-ai__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	background: #F9FAFB;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* Row wrapper pour aligner avatar + bubble */
.wwb-ai-msg-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	animation: wwb-ai-fadein 0.18s ease-out;
}

.wwb-ai-msg-row--user {
	justify-content: flex-end;
}

.wwb-ai-msg-row--assistant,
.wwb-ai-msg-row--welcome {
	justify-content: flex-start;
}

.wwb-ai-msg-row__avatar {
	flex-shrink: 0;
	border-radius: 50%;
	overflow: hidden;
	background: linear-gradient(135deg, #FF99DA, #F47ABF);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 700;
	font-size: 11px;
	margin-bottom: 2px;
}

.wwb-ai-msg-row__avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.wwb-ai-msg {
	max-width: 80%;
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 13.5px;
	line-height: 1.5;
}

@keyframes wwb-ai-fadein {
	from { opacity: 0; transform: translateY(4px); }
	to   { opacity: 1; transform: translateY(0); }
}

.wwb-ai-msg p { margin: 0; }
.wwb-ai-msg p + p { margin-top: 6px; }
.wwb-ai-msg a { color: inherit; text-decoration: underline; font-weight: 500; }

.wwb-ai-msg--user {
	background: #362C49;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.wwb-ai-msg--assistant,
.wwb-ai-msg--welcome {
	background: #fff;
	color: #1F2937;
	border: 1px solid #E5E7EB;
	border-bottom-left-radius: 4px;
}

.wwb-ai-msg--welcome {
	background: linear-gradient(135deg, #FEF3E6, #FDE6CC);
	border-color: #F4B77A;
	color: #78350F;
	font-style: italic;
}

.wwb-ai-msg--system {
	align-self: center;
	background: #F3F4F6;
	color: #6B7280;
	font-size: 12px;
	text-align: center;
	max-width: 100%;
	padding: 6px 12px;
}

.wwb-ai-msg--error {
	background: #FEF2F2;
	border-color: #FCA5A5;
	color: #991B1B;
}

/* Typing indicator */
.wwb-ai-msg--typing {
	display: flex;
	gap: 4px;
	padding: 12px 16px;
}

.wwb-ai-msg--typing span {
	width: 7px;
	height: 7px;
	background: #9CA3AF;
	border-radius: 50%;
	animation: wwb-ai-typing 1.2s infinite;
}

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

@keyframes wwb-ai-typing {
	0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
	30% { opacity: 1; transform: translateY(-4px); }
}

/* Footer / form */
.wwb-ai__footer {
	border-top: 1px solid #E5E7EB;
	background: #fff;
}

.wwb-ai__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px;
}

.wwb-ai__input {
	flex: 1;
	resize: none;
	border: 1px solid #D1D5DB;
	border-radius: 10px;
	padding: 10px 12px;
	font-size: 13.5px;
	font-family: inherit;
	color: #1F2937;
	background: #F9FAFB;
	line-height: 1.4;
	max-height: 100px;
}

.wwb-ai__input:focus {
	outline: 2px solid #FF99DA;
	outline-offset: -1px;
	background: #fff;
}

.wwb-ai__input:disabled {
	background: #F3F4F6;
	color: #9CA3AF;
	cursor: not-allowed;
}

.wwb-ai__send {
	width: 42px;
	height: 42px;
	flex-shrink: 0;
	background: #FF99DA;
	color: #362C49;
	border: 0;
	border-radius: 10px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s;
}

.wwb-ai__send:not(:disabled):hover {
	background: #F980CA;
}

.wwb-ai__send:disabled {
	background: #E5E7EB;
	color: #9CA3AF;
	cursor: not-allowed;
}

.wwb-ai__send--loading {
	opacity: 0.7;
}

.wwb-ai__actions {
	padding: 0 12px 10px;
	display: flex;
	justify-content: flex-end;
}

.wwb-ai__end-conversation {
	background: transparent;
	border: 0;
	color: #6B7280;
	font-size: 11px;
	text-decoration: underline;
	cursor: pointer;
	padding: 4px 6px;
}

.wwb-ai__end-conversation:hover {
	color: #362C49;
}

/* Confirmation inline (remplace le confirm() natif) */
.wwb-ai__confirm {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	justify-content: flex-end;
	width: 100%;
}
.wwb-ai__confirm-text {
	font-size: 12px;
	color: #362C49;
	font-weight: 600;
}
.wwb-ai__confirm-btns {
	display: inline-flex;
	gap: 6px;
}
.wwb-ai__confirm-no,
.wwb-ai__confirm-yes {
	font-size: 11px;
	border-radius: 999px;
	padding: 5px 12px;
	cursor: pointer;
	border: 1px solid transparent;
	transition: background .15s ease, border-color .15s ease;
}
.wwb-ai__confirm-no {
	background: transparent;
	border-color: #D1D5DB;
	color: #6B7280;
}
.wwb-ai__confirm-no:hover {
	background: #F3F4F6;
}
.wwb-ai__confirm-yes {
	background: #362C49;
	color: #fff;
}
.wwb-ai__confirm-yes:hover {
	background: #241C34;
}

/* Formulaire de contact intégré (remplace le mailto hors ligne) */
.wwb-ai__contact {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 16px;
}
.wwb-ai__contact-back {
	background: transparent;
	border: 0;
	color: #6B7280;
	font-size: 12px;
	cursor: pointer;
	padding: 0 0 8px;
	text-decoration: underline;
}
.wwb-ai__contact-back:hover {
	color: #362C49;
}
.wwb-ai__contact-title {
	margin: 4px 0 2px;
	font-size: 16px;
	font-weight: 700;
	color: #362C49;
	font-family: 'Playfair Display', Georgia, serif;
}
.wwb-ai__contact-intro {
	margin: 0 0 12px;
	font-size: 12px;
	color: #6B7280;
}
.wwb-ai__contact-form {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.wwb-ai__contact-field {
	width: 100%;
	border: 1px solid #D1D5DB;
	border-radius: 8px;
	padding: 9px 11px;
	font-size: 13px;
	font-family: inherit;
	color: #1F2937;
	background: #fff;
	box-sizing: border-box;
}
.wwb-ai__contact-field:focus {
	outline: none;
	border-color: #FF99DA;
	box-shadow: 0 0 0 3px rgba(255, 153, 218, 0.25);
}
textarea.wwb-ai__contact-field {
	resize: vertical;
}
.wwb-ai__hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	opacity: 0;
}
.wwb-ai__contact-send {
	margin-top: 2px;
	background: #362C49;
	color: #fff;
	border: 0;
	border-radius: 999px;
	padding: 10px 16px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background .15s ease;
}
.wwb-ai__contact-send:hover {
	background: #241C34;
}
.wwb-ai__contact-send:disabled {
	opacity: 0.6;
	cursor: default;
}
.wwb-ai__contact-feedback {
	font-size: 12px;
	min-height: 16px;
}
.wwb-ai__contact-feedback--err {
	color: #B91C1C;
}
.wwb-ai__contact-feedback--ok {
	color: #6B7280;
}
.wwb-ai__contact-success {
	text-align: center;
	padding: 24px 12px;
	color: #362C49;
}
.wwb-ai__contact-success strong {
	font-size: 15px;
}
.wwb-ai__contact-success p {
	margin: 8px 0 0;
	font-size: 13px;
	color: #6B7280;
}

/* Responsive */
@media (max-width: 480px) {
	.wwb-ai {
		bottom: 16px;
		right: 16px;
	}
	.wwb-ai__trigger span {
		display: none;
	}
	.wwb-ai__trigger {
		padding: 14px;
	}
	.wwb-ai__panel {
		width: calc(100vw - 32px);
		height: calc(100vh - 120px);
	}
}

/* ─────────────────────────────────────────────
   Live chat : bandeau d'état, notices, bulle conseiller humain
   ───────────────────────────────────────────── */
.wwb-ai__banner {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	font-size: 12.5px;
	line-height: 1.35;
	background: #F9FAFB;
	border-bottom: 1px solid #E5E7EB;
	color: #4B5563;
}

.wwb-ai__banner--human {
	background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
	color: #065F46;
	border-bottom-color: #6EE7B7;
}

.wwb-ai__banner--waiting {
	background: linear-gradient(135deg, #FEF3E6, #FDE6CC);
	color: #78350F;
	border-bottom-color: #F4B77A;
}

.wwb-ai__banner-text { flex: 1; }

.wwb-ai__banner-btn {
	flex: none;
	border: 1px solid #FF99DA;
	background: #fff;
	color: #B5247E;
	font-size: 12px;
	font-weight: 600;
	padding: 4px 10px;
	border-radius: 999px;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
	white-space: nowrap;
}

.wwb-ai__banner-btn:hover {
	background: #FF99DA;
	color: #fff;
}

/* Ligne système centrée (un conseiller a rejoint, etc.) */
.wwb-ai-notice {
	align-self: center;
	text-align: center;
	font-size: 12px;
	color: #6B7280;
	background: #F3F4F6;
	border-radius: 999px;
	padding: 5px 14px;
	margin: 4px auto;
	max-width: 90%;
}

/* Réponse d'un conseiller humain : se distingue de l'IA */
.wwb-ai-msg--human {
	background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
	border: 1px solid #6EE7B7;
	color: #064E3B;
}
