/* ==========================================================================
   ChatBot for maknt.ru — BEM
   Блок: chat-bot
   ========================================================================== */

.chat-bot {
    --cb-accent: #3390ec;
    --cb-accent-dark: #227ac6;
    --cb-accent-soft: #e7f1fd;
    --cb-text: #232323;
    --cb-muted: #7d8b99;
    --cb-line: #e6e8eb;
    --cb-panel: #ffffff;
    --cb-chat-bg: #f0f2f5;
    --cb-bubble-bot: #ffffff;
    --cb-online: #35a550;
    --cb-radius: 16px;
}

/* ---------- Плавающая кнопка ---------- */

.chat-bot__button {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2147483000;
    width: 64px;
    height: 64px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--cb-accent);
    box-shadow: 0 6px 20px rgba(51, 144, 236, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.chat-bot__button:hover {
    background: var(--cb-accent-dark);
    transform: translateY(-2px);
}

.chat-bot__button:active {
    transform: translateY(0) scale(0.97);
}

.chat-bot__button-icon {
    width: 30px;
    height: 30px;
    fill: #ffffff;
}

/* ---------- Окно чата ---------- */

.chat-bot__window {
    position: fixed;
    right: 24px;
    bottom: 104px;
    z-index: 2147483001;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 140px);
    display: flex;
    flex-direction: column;
    background: var(--cb-panel);
    border-radius: var(--cb-radius);
    box-shadow: 0 12px 40px rgba(23, 43, 77, 0.18);
    overflow: hidden;
    font-family: inherit;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.97);
    transform-origin: bottom right;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.chat-bot__window--active {
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* ---------- Шапка ---------- */

.chat-bot__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--cb-panel);
    border-bottom: 1px solid var(--cb-line);
}

.chat-bot__header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.chat-bot__avatar {
    position: relative;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--cb-accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-bot__avatar-icon {
    width: 24px;
    height: 24px;
    fill: var(--cb-accent);
}

.chat-bot__avatar-dot {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #b6bcc4;
    border: 2px solid var(--cb-panel);
}

.chat-bot__avatar--online .chat-bot__avatar-dot {
    background: var(--cb-online);
}

.chat-bot__header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-bot__name {
    font-size: 15px;
    font-weight: 600;
    color: var(--cb-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-bot__status {
    font-size: 13px;
    color: var(--cb-muted);
}

.chat-bot__status--online {
    color: var(--cb-online);
}

/* ---------- Кнопки шапки ---------- */

.chat-bot__menu-wrap {
    position: relative;
}

.chat-bot__menu,
.chat-bot__close {
    flex: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.chat-bot__menu:hover,
.chat-bot__close:hover {
    background: rgba(0, 0, 0, 0.06);
}

.chat-bot__menu-dots {
    display: flex;
    gap: 3px;
}

.chat-bot__menu-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #9aa4af;
}

.chat-bot__close-icon {
    width: 16px;
    height: 16px;
    stroke: #5b6672;
    stroke-width: 2.5;
    stroke-linecap: round;
    fill: none;
}

/* ---------- Панель меню ---------- */

.chat-bot__menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 2;
    min-width: 170px;
    padding: 6px;
    background: var(--cb-panel);
    border: 1px solid var(--cb-line);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(23, 43, 77, 0.14);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}

.chat-bot__menu-panel--open {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.chat-bot__menu-item {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 14px;
    color: var(--cb-text);
    text-align: left;
    cursor: pointer;
}

.chat-bot__menu-item:hover {
    background: #f1f3f6;
}

/* ---------- Сообщения ---------- */

.chat-bot__messages {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    overflow-y: auto;
    background: var(--cb-chat-bg);
    overscroll-behavior: contain;
}

.chat-bot__message {
    max-width: 82%;
    padding: 9px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: break-word;
}

.chat-bot__message--user {
    align-self: flex-end;
    background: var(--cb-accent);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-bot__message--bot {
    align-self: flex-start;
    background: var(--cb-bubble-bot);
    color: var(--cb-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(23, 43, 77, 0.06);
}

/* ---------- Индикатор набора ---------- */

.chat-bot__typing {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--cb-bubble-bot);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(23, 43, 77, 0.06);
}

.chat-bot__typing--active {
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-bot__typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9aa4af;
    animation: chatbot-typing 1.2s infinite ease-in-out;
}

.chat-bot__typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-bot__typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chatbot-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* ---------- Быстрые ответы (в потоке сообщений) ---------- */

.chat-bot__quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-self: stretch;
    padding: 0 2px;
}

.chat-bot__quick-reply {
    padding: 7px 14px;
    border: 1px solid var(--cb-accent);
    border-radius: 18px;
    background: transparent;
    color: var(--cb-accent);
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.chat-bot__quick-reply:hover {
    background: var(--cb-accent);
    color: #ffffff;
}

.chat-bot__quick-reply:active {
    transform: scale(0.97);
}

/* ---------- Область ввода ---------- */

.chat-bot__input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: var(--cb-panel);
    border-top: 1px solid var(--cb-line);
}

.chat-bot__input {
    flex: 1;
    min-width: 0;
    padding: 8px 0;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: var(--cb-text);
    resize: none;
    max-height: 120px;
}

.chat-bot__input::placeholder {
    color: #9aa4af;
}

.chat-bot__send {
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--cb-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.chat-bot__send:hover {
    background: var(--cb-accent-dark);
}

.chat-bot__send:active {
    transform: scale(0.95);
}

.chat-bot__send-icon {
    width: 22px;
    height: 22px;
    fill: #ffffff;
}

/* ---------- Доступность ---------- */

.chat-bot__button:focus-visible,
.chat-bot__close:focus-visible,
.chat-bot__menu:focus-visible,
.chat-bot__send:focus-visible,
.chat-bot__quick-reply:focus-visible,
.chat-bot__menu-item:focus-visible {
    outline: 2px solid var(--cb-accent);
    outline-offset: 2px;
}

/* ---------- Скроллбар ---------- */

.chat-bot__messages::-webkit-scrollbar {
    width: 6px;
}

.chat-bot__messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-bot__messages::-webkit-scrollbar-thumb {
    background: rgba(23, 43, 77, 0.18);
    border-radius: 3px;
}

/* ---------- Адаптивность ---------- */

@media (max-width: 480px) {
    .chat-bot__button {
        right: 16px;
        bottom: 16px;
        width: 56px;
        height: 56px;
    }

    .chat-bot__window {
        right: 8px;
        bottom: 84px;
        width: calc(100vw - 16px);
        height: calc(100vh - 110px);
        max-height: none;
    }
}

/* ---------- Ограничение анимаций ---------- */

@media (prefers-reduced-motion: reduce) {
    .chat-bot__button,
    .chat-bot__window,
    .chat-bot__menu-panel,
    .chat-bot__quick-reply,
    .chat-bot__send {
        transition: none;
    }

    .chat-bot__typing-dot {
        animation: none;
    }
}
