/* --- Сброс и базовые стили --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* --- Контейнер чата --- */
.chat-container {
    width: 100%;
    max-width: 520px;
    height: 90vh;
    max-height: 700px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Заголовок --- */
.chat-header {
    background: #1e3a5f;
    color: #fff;
    padding: 16px 20px;
    text-align: center;
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.chat-header p {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
}

/* --- Область сообщений --- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fafafa;
}

/* --- Сообщения --- */
.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.45;
    font-size: 14px;
    word-break: break-word;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.message.bot {
    align-self: flex-start;
    background: #e8eef5;
    color: #1e1e1e;
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: #1e3a5f;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.system {
    align-self: center;
    background: #f5f5f5;
    color: #888;
    font-size: 12px;
    font-style: italic;
    border-radius: 8px;
}

/* --- Списки в сообщениях бота: маркеры не выходят за левое поле текста --- */
.message ul,
.message ol {
    padding-left: 20px;
    margin: 4px 0;
}

.message li {
    margin: 2px 0;
}

/* --- Индикатор набора ответа (typing) --- */
.message.typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.message.typing .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9aa7b5;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.message.typing .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.message.typing .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* --- Кнопки в сообщениях бота --- */
.message .buttons {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.message .buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, transform 0.1s;
}

.message .buttons button:hover {
    transform: scale(1.03);
}

.message .buttons button.primary {
    background: #1e3a5f;
    color: #fff;
}

.message .buttons button.primary:hover {
    background: #2a5080;
}

.message .buttons button.secondary {
    background: #e0e0e0;
    color: #333;
}

.message .buttons button.danger {
    background: #fce4e4;
    color: #c0392b;
}

.message .buttons button.danger:hover {
    background: #f5c6c6;
}

/* --- Поле ввода --- */
.chat-input-area {
    display: flex;
    border-top: 1px solid #e0e0e0;
    padding: 10px;
    gap: 8px;
    background: #fff;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border 0.15s;
}

.chat-input-area input:focus {
    border-color: #1e3a5f;
}

.chat-input-area button {
    width: 44px;
    height: 44px;
    border: none;
    background: #1e3a5f;
    color: #fff;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s;
}

.chat-input-area button:hover {
    background: #2a5080;
}