/* Koala AI Chat Widget */

.koala-chat {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99999;
	font-family: 'Inter', sans-serif;
}

/* Toggle button — тёмная пилюля со светящейся рамкой (стиль Artlist) */
@property --koala-glow-angle {
	syntax: '<angle>';
	initial-value: 0deg;
	inherits: false;
}

.koala-chat__toggle {
	height: 44px;
	padding: 0 18px 0 16px;
	border-radius: 32px;
	background: #141414 linear-gradient(279deg, rgba(255, 255, 255, 0) 4%, rgba(255, 255, 255, 0.07) 82%);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	position: relative;
	z-index: 1;
}

.koala-chat__label {
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	white-space: nowrap;
}

/* Вращающийся блик по рамке: conic-gradient, mask вырезает середину —
   остаётся светящееся кольцо толщиной 1px */
.koala-chat__toggle::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	padding: 2px;
	background: conic-gradient(from var(--koala-glow-angle),
		transparent 0deg,
		#fff 50deg,
		rgba(255, 138, 138, 0.5) 90deg,
		transparent 160deg);
	-webkit-mask: linear-gradient(#fff 0 0) content-box exclude, linear-gradient(#fff 0 0);
	mask: linear-gradient(#fff 0 0) content-box exclude, linear-gradient(#fff 0 0);
	pointer-events: none;
	animation: koala-glow-rotate 2.5s linear infinite;
}

@keyframes koala-glow-rotate {
	to { --koala-glow-angle: 360deg; }
}

/* Мягкий блик, заходящий на саму кнопку: тот же conic-градиент, но размытый
   и без маски — светлое пятно скользит по поверхности синхронно с рамкой */
.koala-chat__toggle .koala-chat__sheen {
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: conic-gradient(from var(--koala-glow-angle),
		transparent 0deg,
		rgba(255, 255, 255, 0.38) 50deg,
		rgba(255, 138, 138, 0.2) 90deg,
		transparent 160deg);
	filter: blur(6px);
	/* Радиальная маска гасит клин из центра — свет живёт только у краёв */
	-webkit-mask: radial-gradient(farthest-side, transparent 45%, #fff 82%);
	mask: radial-gradient(farthest-side, transparent 45%, #fff 82%);
	pointer-events: none;
	animation: koala-glow-rotate 2.5s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
	.koala-chat__toggle::before,
	.koala-chat__toggle .koala-chat__sheen {
		animation: none;
	}
}

.koala-chat__icon-close {
	display: none;
}

.koala-msg-img {
	max-width: 100%;
	border-radius: 12px;
	margin-top: 8px;
	display: block;
}

.koala-chat--open .koala-chat__icon-chat {
	display: none;
}

.koala-chat--open .koala-chat__icon-close {
	display: block;
}

/* Panel */
.koala-chat__panel {
	position: absolute;
	bottom: 60px;
	right: 0;
	width: 380px;
	max-width: calc(100vw - 32px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: #fff;
	border-radius: 20px;
	box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	transform: scale(0.92) translateY(8px);
	opacity: 0;
	transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s ease;
	pointer-events: none;
}

.koala-chat__panel:not([hidden]) {
	pointer-events: auto;
}

.koala-chat--open .koala-chat__panel {
	transform: scale(1) translateY(0);
	opacity: 1;
}

/* Header */
.koala-chat__header {
	background: var(--cheader, #1D2939);
	color: #fff;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	border-radius: 20px 20px 0 0;
}

.koala-chat__header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.koala-chat__avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--caccent, #3B71FE);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 16px;
	flex-shrink: 0;
}

.koala-chat__title {
	font-weight: 600;
	font-size: 16px;
	line-height: 1.2;
}

.koala-chat__subtitle {
	font-size: 11px;
	opacity: 0.7;
	line-height: 1.2;
}

.koala-chat__close {
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	padding: 4px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0.7;
	transition: opacity 0.15s;
}

.koala-chat__close:hover {
	opacity: 1;
}

/* Messages */
.koala-chat__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	scroll-behavior: smooth;
}

.koala-chat__messages::-webkit-scrollbar {
	width: 4px;
}

.koala-chat__messages::-webkit-scrollbar-track {
	background: transparent;
}

.koala-chat__messages::-webkit-scrollbar-thumb {
	background: var(--cdarkgrey, #E6E8EC);
	border-radius: 4px;
}

/* Message bubbles */
.koala-msg {
	max-width: 88%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 16px;
	line-height: 1.5;
	word-break: break-word;
}

.koala-msg--user {
	align-self: flex-end;
	background: var(--caccent, #3B71FE);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.koala-msg--ai {
	align-self: flex-start;
	background: var(--cbackground, #F4F5F6);
	color: var(--cubold, #23262F);
	border-bottom-left-radius: 4px;
}

.koala-msg--ai a {
	color: var(--caccent, #3B71FE);
	text-decoration: underline;
}

.koala-msg--typing {
	align-self: flex-start;
	background: var(--cbackground, #F4F5F6);
	border-bottom-left-radius: 4px;
	padding: 12px 16px;
}

.koala-typing-dots {
	display: flex;
	gap: 4px;
	align-items: center;
}

.koala-typing-dots span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--clight, #747B8D);
	animation: koala-bounce 1.2s infinite ease-in-out;
}

.koala-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.koala-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes koala-bounce {
	0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
	40%            { transform: scale(1);   opacity: 1; }
}

/* Input area */
.koala-chat__input-area {
	border-top: 1px solid var(--cdarkgrey, #E6E8EC);
	flex-shrink: 0;
}

/* Suggestions */
.koala-chat__suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 10px 12px 6px;
}

.koala-chat__suggestions:empty {
	display: none;
}

.koala-suggestion {
	background: none;
	border: 1px solid var(--cdarkgrey, #E6E8EC);
	border-radius: 20px;
	padding: 5px 12px;
	font-size: 12px;
	font-family: inherit;
	color: var(--ctext, #667085);
	cursor: pointer;
	transition: border-color 0.15s, color 0.15s;
	line-height: 1.4;
}

.koala-suggestion:hover {
	border-color: var(--caccent, #3B71FE);
	color: var(--caccent, #3B71FE);
}

/* Input row */
.koala-chat__input-row {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px 12px;
}

.koala-chat__input {
	flex: 1;
	border: 1px solid var(--cdarkgrey, #E6E8EC);
	border-radius: 12px;
	padding: 9px 12px;
	font-size: 16px;  /* prevent iOS zoom */
	font-family: inherit;
	color: var(--cubold, #23262F);
	resize: none;
	outline: none;
	min-height: 40px;
	max-height: 120px;
	overflow-y: auto;
	transition: border-color 0.15s;
	line-height: 1.45;
}

.koala-chat__input:focus {
	border-color: var(--caccent, #3B71FE);
}

.koala-chat__input::placeholder {
	color: var(--culight, #B1B5C3);
}

.koala-chat__send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--caccent, #3B71FE);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: opacity 0.15s, transform 0.15s;
}

.koala-chat__send:hover:not(:disabled) {
	opacity: 0.88;
	transform: scale(1.05);
}

.koala-chat__send:disabled {
	opacity: 0.4;
	cursor: default;
}

/* Mobile */
@media (max-width: 480px) {
	.koala-chat {
		bottom: 16px;
		right: 16px;
	}

	.koala-chat__panel {
		width: calc(100vw - 32px);
		right: -16px;
		bottom: 56px;
		height: calc(100dvh - 100px - env(safe-area-inset-top));
		max-height: none;
		border-radius: 16px 16px 0 0;
		padding-top: env(safe-area-inset-top);
	}
}

.koala-chat--open .koala-chat__panel {
	transform: scale(1) translateY(0);
}
