/* Основные стили для десктопов */
#chatbot-container {
    /*max-width: 1200px;*/
    width: 85%; /* Увеличиваем ширину до 80% экрана */
    max-height: 80vh;
    min-height: 360px;
    border: 1px solid #ccc;
    padding: 20px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    font-family: Arial, sans-serif;
    margin: 10px auto; /* Центрируем контейнер */
    display: flex;
    flex-direction: column; /* Сообщения и поле ввода располагаются вертикально */
    justify-content: flex-end; /* Поле ввода зафиксировано внизу */
    gap: 20px;
    z-index: 999;
    /* Ширина вертикальной полосы прокрутки */
}

/* Заголовок бота */
h3#custom-title-chatbot-container {
    margin: 10px auto !important;
    transition: opacity 0.5s, transform 0.5s;
}

.fade-up {
    opacity: 0;
    transform: translateY(-20px);
}

/* Область сообщений */
#chatbot-messages {
    display: flex;
    flex-direction: column;
    max-height: 400px; /* Максимальная высота области сообщений */
    /*max-height: 500px;*/ /* Увеличенная максимальная высота */
    overflow-y: auto;
    padding: 0 10px 0 0;
    background-color: #ffffff;
    word-wrap: break-word;
    line-height: 1.5; /* Улучшенная читаемость текста */
    scroll-behavior: smooth;
}

/* Сообщения пользователя */
.user-message {
    align-self: flex-end;
    text-align: left;
    color: #333;
    background-color: #f0f0f0;
    padding: 10px;
    margin: 10px 0;
    border-radius: 5px;
    display: block; /* Сообщение на отдельной строке */
    width: auto;
    max-width: 80%;
    margin-left: auto; /* Выравнивание вправо */
    word-wrap: break-word;
}

/* Сообщения бота */
.bot-message {
    text-align: left;
    color: #333;
    padding: 0 10px 0 0;
    margin: 10px 0;
    border-radius: 10px;
    display: block; /* Сообщение на отдельной строке */
    width: auto;
    max-width: 90%;
    margin-right: auto; /* Выравнивание влево */
    /*white-space: pre-line; /* Отображает переводы строк */
    word-wrap: break-word;
}

/* Контейнер для поля ввода*/
#chatbot-input-container {
    flex-shrink: 0; /* Предотвращает сжатие поля ввода */
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Поле ввода сообщения */
#chatbot-input {
    align-self: flex-end;
    height: auto;
    min-height: 45px; /* Установите желаемую высоту */
    max-height: 200px; /* Максимальная высота, если пользователь вручную изменит размер */
    resize: none;
    padding: 10px;
    border: 1px solid #f0f0f0;
    border-radius: 5px;
    /*box-sizing: border-box;*/
    background-color: #f0f0f0;
    word-wrap: break-word;
    font-size: 14px;
}

#chatbot-input:active {
    border: 1px solid #000;  
}

#chatbot-input:focus {
    outline: none;
    border: 1px solid #000;
}

/* Блок с кнопками*/
#chatbot-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Кнопка закрытия Popup*/
#chatbot-container.popup #chatbot-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    background-color: #f44336;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s;
}

#chatbot-container.popup #chatbot-close:hover {
    background-color: #d32f2f;
}

/* Кнопка очистки сообщений на странице*/
#chatbot-container:not(.popup) #chatbot-close {
    background-color: #f44336;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    padding: 8px 15px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-right: auto; /* Перемещаем кнопку влево */
    margin-left: 0;
    align-self: flex-start;
}

#chatbot-container:not(.popup) #chatbot-close:hover {
    background-color: #d32f2f;
}

/* Кнопка отправки */
#chatbot-send {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    color: #fff; /* Цвет текста — белый */
    background-color: #d7d7d7; /* Фон неактивной кнопки */
    border: 2px solid #d7d7d7;
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    width: 45px;
    height: 45px;
    transition: background-color 0.3s;
    flex-shrink: 0;
    cursor: not-allowed;
    /*font-size: 16px;
    gap: 10px; /* Отступ между иконкой и текстом */
}

#chatbot-send.active {
    background-color: #000; /* Цвет кнопки при активном поле ввода */
    cursor: pointer;
    border: 2px solid #d7d7d7; /* Изменяем курсор на указатель */
}

/* Иконка стрелки вверх */
#chatbot-send i {
    color: #fff; /* Белый цвет иконки */
    font-size: 20px; /* Размер иконки */
}

/* Стили кнопки в состоянии загрузки */
#chatbot-send.loading {
    background-color: #000;
    border: 1px solid #d7d7d7;
}

#chatbot-send.loading i {
    color: #fff;
    font-size: 16px;
    content: "\f04d"; /* Иконка квадрата (Font Awesome: fa-solid fa-stop) */
}

/* Кнопка отправки в Popup*/
#chatbot-container #chatbot-controls {
    display: flex;
    justify-content: flex-end; /* Выравнивание кнопки справа */
    align-items: center;
    gap: 10px; /* Отступ между полем ввода и кнопкой */
}


/* Скроллбар для области сообщений */
#chatbot-messages::-webkit-scrollbar {
    width: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background-color: #d7d7d7;
    border-radius: 10px;
}

#chatbot-messages {
    scrollbar-width: thin; /* Возможные значения: auto, thin, none */
    scrollbar-color: #d7d7d7 transparent; /* Первый цвет для ползунка, второй для трека */
    border-radius: 10px;
}

/*Информация внизу контейнера*/
#chatbot-custom-info {
    margin: 0 auto;
    font-size: 10px;
    text-align: center;
}

/* Адаптивные стили для планшетов (максимальная ширина 768px) */
@media (max-width: 768px) {
    #chatbot-container {
        max-width: 100%;
        width: 90%;
        max-height: 80vh;
        min-height: 400px;
        padding: 15px;
        margin: 20px 20px 0 10px;
        font-size: 14px;
    }
    
    #chatbot-container.popup #chatbot-close {
        position: absolute;
        top: 0;
        right: 0;
    }

    #chatbot-messages {
        /*max-height: 300px;*/
    }

    #chatbot-input {
        padding: 10px;
        word-wrap: break-word;
        font-size: 14px;
    }

    #chatbot-send {
        padding: 12px;
        width: 45px;
        height: 45px;
    }

    #chatbot-container:not(.popup) #chatbot-close {
        width: 45px;
        height: 45px;
        padding: 0;
        font-size: 18px;
        margin-right: auto; /* Перемещаем кнопку влево */
        margin-left: 0;
        align-self: flex-start;
    }
    /*Информация внизу контейнера*/
    #chatbot-custom-info {
        margin: 0 auto;
        font-size: 10px;
        text-align: center;
    }
}

/* Адаптивные стили для мобильных устройств (максимальная ширина 480px) */
@media (max-width: 480px) {
    #chatbot-container {
        max-width: 95%;
        width: 90%;
        min-height: 350px;
        max-height: 80vh;
        padding: 10px;
        margin: 20px 20px 0 10px;
        font-size: 14px;
    }
    /* Кнопка закрыть Popup */
    #chatbot-container.popup #chatbot-close {
        position: absolute;
        top: 0;
        right: 0;
    }

    /* Заголовок бота */
    #custom-title-chatbot-container {
        margin: 10px auto;
    }

    #chatbot-messages {
        /*max-height: 400px;*/
    }

    #chatbot-input {
        padding: 10px;
        word-wrap: break-word;
        font-size: 14px;
    }

    #chatbot-send {
        padding: 8px;
        width: 40px;
        height: 40px;
    }

    #chatbot-send.loading i {
        color: #fff;
        font-size: 16px;
        content: "\f04d"; /* Иконка квадрата (Font Awesome: fa-solid fa-stop) */
    }  
    
    /* Кнопка закрыть */
    #chatbot-container:not(.popup) #chatbot-close {
        width: 40px;
        height: 40px;
        padding: 0;
        font-size: 18px;
        margin-right: auto; /* Перемещаем кнопку влево */
        margin-left: 0;
        align-self: flex-start;
    }

    .user-message,
    .bot-message {
        max-width: 100%;
        font-size: 14px;
        word-break: break-word;
    }
    /*Информация внизу контейнера*/
    #chatbot-custom-info {
        margin: 0 auto;
        font-size: 10px;
        text-align: center;
    }
}

/* Адаптивные стили для мобильных устройств (максимальная ширина 320px) */
@media (max-width: 320px) {
    h3#custom-title-chatbot-container {
      font-size: 25px;
      margin: 10px auto !important;
    }

    #chatbot-container {
        margin: 20px 20px 0 10px;
    }

    #chatbot-container.popup #chatbot-close {
        position: absolute;
        top: 0;
        right: 0;
    }

    #chatbot-send {
        padding: 8px;
        width: 40px;
        height: 40px;
    }

    /* Кнопка закрыть*/
    #chatbot-container:not(.popup) #chatbot-close {
        width: 40px;
        height: 40px;
        padding: 0;
        font-size: 18px;
        margin-right: auto; /* Перемещаем кнопку влево */
        margin-left: 0;
        align-self: flex-start;
    }
    /*Информация внизу контейнера*/
    #chatbot-custom-info {
        margin: 0 auto;
        font-size: 10px;
        text-align: center;
    }
  }