/* ВИДЖЕТ MIMI
 *
 * Подключается последним, после style.css и ui-kit.css.
 *
 * Раньше виджет был описан в трёх местах одного файла —
 * 68 правил, которые спорили друг с другом: круглые углы
 * по 24 и 28 пикселей, тени в четверть экрана, чёрные
 * градиенты. Здесь он собран в одном месте и по той же
 * системе, что и весь сайт: почти прямые углы, тонкие
 * линии в один пиксель, сине-серо-золотая гамма.
 */

/* ========================================
   КНОПКА ВЫЗОВА
======================================== */

.chat-button {
    width: 58px;
    height: 58px;

    /* Прямоугольник со срезанным углом, как у кнопок сайта */
    border-radius: 2px;

    background: var(--butterfly-deep);
    color: var(--white);

    border: 1px solid var(--butterfly-deep);

    font-size: 24px;

    /* Тень едва заметная: тяжёлая спорит с тонкими линиями */
    box-shadow: 0 6px 18px rgba(29, 79, 107, 0.22);

    transition:
        background-color 0.25s ease,
        border-color 0.25s ease,
        box-shadow 0.25s ease;
}

@media (hover: hover) {

    .chat-button:hover {
        background: var(--butterfly-strong);
        border-color: var(--accent-gold);

        transform: none;
        box-shadow: 0 8px 22px rgba(29, 79, 107, 0.28);
    }
}


/* ========================================
   ОКНО
======================================== */

.chat-window {
    border-radius: 2px;

    background: var(--bg-secondary);

    border: 1px solid var(--butterfly-border);

    box-shadow: 0 18px 50px rgba(29, 79, 107, 0.16);
}


/* ========================================
   ШАПКА
======================================== */

.chat-header {
    padding: 15px 16px;
    gap: 11px;

    background: var(--butterfly-deep);
    color: var(--white);

    /* Золотая волосяная линия — единственное золото
       в шапке, поэтому она и читается как акцент */
    border-bottom: 1px solid var(--accent-gold);
}

.chat-avatar {
    flex: 0 0 auto;

    width: 36px;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 2px;

    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);

    font-size: 18px;
}

.chat-header-info {
    flex: 1;
    min-width: 0;

    gap: 2px;
}

.chat-header strong {
    font-family: var(--font-header);
    font-size: 18px;
    font-weight: 600;

    text-transform: uppercase;
    letter-spacing: var(--heading-tracking);
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 6px;

    color: rgba(255, 255, 255, 0.55);

    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chat-status i {
    width: 5px;
    height: 5px;

    border-radius: 50%;
    background: var(--accent-gold);

    animation: mimi-pulse 2s ease-in-out infinite;
}

@keyframes mimi-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}


/* ========================================
   КРЕСТИК
======================================== */

/* Знак × — глиф, он сидит по математической оси шрифта,
   ниже оптического центра круга. Рамка текста при этом
   отцентрована верно, а сам штрих выглядит смещённым.
   Поэтому крестик нарисован двумя полосками: так он
   центрируется точно и не зависит от шрифта. */

.chat-header #chat-close {
    position: relative;

    flex: 0 0 auto;

    width: 30px;
    height: 30px;

    padding: 0;
    border: 1px solid transparent;
    border-radius: 2px;

    background: transparent;

    /* Прячем сам символ, оставляя его для чтения с экрана */
    font-size: 0;
    color: rgba(255, 255, 255, 0.7);

    cursor: pointer;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.chat-header #chat-close::before,
.chat-header #chat-close::after {
    content: "";

    position: absolute;
    left: 50%;
    top: 50%;

    width: 13px;
    height: 1px;

    background: currentColor;
}

.chat-header #chat-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.chat-header #chat-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

@media (hover: hover) {

    .chat-header #chat-close:hover {
        color: var(--white);
        border-color: var(--accent-gold);
        background: transparent;

        /* Поворот на 90 градусов у крестика не виден:
           он симметричен. Раньше это была пустая анимация. */
        transform: none;
    }
}

.chat-header #chat-close:active {
    transform: none;
    background: rgba(255, 255, 255, 0.08);
}


/* ========================================
   СООБЩЕНИЯ
======================================== */

.chat-messages {
    padding: 16px;
    gap: 9px;

    background: var(--bg-secondary);
}

.chat-message {
    max-width: 86%;

    padding: 11px 13px;

    border-radius: 2px;

    font-size: 14px;
    line-height: 1.6;
}

.chat-message.bot {
    /* В style.css скругление задано селектором из двух
       классов — чтобы его перекрыть, повторяем его здесь */
    border-radius: 2px;

    background: var(--white);
    color: var(--text-main);

    border: 1px solid var(--border);

    /* Тонкая синяя черта слева: видно, где говорит Mimi,
       без цветного пузыря на весь ответ */
    border-left: 2px solid var(--butterfly);

    box-shadow: none;
}

.chat-message.user {
    border-radius: 2px;

    background: var(--butterfly-deep);
    color: var(--white);

    border: 1px solid var(--butterfly-deep);
    border-right: 2px solid var(--accent-gold);

    box-shadow: none;
}

.chat-message.typing {
    border-radius: 2px;
    background: transparent;
    border: 0;
    border-left: 2px solid var(--butterfly-border);

    color: var(--text-muted);
    font-style: normal;
}

.chat-message.bot strong,
.chat-message.bot .chat-heading {
    color: var(--butterfly-deep);
}

.chat-message.bot ul li::before {
    color: var(--accent-gold);
}

.chat-message.bot code {
    border-radius: 2px;
    background: var(--butterfly-soft);
}


/* ========================================
   БЫСТРЫЕ ВОПРОСЫ
======================================== */

.chat-suggestions,
.chat-quick-buttons {
    padding: 0 16px 12px;
    background: var(--bg-secondary);
}

.chat-suggestions button,
.chat-quick-buttons .quick-question {
    padding: 8px 11px;

    border-radius: 2px;

    background: transparent;
    border: 1px solid var(--butterfly-border);
    color: var(--butterfly-deep);

    font-family: var(--font-body);
    font-size: 12px;

    box-shadow: none;
    cursor: pointer;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

@media (hover: hover) {

    .chat-suggestions button:hover,
    .chat-quick-buttons .quick-question:hover {
        background: var(--butterfly-soft);
        border-color: var(--accent-gold);
        color: var(--butterfly-deep);

        transform: none;
        box-shadow: none;
    }
}


/* ========================================
   ПОЛЕ ВВОДА
======================================== */

.chat-form,
.chat-input-area {
    padding: 11px 12px;
    gap: 8px;

    background: var(--white);

    border-top: 1px solid var(--border);
}

.chat-form input,
.chat-input-area input {
    height: 42px;
    padding: 0 12px;

    /* Пилюля ушла: в системе углы почти прямые */
    border-radius: 2px;

    background: var(--white);
    border: 1px solid var(--border-strong);

    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 14px;

    outline: none;

    transition: border-color 0.2s ease;
}

.chat-form input::placeholder,
.chat-input-area input::placeholder {
    color: var(--text-muted);
}

.chat-form input:focus,
.chat-input-area input:focus {
    /* Золотая линия на фокусе — как в формах гайда */
    border-color: var(--accent-gold);
    background: var(--white);
}

.chat-form button,
.chat-input-area button {
    width: 42px;
    min-width: 42px;
    height: 42px;

    border-radius: 2px;

    background: var(--butterfly-strong);
    border: 1px solid var(--butterfly-strong);
    color: var(--white);

    font-size: 17px;

    box-shadow: none;
    cursor: pointer;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease;
}

@media (hover: hover) {

    .chat-form button:hover,
    .chat-input-area button:hover {
        background: var(--butterfly-deep);
        border-color: var(--accent-gold);
        transform: none;
    }
}


/* ========================================
   ТЕЛЕФОН И ПЛАНШЕТ
======================================== */

@media (max-width: 700px) {

    .chat-button {
        right: 16px;
        bottom: 16px;

        width: 52px;
        height: 52px;

        font-size: 21px;
    }

    .chat-window {
        right: 12px;
        bottom: 80px;

        width: calc(100vw - 24px);
        height: min(560px, calc(100vh - 104px));

        border-radius: 2px;
    }

    /* Меньше 16 пикселей — и телефон приближает страницу
       при касании поля ввода */
    .chat-form input,
    .chat-input-area input {
        font-size: 16px;
    }

    .chat-form button,
    .chat-input-area button {
        min-width: 44px;
        min-height: 44px;
    }
}
