#rag-chat-container {
    max-width: 90%;
    margin: 0 auto;
    border: 1px solid var(--wp--preset--color--primary);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    font-family: 'Inter', 'Nunito', sans-serif;
}

#rag-chat-container #chat-messages {
    height: 400px !important;
    min-height: 200px !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    padding: 20px !important;
    background: #f9f9f9 !important;
    border-bottom: 1px solid #e0e0e0 !important;
}

.chat-message {
    margin-bottom: 12px;
    padding: 10px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 16px;
}

.chat-message.user {
    background: var(--wp--preset--color--primary);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-message.bot {
    background: #e5e5ea;
    color: #1c1c1e;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    overflow-x: auto;
    max-width: 100%;
    box-sizing: border-box;
}

/* Стили для контента внутри сообщений бота (таблицы, графики и т.д.) */
.chat-message.bot table {
    max-width: 100% !important;
    width: auto !important;
    table-layout: auto;
    font-size: 14px;
    border-collapse: collapse;
}

.chat-message.bot table td,
.chat-message.bot table th {
    padding: 6px 10px;
    white-space: nowrap;
}

.chat-message.bot img {
    max-width: 100% !important;
    height: auto !important;
}

.chat-message.bot * {
    max-width: 100%;
    box-sizing: border-box;
}

#chat-input-area {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: #fff;
    border-top: 1px solid var(--wp--preset--color--primary);
}

#user-question {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    resize: vertical;
    font-family: inherit;
    min-height: 60px;
    margin-bottom: 10px;
}

#send-button {
    margin-top: 10px;
    padding: 10px 24px;
    background: var(--wp--preset--color--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    align-self: flex-end;
    transition: background 0.2s;
    font-weight: 600;
}

#send-button:hover {
    background: #005a87;
}

#send-button:disabled {
    background: #999;
    cursor: not-allowed;
}

#chat-loading {
    text-align: center;
    padding: 12px;
    color: #555;
    font-style: italic;
}

/* =============================================
   Стили для страницы recommend (выбор типа)
   ============================================= */

/* Группа radio-кнопок */
#chat-input-area .radio-group {
    display: flex !important;
    gap: 12px !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    margin-bottom: 16px !important;
}

#chat-input-area .radio-group label {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 12px 20px !important;
    background: #f0f4f8 !important;
    border: 2px solid #dde3e9 !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #333 !important;
    line-height: 1.3 !important;
    min-height: 48px !important;
    box-sizing: border-box !important;
    transition: all 0.2s ease;
    user-select: none;
}

#chat-input-area .radio-group label:hover {
    background: #e4eaf1 !important;
    border-color: #b0bec5 !important;
}

#chat-input-area .radio-group input[type="radio"] {
    accent-color: #4a90d9 !important;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    margin: 0 !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
}

#chat-input-area .radio-group label:has(input[type="radio"]:checked) {
    background: #e3edf7 !important;
    border-color: #4a90d9 !important;
    box-shadow: 0 0 0 1px rgba(74, 144, 217, 0.3) !important;
}

/* =============================================
   Переопределение стилей, вставленных из HTML сервера
   (для /summary и /recommend)
   ============================================= */

/* Контейнер сводки — убираем лишние отступы внутри чата */
#rag-chat-container .summary-container {
    max-width: 100% !important;
    padding: 10px !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

/* Заголовок сводки */
#rag-chat-container .header h1 {
    font-size: 20px !important;
}

/* Таблицы recommend — компактный режим */
#rag-chat-container .recommend-table {
    width: 100% !important;
    font-size: 12px !important;
    table-layout: auto !important;
}

#rag-chat-container .recommend-table th,
#rag-chat-container .recommend-table td {
    padding: 5px 4px !important;
    white-space: normal !important;
    word-break: break-word !important;
}

/* Таблицы info-table (для /summary) */
#rag-chat-container .info-table td {
    padding: 6px 4px !important;
    font-size: 13px !important;
}

/* Секторы — компактнее */
#rag-chat-container .sector-title {
    font-size: 15px !important;
    margin: 12px 0 6px 0 !important;
    padding: 4px 0 !important;
}

/* Блоки summary — компактнее */
#rag-chat-container .block {
    padding: 12px !important;
    margin-bottom: 12px !important;
}

/* Адаптивность */
@media (max-width: 768px) {
    #rag-chat-container {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    #chat-input-area .radio-group {
        flex-direction: column !important;
        align-items: stretch !important;
    }
}