/* Benin4you - widget de l'assistant IA. Reprend les variables du theme (--primary, --ink...) avec des valeurs de repli. */
.b4y-ai {
	--b4y-ai-accent: var(--primary, #B1264F);
	--b4y-ai-accent-dark: var(--primary-dark, #6E1831);
	--b4y-ai-ink: var(--ink, #181722);
	--b4y-ai-muted: var(--muted, #6d6979);
	--b4y-ai-soft: var(--soft, #f7f5fa);
	--b4y-ai-line: var(--line, #e6e1eb);
	--b4y-ai-focus: #1d4ed8;
	font-family: inherit;
	color: var(--b4y-ai-ink);
	line-height: 1.45;
}
.b4y-ai *, .b4y-ai *::before, .b4y-ai *::after { box-sizing: border-box; }
.b4y-ai button, .b4y-ai input { font: inherit; }
.b4y-ai svg { flex: none; display: block; }
.b4y-ai button { margin: 0; text-transform: none; letter-spacing: normal; -webkit-appearance: none; appearance: none; }
.b4y-ai .b4y-ai-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Bouton flottant */
.b4y-ai-launcher {
	position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 9990;
	display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 20px 0 16px;
	border: 0; box-shadow: none; border-radius: 999px; background: linear-gradient(135deg, var(--b4y-ai-accent), var(--b4y-ai-accent-dark)); color: #fff;
	font-weight: 700; font-size: 15px; cursor: pointer; box-shadow: 0 10px 28px rgba(36, 28, 54, .28);
}
.b4y-ai-launcher:hover { background: var(--b4y-ai-accent-dark); }

/* Attire l'oeil sans gener : anneau qui pulse 3 fois (< 5 s, donc sans bouton de pause requis) puis l'icone s'incline une fois. */
.b4y-ai-launcher::after {
	content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
	box-shadow: 0 0 0 0 rgba(177, 38, 79, .55); opacity: 0;
	animation: b4y-ai-pulse 1.5s ease-out 2s 3 both;
}
.b4y-ai-launcher svg { transform-origin: 50% 60%; animation: b4y-ai-wiggle .7s ease-in-out 6.8s 1 both; }
.b4y-ai-launcher:hover::after, .b4y-ai-launcher:focus-visible::after, .b4y-ai-launcher:hover svg { animation: none; }
@keyframes b4y-ai-pulse {
	0% { opacity: 1; box-shadow: 0 0 0 0 rgba(177, 38, 79, .55); }
	100% { opacity: 0; box-shadow: 0 0 0 16px rgba(177, 38, 79, 0); }
}
@keyframes b4y-ai-wiggle {
	0%, 100% { transform: rotate(0); }
	20% { transform: rotate(-14deg); }
	40% { transform: rotate(12deg); }
	60% { transform: rotate(-8deg); }
	80% { transform: rotate(5deg); }
}
.b4y-ai-launcher:focus-visible, .b4y-ai button:focus-visible, .b4y-ai input:focus-visible, .b4y-ai a:focus-visible, .b4y-ai-log:focus-visible {
	outline: 3px solid var(--b4y-ai-focus); outline-offset: 2px;
}

/* Panneau */
.b4y-ai-panel {
	position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 9991;
	display: flex; flex-direction: column; width: 392px; max-width: calc(100vw - 32px);
	height: min(640px, calc(100vh - 116px)); background: #fff; border: 1px solid var(--b4y-ai-line); border-radius: 18px;
	box-shadow: 0 24px 60px rgba(36, 28, 54, .28); overflow: hidden;
}
.b4y-ai-panel[hidden] { display: none; }
.b4y-ai-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 10px 16px; background: linear-gradient(135deg, var(--b4y-ai-accent), var(--b4y-ai-accent-dark)); color: #fff; }
.b4y-ai .b4y-ai-title { margin: 0; font-size: 16px; line-height: 1.2; color: #fff; font-weight: 700; }
.b4y-ai-headbtns { display: flex; gap: 2px; }
.b4y-ai-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; box-shadow: none; border-radius: 12px; background: transparent; color: #fff; cursor: pointer; }
.b4y-ai-iconbtn:hover { background: rgba(255, 255, 255, .18); }
.b4y-ai-head .b4y-ai-iconbtn:focus-visible { outline-color: #fff; }

/* Messages */
.b4y-ai-log { flex: 1 1 auto; min-height: 120px; overflow-y: auto; padding: 14px; background: var(--b4y-ai-soft); display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.b4y-ai-msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; font-size: 15px; overflow-wrap: anywhere; }
.b4y-ai-msg p { margin: 0 0 6px; }
.b4y-ai-msg p:last-child { margin-bottom: 0; }
.b4y-ai-msg--bot { align-self: flex-start; background: #fff; border: 1px solid var(--b4y-ai-line); border-bottom-left-radius: 4px; }
.b4y-ai-msg--user { align-self: flex-end; background: var(--b4y-ai-accent); color: #fff; border-bottom-right-radius: 4px; }
.b4y-ai-msg.is-error { border-color: #b91c1c; background: #fff7f7; }
.b4y-ai-msg.is-error::before { content: "!"; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 8px; border-radius: 50%; background: #b91c1c; color: #fff; font-weight: 800; font-size: 13px; vertical-align: middle; }
.b4y-ai-msg.is-error p { display: inline; }

/* Sources */
.b4y-ai-srchead { margin: 10px 0 6px !important; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--b4y-ai-muted); }
.b4y-ai-srclist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.b4y-ai a.b4y-ai-src { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px; border: 1px solid var(--b4y-ai-line); border-radius: 12px; background: #fff; color: var(--b4y-ai-ink); text-decoration: none; }
.b4y-ai a.b4y-ai-src:hover { border-color: var(--b4y-ai-accent); }
.b4y-ai-src img { width: 44px; height: 44px; flex: none; object-fit: cover; border-radius: 8px; background: var(--b4y-ai-soft); }
.b4y-ai-ph { flex: none; width: 44px; height: 44px; border-radius: 8px; background: var(--b4y-ai-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b51663' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s7-6.2 7-11a7 7 0 1 0-14 0c0 4.8 7 11 7 11z'/%3E%3Ccircle cx='12' cy='10' r='2.5'/%3E%3C/svg%3E") center / 24px no-repeat; }
.b4y-ai-srctext { display: flex; flex-direction: column; min-width: 0; }
.b4y-ai-srctitle { font-size: 14px; font-weight: 700; line-height: 1.25; }
.b4y-ai-srcmeta { font-size: 12.5px; color: var(--b4y-ai-muted); }
.b4y-ai a.b4y-ai-action, .b4y-ai button.b4y-ai-action { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; margin-right: 6px; padding: 0 14px; border: 1.5px solid var(--b4y-ai-accent); border-radius: 999px; background: #fff; color: var(--b4y-ai-accent-dark); font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer; }
.b4y-ai a.b4y-ai-action:hover, .b4y-ai button.b4y-ai-action:hover { background: var(--b4y-ai-soft); }

/* Indicateur de saisie */
.b4y-ai-typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px; }
.b4y-ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--b4y-ai-muted); animation: b4y-ai-dot 1.2s infinite ease-in-out; }
.b4y-ai-typing span:nth-child(2) { animation-delay: .15s; }
.b4y-ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes b4y-ai-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* Suggestions, saisie */
.b4y-ai-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 10px; background: var(--b4y-ai-soft); }
.b4y-ai-chips:empty { display: none; }
.b4y-ai button.b4y-ai-chip { min-height: 44px; padding: 0 14px; border: 1.5px solid var(--b4y-ai-accent); border-radius: 999px; background: #fff; color: var(--b4y-ai-accent-dark); font-size: 14px; font-weight: 600; cursor: pointer; }
.b4y-ai button.b4y-ai-chip:hover { background: #fff0f7; }
.b4y-ai-form { display: flex; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid var(--b4y-ai-line); }
.b4y-ai input.b4y-ai-input { flex: 1 1 auto; min-width: 0; height: 48px; padding: 0 14px; border: 1.5px solid #8a8696; border-radius: 12px; background: #fff; color: var(--b4y-ai-ink); font-size: 16px; }
.b4y-ai input.b4y-ai-input::placeholder { color: #6d6979; opacity: 1; }
.b4y-ai input.b4y-ai-trap { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.b4y-ai button.b4y-ai-send { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 0; border: 0; box-shadow: none; border-radius: 12px; background: var(--b4y-ai-accent); color: #fff; cursor: pointer; }
.b4y-ai button.b4y-ai-send:hover { background: var(--b4y-ai-accent-dark); }
.b4y-ai button.b4y-ai-send:disabled { background: #b9b4c4; cursor: not-allowed; }
.b4y-ai-note { margin: 0; padding: 0 14px 12px; background: #fff; font-size: 12px; color: var(--b4y-ai-muted); }
.b4y-ai-note a { color: var(--b4y-ai-accent-dark); text-decoration: underline; }

/* Mobile : panneau plein largeur */
@media (max-width: 520px) {
	.b4y-ai-panel { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: auto; max-width: none; height: min(86vh, 720px); border-radius: 16px; }
	.b4y-ai.is-open .b4y-ai-launcher { display: none; }
	.b4y-ai-msg { max-width: 96%; }
}
@media (prefers-reduced-motion: reduce) {
	.b4y-ai-typing span { animation: none; opacity: .7; }
	.b4y-ai-launcher::after, .b4y-ai-launcher svg { animation: none; }
}
@media print { .b4y-ai { display: none !important; } }
