/* Общие стили */
body {
    font-family: 'Roboto', sans-serif;
}

.hidden {
    display: none !important;
}

/* Кнопка открытия чата */
#chat-toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #0753FF; /* Фирменный синий */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
    z-index: 9998;
}

#chat-toggle-button:hover {
    transform: scale(1.1);
}

/* Контейнер виджета */
#chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 370px;
    height: 80vh;
    max-height: 600px;
    background-color: #f9f9f9;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
    transform-origin: bottom right;
    z-index: 9999;
}

/* Анимация появления */
#chat-widget-container.hidden {
    opacity: 0;
    transform: scale(0.5);
}

/* Шапка чата */
.chat-header {
    background-color: #003366; /* Темно-синий */
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

#chat-close-button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 24px;
}

/* Область сообщений */
.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user {
    background-color: #0753FF;
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.message.bot {
    background-color: #e5e5ea;
    color: #333;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

/* Карточки товаров в сообщении бота */
.product-card-widget {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
    font-size: 14px;
}

.product-card-widget a {
    text-decoration: none;
    color: #0753FF;
    font-weight: bold;
}

.product-card-widget p {
    margin: 4px 0 0;
    font-size: 12px;
    color: #555;
}

/* Индикатор печати */
#chat-typing-indicator {
    display: flex;
    padding: 10px 20px;
}
#chat-typing-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ccc;
    margin: 0 3px;
    animation: typing 1.4s infinite;
}
#chat-typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
#chat-typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Форма ввода */
.chat-form {
    display: flex;
    padding: 15px;
    border-top: 1px solid #ddd;
    background-color: #fff;
}

#chat-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 15px;
    outline: none;
}

#chat-input:focus {
    border-color: #0753FF;
}

.chat-form button {
    background: #0753FF;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Адаптивность */
@media (max-width: 480px) {
    #chat-widget-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
}

/* --- Уменьшение шрифтов в виджете --- */

/* Устанавливаем базовый размер шрифта для всего виджета */
#chat-widget-container {
    font-size: 15px; /* Стандартный и комфортный размер для чтения */
}

/* Уменьшаем заголовок */
.chat-header h3 {
    font-size: 1.1rem; /* ~16.5px, немного крупнее основного текста */
}

/* Уменьшаем текст в сообщениях */
.message {
    font-size: 0.95rem; /* ~14px, делаем текст компактнее */
    line-height: 1.45;  /* Увеличиваем межстрочный интервал для читаемости */
}

/* Уменьшаем текст в поле ввода */
#chat-input {
    font-size: 0.95rem; /* ~14px, как и в сообщениях */
}

/* Уменьшаем текст в карточках товаров */
.product-card-widget {
    font-size: 0.85rem; /* ~13px, делаем текст в карточках еще меньше */
}