	@font-face {/*подключаем нестандартые шрифты*/
		font-family: 'Montserrat';
		src: url('../fonts/Montserrat-Light.ttf');
	}
/* ==========================================
   0. ТЕМЫ (Variables)
   ========================================== */
:root {
    /* Темная тема (по умолчанию) */
    --bg-body: #121212;
    --bg-chat: #1e1e1e;
    --bg-input: #2a2a2a;
    --text-main: #e0e0e0;
    --border-color: #333;
    --msg-model: #333;
    --msg-user: #005c4b;
    --text-user: #ffffff;
    --system-line: #444;
    --btm-clear: #4e4e4e;
    --btm-color: #c4c4c4;

}

[data-theme="light"] {
    /* Светлая тема */
    --bg-body: #f0f2f5;
    --bg-chat: #ffffff;
    --bg-input: #f0f0f0;
    --text-main: #1c1e21;
    --border-color: #ddd;
    --msg-model: #e4e6eb;
    --msg-user: #dcf8c6;
    --text-user: #000000;
    --system-line: #ccc;
    --btm-color: #2c2c2c;
    --btm-clear: #a8a8a8;
}

/* ==========================================
   1. БАЗОВЫЕ НАСТРОЙКИ (Layout)
   ========================================== */
* {
    box-sizing: border-box;
}

html, body {
    height: 100vh; /* Резервный вариант */
    height: 100dvh; /* Динамическая высота */
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; 
    position: relative; /* Вместо fixed */
}

.clear{/* если нужно отделить блоки чистой строкой. Создается класс "clear" это будет пустая строка*/
    clear: both;
}

body { 
    font-family: 'Montserrat', Arial, sans-serif;  
    background: var(--bg-body); 
    color: var(--text-main); 
    /* font-family: sans-serif;  */
    display: flex; 
    justify-content: center; 
    height: 100dvh; 
    width: 100%;
    transition: background 0.3s, color 0.3s; /* Плавный переход тем */
    overscroll-behavior-y: none; /* Запрещает "ерзанье" экрана вверх-вниз */
}


/* Для блока #chat-window */
#chat-window::-webkit-scrollbar {
    width: 6px;
}

#chat-window::-webkit-scrollbar-track {
    background: transparent;
}

#chat-window::-webkit-scrollbar-thumb {
    background-color: var(--system-line); /* Используем ваши переменные */
    border-radius: 10px;
}

/* Найдите ваш класс хедера (например, .header) и добавьте: */
.header {
    background: rgba(30, 30, 30, 0.7); /* Подстройте под темную тему */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}



#header-content {
    /* z-index: 1000; */
    width: 100%;
    position: absolute;
    height: 8vh; /* Заполнение всего пространства хедера */
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* align-items: center; */
    background-color:rgba(0, 0, 0, 0);
    text-align: center;
}


/* ****************ЛОГО **************************/
#header-logo a{/**Текст Малого Лого**/
    font-weight: normal; /* Убирает жирный текст */ 
    color: rgb(221, 221, 221);
    font-size: 3.5vh; 
    font-family: 'Montserrat', Arial, sans-serif;
    text-transform: uppercase;/*Все буквы заглавные */
    text-decoration: none;
    }
#header-logo a span{
    /* font-family: Handwriting_good, larisa-script_rus, Arial, sans-serif; */
    /* font-family: Geosteam-eJap, Times New Roman, Times, serif; */
    color: #e36565;
}
/* *********************************************ЛОГО*/




.chat-container { 
    width: 100%; 
    max-width: 100%; 
    height: 100%;
    max-height: 100dvh; 
    display: flex; 
    flex-direction: column; 
    background: var(--bg-chat); 
    border-left: 1px solid var(--border-color); 
    border-right: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    transition: background 0.3s, border 0.3s;
    position: relative; /* Оставляем, это важно для позиционирования внутри */

    height: 100%;
    overflow-y: auto; /* Разрешаем скролл ТОЛЬКО внутри чата */
    -webkit-overflow-scrolling: touch; /* Делает скролл на смартфонах плавным */
}



#chat-window { 
    flex: 1; 
    overflow-y: auto; 
    padding: 20px; 
    /* Добавляем большой отступ снизу, чтобы последние сообщения 
       не перекрывались "парящим" полем ввода */
    padding-bottom: 120px; 
    scroll-behavior: smooth; 
}


/* ==========================================
   2. СООБЩЕНИЯ (Messages)
   ========================================== */
.message { 
    position: relative; /* Чтобы кнопка позиционировалась внутри сообщения */
    margin-bottom: 15px; 
    padding: 12px 16px;  
    border-radius: 12px; 
    max-width: 85%; 
    line-height: 1.5;
    word-wrap: break-word;
}

/* Добавьте в style.css */
.message {
    animation: fadeInSlide 2s ease-out forwards;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}



/* Обновляем существующий .copy-btn или добавляем, если его нет */
.copy-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(68, 68, 68, 0.4); /* Чуть прозрачнее для обычных сообщений */
    color: #eee;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    opacity: 0; /* Скрываем по умолчанию */
    transition: opacity 0.2s ease;
    z-index: 10;
}

/* Показываем кнопку при наведении на сообщение */
.message:hover .copy-btn {
    opacity: 1;
}

/* Для блоков кода внутри сообщения кнопка должна быть видна всегда или иметь приоритет */
pre .copy-btn {
    opacity: 1;
    background: rgba(68, 68, 68, 0.8);
}

.user { 
    background: var(--msg-user); 
    color: var(--text-user);
    align-self: flex-end; 
    margin-left: auto; 
    border-bottom-right-radius: 2px; 
}

.model { 
    background: var(--msg-model); 
    align-self: flex-start; 
    border-bottom-left-radius: 2px; 
}

.typing {
    font-style: italic;
    font-size: 0.9em;
    color: #888;
    margin: 10px 20px;
    display: none;
    order: 9999; /* Чтобы всегда был внизу flex-контейнера */
    
    /* Добавляем пульсацию всему блоку */
    animation: pulse 2s infinite ease-in-out;
}

/* Анимация точек (оставляем как была) */
.typing::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

/* Новая анимация мягкого затухания */
@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '. .'; }
    80% { content: '. . .'; }
}

/* ==========================================
   3. ФОРМАТИРОВАНИЕ MARKDOWN
   ========================================== */
code {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
    background: rgba(0,0,0,0.2);
    padding: 2px 5px;
    border-radius: 4px;
}

pre {
    background: #0d1117 !important; /* Код всегда оставляем темным для стиля */
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    position: relative;
    border: 1px solid #30363d;
    margin: 10px 0;
}

pre code {
    display: block;
    padding-right: 40px; 
    background: transparent;
    color: #c9d1d9; /* Цвет текста кода в блоке */
}

.message table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

.message th, .message td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
}

/* ==========================================
   4. ИНТЕРФЕЙС УПРАВЛЕНИЯ
   ========================================== */

.controls { 
    padding: 15px 20px; 
    background: transparent; 
    border: none; 
    
    /* Эффект матового стекла */
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px);
    
    position: absolute; 
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 10;

    /* --- МАГИЯ ГРАДИЕНТА ТУТ --- */
    /* Создаем маску: сверху (0%) прозрачно, к 20% высоты — полная видимость */
    -webkit-mask-image: linear-gradient(to bottom, 
        transparent 0%, 
        black 20%, 
        black 100%
    );
    mask-image: linear-gradient(to bottom, 
        transparent 0%, 
        black 20%, 
        black 100%
    );
}


/* Общая "капсула" ввода */
.input-wrapper {
    display: flex;
    align-items: flex-end; /* Чтобы кнопки оставались внизу при росте текста */
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 24px; /* Скругление как в современных мессенджерах */
    padding: 8px 15px;
    transition: border-color 0.3s ease;
}

/* Зона текста */
.input-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.input-wrapper:focus-within {
    border-color: #4ade80; /* Подсветка при клике */
}

input { 
    flex: 1; 
    padding: 12px; 
    background: var(--bg-input); 
    border: 1px solid var(--border-color); 
    color: var(--text-main); 
    border-radius: 6px;
    outline: none;
    font-size: 16px;
}

button { 
    padding: 10px 16px; 
    border: none; 
    border-radius: 6px; 
    cursor: pointer; 
    font-weight: bold; 
    min-height: 45px;
}

.btn-send { background: var(--system-line); color: var(--btm-color) }
#btn-reset, #btn-clear, #install-button { background: var(--btm-clear); color: var(--btm-color)}
#btn-file {
    background: var(--system-line);
    color: var(--btm-color);
    transition: transform 0.3s ease;
}
#btn-file:hover {
    filter: brightness(1.2);
    transform: rotate(-15deg) scale(1.1);
    transition: transform 0.2s ease;
}



.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(68, 68, 68, 0.8);
    color: #eee;
    padding: 4px 8px;
    font-size: 10px;
    border-radius: 4px;
}

.system-msg { 
    text-align: center; 
    color: #888; 
    font-size: 0.8em; 
    margin: 20px 0; 
    border-bottom: 1px dashed var(--system-line); 
    line-height: 0.1em; 
}
.system-msg span { background: var(--bg-chat); padding: 0 10px; }





.controls div[style*="flex: 1"] {
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Важно: заставляет поле расти снизу вверх */
}

textarea {
    width: 100%; /* Вместо flex: 1 */
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 6px;
    outline: none;
    font-size: 16px;
    resize: none;
    /* font-family: inherit; */
    font-family: 'Montserrat', Arial, sans-serif;  
    line-height: 1.4;
    overflow-y: hidden;
    box-sizing: border-box;
    min-height: 45px;
    /* height: 45px; <- УДАЛЕНО, чтобы не блокировать JS */
}

textarea {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px 0;
    margin: 0;
    min-height: 24px;
    max-height: 200px;
}

.message.model img {/* Гарантирует, что клики проходят к картинке */
    pointer-events: auto; 
    display: block;
}


/* Стили иконок-кнопок */
.action-icon, .btn-send-icon {
    background: none !important;
    border: none !important;
    padding: 8px !important;
    min-height: auto !important;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--btm-color);
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
}


.action-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}



/* Начальное состояние кнопки (тусклое) */
.btn-send-icon {
    color: #4ade80;
    opacity: 0.3; /* Кнопка почти прозрачная, когда текста нет */
    transition: opacity 0.3s ease, transform 0.2s ease;
    pointer-events: none; /* Запрещаем клик по пустой кнопке (опционально) */
}

/* Состояние, когда в поле есть текст */
.btn-send-icon.active {
    opacity: 1; /* Кнопка загорается ярко */
    pointer-events: auto; /* Разрешаем клик */
    transform: scale(1.1); /* Можно добавить легкое увеличение */
}

/* Исправляем превью файла внутри капсулы */
#filePreview {
    background: rgba(74, 222, 128, 0.1);
    color: var(--text-main);
    padding: 4px 10px;
    border-radius: 10px;
    margin-bottom: 5px;
    font-size: 0.8em;
    width: fit-content;
}


/* *********************************Ждем загрузки картинки*************************** */
/* Контейнер для картинки с фоном загрузки */
.message.model img {
    display: block;
    max-width: 100%;
    border-radius: 8px;
    margin-top: 10px;
    
    /* Эффект загрузки (Skeleton) */
    min-height: 200px; /* Чтобы спичбабл не был схлопнутым */
    min-width: 200px;
    background: #f0f0f0 linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    
    /* Иконка "картинка" по центру, пока грузится */
    position: relative;
}


/* Анимация перелива */
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Когда картинка загрузилась — убираем фон и анимацию */
/* Состояние, когда картинка загрузилась */
.message.model img.loaded {
    min-width: auto;
    min-height: auto;
    background: none !important;
    animation: none !important;
}
/* ******************************************************************************************* Ждем загрузки картинки*/



/* *****************КАРТИНКИ В ЧАТЕ ************************************/

/* 1. Маленькие превью в самом чате */
/* Состояние картинки во время загрузки */
.message.model img {
    display: block;
    max-width: 30%;
    height: auto;
    min-width: 200px; /* Минимальная ширина для скелетона */
    min-height: 200px; /* Минимальная высота для скелетона */
    border-radius: 12px;
    margin: 10px 0;
    cursor: pointer;
    transition: opacity 0.3s ease;
    
    /* Эффект скелетона Gemini */
    background: linear-gradient(
        90deg, 
        var(--bg-input) 25%, 
        var(--system-line) 50%, 
        var(--bg-input) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite linear;
}

.message.model img:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    border-color: #4ade80;
}

/* 2. Модальное окно (Lightbox) */
.img-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    cursor: zoom-out;
}

.modal-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

/* 3. Обертка картинки внутри модалки — ГЛАВНОЕ ДЛЯ КНОПКИ */
.image-wrapper {
    position: relative; /* Чтобы кнопка позиционировалась ВНУТРИ */
    display: inline-flex; /* Контейнер примет размер картинки */
    max-width: 90%;
    max-height: 90vh;
}

.modal-content {
    display: block;
    max-width: 100%;   /* Относительно wrapper */
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    animation: zoomIn 0.3s ease;
    cursor: default;
}

/* 4. Кнопка СКАЧАТЬ поверх изображения */
.download-btn-overlay {
    position: absolute;
    top: 20px;      /* Отступ от верхнего края КАРТИНКИ */
    right: 20px;    /* Отступ от правого края КАРТИНКИ */
    width: 45px;
    height: 45px;
    /* background: rgba(0, 0, 0, 0.6); */
    color: #fff !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 24px;
    z-index: 10100; /* Выше всего */
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.download-btn-overlay:hover {
    background: #a7a7a7;
    color: #000 !important;
    transform: scale(1.1);
}


#btn-send:hover {
    filter: brightness(1.2);
    transform: translateY(-0.5px) scale(1.3) !important; 
    transition: transform 0.2s ease, filter 0.2s ease !important;
}

/* 5. Кнопка закрытия (крестик) */
.close-modal {
    position: absolute;
    top: 20px;
    left: 35px; /* Перенес влево, чтобы не мешать кнопке скачать */
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10101;
}

/* Анимации */
@keyframes imgPopIn {
    0% { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}


/* ****************************************************************КАРТИНКИ В ЧАТЕ */





/* ********************Эмодзи***************************************************** */
/* style.css */
.btn-emoji {
    background: var(--system-line); /* Используем вашу переменную */
    color: var(--btm-color);
    font-size: 20px;
    padding: 0 10px;
    transition: transform 0.2s ease;
}

.btn-emoji:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

/* На мобильных устройствах немного увеличим отступы */
@media (max-width: 768px) {
    .btn-emoji {
        padding: 10px;
    }
}
/* **********************************************************************************Эмодзи*/



/* ==========================================
   5. АДАПТИВНОСТЬ
   ========================================== */
@media (max-width: 768px) {
    .chat-container { max-width: 100%; border: none; }
    .message { max-width: 90%; }
    .controls { flex-wrap: wrap; padding: 10px; }
    
    /* Заменяем input на textarea здесь */
    textarea { width: 100%; order: -1; flex: none; min-height: 50px; } 
    
    /* button { flex: 1; font-size: 12px; padding: 12px 5px; } */

    .message.model img {
    max-width: 100%;
    }

    .controls { padding: 10px; }
    .input-wrapper {
        align-items: center; 
        gap: 5px;
        padding: 5px 12px;
    }
    
    .action-icon, .btn-send-icon {
        /* Убираем лишние отступы внутри кнопок, которые могут смещать иконку */
        padding: 4px !important; 
        line-height: 1; /* Обнуляем межстрочный интервал для точного позиционирования */
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    textarea {
        /* Убираем лишние отступы у поля ввода на мобилках */
        padding: 10px 0 !important; 
    }

    #chat-window { padding-bottom: 100px; }
}