/* ==================================================================
   Чат-помощник ФБУЗ — /assets/css/assistant.css
   Версия 3.2 — стили списка тем переведены на селектор по id
   (#quickQuestions), а не по классу — сработает гарантированно,
   независимо от того, какой класс фактически висит на элементе.
   Всё усилено !important, чтобы перебить конфликтующие глобальные
   стили сайта (Bootstrap/тема), которые схлопывали список в полоску.
================================================================== */

/* ------------------------------------------------------------------
   Обёртка виджета — фиксирована к правому нижнему углу окна браузера,
   не двигается при скролле страницы в любую сторону.
------------------------------------------------------------------ */
.chat-widget-wrapper {
    position: fixed;
    right: 34px;
    bottom: 24px;
    z-index: 2147483647; /* максимум — гарантированно поверх всего сайта */
    font-family: inherit;
    isolation: isolate;
    pointer-events: none;
}

.chat-widget-wrapper > * {
    pointer-events: auto;
}

/* ------------------------------------------------------------------
   Кнопка-переключатель
------------------------------------------------------------------ */
.chat-toggle-btn {
    position: relative;
    width: 76px;
    height: 76px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bs-primary, #0d6efd), #0b4dc4);
    color: #fff;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(13, 110, 253, .4);
    transition: transform .25s ease, box-shadow .25s ease;
    animation: chatPulse 2.4s ease-in-out infinite;
}

.chat-toggle-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 12px 34px rgba(13, 110, 253, .48);
}

.chat-toggle-btn .chat-icon-close { display: none; }
.chat-toggle-btn.open .chat-icon-open { display: none; }
.chat-toggle-btn.open .chat-icon-close { display: inline-block; }

@keyframes chatPulse {
    0%, 100% { box-shadow: 0 10px 30px rgba(13, 110, 253, .4); }
    50%      { box-shadow: 0 10px 30px rgba(13, 110, 253, .65); }
}

.chat-toggle-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e25c00;
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2.5px solid #fff;
}

.chat-toggle-btn.open .chat-toggle-badge { display: none; }

/* ------------------------------------------------------------------
   Окно чата
------------------------------------------------------------------ */
.chat-window {
    position: fixed;
    right: 12px;
    bottom: 104px; /* 76px кнопка + отступ */
    width: 400px;
    max-width: calc(100vw - 32px);
    max-height: min(640px, 75vh);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .22);
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(.85) translateY(16px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform .22s ease, opacity .22s ease, visibility .22s;
    z-index: 2147483647;
}

.chat-window.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ------------------------------------------------------------------
   Шапка
------------------------------------------------------------------ */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--bs-primary, #0d6efd), #0b4dc4);
    color: #fff;
    flex-shrink: 0;
}

.chat-header-info { display: flex; align-items: center; gap: 12px; }

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.chat-header-title { font-weight: 600; line-height: 1.2; }

.chat-header-status {
    font-size: .78rem;
    opacity: .9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.chat-close-btn {
    background: rgba(255, 255, 255, .15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s ease;
    flex-shrink: 0;
}

.chat-close-btn:hover { background: rgba(255, 255, 255, .28); }

/* ------------------------------------------------------------------
   Тело чата
------------------------------------------------------------------ */
.chat-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: #f6f8fb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message { display: flex; }
.chat-message.user { justify-content: flex-end; }

.chat-message .message-content {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.45;
}

.chat-message.bot .message-content {
    background: #fff;
    border: 1px solid #e7ebf1;
    border-bottom-left-radius: 4px;
}

.chat-message.user .message-content {
    background: var(--bs-primary, #0d6efd);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: .68rem;
    opacity: .6;
    margin-top: 4px;
}

.message-link { color: inherit; text-decoration: underline; font-weight: 600; }
.chat-message.bot .message-link { color: var(--bs-primary, #0d6efd); }

/* ==================================================================
   СТАРТОВЫЙ СПИСОК ТЕМ — селектор по id #quickQuestions
   (а не по классу), чтобы гарантированно сработать вне зависимости
   от фактического класса на элементе. Усилено !important — перебивает
   глобальные стили сайта (Bootstrap/тема), из-за которых кнопки
   схлопывались в горизонтальную полоску.
================================================================== */
.chat-window #quickQuestions {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 320px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    gap: 6px !important;
    background: #fff !important;
    border: 1px solid #e7ebf1 !important;
    border-radius: 14px !important;
    padding: 6px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.chat-window #quickQuestions::-webkit-scrollbar {
    width: 5px !important;
    height: 0 !important;
}

.chat-window #quickQuestions::-webkit-scrollbar-thumb {
    background: #d7dee7 !important;
    border-radius: 999px !important;
}

.chat-window #quickQuestions .quick-question-btn {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    text-align: left !important;
    white-space: normal !important;
    background: transparent !important;
    background-image: none !important;
    border: none !important;
    border-radius: 10px !important;
    padding: 10px !important;
    margin: 0 !important;
    font-size: .84rem !important;
    font-family: inherit !important;
    font-weight: 400 !important;
    line-height: 1.3 !important;
    color: #22293a !important;
    cursor: pointer !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    box-shadow: none !important;
    outline: none !important;
    min-height: 44px !important;
    text-decoration: none !important;
}

.chat-window #quickQuestions .quick-question-btn:hover {
    background: #eef4ff !important;
}

.chat-window #quickQuestions .qqb-icon {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    flex-shrink: 0 !important;
    border-radius: 9px !important;
    background: #eef4ff !important;
    color: var(--bs-primary, #0d6efd) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1rem !important;
    transition: background .15s ease, color .15s ease;
}

.quick-question-btn:hover .qqb-icon {
    background: var(--bs-primary, #0d6efd) !important;
    color: #fff !important;
}

.chat-window #quickQuestions .qqb-text {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    white-space: normal !important;
    word-break: break-word !important;
    display: block !important;
    text-align: left !important;
}

.chat-window #quickQuestions .qqb-arrow {
    flex-shrink: 0 !important;
    color: #c4cbd6 !important;
    font-size: .78rem !important;
    transition: transform .15s ease, color .15s ease;
}

.quick-question-btn:hover .qqb-arrow {
    color: var(--bs-primary, #0d6efd) !important;
    transform: translateX(2px);
}

/* ==================================================================
   Чипы «похожие вопросы» после каждого ответа бота —
   компактные, в один горизонтальный ряд со скроллом.
   (Отдельный контейнер, не #quickQuestions — конфликтов нет.)
================================================================== */
.chat-body .chat-suggestions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 6px !important;
    padding-bottom: 2px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.chat-body .chat-suggestions::-webkit-scrollbar { height: 4px !important; }
.chat-body .chat-suggestions::-webkit-scrollbar-thumb {
    background: #d7dee7 !important;
    border-radius: 999px !important;
}

.chat-body .chat-suggestions .suggestion-chip {
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    white-space: nowrap !important;
    background: #eef4ff !important;
    background-image: none !important;
    border: 1px solid #dce7fb !important;
    border-radius: 999px !important;
    padding: 7px 13px !important;
    margin: 0 !important;
    font-size: .74rem !important;
    font-family: inherit !important;
    color: #22293a !important;
    cursor: pointer !important;
    box-shadow: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.suggestion-chip i { color: var(--bs-primary, #0d6efd); flex-shrink: 0; }

.suggestion-chip:hover {
    background: var(--bs-primary, #0d6efd) !important;
    border-color: var(--bs-primary, #0d6efd) !important;
    color: #fff !important;
}

.suggestion-chip:hover i { color: #fff; }

/* ------------------------------------------------------------------
   Индикатор «печатает…»
------------------------------------------------------------------ */
.typing-indicator { display: flex; gap: 4px; padding: 4px 2px; }

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9aa5b1;
    display: inline-block;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ------------------------------------------------------------------
   Футер / поле ввода
------------------------------------------------------------------ */
.chat-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e7ebf1;
    background: #fff;
    flex-shrink: 0;
}

.chat-menu-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid #e7ebf1;
    border-radius: 50%;
    background: #fff;
    color: var(--bs-primary, #0d6efd);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease;
}

.chat-menu-btn:hover {
    background: #eef4ff;
    border-color: var(--bs-primary, #0d6efd);
}

.chat-input {
    flex: 1;
    border: 1px solid #e7ebf1;
    border-radius: 999px;
    padding: 9px 14px;
    font-size: .88rem;
    outline: none;
    transition: border-color .2s ease;
    min-width: 0; /* чтобы не растягивал футер за пределы окна на мобильных */
}

.chat-input:focus { border-color: var(--bs-primary, #0d6efd); }

.chat-send-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: var(--bs-primary, #0d6efd);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s ease;
}

.chat-send-btn:hover { background: #0b4dc4; }

/* ------------------------------------------------------------------
   Доступность: видимый фокус при клавиатурной навигации
------------------------------------------------------------------ */
.chat-close-btn:focus-visible,
.chat-toggle-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.quick-question-btn:focus-visible,
.suggestion-chip:focus-visible,
.chat-menu-btn:focus-visible,
.chat-send-btn:focus-visible {
    outline: 2px solid var(--bs-primary, #0d6efd) !important;
    outline-offset: 2px;
}

.chat-input:focus-visible {
    outline: none; /* свой border-color на :focus уже есть */
}

/* ------------------------------------------------------------------
   Мобильная адаптация
------------------------------------------------------------------ */
@media (max-width: 480px) {
    .chat-widget-wrapper { right: 12px; bottom: 12px; }

    .chat-toggle-btn {
        width: 64px;
        height: 64px;
        font-size: 1.7rem;
    }

    .chat-window {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 88px;
        max-height: 78vh;
    }

    .chat-window #quickQuestions {
        max-height: 240px !important;
    }
}