/* Плавающий виджет чата с AI агентом */
.ai-agent-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: "PT Sans", sans-serif;
}

/* Кнопка открытия чата */
.ai-agent-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--blue, #0066AE);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
    opacity: 0.6; /* Полупрозрачность по умолчанию (чат свернут) */
}

.ai-agent-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    opacity: 0.9; /* При наведении увеличиваем непрозрачность */
}

/* Когда чат открыт - кнопка полностью непрозрачна */
.ai-agent-chat-button--active {
    opacity: 1;
}

.ai-agent-chat-button--active:hover {
    opacity: 1;
}

.ai-agent-chat-button__icon {
    width: 32px;
    height: 32px;
    filter: brightness(0) invert(1);
}

.ai-agent-chat-button__badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--red, #EA051A);
    color: var(--white);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid var(--white);
}

/* Окно чата */
.ai-agent-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background-color: var(--white);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Заголовок окна */
.ai-agent-chat-window__header {
    background-color: var(--blue, #0066AE);
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-agent-chat-window__header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-agent-chat-window__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--white);
    padding: 4px;
}

.ai-agent-chat-window__header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-agent-chat-window__name {
    font-weight: bold;
    font-size: 16px;
}

.ai-agent-chat-window__status {
    font-size: 12px;
    opacity: 0.9;
}

.ai-agent-chat-window__close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.ai-agent-chat-window__close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Область сообщений */
.ai-agent-chat-window__messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--grey3, #F1F1F1);
}

.ai-agent-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-agent-chat-message--assistant {
    align-self: flex-start;
}

.ai-agent-chat-message--user {
    align-self: flex-end;
}

.ai-agent-chat-message__content {
    padding: 12px 16px;
    border-radius: 12px;
    background-color: var(--white);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
}

.ai-agent-chat-message--user .ai-agent-chat-message__content {
    background-color: var(--blue, #0066AE);
    color: var(--white);
}

/* Стили для параграфов напрямую в content (приветственное сообщение) */
.ai-agent-chat-message__content > p {
    margin: 0 0 8px 0;
    line-height: 1.5;
    font-size: 14px;
}

.ai-agent-chat-message__content > p:last-child {
    margin-bottom: 0;
}

/* Стили для markdown элементов внутри сообщений */
.ai-agent-chat-message__text {
    font-size: 14px;
    line-height: 1.5;
    color: inherit;
}

.ai-agent-chat-message__text p {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.ai-agent-chat-message__text p:last-child {
    margin-bottom: 0;
}

.ai-agent-chat-message__text ul,
.ai-agent-chat-message__text ol {
    margin: 8px 0;
    padding-left: 24px;
    list-style-position: outside;
}

.ai-agent-chat-message__text ul {
    list-style-type: disc;
}

.ai-agent-chat-message__text ol {
    list-style-type: decimal;
}

.ai-agent-chat-message__text li {
    margin: 4px 0;
    padding-left: 4px;
    line-height: 1.5;
}

.ai-agent-chat-message__text li:last-child {
    margin-bottom: 0;
}

.ai-agent-chat-message__text h1,
.ai-agent-chat-message__text h2,
.ai-agent-chat-message__text h3,
.ai-agent-chat-message__text h4,
.ai-agent-chat-message__text h5,
.ai-agent-chat-message__text h6 {
    margin: 12px 0 8px 0;
    font-weight: bold;
    line-height: 1.3;
    color: inherit;
}

.ai-agent-chat-message__text h1 {
    font-size: 18px;
}

.ai-agent-chat-message__text h2 {
    font-size: 16px;
}

.ai-agent-chat-message__text h3 {
    font-size: 15px;
}

.ai-agent-chat-message__text h4,
.ai-agent-chat-message__text h5,
.ai-agent-chat-message__text h6 {
    font-size: 14px;
}

.ai-agent-chat-message__text h1:first-child,
.ai-agent-chat-message__text h2:first-child,
.ai-agent-chat-message__text h3:first-child,
.ai-agent-chat-message__text h4:first-child,
.ai-agent-chat-message__text h5:first-child,
.ai-agent-chat-message__text h6:first-child {
    margin-top: 0;
}

.ai-agent-chat-message__text strong,
.ai-agent-chat-message__text b {
    font-weight: bold;
}

.ai-agent-chat-message__text em,
.ai-agent-chat-message__text i {
    font-style: italic;
}

.ai-agent-chat-message__text code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
}

.ai-agent-chat-message__text pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: monospace;
    font-size: 13px;
    line-height: 1.4;
}

.ai-agent-chat-message__text pre code {
    background-color: transparent;
    padding: 0;
}

.ai-agent-chat-message__text blockquote {
    margin: 8px 0;
    padding-left: 16px;
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    color: inherit;
    opacity: 0.9;
}

.ai-agent-chat-message__text a {
    color: inherit;
    text-decoration: underline;
    opacity: 0.9;
}

.ai-agent-chat-message__text a:hover {
    opacity: 1;
}

/* Для сообщений пользователя - инвертируем некоторые стили */
.ai-agent-chat-message--user .ai-agent-chat-message__text code,
.ai-agent-chat-message--user .ai-agent-chat-message__text pre {
    background-color: rgba(255, 255, 255, 0.2);
}

.ai-agent-chat-message--user .ai-agent-chat-message__text blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
}

.ai-agent-chat-message--loading {
    align-self: flex-start;
}

.ai-agent-chat-message--loading .ai-agent-chat-message__content {
    background-color: var(--white);
    padding: 12px 20px;
}

.ai-agent-chat-message__loading-dots {
    display: flex;
    gap: 4px;
}

.ai-agent-chat-message__loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--blue, #0066AE);
    animation: bounce 1.4s infinite ease-in-out;
}

.ai-agent-chat-message__loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-agent-chat-message__loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Контейнер ввода */
.ai-agent-chat-window__input-container {
    padding: 16px;
    background-color: var(--white);
    border-top: 1px solid var(--grey2, #DCDCDC);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.ai-agent-chat-window__input-wrapper {
    flex: 1;
    position: relative;
}

.ai-agent-chat-window__input {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 80px 10px 12px;
    border: 1px solid var(--grey2, #DCDCDC);
    border-radius: 8px;
    font-family: "PT Sans", sans-serif;
    font-size: 14px;
    resize: none;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.ai-agent-chat-window__input:focus {
    outline: none;
    border-color: var(--blue, #0066AE);
}

.ai-agent-chat-window__char-counter {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 11px;
    color: var(--grey3, #999);
    pointer-events: none;
}

.ai-agent-chat-window__send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background-color: var(--blue, #0066AE);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.ai-agent-chat-window__send:hover:not(:disabled) {
    background-color: var(--dark_blue, #053982);
}

.ai-agent-chat-window__send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-agent-chat-window__send .material-symbols-rounded {
    font-size: 20px;
}

/* Адаптивность для мобильных устройств */
@media screen and (max-width: 480px) {
    .ai-agent-chat-widget {
        bottom: 10px;
        right: 10px;
    }

    .ai-agent-chat-button {
        width: 56px;
        height: 56px;
    }

    .ai-agent-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 70px;
        right: 10px;
        border-radius: 12px 12px 0 0;
    }

    .ai-agent-chat-message {
        max-width: 85%;
    }
}

/* Скроллбар для области сообщений */
.ai-agent-chat-window__messages::-webkit-scrollbar {
    width: 6px;
}

.ai-agent-chat-window__messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-agent-chat-window__messages::-webkit-scrollbar-thumb {
    background-color: var(--grey2, #DCDCDC);
    border-radius: 3px;
}

.ai-agent-chat-window__messages::-webkit-scrollbar-thumb:hover {
    background-color: var(--grey3, #999);
}

