/* ============================================================
   Șerban și Asociații – Asistent Virtual
   Widget flotant de chat. Namespace: .sa-cb
   ============================================================ */

.sa-cb,
.sa-cb *,
.sa-cb *::before,
.sa-cb *::after {
	box-sizing: border-box;
}

.sa-cb {
	--sa-accent: #1f7a44;
	--sa-accent-dark: #176035;
	--sa-accent-soft: rgba(31, 122, 68, 0.10);
	--sa-wa: #25d366;
	--sa-wa-dark: #1da851;
	--sa-text: #1f2430;
	--sa-muted: #6b7280;
	--sa-bg: #ffffff;
	--sa-bubble-bot: #f1f4f2;
	--sa-border: #e5e7eb;
	--sa-shadow: 0 18px 48px rgba(16, 32, 24, 0.22);
	position: fixed;
	bottom: 22px;
	z-index: 2147483000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var(--sa-text);
}

.sa-cb--right { right: 22px; }
.sa-cb--left  { left: 22px; }

/* ---------- Butonul flotant (launcher) ---------- */
.sa-cb__launcher {
	display: flex;
	align-items: center;
	gap: 10px;
	border: none;
	cursor: pointer;
	background: var(--sa-accent);
	color: #fff;
	padding: 0;
	height: 60px;
	width: 60px;
	border-radius: 50%;
	box-shadow: var(--sa-shadow);
	transition: transform .18s ease, box-shadow .18s ease, width .18s ease, border-radius .18s ease;
	justify-content: center;
	position: relative;
	overflow: hidden;
}
.sa-cb__launcher:hover { transform: translateY(-2px) scale(1.03); }
.sa-cb__launcher:focus-visible { outline: 3px solid var(--sa-accent-dark); outline-offset: 2px; }

.sa-cb__launcher svg { width: 28px; height: 28px; flex-shrink: 0; }
.sa-cb__launcher-label { display: none; }

/* Pastila „Bună ziua" opțională lângă buton pe desktop */
.sa-cb__nudge {
	position: absolute;
	bottom: 74px;
	white-space: nowrap;
	background: #fff;
	color: var(--sa-text);
	padding: 10px 14px;
	border-radius: 14px;
	box-shadow: var(--sa-shadow);
	font-size: 14px;
	font-weight: 500;
	max-width: 240px;
	opacity: 0;
	transform: translateY(8px);
	pointer-events: none;
	transition: opacity .25s ease, transform .25s ease;
}
.sa-cb--right .sa-cb__nudge { right: 4px; }
.sa-cb--left  .sa-cb__nudge { left: 4px; }
.sa-cb__nudge.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.sa-cb__nudge-close {
	position: absolute; top: -8px; right: -8px;
	width: 22px; height: 22px; border-radius: 50%;
	border: none; background: #fff; color: var(--sa-muted);
	box-shadow: 0 2px 6px rgba(0,0,0,.2); cursor: pointer; font-size: 14px; line-height: 1;
}

/* Badge cu punct de notificare */
.sa-cb__badge {
	position: absolute;
	top: -2px; right: -2px;
	width: 16px; height: 16px;
	background: #ef4444;
	border: 2px solid #fff;
	border-radius: 50%;
}

/* ---------- Panoul de chat ---------- */
.sa-cb__panel {
	position: absolute;
	bottom: 0;
	width: 384px;
	max-width: calc(100vw - 32px);
	height: 640px;
	max-height: calc(100vh - 48px);
	background: var(--sa-bg);
	border-radius: 20px;
	box-shadow: var(--sa-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(16px) scale(.98);
	pointer-events: none;
	transition: opacity .22s ease, transform .22s ease;
	border: 1px solid var(--sa-border);
}
.sa-cb--right .sa-cb__panel { right: 0; }
.sa-cb--left  .sa-cb__panel { left: 0; }
.sa-cb.is-open .sa-cb__panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.sa-cb.is-open .sa-cb__launcher { transform: scale(.9); opacity: 0; pointer-events: none; }

/* ---------- Antet ---------- */
.sa-cb__header {
	background: linear-gradient(135deg, var(--sa-accent), var(--sa-accent-dark));
	color: #fff;
	padding: 16px 16px 14px;
	display: flex;
	align-items: center;
	gap: 12px;
}
.sa-cb__avatar {
	width: 42px; height: 42px; flex-shrink: 0;
	border-radius: 50%;
	background: rgba(255,255,255,.18);
	display: flex; align-items: center; justify-content: center;
}
.sa-cb__avatar svg { width: 24px; height: 24px; }
.sa-cb__title { flex: 1; min-width: 0; }
.sa-cb__title strong { display: block; font-size: 16px; font-weight: 600; }
.sa-cb__title span { display: block; font-size: 12.5px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-cb__status { display: inline-flex; align-items: center; gap: 5px; }
.sa-cb__status i { width: 8px; height: 8px; border-radius: 50%; background: #7CFC9E; display: inline-block; box-shadow: 0 0 0 0 rgba(124,252,158,.6); animation: sa-pulse 2s infinite; }
@keyframes sa-pulse { 0% { box-shadow: 0 0 0 0 rgba(124,252,158,.55);} 70% { box-shadow: 0 0 0 7px rgba(124,252,158,0);} 100%{ box-shadow: 0 0 0 0 rgba(124,252,158,0);} }

.sa-cb__header-btn {
	border: none; background: rgba(255,255,255,.14); color: #fff;
	width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	transition: background .15s ease;
}
.sa-cb__header-btn:hover { background: rgba(255,255,255,.28); }
.sa-cb__header-btn svg { width: 18px; height: 18px; }

/* ---------- Bara de contact rapid ---------- */
.sa-cb__contactbar {
	display: flex;
	gap: 8px;
	padding: 10px 12px;
	background: #fafbfa;
	border-bottom: 1px solid var(--sa-border);
}
.sa-cb__contact {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 9px 10px;
	border-radius: 11px;
	font-size: 13.5px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	border: 1px solid transparent;
	transition: transform .12s ease, filter .12s ease;
}
.sa-cb__contact:hover { transform: translateY(-1px); filter: brightness(1.03); }
.sa-cb__contact svg { width: 17px; height: 17px; flex-shrink: 0; }
.sa-cb__contact--wa { background: var(--sa-wa); color: #fff; }
.sa-cb__contact--call { background: #fff; color: var(--sa-accent); border-color: var(--sa-border); }

/* ---------- Zona de mesaje ---------- */
.sa-cb__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 14px 6px;
	background: #fff;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}
.sa-cb__messages::-webkit-scrollbar { width: 8px; }
.sa-cb__messages::-webkit-scrollbar-thumb { background: #d5dbd7; border-radius: 8px; }

.sa-cb__msg {
	max-width: 84%;
	padding: 10px 13px;
	border-radius: 15px;
	font-size: 14.5px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
	animation: sa-in .22s ease;
}
@keyframes sa-in { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }
.sa-cb__msg--bot {
	align-self: flex-start;
	background: var(--sa-bubble-bot);
	color: var(--sa-text);
	border-bottom-left-radius: 5px;
}
.sa-cb__msg--user {
	align-self: flex-end;
	background: var(--sa-accent);
	color: #fff;
	border-bottom-right-radius: 5px;
}
.sa-cb__msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.sa-cb__msg--bot a { color: var(--sa-accent-dark); }

/* Indicator „scrie…" */
.sa-cb__typing {
	align-self: flex-start;
	background: var(--sa-bubble-bot);
	border-radius: 15px;
	border-bottom-left-radius: 5px;
	padding: 13px 15px;
	display: inline-flex;
	gap: 5px;
}
.sa-cb__typing span {
	width: 7px; height: 7px; border-radius: 50%; background: #9aa5a0;
	animation: sa-bounce 1.3s infinite ease-in-out;
}
.sa-cb__typing span:nth-child(2) { animation-delay: .18s; }
.sa-cb__typing span:nth-child(3) { animation-delay: .36s; }
@keyframes sa-bounce { 0%,60%,100%{ transform: translateY(0); opacity:.5;} 30%{ transform: translateY(-5px); opacity:1;} }

/* ---------- Butoane de întrebări rapide ---------- */
.sa-cb__quick {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 4px 14px 12px;
	background: #fff;
}
.sa-cb__chip {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--sa-accent);
	background: var(--sa-accent-soft);
	color: var(--sa-accent-dark);
	padding: 7px 12px;
	border-radius: 999px;
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	text-decoration: none;
	transition: background .14s ease, color .14s ease, border-color .14s ease;
	line-height: 1.2;
}
.sa-cb__chip:hover { background: var(--sa-accent); color: #fff; }
.sa-cb__chip:focus-visible { outline: 2px solid var(--sa-accent-dark); outline-offset: 2px; }

/* Chip WhatsApp (verde, plin) */
.sa-cb__chip--wa {
	background: var(--sa-wa);
	border-color: var(--sa-wa);
	color: #fff;
}
.sa-cb__chip--wa:hover { background: var(--sa-wa-dark); border-color: var(--sa-wa-dark); color: #fff; }

/* Chip „meniu" (discret) */
.sa-cb__chip--ghost {
	background: #fff;
	border-color: var(--sa-border);
	color: var(--sa-muted);
}
.sa-cb__chip--ghost:hover { background: #f1f4f2; border-color: var(--sa-muted); color: var(--sa-text); }

/* ---------- Zona de input ---------- */
.sa-cb__inputbar {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid var(--sa-border);
	background: #fff;
}
.sa-cb__input {
	flex: 1;
	border: 1px solid var(--sa-border);
	border-radius: 13px;
	padding: 10px 12px;
	font-family: inherit;
	font-size: 14.5px;
	line-height: 1.4;
	resize: none;
	max-height: 110px;
	color: var(--sa-text);
	background: #fff;
	transition: border-color .15s ease;
}
.sa-cb__input:focus { outline: none; border-color: var(--sa-accent); }
.sa-cb__send {
	border: none;
	background: var(--sa-accent);
	color: #fff;
	width: 44px; height: 44px;
	min-width: 44px;
	border-radius: 13px;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	transition: background .15s ease, transform .12s ease;
}
.sa-cb__send:hover:not(:disabled) { background: var(--sa-accent-dark); transform: scale(1.04); }
.sa-cb__send:disabled { opacity: .45; cursor: default; }
.sa-cb__send svg { width: 20px; height: 20px; }

.sa-cb__footer {
	text-align: center;
	font-size: 11px;
	color: var(--sa-muted);
	padding: 0 12px 10px;
	background: #fff;
}
.sa-cb__footer a { color: var(--sa-muted); text-decoration: none; }
.sa-cb__footer strong { color: var(--sa-accent-dark); font-weight: 600; }

/* ---------- Responsiv (mobil) ---------- */
@media (max-width: 480px) {
	.sa-cb { bottom: 16px; }
	.sa-cb--right { right: 16px; }
	.sa-cb--left { left: 16px; }
	.sa-cb__panel {
		width: 100vw;
		height: 100dvh;
		max-height: 100dvh;
		max-width: 100vw;
		border-radius: 0;
		border: none;
		position: fixed;
		bottom: 0;
		right: 0;
		left: 0;
	}
	.sa-cb.is-open .sa-cb__launcher { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.sa-cb *, .sa-cb *::before, .sa-cb *::after { animation: none !important; transition: none !important; }
}
