/* Сброс стилей и базовые настройки */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS переменная для правильной работы с viewport на мобильных устройствах */
:root {
    --vh: 1vh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #0f0f0f;
    color: #ffffff;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    
    /* Предотвращаем масштабирование */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Блокировка горизонтальной прокрутки при открытом меню */
body.menu-open {
    overflow-x: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Дополнительная блокировка для мобильных устройств */
@media (max-width: 768px) {
    /* Предотвращаем масштабирование */
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    /* Предотвращаем масштабирование при фокусе на input */
    input, textarea, select {
        font-size: 16px !important;
        -webkit-appearance: none;
        border-radius: 0;
    }
    
    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
        touch-action: pan-y; /* Разрешаем только вертикальные жесты */
    }
    
    body.menu-open * {
        touch-action: pan-y; /* Разрешаем только вертикальные жесты для всех элементов */
    }
}

/* Основной контейнер чата */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background-color: #0f0f0f;
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    overflow: hidden;
}

/* Порядок элементов в контейнере:
   1. .top-bar (верхняя панель) - order: 1
   2. .subject-selection (панель выбора предметов) - order: 2
   3. .chat-area (область чата) - order: 3, flex: 1
   4. .bottom-input-bar (панель ввода) - order: 4
*/

.chat-container.shifted {
    width: calc(100% - 280px);
    margin-left: 280px;
}

/* Верхняя панель */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 20px;
    background-color: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
    position: relative;
    z-index: 10;
    backdrop-filter: blur(20px);
    order: 1; /* Порядок: чат, предметы, ввод */
}

.menu-button,
.new-chat-button {
    background: transparent;
    border: none;
    color: #ffffff;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.menu-button:hover,
.new-chat-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.logo {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
}

/* Панель выбора предметов */
.subject-selection {
    padding: 16px;
    background-color: #1C1C1E;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    position: relative;
    z-index: 20; /* Выше панели ввода */
    display: block; /* Видна по умолчанию */
    order: 2; /* Порядок: хедер, предметы, чат, ввод */
}

.subject-selection.hidden {
    display: none;
}

.subject-selection h3 {
    font-size: 17px;
    font-weight: 600;
    color: #FFFFFF;
    margin-bottom: 16px;
    text-align: center;
}

.subject-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.subject-btn {
    background-color: #1C1C1E;
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.subject-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.subject-btn.selected {
    background-color: rgb(255, 176, 92);
    color: #000000;
    border-color: rgb(255, 176, 92);
}

/* Область чата */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #0f0f0f;
    position: relative;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(120, 219, 255, 0.1) 0%, transparent 50%);
    
    /* Улучшенный скролл для мобильных устройств */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    
    /* Скрываем скроллбар */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    
    /* Ограничиваем высоту */
    min-height: 0;
    max-height: calc(100vh - 56px - 60px); /* Высота экрана минус верхняя панель и панель ввода (панель предметов скрыта) */
    order: 3; /* Порядок: хедер, предметы, чат, ввод */
}

/* Скрываем скроллбар для WebKit браузеров */
.chat-area::-webkit-scrollbar {
    display: none;
}

/* Контейнер для сообщений, который прижимает их к низу */
.chat-area::after {
    content: '';
    flex: 1;
    min-height: 0;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #A1A1A1;
}

.welcome-message h2 {
    font-size: 20px;
    font-weight: 600;
    color: #FFFFFF;
    margin-bottom: 8px;
}

.welcome-message p {
    font-size: 14px;
    line-height: 1.5;
}

/* Сообщения чата */
.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.moderator {
    align-items: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message.user .message-bubble {
    background-color: rgb(255, 176, 92);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.message.moderator .message-bubble {
    background-color: #2b2b2b;
    color: #ffffff;
    border-bottom-left-radius: 4px;
    margin-right: auto;
}

/* Сообщения с файлами */
.file-message {
    padding: 12px;
}

.file-attachment {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
}

.file-attachment:last-child {
    margin-bottom: 0;
}

.image-attachment {
    max-width: 200px;
    background-color: #2C2C2E;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.image-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}

.download-image-btn {
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: #FFFFFF;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.download-image-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.05);
}

.file-preview-image {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    display: block;
    image-rendering: high-quality;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.document-attachment {
    display: flex;
    align-items: center;
    padding: 12px;
    background-color: #2C2C2E;
    gap: 12px;
    transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.document-attachment:hover {
    background-color: #3C3C3E;
}

.file-icon-folder {
    font-size: 24px;
    flex-shrink: 0;
}

.file-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.file-name {
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 500;
    word-break: break-word;
    line-height: 1.2;
}

.file-message-text {
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    margin-top: 8px;
    color: inherit;
}

/* Стили для пользователя */
.message.user .file-attachment {
    background-color: rgba(0, 255, 100, 0.1);
}

.message.user .document-attachment {
    background-color: rgba(0, 255, 100, 0.1);
}

.message.user .document-attachment:hover {
    background-color: rgba(0, 255, 100, 0.15);
}

.message.user .file-name {
    color: #000000;
}

/* Стили для модератора */
.message.moderator .file-attachment {
    background-color: #2C2C2E;
}

.message.moderator .document-attachment {
    background-color: #2C2C2E;
}

.message.moderator .file-name {
    color: #FFFFFF;
}



.message-time {
    font-size: 12px;
    color: #A1A1A1;
    margin-top: 4px;
    padding: 0 8px;
}

/* Отображение прикрепленных файлов */
.attached-files-display {
    background-color: #1C1C1E;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 16px;
    max-height: 120px;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.attached-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: #2C2C2E;
    border-radius: 8px;
    transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    min-width: 200px;
    max-width: 300px;
}

.attached-file-item:hover {
    background-color: #3C3C3E;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.file-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.file-name {
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    max-width: 120px;
}

.file-size {
    color: #A1A1A1;
    font-size: 11px;
    flex-shrink: 0;
    margin-left: 4px;
}

.remove-file-btn {
    background: transparent;
    border: none;
    color: #A1A1A1;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-file-btn:hover {
    background-color: rgba(255, 0, 0, 0.1);
    color: #FF4444;
}

/* Нижняя панель ввода */
.bottom-input-bar {
    display: none; /* Скрыта по умолчанию */
    align-items: flex-end;
    padding: 12px 20px;
    background-color: #1a1a1a;
    border-top: 1px solid #2a2a2a;
    gap: 12px;
    backdrop-filter: blur(20px);
    min-height: 60px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    order: 4; /* Порядок: хедер, предметы, чат, ввод */
}

/* Показываем панель ввода когда она активна */
.bottom-input-bar.visible {
    display: flex !important;
}

.file-upload-button {
    background: #2b2b2b;
    border: none;
    color: #ffffff;
    padding: 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 54px;
    min-height: 54px;
    align-self: center;
}

.file-upload-button:hover {
    background-color: #3a3a3a;
    transform: scale(1.05);
}

.input-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    background-color: #2b2b2b;
    border-radius: 20px;
    padding: 8px 16px;
    gap: 8px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    min-height: 40px;
}

.input-container:focus-within {
    border-color: rgb(255, 176, 92);
    background-color: #333333;
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    align-self: center;
    
    /* Разрешаем выделение текста в поле ввода */
    -webkit-user-select: text;
    -khtml-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    touch-action: manipulation;
}

.message-input::placeholder {
    color: #8a8a8a;
}

.message-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-button {
    background: rgb(255, 176, 92);
    border: none;
    color: #ffffff;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    min-height: 36px;
    align-self: flex-start;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
}

.send-button.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.send-button.visible:hover:not(:disabled) {
    background-color: rgb(255, 176, 92);
    transform: scale(1.05);
}

.send-button:disabled {
    background-color: #3a3a3a;
    color: #8a8a8a;
    cursor: not-allowed;
    transform: none;
}

/* Панель истории */
.history-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background-color: #1a1a1a;
    border-right: 1px solid #2a2a2a;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
}

.history-panel.open {
    transform: translateX(0);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid #2a2a2a;
}

.history-header h3 {
    font-size: 17px;
    font-weight: 600;
    color: #FFFFFF;
}

.close-history-button {
    background: transparent;
    border: none;
    color: #A1A1A1;
    padding: 4px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-history-button:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #FFFFFF;
}

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    
    /* Скрываем скроллбар */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* Скрываем скроллбар для WebKit браузеров */
.history-content::-webkit-scrollbar {
    display: none;
}

.history-item {
    padding: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.history-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.history-item.active {
    background-color: rgba(255, 255, 255, 0.15);
    border-left: 3px solid rgb(255, 176, 92);
}

.history-item-content {
    padding: 12px 16px;
    flex: 1;
    min-width: 0;
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.history-item-actions {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 60px;
    background-color: #FF4444;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateX(100%);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.history-item.swiped .history-item-content {
    transform: translateX(-60px);
}

.history-item.swiped .history-item-actions {
    transform: translateX(0);
}

.history-delete-btn {
    background: transparent;
    border: none;
    color: #FFFFFF;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-delete-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.history-item.active .history-subject {
    color: #FFFFFF;
    font-weight: 600;
}

.history-item.active .history-preview {
    color: #FFFFFF;
}

.history-item.active .history-time {
    color: rgb(255, 176, 92);
}

.history-subject {
    font-size: 14px;
    font-weight: 500;
    color: rgb(255, 176, 92);
    margin-bottom: 4px;
}

.history-preview {
    font-size: 12px;
    color: #A1A1A1;
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-time {
    font-size: 11px;
    color: #A1A1A1;
}

/* Модальное окно для просмотра изображений */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.image-modal.open {
    display: flex;
}

.image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.image-modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    image-rendering: high-quality;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.image-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #FFFFFF;
    font-size: 24px;
    font-weight: bold;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2001;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Overlay для истории - убран, так как панель теперь сдвигает контент */

/* Анимации */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: slideIn 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Скроллбар - полностью скрыт */
::-webkit-scrollbar {
    width: 0px;
    height: 0px;
    background: transparent;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: transparent;
}

::-webkit-scrollbar-thumb:hover {
    background: transparent;
}

/* Горизонтальная прокрутка для файлов */
.attached-files-display::-webkit-scrollbar {
    height: 6px;
}

.attached-files-display::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.attached-files-display::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.attached-files-display::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}



/* Адаптивность */
@media (max-width: 768px) {
    .subject-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .history-panel {
        width: 80%;
        max-width: 320px;
        min-width: 280px;
    }
    
    .chat-container.shifted {
        transform: translateX(320px);
        width: 100%;
        margin-left: 0;
    }
    
    .typing-dots-container {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
    }
    
    .image-modal-close {
        display: none;
    }
    
    /* В мобильной версии панель ввода всегда видна после выбора предмета */
    .bottom-input-bar.visible {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        padding: 12px 16px;
        background-color: #1a1a1a;
        border-top: 1px solid #2a2a2a;
        backdrop-filter: blur(20px);
        order: 4; /* Порядок: хедер, предметы, чат, ввод */
        transition: all 0.3s ease;
    }
    
    /* Стили когда клавиатура открыта */
    body.keyboard-open .bottom-input-bar.visible {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        transform: translateY(0) !important;
        background-color: #1a1a1a;
        border-top: 1px solid #2a2a2a;
        backdrop-filter: blur(20px);
        transition: bottom 0.3s ease !important;
        margin: 0 !important;
        padding: 12px 16px !important;
        border-radius: 0 !important; /* Убираем скругления */
        /* bottom будет установлен через JavaScript */
    }
    
    /* Анимация для плавного появления/исчезновения */
    body.keyboard-open .chat-area {
        transition: max-height 0.3s ease, padding-bottom 0.3s ease;
    }
    
    /* Панель выбора предметов в мобильной версии */
    .subject-selection {
        position: relative;
        z-index: 90;
        order: 2; /* Порядок: хедер, предметы, чат, ввод */
    }
    
    .subject-selection.hidden {
        display: none !important;
    }
    
    /* Добавляем отступ снизу для контента, чтобы он не перекрывался панелью ввода */
    .chat-area {
        padding-bottom: 80px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scroll-behavior: smooth;
        max-height: calc(100vh - 56px - 80px); /* Высота экрана минус верхняя панель и мобильная панель ввода (панель предметов скрыта) */
        transition: max-height 0.3s ease, padding-bottom 0.3s ease;
    }
    
    /* Когда клавиатура открыта, уменьшаем высоту чата */
    body.keyboard-open .chat-area {
        max-height: calc(100vh - 56px - 80px);
        padding-bottom: 0px !important; /* Убираем отступ снизу */
        transition: max-height 0.3s ease, padding-bottom 0.3s ease;
    }
    
    /* Дополнительные стили для поля ввода при открытой клавиатуре */
    body.keyboard-open .message-input {
        font-size: 16px !important; /* Предотвращает зум на iOS */
    }
    
    /* Предотвращаем появление черного поля при свайпе */
    body.keyboard-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    /* Убираем возможность прокрутки когда клавиатура открыта */
    body.keyboard-open .chat-area {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* Дополнительные ограничения для очень маленьких экранов */
@media (max-width: 480px) {
    .history-panel {
        width: 90%;
        max-width: 300px;
        min-width: 260px;
    }
    
    .chat-container.shifted {
        transform: translateX(300px);
        width: 100%;
    }
    
    .typing-dots-container {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
    }
    
    .image-modal-close {
        display: none;
    }
}

/* Состояния загрузки */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background-color: #1C1C1E;
    border-radius: 20px;
    border-bottom-left-radius: 8px;
    max-width: 70px;
}

.typing-dots-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #A1A1A1;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateX(0);
        opacity: 0.5;
    }
    30% {
        transform: translateX(8px);
        opacity: 1;
    }
}

