/* --- ПЕРЕМЕННЫЕ КАПИТАНА ВЕСЕЛЬЧАК ЧАК --- */
:root {
    --bg-main: #0a0e1a;         /* Глубина океана */
    --bg-sidebar: #070a12;      /* Бездна */
    --bg-bubble-bot: #151c2e;   /* Тёмная палуба */
    --accent-gold: #d4af37;     /* Сокровища */
    --accent-gold-dim: #a68a2d; 
    --text-gold: #d4af37;
    --text-muted: #7a8a9a;
    --danger: #ff4a4a;
    --border: rgba(212, 175, 55, 0.3);
}

/* --- ОБЩИЕ ПРАВИЛА --- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: var(--accent-gold) !important; border-radius: 10px; }

body {
    background-color: var(--bg-main);
    color: var(--text-gold);
    font-family: 'Segoe UI', Roboto, sans-serif;
    height: 100vh;
    overflow: hidden;
}

.app-layout { display: flex; width: 100vw; height: 100vh; position: relative; }

/* --- САЙДБАР (МЕНЮ) --- */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 2000;
}
.sidebar.collapsed { width: 0; border-right: none; opacity: 0; pointer-events: none; }

.sidebar-header { padding: 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.sidebar-title { color: var(--accent-gold) !important; font-size: 0.8rem; font-weight: bold; letter-spacing: 2px; }

/* Кнопка "Плюс" - всегда золото */
.icon-btn-plus { 
    background: none; 
    border: 1px solid var(--accent-gold); 
    color: var(--accent-gold) !important; 
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer; 
}

.chat-list { flex: 1; overflow-y: auto; padding: 10px; list-style: none; }
.chat-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; margin-bottom: 5px; border-radius: 10px; cursor: pointer; transition: 0.2s; color: var(--text-muted); }
.chat-item.active { background: rgba(212, 175, 55, 0.15); color: var(--accent-gold) !important; border: 1px solid var(--border); }

/* Затемнение фона для мобилок */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 1500; }
.sidebar-overlay.active { display: block; }

/* --- ОСНОВНОЙ ЧАТ --- */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background-color: var(--bg-main); transition: all 0.3s ease; position: relative; }

/* --- ШАПКА (ИСПРАВЛЕННОЕ ПОЗИЦИОНИРОВАНИЕ) --- */
.chat-header { 
    height: 64px; 
    padding: 0 20px; 
    display: flex; 
    align-items: center; 
    justify-content: flex-start; /* Элементы в ряд слева */
    border-bottom: 1px solid var(--border); 
}

.menu-toggle-btn { 
    background: none; border: none; 
    color: var(--accent-gold) !important; 
    font-size: 1.5rem; cursor: pointer; 
    margin-right: 15px; display: flex; align-items: center; 
}

.header-center { display: flex; align-items: center; gap: 12px; }

.header-avatar { 
    width: 40px !important; 
    height: 40px !important; 
    border-radius: 50%; 
    border: 2px solid var(--accent-gold); 
    object-fit: cover; 
    flex-shrink: 0; 
}

.bot-name { color: var(--accent-gold) !important; font-weight: bold; }
.bot-status { font-size: 0.7rem; color: #2ecc71; margin-left: 4px; }

/* Магическая иконка справа */
.header-right { margin-left: auto; display: flex; align-items: center; opacity: 0.3; }

/* --- СООБЩЕНИЯ --- */
.chat-container { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.message { max-width: 85%; display: flex; gap: 12px; }
.bot-message { align-self: flex-start; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }

.message-bubble { padding: 14px; border-radius: 18px; line-height: 1.6; font-size: 0.95rem; word-break: break-word; }
.bot-message .message-bubble { background-color: var(--bg-bubble-bot); border: 1px solid var(--border); color: var(--accent-gold); }
.user-message .message-bubble { background-color: var(--accent-gold); color: #000 !important; font-weight: 500; }

/* --- ЗОНА ВВОДА --- */
.input-area { padding: 15px 20px 25px; background: var(--bg-main); border-top: 1px solid var(--border); }

.input-wrapper { 
    background: var(--bg-sidebar); 
    border: 1px solid var(--border); 
    border-radius: 15px; 
    padding: 8px 12px; /* Увеличили отступы внутри рамки */
    display: flex; 
    align-items: flex-end; 
    gap: 10px; 
    min-height: 50px; /* Минимальная высота всей строки */
}

#user-input { 
    flex: 1; 
    background: transparent; 
    border: none; 
    color: var(--accent-gold) !important; 
    font-size: 1.1rem; /* Сделали текст чуть крупнее */
    line-height: 1.4;  /* Добавили межстрочный интервал */
    resize: none; 
    outline: none; 
    padding: 6px 0;    /* Отступы сверху и снизу текста внутри */
    max-height: 200px; /* Максимальная высота, дальше появится скролл */
    min-height: 24px;  /* Чтобы одна строка была сразу видна полностью */
    font-family: inherit;
}

/* Фикс для иконок внутри ввода, чтобы они не «давили» на текст */
.action-btn { 
    margin-bottom: 4px; /* Приподнимаем иконки чуть выше дна */
    padding: 4px;
}

.send-btn, .abort-btn {
    margin-bottom: 2px;
}

/* Кнопки действий (скрепка, микрофон) */
.action-btn { background: none; border: none; color: var(--accent-gold) !important; font-size: 1.3rem; cursor: pointer; }

/* Кнопка отправить */
.send-btn { 
    background: var(--accent-gold); color: #000; border: none; 
    width: 38px; height: 38px; border-radius: 50%; 
    cursor: pointer; display: flex; align-items: center; justify-content: center; 
}

/* КНОПКА СТОП (КРАСНО-ЗОЛОТАЯ) */
.abort-btn { 
    background: #2a0a0a !important; 
    color: var(--danger) !important; 
    border: 2px solid var(--danger); 
    width: 38px; height: 38px; border-radius: 50%; 
    cursor: pointer; display: flex; align-items: center; justify-content: center; 
    box-shadow: 0 0 10px rgba(255, 74, 74, 0.2);
}

.hidden { display: none !important; }

/* --- МОБИЛЬНАЯ АДАПТАЦИЯ (ШТОРКА) --- */
@media (max-width: 768px) {
    .sidebar { 
        position: fixed; left: 0; top: 0; bottom: 0; 
        width: 80%; /* Сайдбар на 80% экрана */
        max-width: 300px;
        transform: translateX(-100%); 
        z-index: 2000;
        box-shadow: 10px 0 20px rgba(0,0,0,0.5);
    }
    .sidebar.active { transform: translateX(0); }
    
    .chat-main { 
        width: 100vw; 
        flex: none; /* Не даем чату сжиматься */
    }
    
    .message { max-width: 95%; }
}

/* --- КНОПКА УСТАНОВКИ PWA (домик) --- */
.install-hint {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: var(--accent-gold);
    color: #000;
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.5;
    transition: opacity 0.25s, transform 0.2s;
    z-index: 999;
    box-shadow: 0 2px 12px rgba(212, 175, 55, 0.25);
}
.install-hint:hover { opacity: 1; transform: scale(1.1); }
.install-hint:active { transform: scale(0.95); }
.install-hint.hidden { display: none !important; }

/* Тултип-предупреждение для не-Chrome */
.install-toast {
    position: fixed;
    bottom: 80px;
    right: 24px;
    background: #1a0505;
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    max-width: 260px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    line-height: 1.5;
    animation: toast-in 0.3s ease;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* В PWA-режиме кнопка не нужна */
@media all and (display-mode: standalone) {
    .install-hint { display: none !important; }
}