.gos-ai {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

/* =========================================================
   КНОПКА-МАСКОТ
   ========================================================= */

.gos-ai-toggle {
    position: relative;
    width: 94px;
    height: 94px;
    min-width: 94px;
    padding: 0;
    border: 2px solid rgba(31, 77, 151, 0.14);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.97);
    cursor: pointer;
    box-shadow:
        0 14px 34px rgba(15, 42, 88, 0.18),
        0 4px 12px rgba(15, 42, 88, 0.10);
    transition:
        transform 0.20s ease,
        box-shadow 0.20s ease,
        border-color 0.20s ease;
}

.gos-ai-toggle:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: rgba(31, 77, 151, 0.30);
    box-shadow:
        0 18px 40px rgba(15, 42, 88, 0.22),
        0 6px 15px rgba(15, 42, 88, 0.12);
}

.gos-ai-toggle:active {
    transform: translateY(-1px) scale(0.99);
}

.gos-ai-mascot {
    width: 86px;
    height: 86px;
    display: block;
    margin: 2px auto 0;
    object-fit: contain;
    pointer-events: none;
    animation: gos-ai-mascot-idle 4.8s ease-in-out infinite;
}

/* Надпись больше не нужна: сам барс является кнопкой. */
.gos-ai-toggle-text {
    display: none;
}

@keyframes gos-ai-mascot-idle {
    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-3px) rotate(0.7deg);
    }
}

/* =========================================================
   ОКНО ЧАТА
   ========================================================= */

.gos-ai-panel {
    width: min(410px, calc(100vw - 28px));
    height: min(590px, calc(100vh - 90px));
    border: 1px solid rgba(31, 77, 151, 0.16);
    border-radius: 24px;
    overflow: hidden;
    background: #f7f9fd;
    box-shadow:
        0 26px 70px rgba(13, 35, 73, 0.24),
        0 8px 24px rgba(13, 35, 73, 0.10);
}

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

.gos-ai-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #214f9b 0%, #173b7b 100%);
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.gos-ai-header::before {
    content: "";
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background:
        #ffffff
        url("/ai_chatbot/img/consultant.webp")
        center / 43px 43px
        no-repeat;
    box-shadow:
        0 3px 10px rgba(0, 0, 0, 0.16),
        inset 0 0 0 1px rgba(31, 77, 151, 0.12);
}

.gos-ai-header strong {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 18px;
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: 0.1px;
}

.gos-ai-close {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.13);
    color: #ffffff;
    font-size: 27px;
    line-height: 1;
    cursor: pointer;
    transition:
        background 0.18s ease,
        transform 0.18s ease;
}

.gos-ai-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: rotate(90deg);
}

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

.gos-ai-messages {
    height: calc(100% - 164px);
    overflow-y: auto;
    padding: 18px 16px;
    background:
        radial-gradient(circle at 90% 0%, rgba(33, 79, 155, 0.055), transparent 34%),
        linear-gradient(180deg, #f8fbff 0%, #f4f7fb 100%);
    scrollbar-width: thin;
    scrollbar-color: #bfccdc transparent;
}

.gos-ai-messages::-webkit-scrollbar {
    width: 7px;
}

.gos-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.gos-ai-messages::-webkit-scrollbar-thumb {
    background: #bfccdc;
    border-radius: 10px;
}

.gos-ai-message {
    max-width: 88%;
    margin: 0 0 13px;
    padding: 12px 14px;
    border-radius: 18px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.55;
    box-sizing: border-box;
}

.gos-ai-message.bot {
    margin-right: auto;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid #dce5f1;
    color: #26354a;
    border-top-left-radius: 8px;
    box-shadow: 0 5px 18px rgba(30, 54, 91, 0.065);
}

.gos-ai-message.user {
    margin-left: auto;
    background: linear-gradient(135deg, #2857a5 0%, #194488 100%);
    color: #ffffff;
    border: 0;
    border-top-right-radius: 8px;
    box-shadow: 0 7px 18px rgba(25, 68, 136, 0.16);
}

.gos-ai-message.waiting {
    opacity: 0.78;
    font-style: italic;
}

.gos-ai-message-text {
    white-space: pre-wrap;
}

/* =========================================================
   ИСТОЧНИКИ
   ========================================================= */

.gos-ai-sources {
    margin-top: 13px;
    padding-top: 11px;
    border-top: 1px solid rgba(23, 59, 123, 0.12);
}

.gos-ai-sources-title {
    margin-bottom: 7px;
    color: #718096;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gos-ai-source-link {
    position: relative;
    display: block;
    margin-top: 6px;
    padding: 8px 10px 8px 28px;
    border: 1px solid #e1e8f2;
    border-radius: 10px;
    background: #f8fbff;
    color: #174a95;
    font-size: 13px;
    font-weight: 650;
    line-height: 1.35;
    text-decoration: none;
    overflow-wrap: anywhere;
    transition:
        background 0.16s ease,
        border-color 0.16s ease,
        transform 0.16s ease;
}

.gos-ai-source-link::before {
    content: "↗";
    position: absolute;
    left: 10px;
    top: 8px;
    font-size: 13px;
    font-weight: 800;
}

.gos-ai-source-link:hover {
    background: #f1f6fd;
    border-color: #cbd9eb;
    transform: translateY(-1px);
    text-decoration: none;
}

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

.gos-ai-form {
    height: 92px;
    display: flex;
    gap: 10px;
    align-items: stretch;
    padding: 11px 12px;
    border-top: 1px solid #dfe7f1;
    background: rgba(255, 255, 255, 0.98);
    box-sizing: border-box;
}

.gos-ai .gos-ai-form textarea {
    min-width: 0;
    flex: 1 1 auto;
    resize: none;
    border: 1px solid #cbd7e7 !important;
    border-radius: 16px !important;
    padding: 12px 14px !important;
    background: #ffffff !important;
    color: #26354a !important;
    font: inherit !important;
    line-height: 1.4 !important;
    outline: none !important;
    box-shadow: none !important;
    box-sizing: border-box;
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease !important;
}

.gos-ai .gos-ai-form textarea:focus {
    border-color: #2b5aa5 !important;
    box-shadow: 0 0 0 3px rgba(43, 90, 165, 0.10) !important;
}

.gos-ai .gos-ai-form textarea::placeholder {
    color: #8a98ab;
}

.gos-ai .gos-ai-form button {
    flex: 0 0 auto;
    min-width: 116px;
    border: 0 !important;
    border-radius: 16px !important;
    padding: 0 18px !important;
    background: linear-gradient(135deg, #2857a5 0%, #194488 100%) !important;
    color: #ffffff !important;
    font-size: 15px !important;
    font-weight: 750 !important;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(25, 68, 136, 0.16) !important;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        opacity 0.18s ease;
}

.gos-ai .gos-ai-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 11px 24px rgba(25, 68, 136, 0.21) !important;
}

.gos-ai .gos-ai-form button:disabled {
    opacity: 0.58;
    cursor: default;
    transform: none;
    box-shadow: none !important;
}

/* =========================================================
   МОБИЛЬНАЯ ВЕРСИЯ
   ========================================================= */

@media (max-width: 520px) {
    .gos-ai {
        right: 10px;
        bottom: 10px;
    }

    .gos-ai-toggle {
        width: 82px;
        height: 82px;
        min-width: 82px;
    }

    .gos-ai-mascot {
        width: 75px;
        height: 75px;
    }

    .gos-ai-panel {
        width: calc(100vw - 20px);
        height: min(590px, calc(100dvh - 20px));
        border-radius: 20px;
    }

    .gos-ai-header {
        min-height: 66px;
        padding: 10px 12px;
    }

    .gos-ai-header::before {
        flex-basis: 42px;
        width: 42px;
        height: 42px;
        background-size: 39px 39px;
    }

    .gos-ai-header strong {
        font-size: 17px;
    }

    .gos-ai-messages {
        height: calc(100% - 156px);
        padding: 14px 12px;
    }

    .gos-ai-message {
        max-width: 91%;
        font-size: 14px;
    }

    .gos-ai-form {
        height: 90px;
        gap: 8px;
        padding: 10px;
    }

    .gos-ai .gos-ai-form button {
        min-width: 105px;
        padding: 0 14px !important;
        font-size: 14px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gos-ai-mascot {
        animation: none;
    }

    .gos-ai-toggle,
    .gos-ai-close,
    .gos-ai-source-link,
    .gos-ai .gos-ai-form button {
        transition: none;
    }
}


/* =========================================================
   ПРИВЕТСТВИЕ МАСКОТА
   Добавить в конец текущего widget.css
   ========================================================= */

.gos-ai-invite {
    position: absolute;
    right: 104px;
    bottom: 18px;
    z-index: 2;
    width: max-content;
    max-width: 220px;
    padding: 10px 14px;
    border: 1px solid #d9e4f2;
    border-radius: 16px 16px 4px 16px;
    background: #ffffff;
    color: #26354a;
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(15, 42, 88, 0.16);
    opacity: 0;
    transform: translateX(8px) scale(0.97);
    transform-origin: right bottom;
    pointer-events: none;
    transition: opacity 0.20s ease, transform 0.20s ease;
}

.gos-ai-invite::after {
    content: "";
    position: absolute;
    right: -8px;
    bottom: 15px;
    width: 15px;
    height: 15px;
    background: #ffffff;
    border-top: 1px solid #d9e4f2;
    border-right: 1px solid #d9e4f2;
    transform: rotate(45deg);
}

.gos-ai-invite.is-visible {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

.gos-ai-toggle.gos-ai-hello .gos-ai-mascot {
    animation: gos-ai-mascot-hello 0.62s ease-in-out 2;
}

@keyframes gos-ai-mascot-hello {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }

    35% {
        transform: translateY(-6px) rotate(-3deg);
    }

    70% {
        transform: translateY(-2px) rotate(3deg);
    }
}

@media (max-width: 520px) {
    .gos-ai-invite {
        right: 90px;
        bottom: 13px;
        max-width: min(205px, calc(100vw - 125px));
        padding: 9px 12px;
        font-size: 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gos-ai-toggle.gos-ai-hello .gos-ai-mascot {
        animation: none;
    }
}
