:root {
    /* Светлая тема - белый шоколад и кремовые оттенки */
    --bg-body: #fff9f5; /* Кремовый фон */
    --bg-panel: #fffdf9; /* Почти белый с кремовым оттенком */
    --text-primary: #3a2a23; /* Тёмно-коричневый текст */
    --text-secondary: #7a6558; /* Средне-коричневый второстепенный текст */
    --border-color: #e8d8c5; /* Кремовая граница */
    --btn-bg: #f5e9d9; /* Светло-кремовый фон кнопок */
    --btn-hover-bg: #d4a798; /* Нежно-коричневый при наведении */
    --btn-hover-color: #3a2a23; /* Тёмный текст на кнопках */
    --user-msg-bg: #f0e6d9; /* Кремовый фон сообщений пользователя */
    --bot-msg-bg: #f5f0e6; /* Светло-бежевый фон сообщений бота */
    --input-focus-border: #d4a798; /* Коричневая граница при фокусе */
    --shadow: rgba(58, 42, 35, 0.08); /* Тёмно-коричневая тень */
}

.dark-theme {
    /* Тёмная тема - тёмный шоколад */
    --bg-body: #1a0f0b; /* Тёмно-коричневый фон */
    --bg-panel: #2a1a12; /* Шоколадный фон панелей */
    --text-primary: #f5e9d9; /* Кремовый текст */
    --text-secondary: #c69a5a; /* Золотисто-коричневый второстепенный текст */
    --border-color: #4a3528; /* Тёмная граница */
    --btn-bg: #3a2518; /* Тёмный фон кнопок */
    --btn-hover-bg: #8b5a3d; /* Тёплый коричневый при наведении */
    --btn-hover-color: #f5e9d9; /* Светлый текст на кнопках */
    --user-msg-bg: #3a2a23; /* Тёмно-коричневый фон сообщений пользователя */
    --bot-msg-bg: #35251d; /* Шоколадный фон сообщений бота */
    --input-focus-border: #8b5a3d; /* Золотисто-коричневая граница при фокусе */
    --shadow: rgba(0, 0, 0, 0.4); /* Глубокая тень */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    background: var(--bg-body);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

#chatContainer {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-radius: 1px;
    box-shadow: 0 4px 20px var(--shadow);
    overflow: hidden;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

#chatHeader {
    padding: 16px 20px;
    background: linear-gradient(135deg, #d4a798, #c89b8c); /* Нежно-коричневый градиент */
    color: #3a2a23; /* Тёмный текст для контраста */
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(58, 42, 35, 0.15);
    height: 60px;
    position: relative;
}

.dark-theme #chatHeader {
    background: linear-gradient(135deg, #8b5a3d, #7a4a2f); /* Тёплый шоколадный градиент */
    color: #f5e9d9; /* Светлый текст */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Три колонки: левая (название), центр (индикатор), правая (кнопка) */
.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
}

.header-center {
    display: flex;
    justify-content: center;
    flex: 1;
    min-width: 100px;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 40px;
}

/* Индикатор пинга с эмодзи */
#pingIndicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.3);
    padding: 5px 12px;
    border-radius: 20px;
    color: #3a2a23;
    white-space: nowrap;
    border: 1px solid rgba(232, 216, 197, 0.5);
    font-weight: 500;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.dark-theme #pingIndicator {
    background: rgba(0, 0, 0, 0.3);
    color: #f5e9d9;
    border: 1px solid rgba(74, 53, 40, 0.7);
}

#pingDot {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

#themeToggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: #3a2a23;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}

.dark-theme #themeToggle {
    background: rgba(0, 0, 0, 0.3);
    color: #f5e9d9;
}

#themeToggle:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.dark-theme #themeToggle:hover {
    background: rgba(0, 0, 0, 0.4);
}

#chatBox {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--bg-panel);
    transition: background-color 0.3s ease;
}

.message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    max-width: 85%;
    position: relative;
    animation: fadeIn 0.3s ease;
    transition: background-color 0.3s ease, color 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user {
    background: var(--user-msg-bg);
    margin-left: auto;
    text-align: right;
    border-bottom-right-radius: 4px;
    color: var(--text-primary);
}

.bot {
    background: var(--bot-msg-bg);
    margin-right: auto;
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.message strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    opacity: 0.8;
    color: var(--text-secondary);
}

.thinking {
    background: var(--bot-msg-bg);
    margin-right: auto;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.meta {
    margin-top: 8px;
    text-align: right;
    font-size: 11px;
    color: var(--text-secondary);
}

.feedback-buttons {
    margin-top: 8px;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-feedback {
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-feedback-good {
    background: #e8f5e9; /* Светло-зелёный */
    color: #2e7d32; /* Тёмно-зелёный */
}

.dark-theme .btn-feedback-good {
    background: #2e7d32; /* Тёмно-зелёный */
    color: #e8f5e9; /* Светлый текст */
}

.btn-feedback-good:hover {
    background: #c8e6c9;
    transform: scale(1.05);
}

.dark-theme .btn-feedback-good:hover {
    background: #4caf50;
}

.btn-feedback-bad {
    background: #ffebee; /* Светло-красный */
    color: #c62828; /* Тёмно-красный */
}

.dark-theme .btn-feedback-bad {
    background: #c62828; /* Тёмно-красный */
    color: #ffebee; /* Светлый текст */
}

.btn-feedback-bad:hover {
    background: #ffcdd2;
    transform: scale(1.05);
}

.dark-theme .btn-feedback-bad:hover {
    background: #e53935;
}

.input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-panel);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    height: 40px;
    min-height: 40px;
    padding: 12px 16px;
    font-size: 14px;
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

#userInput:focus {
    outline: none;
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px rgba(212, 167, 152, 0.2);
}

.dark-theme #userInput:focus {
    box-shadow: 0 0 0 3px rgba(139, 90, 61, 0.3);
}

#clearBtn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f5e9d9, #e8d8c5);
    border: 2px solid var(--border-color);
    color: #3a2a23;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#clearBtn:hover {
    background: linear-gradient(135deg, #d4a798, #c89b8c);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(212, 167, 152, 0.4);
}

.dark-theme #clearBtn {
    background: linear-gradient(135deg, #3a2518, #2a1a12);
    border-color: #4a3528;
    color: #f5e9d9;
}

.dark-theme #clearBtn:hover {
    background: linear-gradient(135deg, #8b5a3d, #7a4a2f);
    color: white;
    box-shadow: 0 2px 8px rgba(139, 90, 61, 0.5);
}

#sendBtn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d4a798, #c89b8c);
    color: #3a2a23;
    border: none;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(212, 167, 152, 0.3);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sendBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(212, 167, 152, 0.4);
}

.dark-theme #sendBtn {
    background: linear-gradient(135deg, #8b5a3d, #7a4a2f);
    color: #f5e9d9;
    box-shadow: 0 2px 8px rgba(139, 90, 61, 0.4);
}

.dark-theme #sendBtn:hover {
    box-shadow: 0 4px 12px rgba(139, 90, 61, 0.5);
}

#sendBtn:active {
    transform: scale(0.95);
}

/* Стили для калорийного ховера */
.kcal-calc {
    cursor: help;
    position: relative;
    display: inline-block;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
    transition: all 0.2s ease;
}

.kcal-calc:hover {
    background: rgba(212, 167, 152, 0.2);
    border-radius: 4px;
    padding: 0 4px;
}

.kcal-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: linear-gradient(135deg, #d4a798, #c89b8c);
    color: #3a2a23;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(58, 42, 35, 0.3);
    z-index: 100;
    transition: all 0.2s ease;
    pointer-events: none;
}

.kcal-calc:hover .kcal-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.dark-theme .kcal-tooltip {
    background: linear-gradient(135deg, #8b5a3d, #7a4a2f);
    color: #f5e9d9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Стили для уведомлений */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #d4a798, #c89b8c);
    color: #3a2a23;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(58, 42, 35, 0.3);
    z-index: 10000;
    font-weight: 500;
    font-size: 14px;
    animation: slideIn 0.3s ease, fadeOut 0.5s 2.5s ease forwards;
}

.dark-theme .notification {
    background: linear-gradient(135deg, #8b5a3d, #7a4a2f);
    color: #f5e9d9;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
    transition: background-color 0.3s ease;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
    transition: background-color 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.dark-theme ::-webkit-scrollbar-track {
    background: var(--bg-body);
}

.dark-theme ::-webkit-scrollbar-thumb {
    background: #4a3528;
}

.dark-theme ::-webkit-scrollbar-thumb:hover {
    background: #c69a5a;
}