/* Основной контейнер чата */
#n8n-chat-widget {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 99999 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* Кнопка открытия чата */
.chat-toggle-btn {
    width: 60px !important;
    height: 60px !important;
    background: #007cba !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
    color: white !important;
    font-size: 24px !important;
    transition: all 0.3s ease !important;
    border: none !important;
    outline: none !important;
}

.chat-toggle-btn:hover {
    background: #005a87 !important;
    transform: scale(1.05) !important;
}

/* Контейнер чата */
.chat-container {
    position: absolute !important;
    bottom: 70px !important;
    right: 0 !important;
    width: 350px !important;
    height: 500px !important;
    background: white !important;
    border: 1px solid #ddd !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    font-size: 14px !important;
}

/* Заголовок чата */
.chat-header {
    padding: 15px !important;
    background: #007cba !important;
    color: white !important;
    border-radius: 12px 12px 0 0 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    min-height: 50px !important;
    box-sizing: border-box !important;
}

.chat-header h4 {
    margin: 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: white !important;
}

.chat-close {
    cursor: pointer !important;
    font-size: 24px !important;
    font-weight: bold !important;
    color: white !important;
    line-height: 1 !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.chat-close:hover {
    background: rgba(255,255,255,0.2) !important;
    border-radius: 50% !important;
}

/* Область сообщений */
.chat-messages {
    flex: 1 !important;
    padding: 15px !important;
    overflow-y: auto !important;
    background: #f9f9f9 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
}

/* Стили для скроллбара */
.chat-messages::-webkit-scrollbar {
    width: 6px !important;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1 !important;
    border-radius: 3px !important;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8 !important;
}

/* Сообщения */
.message {
    margin: 5px 0 !important;
    display: flex !important;
    max-width: 100% !important;
    word-wrap: break-word !important;
}

.message.user {
    justify-content: flex-end !important;
}

.message.bot {
    justify-content: flex-start !important;
}

.message span {
    padding: 10px 14px !important;
    border-radius: 18px !important;
    max-width: 85% !important;
    word-wrap: break-word !important;
    line-height: 1.4 !important;
    font-size: 14px !important;
}

.message.user span {
    background: #007cba !important;
    color: white !important;
    border-bottom-right-radius: 4px !important;
}

.message.bot span {
    background: white !important;
    color: #333 !important;
    border: 1px solid #e1e5e9 !important;
    border-bottom-left-radius: 4px !important;
}

.message.bot.typing span {
    background: #e0e0e0 !important;
    font-style: italic !important;
    color: #666 !important;
}

/* Область ввода */
.chat-input-container {
    padding: 15px !important;
    border-top: 1px solid #e1e5e9 !important;
    background: white !important;
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
}

#chat-input {
    flex: 1 !important;
    padding: 12px 16px !important;
    border: 1px solid #ddd !important;
    border-radius: 24px !important;
    outline: none !important;
    font-size: 14px !important;
    font-family: inherit !important;
    background: white !important;
    color: #333 !important;
    box-sizing: border-box !important;
}

#chat-input:focus {
    border-color: #007cba !important;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2) !important;
}

#chat-input::placeholder {
    color: #999 !important;
}

#chat-send {
    padding: 12px 16px !important;
    background: #007cba !important;
    color: white !important;
    border: none !important;
    border-radius: 24px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    transition: background 0.2s ease !important;
    white-space: nowrap !important;
    outline: none !important;
}

#chat-send:hover {
    background: #005a87 !important;
}

#chat-send:active {
    transform: scale(0.98) !important;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 480px) {
    #n8n-chat-widget {
        bottom: 10px !important;
        right: 10px !important;
    }
    
    .chat-container {
        width: calc(100vw - 20px) !important;
        height: calc(100vh - 100px) !important;
        right: -15px !important;
        bottom: 70px !important;
    }
    
    .chat-toggle-btn {
        width: 55px !important;
        height: 55px !important;
        font-size: 22px !important;
    }
}

/* Анимации */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-container {
    animation: slideUp 0.3s ease-out !important;
}

/* Скрытие элементов */
.chat-container[style*="display: none"] {
    display: none !important;
}

/* Переопределение стилей темы WordPress */
#n8n-chat-widget * {
    box-sizing: border-box !important;

}

#n8n-chat-widget a {
    text-decoration: none !important;
}

#n8n-chat-widget button {
    background: none !important;
    border: none !important;
    cursor: pointer !important;
}

#n8n-chat-widget {
    position: fixed !important;
    bottom: 20px !important;
    left: 20px !important;  /* ИЗМЕНЕНО: переносим влево */
    right: auto !important;
    z-index: 99999 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
}

/* Контейнер чата - тоже корректируем позицию */
.chat-container {
    position: absolute !important;
    bottom: 70px !important;
    left: 0 !important;  /* ИЗМЕНЕНО: чат открывается слева */
    right: auto !important;
    width: 350px !important;
    height: 500px !important;
    background: white !important;
    border: 1px solid #ddd !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    font-size: 14px !important;
}