/* Спаси Лид — AI-ассистент. Виджет чата. */

#sla-root, #sla-root * { box-sizing: border-box; }

/* Значения по умолчанию держим на :root, а не на #sla-root.
   На #sla-root они оказывались ближе к элементу, чем настройки из админки,
   и перебивали выбранные цвета — виджет всегда оставался цветов по умолчанию. */
:root {
	--sla-accent: #C6A15B;
	--sla-panel: #171410;
	--sla-text: #F5F1EA;
}

#sla-root {
	position: fixed;
	bottom: 24px;
	z-index: 999998;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
}
#sla-root.sla-pos-left  { left: 24px; }
#sla-root.sla-pos-right { right: 24px; }

/* --- Кнопка (FAB) --- */
.sla-fab {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 20px 12px 14px;
	background: var(--sla-accent);
	color: #1a1509;
	border: none;
	border-radius: 999px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 10px 30px rgba(0,0,0,.35);
	transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
	white-space: nowrap;
}
.sla-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(0,0,0,.45); }
.sla-fab svg { width: 22px; height: 22px; flex: none; }
.sla-fab .sla-fab-badge {
	position: absolute;
	top: -4px;
	width: 12px; height: 12px;
	background: #e5484d;
	border-radius: 50%;
	border: 2px solid var(--sla-panel);
}
#sla-root.sla-pos-left  .sla-fab-badge { left: 8px; }
#sla-root.sla-pos-right .sla-fab-badge { right: 8px; }

/* --- Панель чата --- */
.sla-panel {
	position: absolute;
	bottom: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 560px;
	max-height: calc(100vh - 48px);
	background: var(--sla-panel);
	color: var(--sla-text);
	border: 1px solid rgba(255,255,255,.09);
	border-radius: 18px;
	box-shadow: 0 24px 64px rgba(0,0,0,.5);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	transform: translateY(16px) scale(.98);
	pointer-events: none;
	transition: opacity .2s ease, transform .2s ease;
}
#sla-root.sla-pos-left  .sla-panel { left: 0; }
#sla-root.sla-pos-right .sla-panel { right: 0; }
#sla-root.sla-open .sla-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
#sla-root.sla-open .sla-fab   { opacity: 0; pointer-events: none; }

/* Шапка */
.sla-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 16px 14px;
	border-bottom: 1px solid rgba(255,255,255,.08);
	background: linear-gradient(180deg, rgba(255,255,255,.04), transparent);
}
.sla-avatar {
	width: 40px; height: 40px; flex: none;
	border-radius: 50%;
	background: var(--sla-accent);
	color: #1a1509;
	display: flex; align-items: center; justify-content: center;
}
.sla-avatar svg { width: 22px; height: 22px; }
.sla-head-txt { flex: 1; min-width: 0; }
.sla-title { font-family: Georgia, "Times New Roman", serif; font-size: 16px; font-weight: 600; }
.sla-status { font-size: 12px; color: rgba(245,241,234,.6); display: flex; align-items: center; gap: 6px; }
.sla-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ecf8e; }
.sla-close {
	background: none; border: none; color: var(--sla-text);
	opacity: .6; cursor: pointer; font-size: 22px; line-height: 1; padding: 4px 6px;
}
.sla-close:hover { opacity: 1; }

/* Сообщения */
.sla-body {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.sla-msg {
	max-width: 84%;
	padding: 10px 13px;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.sla-bot {
	align-self: flex-start;
	background: rgba(255,255,255,.07);
	border: 1px solid rgba(255,255,255,.06);
	border-bottom-left-radius: 4px;
}
.sla-user {
	align-self: flex-end;
	background: var(--sla-accent);
	color: #1a1509;
	border-bottom-right-radius: 4px;
}
.sla-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.sla-typing span {
	width: 7px; height: 7px; border-radius: 50%;
	background: rgba(245,241,234,.5);
	animation: sla-bounce 1.2s infinite ease-in-out;
}
.sla-typing span:nth-child(2){ animation-delay: .15s; }
.sla-typing span:nth-child(3){ animation-delay: .3s; }
@keyframes sla-bounce { 0%,80%,100%{ transform: scale(.6); opacity:.4 } 40%{ transform: scale(1); opacity:1 } }

/* Ввод */
.sla-foot {
	padding: 12px;
	border-top: 1px solid rgba(255,255,255,.08);
	display: flex;
	gap: 8px;
	align-items: flex-end;
}
.sla-input {
	flex: 1;
	resize: none;
	max-height: 96px;
	min-height: 42px;
	padding: 10px 12px;
	background: rgba(255,255,255,.06);
	color: var(--sla-text);
	border: 1px solid rgba(255,255,255,.12);
	border-radius: 12px;
	font: inherit;
	outline: none;
}
.sla-input::placeholder { color: rgba(245,241,234,.4); }
.sla-input:focus { border-color: var(--sla-accent); }
.sla-send {
	flex: none;
	width: 42px; height: 42px;
	border: none; border-radius: 12px;
	background: var(--sla-accent); color: #1a1509;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	transition: opacity .15s ease;
}
.sla-send:hover { opacity: .88; }
.sla-send:disabled { opacity: .4; cursor: default; }
.sla-send svg { width: 20px; height: 20px; }
.sla-powered { text-align: center; font-size: 11px; color: rgba(245,241,234,.35); padding: 0 0 8px; }
.sla-powered a { color: inherit; text-decoration: none; }

/* --- Мобильная версия --- */
@media (max-width: 480px) {
	#sla-root { bottom: 14px; }
	#sla-root.sla-pos-left  { left: 14px; }
	#sla-root.sla-pos-right { right: 14px; }
	.sla-fab { padding: 12px 16px 12px 13px; font-size: 14px; }
	.sla-panel {
		position: fixed;
		left: 0; right: 0; bottom: 0;
		width: 100vw;
		max-width: 100vw;
		height: 88vh;
		max-height: 88vh;
		border-radius: 18px 18px 0 0;
		border-left: none; border-right: none; border-bottom: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sla-fab, .sla-panel { transition: none; }
	.sla-typing span { animation: none; }
}
