/* Палитра redico.ru. Без градиентов: только плоские заливки, тонкие линии и воздух. */
.rx-ai {
	--rx-accent: #DA291C;
	--rx-coral: #FF6A57;
	--rx-green: #34D17E;
	--rx-blue: #229ED9;
	--rx-ink: #14171C;
	--rx-ink-2: #3A424E;
	--rx-muted: #5A626E;
	--rx-faint: #8B919B;
	--rx-line: #ECEEF1;
	--rx-line-2: #E4E7EB;
	--rx-paper: #FFFFFF;
	--rx-tint: #F7F8FA;
	--rx-h: 680px;

	font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	color: var(--rx-ink);
	background: var(--rx-paper);
	border: 1px solid var(--rx-line);
	border-radius: 20px;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.rx-ai[hidden], [data-rx-ai][hidden] { display: none !important; }

.rx-ai--inline {
	height: var(--rx-h);
	min-height: 580px;
	width: 100%;
	opacity: 0;
	transform: translateY(18px);
	transition: opacity .8s cubic-bezier(.16,1,.3,1), transform .8s cubic-bezier(.16,1,.3,1), box-shadow .5s ease;
	box-shadow: 0 2px 4px rgba(20,23,28,.02);
}
.rx-ai--inline.is-in { opacity: 1; transform: none; }
.rx-ai--inline:hover { box-shadow: 0 24px 60px -20px rgba(20,23,28,.14); }
.rx-ai--inline:focus-within { box-shadow: 0 24px 60px -20px rgba(20,23,28,.18); }

/* ——— Шапка: светлая, воздушная ——— */
.rx-ai__head {
	display: flex; align-items: center; justify-content: space-between; gap: 16px;
	padding: 22px 30px 20px;
	border-bottom: 1px solid var(--rx-line);
	background: var(--rx-paper);
}
.rx-ai__title {
	font-family: 'JetBrains Mono', ui-monospace, monospace;
	font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--rx-ink);
}
.rx-ai__head-right { display: inline-flex; align-items: center; gap: 18px; }
.rx-ai__sub { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--rx-faint); }
.rx-ai__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rx-green); position: relative; }
.rx-ai__dot::after {
	content: ''; position: absolute; inset: -5px; border-radius: 50%;
	border: 1px solid var(--rx-green); opacity: 0; animation: rx-ai-pulse 3s ease-out infinite;
}
@keyframes rx-ai-pulse {
	0% { transform: scale(.5); opacity: .5; }
	70% { transform: scale(1.7); opacity: 0; }
	100% { opacity: 0; }
}
.rx-ai__cta {
	font: inherit; font-size: 13px; font-weight: 500; color: var(--rx-ink);
	background: none; border: 1px solid var(--rx-line-2); border-radius: 100px;
	padding: 9px 18px; cursor: pointer;
	transition: border-color .3s ease, color .3s ease, transform .3s ease;
}
.rx-ai__cta:hover { border-color: var(--rx-ink); transform: translateY(-1px); }
.rx-ai__close { border: 0; background: none; cursor: pointer; font-size: 20px; color: var(--rx-faint); }

/* ——— Диалог: много воздуха ——— */
.rx-ai__log {
	flex: 1; overflow-y: auto;
	padding: 30px; display: flex; flex-direction: column; gap: 26px;
	scrollbar-width: thin;
}
.rx-ai__log::-webkit-scrollbar { width: 6px; }
.rx-ai__log::-webkit-scrollbar-thumb { background: #E4E7EB; border-radius: 3px; }

.rx-ai__msg { max-width: 82%; font-size: 16px; line-height: 1.75; letter-spacing: -.003em; }
.rx-ai__msg p { margin: 0 0 .85em; }
.rx-ai__msg p:last-child { margin-bottom: 0; }
.rx-ai__msg ul { margin: .2em 0 .9em; padding-left: 0; list-style: none; }
.rx-ai__msg li {
	position: relative; padding-left: 22px; margin-bottom: .5em; color: var(--rx-ink-2);
	animation: rx-ai-fade .5s ease both;
}
.rx-ai__msg li::before {
	content: ''; position: absolute; left: 3px; top: .72em;
	width: 5px; height: 5px; border-radius: 50%; background: var(--rx-coral);
}
.rx-ai__msg li:nth-child(2) { animation-delay: .06s; }
.rx-ai__msg li:nth-child(3) { animation-delay: .12s; }
.rx-ai__msg li:nth-child(4) { animation-delay: .18s; }
@keyframes rx-ai-fade { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }

.rx-ai__msg a {
	color: var(--rx-ink); text-decoration: none;
	border-bottom: 1px solid var(--rx-coral);
	padding-bottom: 1px; transition: color .25s ease, border-color .25s ease;
}
.rx-ai__msg a:hover { color: var(--rx-accent); border-color: var(--rx-accent); }

.rx-ai__msg--bot { animation: rx-ai-rise .6s cubic-bezier(.16,1,.3,1) both; }
@keyframes rx-ai-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.rx-ai__msg--user {
	align-self: flex-end; max-width: 74%;
	background: var(--rx-tint); border-radius: 18px 18px 6px 18px;
	padding: 14px 20px; font-size: 15.5px; line-height: 1.6;
}

.rx-ai__chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.rx-ai__chip {
	font: inherit; font-size: 13px; color: var(--rx-muted);
	background: none; border: 1px solid var(--rx-line-2); border-radius: 100px;
	padding: 9px 17px; cursor: pointer;
	transition: border-color .3s ease, color .3s ease, transform .3s ease;
}
.rx-ai__chip:hover { color: var(--rx-ink); border-color: var(--rx-ink); transform: translateY(-1px); }

.rx-ai__name { display: flex; gap: 12px; align-items: center; margin-top: 22px; }
.rx-ai__name input { flex: 1; max-width: 260px; }
.rx-ai__name button {
	font: inherit; font-size: 14px; color: var(--rx-ink);
	background: none; border: 1px solid var(--rx-line-2); border-radius: 100px;
	padding: 13px 24px; cursor: pointer; transition: border-color .3s ease, background .3s ease, color .3s ease;
}
.rx-ai__name button:hover { background: var(--rx-ink); border-color: var(--rx-ink); color: #fff; }

.rx-ai__error { color: #9A3324; }

.rx-ai__typing { display: inline-flex; gap: 6px; align-items: center; color: var(--rx-faint); font-size: 14.5px; }
.rx-ai__typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--rx-coral); opacity: .3; animation: rx-ai-blink 1.4s ease-in-out infinite; }
.rx-ai__typing i:nth-child(2) { animation-delay: .18s; }
.rx-ai__typing i:nth-child(3) { animation-delay: .36s; }
@keyframes rx-ai-blink { 0%, 65%, 100% { opacity: .22; transform: none; } 32% { opacity: 1; transform: translateY(-2px); } }

/* ——— Строка ввода ——— */
.rx-ai__form {
	position: relative;
	display: flex; gap: 14px; align-items: center;
	padding: 24px 30px 28px;
	border-top: 1px solid var(--rx-line);
	background: var(--rx-paper);
}
.rx-ai__form::before {
	content: 'Спросите про свою продукцию';
	position: absolute; top: -8px; left: 34px;
	background: var(--rx-paper); padding: 0 10px;
	font-family: 'JetBrains Mono', ui-monospace, monospace;
	font-size: 10px; letter-spacing: .15em; text-transform: uppercase; color: var(--rx-faint);
}

.rx-ai textarea, .rx-ai input[type="text"] {
	width: 100%; font: inherit; font-size: 17px; color: var(--rx-ink);
	background: var(--rx-paper); border: 1px solid var(--rx-line-2);
	border-radius: 100px; padding: 17px 26px; resize: none; line-height: 1.4;
	transition: border-color .35s ease, box-shadow .35s ease;
}
.rx-ai textarea { max-height: 120px; }
.rx-ai textarea:focus, .rx-ai input:focus {
	outline: none; border-color: var(--rx-ink);
	box-shadow: 0 6px 24px -12px rgba(20,23,28,.4);
}
.rx-ai ::placeholder { color: #B0B6BE; }

/* Пока не начали печатать — поле едва заметно дышит */
.rx-ai__form.is-idle textarea { animation: rx-ai-breathe 4s ease-in-out infinite; }
@keyframes rx-ai-breathe {
	0%, 100% { border-color: var(--rx-line-2); box-shadow: 0 0 0 0 rgba(255,106,87,0); }
	50% { border-color: var(--rx-coral); box-shadow: 0 0 0 5px rgba(255,106,87,.06); }
}

.rx-ai__send {
	font: inherit; font-size: 15px; font-weight: 500; color: #fff;
	background: var(--rx-ink); border: 0; border-radius: 100px;
	padding: 17px 34px; cursor: pointer; white-space: nowrap;
	transition: background .3s ease, transform .3s ease, box-shadow .3s ease, opacity .3s ease;
}
.rx-ai__send:hover { background: var(--rx-accent); transform: translateY(-1px); box-shadow: 0 12px 28px -12px rgba(218,41,28,.6); }
.rx-ai__send[disabled] { opacity: .4; cursor: default; transform: none; box-shadow: none; }

/* ——— Панель заявки ——— */
.rx-ai-cta-panel {
	display: flex; align-items: center; justify-content: space-between; gap: 26px; flex-wrap: wrap;
	margin: 18px 0 0; padding: 30px 34px;
	background: var(--rx-ink); border-radius: 20px; color: #fff;
	font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	position: relative; overflow: hidden;
}
.rx-ai-cta-panel::before {
	content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--rx-accent);
}
.rx-ai-cta-panel__text { display: flex; flex-direction: column; gap: 7px; }
.rx-ai-cta-panel__text strong { font-size: 19px; font-weight: 500; letter-spacing: -.01em; }
.rx-ai-cta-panel__text span { font-size: 14px; color: #A8AEB8; line-height: 1.5; }
.rx-ai-cta-panel .rx-ai__cta-inline {
	font: inherit; font-size: 15px; font-weight: 500; color: var(--rx-ink);
	background: #fff; border: 0; border-radius: 100px;
	padding: 16px 32px; cursor: pointer; white-space: nowrap;
	transition: background .3s ease, color .3s ease, transform .3s ease;
}
.rx-ai-cta-panel .rx-ai__cta-inline:hover { background: var(--rx-accent); color: #fff; transform: translateY(-1px); }
.rx-ai-cta-panel .rx-ai__cta-inline span { display: inline-block; margin-left: 4px; transition: transform .3s ease; }
.rx-ai-cta-panel .rx-ai__cta-inline:hover span { transform: translateX(5px); }

/* ——— Планшет ——— */
@media (max-width: 1024px) {
	.rx-ai--inline { height: clamp(480px, 66vh, 640px); }
	.rx-ai__msg { max-width: 92%; }
	.rx-ai__log { padding: 24px; gap: 22px; }
	.rx-ai__head, .rx-ai__form { padding-left: 24px; padding-right: 24px; }
}

/* ——— Телефон ——— */
@media (max-width: 680px) {
	.rx-ai { border-radius: 16px; }
	.rx-ai--inline { height: clamp(440px, 70vh, 640px); min-height: 0; }

	.rx-ai__head { flex-wrap: wrap; gap: 12px; padding: 18px 18px 16px; }
	.rx-ai__head-right { width: 100%; justify-content: space-between; }
	.rx-ai__title { font-size: 10px; }

	.rx-ai__log { padding: 18px; gap: 18px; }
	.rx-ai__msg { max-width: 100%; font-size: 15.5px; line-height: 1.7; }
	.rx-ai__msg--user { max-width: 88%; }

	.rx-ai__form { flex-direction: column; align-items: stretch; gap: 12px; padding: 22px 16px 18px; }
	.rx-ai__form::before { left: 22px; }
	.rx-ai textarea, .rx-ai input[type="text"] { font-size: 16px; padding: 15px 20px; }
	.rx-ai__send { width: 100%; padding: 16px 20px; }

	.rx-ai__name { flex-wrap: wrap; }
	.rx-ai__name input { max-width: none; }
	.rx-ai__name button { width: 100%; }

	.rx-ai-cta-panel { padding: 24px 22px; gap: 18px; border-radius: 16px; }
	.rx-ai-cta-panel__text strong { font-size: 17px; }
	.rx-ai-cta-panel .rx-ai__cta-inline { width: 100%; text-align: center; }
}

@media (max-width: 380px) {
	.rx-ai__sub { display: none; }
	.rx-ai__head-right { justify-content: flex-end; }
}

@media (max-height: 520px) and (orientation: landscape) {
	.rx-ai--inline { height: 400px; }
}

@media (prefers-reduced-motion: reduce) {
	.rx-ai--inline { opacity: 1; transform: none; transition: none; }
	.rx-ai__msg--bot, .rx-ai__msg li, .rx-ai__dot::after, .rx-ai__typing i { animation: none; }
	.rx-ai__form.is-idle textarea { animation: none; }
}
