.ai-chat__input-wrapper {
	position: relative;
	width: 100%;
}

.ai-chat ::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

.ai-chat ::-webkit-scrollbar-track {
	border-radius: 4px;
	background: #f5f5f5;
}

.ai-chat ::-webkit-scrollbar-thumb {
	border: 2px solid #f5f5f5;
	border-radius: 4px;
	background-color: #ccc;
}

.ai-chat ::-webkit-scrollbar-thumb:hover {
	background-color: #aaa;
}

.ai-chat-input {
	background: #fff;
	border: none;
	border-radius: 16px;
	padding: 12px 16px 12px 40px;
	resize: none;
	line-height: 18px;
	font-size: 16px;
	width: 100%;
	box-shadow: 0 0 8px rgba(157, 157, 157, .2);

	&::placeholder {
		color: #9D9D9D;
	}
}

.ai-btn,
.ai-btn-send,
.ai-btn-repeat,
.ai-btn-auth {
	background: #BB0523;
	border: none;
	border-radius: 50%;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .2s ease;
	padding: 0;

	&:hover {
		background: #F9062F;
	}
}

.ai-btn {
	border-radius: 16px;
	color: #fff;
	padding: 0 16px;
	height: 32px;
}

.ai-btn-send {
	min-width: 32px;
	min-height: 32px;
	font-size: 11px;
	margin-bottom: 4px;

	&:disabled {
		background: #9D9D9D;
	}
}

.ai-btn-auth {
	height: 28px;
	font-size: 12px;
	line-height: 11px;
	display: inline-flex;
	margin-left: 5px;
	border-radius: 10px;
	text-decoration: none;
	padding: 0 12px;

	&:hover {
		color: #fff !important;
	}

	@media screen and (max-width: 1199px) {
		& {
			display: flex;
			width: 100%;
			margin-top: 8px;
		}
	}
}

.ai-btn-repeat {
	width: 24px;
	height: 24px;
	font-size: 12px;
	line-height: 11px;
	display: inline;
	margin-left: 5px;

	span {
		display: none;
	}

	@media screen and (max-width: 1199px) {
		& {
			display: block;
			width: 100%;
			border-radius: 10px;
			height: 32px;
			margin-top: 8px;
		}

		span {
			display: block;
		}

		svg {
			display: none;
		}
	}
}

.ai-btn-history {
	min-width: 32px;
	min-height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid #F2F2F2;
	background: #fff;
	border-radius: 100%;
	padding: 0;
	margin-bottom: 4px;
	transition: background .4s ease;

	svg {
		width: 24px;
		height: 24px;
	}

	&:hover {
		background: #F2F2F2;
	}

	.mobile-menu-nav & {
		display: none;
	}
}

.ai-messages {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 8px;
}

.ai-message-time {
	font-size: 11px;
	line-height: 11px;
	text-align: center;
	align-self: center;
	position: sticky;
	top: -16px;
	padding: 16px 0;
	z-index: 1;
	background: #F2F2F2;
	width: 100%;
}

.ai-message__wrapper {
	z-index: 1;
}

.ai-message {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	max-width: calc(100% - 24px);
}

.ai-message--assistant {
	align-self: flex-start;
}

.ai-message--user {
	align-self: flex-end;
}

.ai-message--quick {
	align-self: flex-start;
}

.ai-quick-buttons {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
}

.ai-message__feedback {
	width: 100%;
	margin-left: 36px;

	button {
		border: none;
		background: none;
		color: #9D9D9D;
		transition: color .2s ease-out;

		&:not(.active):hover {
			color: #000;
		}

		&.active {
			color: #BD0C1E;
		}
	}
}

.feedback-hint {
	display: inline-block;

	.feedback-hint__button {
		width: 16px;
		height: 16px;
		background: #BD0C1E;
		border-radius: 100%;
		font-size: 12px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		color: #fff;

		&:hover {
			color: #fff !important;
		}

		span {
			display: flex;
		}
	}

	.tippy-box {
		background: #fff;
		border-radius: 8px;
		padding: 16px;
		box-shadow: 0 0 8px rgba(157, 157, 157, .2);
		max-width: 368px;
	}

	.tippy-content {
		font-size: 12px;
		line-height: 16px;
		color: #121217;
		padding: 0;
	}

	.tippy-arrow {
		display: none;
	}
}

.ai-quick-buttons__item {
	background: #fff;
	border: 1px solid #F2F2F2;
	padding: 8px 8px 8px 16px;
	font-size: 14px;
	line-height: 100%;
	display: flex;
	align-items: center;
	gap: 4px;
	border-radius: 16px;
	transition: background .4s ease;

	&:hover {
		cursor: pointer;
		background: #F2F2F2;
	}
}

.ai-message__logo {
	border-radius: 50%;
	width: 28px;
	height: 28px;
	overflow: hidden;

	& img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

.ai-message__content {
	background: #F2F2F2;
	color: #000;
	font-size: 14px;
	border-radius: 16px;
	padding: 12px 10px;
	line-height: 18px;
	flex: 1;
	max-width: 684px;
	word-break: break-word;
	margin-left: 4px;

	.ai-message--assistant & {
		box-shadow: -2px 0 0 0 #BD0C1E;
		position: relative;
		left: 2px;
	}
}

.ai-message__content {
	h2 {
		font-size: 2em !important;
		margin-bottom: .5em !important;
	}

	h3 {
		font-size: 1.75em !important;
		margin-bottom: .5em !important;
	}

	h4 {
		font-size: 1.5em !important;
		margin-bottom: .5em !important;
	}

	h5 {
		font-size: 1.25em !important;
		margin-bottom: .5em !important;
	}

	h6 {
		font-size: 1em !important;
		margin-bottom: .5em !important;
	}

	p, strong, b, span, a, li {
		font-size: 14px !important;
		line-height: 18px !important;
	}

	a:hover {
		color: #BD0C1E;
	}

	table {
		margin: 5px 0;
		width: 100%;

		th, td {
			border: 1px solid #999;
			padding: 7px 12px;
		}
	}

	ol, ul {
		padding-left: 25px;

		&:not(:last-child) {
			margin-bottom: 10px;
		}
	}

	ul li {
		position: relative;

		&::before {
			content: '';
			width: 5px;
			height: 5px;
			display: inline-block;
			background: #000;
			border-radius: 100%;
			position: absolute;
			left: -15px;
			top: 6px;
		}
	}
}

.ai-chat-form {
	display: flex;
	gap: 8px;
	align-items: center;
	width: 100%;
	margin: 0 auto;
	font-family: "Factor A", sans-serif;
}

.ai-wait {
	display: inline-block;
	margin-left: 8px;

	.dot {
		animation: colorChange 1.5s infinite ease-in-out;
	}

	.dot:nth-child(1) {
		animation-delay: 0s;
	}

	.dot:nth-child(2) {
		animation-delay: 0.2s;
	}

	.dot:nth-child(3) {
		animation-delay: 0.4s;
	}
}

.ai-info {
	position: relative;

	.ai-info__modal {
		opacity: 0;
		transform: translateY(20px);
		pointer-events: none;
		position: absolute;
		top: calc(100% + 10px);
		right: 0;
		background: #fff;
		width: 258px;
		box-shadow: 1px 1px 5px 0 #ECECEC;
		border-radius: 16px;
		padding: 8px 0 16px;
		transition: all .2s ease-out;

		.ai-menu__section {
			font-weight: 550;
			font-size: 14px;
			padding: 16px 16px 8px;
		}

		.ai-menu__link {
			display: flex;
			gap: 8px;
			align-items: center;
			padding: 10px 16px;
			font-size: 12px;
			line-height: 12px;
			text-decoration: none;
			height: 40px;

			&:hover {
				background: #F2F2F2;
			}
		}
	}

	&:focus-within .ai-info__modal,
	&:focus .ai-info__modal {
		opacity: 1;
		transform: translateY(0);
		pointer-events: all;
	}
}

.ai-info__button,
.ai-mobile-menu,
.ai-history {
	cursor: pointer;
	margin-left: 16px;
	color: #626262;
	display: flex;
	gap: 8px;
	align-items: center;
	font-size: 12px;
	@media screen and (max-width: 767px) {
		span {
			display: none;
		}
	}
	&:hover {
		color: #121217;
	}
}

.ai-mobile-menu {
	@media screen and (min-width: 1200px) {
		display: none;
	}
}

/* История - START */
.ai-chat-history {
	position: absolute;
	z-index: 2;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	margin-top: 61px;
	padding: 30px 24px;
	border-radius: 16px;
	background: #F2F2F2;
}

.ai-chat-history__container {
	display: flex;
	align-items: center;
	flex-direction: column;
	width: 100%;
	height: 100%;
	margin: 0 auto;
}

.ai-chat-history__close {
	position: absolute;
	left: 16px;
	top: 16px;
	background: none;
	border: none;
	padding: 0;
	display: flex;

	.ai-chat-history__close-desktop {
		display: none;
	}
}

.ai-chat-history__title {
	font-size: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 30px;
	text-align: center;
}

.ai-chat-history__header {
	flex-shrink: 0;
	width: 100%;
	max-width: 726px;
}

.ai-chat-history__search-input {
	display: flex;
	align-items: center;
	width: 100%;
	margin-bottom: 16px;
	padding: 0 16px 0 0;
	border-radius: 16px;
	background: #fff;


	input {
		border: none;
		background: none;
		flex: 1;
		padding: 0 16px;
		font-size: 16px;
		height: 32px;

		&::placeholder {
			color: #9D9D9D;
		}
	}
}

.ai-chat-history__items {
	display: flex;
	overflow: auto;
	align-items: center;
	flex-direction: column;
	width: 100%;
	height: 100%;
	gap: 8px;
}

.ai-chat-history__item {
	position: relative;
	width: 100%;
	max-width: 726px;
	padding: 16px;
	border-radius: 16px;
	background: #fff;
	display: flex;
	flex-direction: column;
	gap: 4px;

	&:hover {
		cursor: pointer;
		box-shadow: 0 0 6px rgba(157, 157, 157, .4);
	}
}

.ai-chat-history__item-title {
	font-size: 14px;
	line-height: 18px;
	padding-right: 32px;
	text-overflow: ellipsis;
	white-space: nowrap;
	overflow: hidden;
}

.ai-chat-history__item-date {
	font-size: 11px;
	line-height: 12px;
	color: #9D9D9D;
}

.ai-chat-history__item-more {
	position: absolute;
	right: 16px;
	top: 50%;
	transform: translateY(-50%);
	color: #9D9D9D;
	z-index: 1;

	&:hover {
		color: #121217;
	}
}

.ai-chat-history__item-actions {
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 0 8px rgba(157, 157, 157, .2);
	padding: 8px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	position: absolute;
	right: -70px;
	min-width: 150px;
	z-index: 1;

	transition: all .4s ease;
	opacity: 0;
	top: calc(100% + 20px);
	pointer-events: none;
}

.ai-chat-history__item-action {
	color: #121217;
	font-size: 14px;
	line-height: 16px;
	background: #fff;
	border-radius: 8px;
	transition: background .4s ease;
	height: 32px;
	padding: 0 8px;
	border: none;
	display: flex;
	align-items: center;
	gap: 8px;

	&:hover {
		cursor: pointer;
		background: #F2F2F2;
	}

	&.ai-chat-history__item-action--danger {
		color: #BD0C1E;
	}
}

.ai-chat-history__item-more:focus,
.ai-chat-history__item-more:focus-within {
	color: #121217;

	.ai-chat-history__item-actions {
		opacity: 1;
		top: 100%;
		pointer-events: all;
	}
}

@media screen and (max-width: 1200px) {
	.ai-chat-history__item-actions {
		right: -16px;
	}
}

/* История - END */

/* Карточки в сообщении - START */
.ai-chat-card {
	background: #fff;
	border-radius: 16px;
	padding: 16px;
	margin-bottom: 10px;
	border: 1px solid #F2F2F2;
}

.ai-chat-card__header {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 4px;
}

.ai-chat-card__image {
	width: 46px;
	height: 46px;
	overflow: hidden;
	border-radius: 8px;

	img {
		width: 100%;
		height: 100%;
		object-fit: contain;
	}
}

.ai-chat-card__title {
	display: flex;
	flex-direction: column;
	gap: 4px;
	text-decoration: none;
	font-size: 14px;
	font-weight: 550;
	transition: color .4s ease;

	&:hover {
		color: #BD0C1E;
	}

	span {
		position: relative;
		display: flex;
		align-items: center;

		&:not(:first-child) {
			color: #626262;
		}
	}
}

.ai-chat-card__description {
	color: #a4a4a4;
	font-size: 12px;
	margin-bottom: 16px;
}

.ai-chat-card__tag {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 16px;

	span {
		text-wrap: nowrap;
		font-size: 12px !important;
		line-height: 16px !important;
		padding: 7px;
		border: 1px solid #F2F2F2;
		border-radius: 16px;
	}
}

.ai-chat-card__detail {
	background: #BB0523;
	border: none;
	border-radius: 16px;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .2s ease;
	padding: 0 16px;
	height: 32px;
	width: fit-content;
	text-decoration: none;

	&:hover {
		cursor: pointer;
		background: #F9062F;
		color: #fff !important;
	}
}

/* Карточки в сообщении - END */

/* Опросник - START */
.ai-chat-soft-test__question {
	line-height: 24px;
}

.ai-chat-quiz {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 16px 0;
}

.ai-chat-quiz__item {
	background: #fff;
	border-radius: 16px;
	border: 1px solid #F2F2F2;
	padding: 16px;
	font-size: 14px;
	line-height: 140%;
	transition: all .4s ease;

	.ai-chat-quiz:not(.selected) &:hover {
		cursor: pointer;
		box-shadow: 0 0 6px rgba(157, 157, 157, .4);
	}

	.ai-chat-quiz.selected &:not(.active) {
		opacity: .4;
	}

	.ai-chat-quiz.selected &.active {
		border-color: transparent;
		box-shadow: 0 0 6px rgba(157, 157, 157, .4);
	}
}

/* Опросник - END */

/* Инструменты - START */

.ai-chat-tools-btn {
	top: 0;
	left: 0;
	background: transparent;
	border: none;
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	width: 32px;
	height: 42px;
	padding: 0;
	z-index: 1;
}

.ai-chat-tools-popup {
	position: absolute;
	left: 0;
	background: #fff;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	box-shadow: 0 0 8px rgba(157, 157, 157, .2);
	border-radius: 16px;
	opacity: 0;
	bottom: calc(100% + 30px);
	pointer-events: none;
	transition: all .4s ease;

    &:hover {
        cursor: default;
    }

    &.open {
        bottom: calc(100% + 20px);
        opacity: 1;
        pointer-events: all;
    }
}


.ai-chat-tools-popup__item {
	text-wrap: nowrap;
	padding: 8px;
	gap: 8px;
	display: flex;
	align-items: center;
	border-radius: 8px;
	transition: background .4s ease;
	font-size: 14px;
	line-height: 16px;
	letter-spacing: 0;
	color: #121217;

	&:hover {
		cursor: pointer;
		background: #F2F2F2;
	}
}

/* Инструменты - END */

@keyframes colorChange {
	0%, 100% {
		fill: #808080;
	}
	33% {
		fill: #AFAFAF;
	}
	66% {
		fill: #D9D9D9;
	}
}

.fadeUp {
	opacity: 0;
	top: 20px;
	position: relative;
	animation: messageAppear 0.3s ease-out forwards;
}

@keyframes messageAppear {
	from {
		opacity: 0;
		top: 20px;
	}
	to {
		opacity: 1;
		top: 0
	}
}

@media (max-width: 1200px) {
	.ai-chat-history {
		padding: 17px 0 190px 0;
	}

	.ai-chat-history__title {
		margin-bottom: 17px;
	}

	.ai-chat-history__header {
		padding: 0 16px;
	}

	.ai-chat-history__items {
		padding: 0 8px 0 16px;
		scrollbar-gutter: stable;
	}
}