/* Базовые стили */
#ba-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Кнопка включения виджета (круглая, меньше, текст Ai) */
#ba-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0073aa;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
#ba-toggle:hover {
    transform: scale(1.05);
    background: #005a87;
}

/* Окно чата */
#ba-window {
    display: none;
    flex-direction: column;
    width: 380px;
    height: 520px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    right: 0;
    border: 1px solid #e0e0e0;
}
#ba-window.ba-window-open {
    display: flex !important;
}

#ba-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    flex-shrink: 0;
    background: #0073aa;
    color: #fff;
}
#ba-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

#ba-messages {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 16px;
    overflow-y: auto !important;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}
#ba-messages .bot-msg {
    background: #e9ecef;
    padding: 10px 14px;
    border-radius: 12px 12px 12px 0;
    max-width: 85%;
    align-self: flex-start;
    white-space: pre-wrap;
    word-break: break-word;
}
#ba-messages .user-msg {
    background: #0073aa;
    color: #fff;
    padding: 10px 14px;
    border-radius: 12px 12px 0 12px;
    max-width: 85%;
    align-self: flex-end;
}
#ba-messages .typing {
    font-style: italic;
    color: #888;
}
#ba-messages .error {
    background: #f8d7da;
    color: #721c24;
}

#ba-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ddd;
    background: #fff;
    flex-shrink: 0;
}
#ba-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
}
#ba-input:focus {
    border-color: #0073aa;
}

/* Кнопка отправки (круглая, меньше, символ V) */
#ba-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-left: 8px;
    background: #0073aa;
    color: #fff;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
#ba-send:hover {
    background: #005a87;
}

#ba-toolbar {
    padding: 8px 10px;
    border-top: 1px solid #eee;
    background: #fafafa;
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}
#ba-send-dialog {
    background: #28a745;
    color: #fff;
    border: none;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
}
#ba-send-dialog:hover {
    background: #218838;
}

/* ------------------------------------------------------------
   АДАПТИВ ДЛЯ ПЛАНШЕТОВ И МОБИЛЬНЫХ
   ------------------------------------------------------------ */
@media (max-width: 768px) {
    #ba-window {
        width: 95vw;
        height: 90vh;
        max-height: 90vh;
        bottom: 5vh;
        right: 2.5vw;
        border-radius: 12px;
    }
    #ba-toggle {
        width: 36px;
        height: 36px;
        font-size: 14px;
        bottom: 16px;
        right: 16px;
    }
}

@media (max-width: 480px) {
    #ba-window {
        width: 98vw;
        height: 95vh;
        max-height: 95vh;
        bottom: 10vh; /* увеличенный отступ снизу, чтобы не перекрывать toggle */
        right: 1vw;
        border-radius: 8px;
    }
    #ba-toggle {
        width: 36px;
        height: 36px;
        font-size: 14px;
        bottom: 12px;
        right: 12px;
    }
    #ba-header {
        padding: 10px 14px;
        font-size: 16px;
    }
    #ba-close {
        font-size: 24px;
    }
    #ba-messages {
        padding: 10px 12px;
    }
    #ba-input {
        font-size: 16px;
        padding: 12px 14px;
    }
    #ba-send {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    #ba-send-dialog {
        font-size: 14px;
        padding: 8px 16px;
    }
}