/* ==== exai.css ==== */
:root {
    --chat-width: 380px;
    --chat-height: 100vh;
    --min-height: 400px;
    --max-height: 90vh;
    --header-height: 65px;
    --radius: 12px;
    --transition: .35s ease;
    --grad: linear-gradient(135deg, #9d080d, #777);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --keyboard-height: 0px;
}

/* ==== КОНТЕЙНЕР ==== */
.chatbot-container {
    position: fixed;
    bottom: 0;
    width: var(--chat-width);
    z-index: 99999;
    user-select: none;
    right: 60px;
    touch-action: manipulation;
}

/* ==== КНОПКА АКТИВАЦИИ ==== */
.chatbot-toggle {
    border: none;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--grad);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 18px;
    cursor: pointer;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
    position: relative;
    z-index: 2;
    width: 100%;
    touch-action: manipulation;
}

.chatbot-toggle.hide {
    display: none !important;
}

.chatbot-toggle .toggle-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #3498db;
    overflow: hidden;
    background: black;
    flex: 0 0 34px;
}

.toggle-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.toggle-text {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-indicator {
    margin-left: auto;
    font-size: 11px;
    color: #1dd65f;
    white-space: nowrap;
}

.status-indicator::before {
    content: "";
    width: 7px;
    height: 7px;
    background: #1dd65f;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

/* ==== ОКНО ЧАТА ==== */
.chatbot-window {
    position: fixed;
    width: var(--chat-width);
    height: var(--chat-height);
    background: #eef1f5;
    overflow: hidden;
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid #ccc;
    border-bottom: none;
    opacity: 0;
    transition: opacity .25s ease, transform var(--transition);
    box-shadow: 0 -8px 22px rgba(0, 0, 0, 0.22);
    display: none;
    z-index: 100000;
    bottom: 0;
    right: 20px;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.chatbot-window.open {
    opacity: 1;
    display: flex;
    flex-direction: column;
}

.chatbot-window.resizing {
    transition: none !important;
    user-select: none;
}

/* ==== ШАПКА ОКНА ==== */
.chat-header {
    background: var(--grad);
    height: var(--header-height);
    display: flex;
    flex-shrink: 0;
    align-items: center;
    padding: 5px 5px 5px 15px;
    gap: 12px;
    color: white;
    cursor: move;
    user-select: none;
    border-radius: var(--radius) var(--radius) 0 0;
    touch-action: pan-x pan-y;
    -webkit-touch-callout: none;
}

.chat-header:active {
    cursor: grabbing;
}

.chat-header .toggle-icon {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px;
    min-height: 34px;
    max-width: 34px;
    max-height: 34px;
    border-radius: 50%;
    border: 2px solid #3498db;
    overflow: hidden;
    background: black;
    flex: 0 0 34px;
}

.chat-header-text {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    flex: 1;
    white-space: nowrap;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 100001;
    padding: 0;
    margin: 0;
    line-height: 1;
    touch-action: manipulation;
    border-radius: 50%;
    transition: background-color 0.2s;
    position: relative;
}

.chatbot-close .close-icon {
    display: block;
    width: 100%;
    height: 100%;
    line-height: 44px;
    font-size: 32px;
    font-weight: 300;
}

.chatbot-close:hover,
.chatbot-close:active,
.chatbot-close:focus {
    background: rgba(255, 255, 255, 0.15);
    outline: none;
}

/* ==== ОБЛАСТЬ СООБЩЕНИЙ ==== */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f5f5f5;
    transition: height 0.2s ease;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 100px;
    box-sizing: border-box;
    position: relative;
    min-height: 0;
}

.chatbot-messages::-webkit-scrollbar {
    display: none;
    width: 0;
}

/* ==== FAKE SCROLLBAR - ИСПРАВЛЕННАЯ ВЕРСИЯ (ПО ВСЕЙ ВЫСОТЕ) ==== */
.fake-scrollbar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
    pointer-events: auto;
    z-index: 1000;
    cursor: pointer;
    border-radius: 3px;
    margin: 2px;
    height: auto !important;
}

.fake-scrollbar.visible {
    opacity: 1;
    visibility: visible;
}

.fake-scrollbar-thumb {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 40px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.35);
    transition: top .08s linear, height .08s linear;
    cursor: grab;
    min-height: 20px;
}

.fake-scrollbar.dragging .fake-scrollbar-thumb {
    cursor: grabbing;
}

.fake-scrollbar:hover {
    opacity: 1 !important;
    visibility: visible !important;
    background: rgba(0, 0, 0, 0.08);
}

.fake-scrollbar:hover .fake-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.55);
}

/* ==== СООБЩЕНИЯ ==== */
.message {
    display: flex;
    margin-bottom: 15px;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    justify-content: flex-start;
}

.bot-message .message-content {
    background: #ffffff;
    color: #000;
    border-radius: 12px 12px 12px 4px;
    max-width: 85%;
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    background: #fdf0f0;
    color: #900;
    border-radius: 12px 12px 4px 12px;
    max-width: 85%;
}

.message-content {
    padding: 12px 15px !important;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-size: 14px;
    max-width: 85%;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
    margin-left: 10px;
    margin-right: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.5;
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content pre {
    margin: 12px 0 !important;
    padding: 12px !important;
    max-width: 100%;
    overflow-x: auto;
    font-size: 13px;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

/* ==== БЛОК ВВОДА ==== */
.chatbot-input {
    padding: 0 12px;
    background: #f5f5f5;
    border-top: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    padding-bottom: calc(10px + var(--safe-area-inset-bottom));
    transition: bottom 0.3s ease;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    height: auto;
    min-height: 120px;
}

/* Активное состояние при открытой клавиатуре */
.chatbot-input.keyboard-active {
    bottom: var(--keyboard-height);
}

/* Верхняя строка ввода */
.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.input-wrapper {
    position: relative;
    flex: 1;
    min-height: 50px;
    max-height: 120px;
    background: white;
    /*border-radius: 25px;*/
    border: 1px solid #ddd;
    overflow: hidden;
}

.chat-input-editor {
    min-height: 50px !important;
    max-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 15px !important;
    padding-right: 25px !important;
    scrollbar-width: none;
    -ms-overflow-style: none;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    box-sizing: border-box;
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    border: none;
    background: transparent;
    width: 100%;
}

.chat-input-editor::-webkit-scrollbar {
    display: none;
    width: 0;
}

.chat-input-editor:empty::before {
    content: attr(data-placeholder);
    color: #999;
    pointer-events: none;
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
}

.chat-input-editor:focus {
    outline: none;
}

/* Fake scrollbar для поля ввода */
.input-scroll {
    position: absolute;
    top: 4px;
    bottom: 4px;
    right: 2px;
    width: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.input-scroll.visible {
    opacity: 1;
}

/* Кнопка отправки */
.send-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    max-width: 42px;
    max-height: 42px;
    border-radius: 50%;
    border: none;
    padding: 0;
    background: #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: .25s;
    flex-shrink: 0;
    touch-action: manipulation;
}

.send-btn .send-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: invert(50%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(90%);
    transition: filter .25s;
}

.send-btn.active {
    background: #9d080d;
}

.send-btn.active .send-icon {
    filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(200%);
}

/* Панель инструментов */
.input-toolbar {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 6px;
}

.emoji-btn,
.file-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: #eee;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    touch-action: manipulation;
    transition: background-color 0.2s;
    position: relative;
}

.emoji-btn:hover,
.file-btn:hover {
    background: #ddd;
}

/* Обертка для загрузки файлов */
.file-upload-wrapper {
    position: relative;
    display: inline-block;
}

.file-input-hidden {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    top: 0;
    left: 0;
    z-index: 10;
}

/* ==== ПИКЕР ЭМОДЗИ ==== */
.emoji-picker {
    position: absolute;
    bottom: 70px;
    left: 10px;
    width: 240px;
    padding: 3px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    display: none;
    grid-template-columns: repeat(6, 1fr);
    z-index: 100001;
    gap: 2px;
}

.emoji-picker.open {
    display: grid;
}

.emoji-picker span {
    cursor: pointer;
    font-size: 22px;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    transition: background-color 0.2s;
    user-select: none;
}

.emoji-picker span:hover {
    background: #f0f0f0;
}

.emoji-arrow {
    position: absolute;
    bottom: 58px;
    left: 26px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid #28d14c;
    opacity: 0;
    transform: translateY(6px);
    transition: .25s ease;
    pointer-events: none;
    z-index: 100002;
}

.emoji-arrow.show {
    opacity: 1;
    transform: translateY(0);
}

/* ==== КНОПКА ПРОКРУТКИ ВНИЗ ==== */
.scroll-down-btn {
    position: absolute;
    bottom: 20px;
    right: 14px;
    width: 40px;
    height: 40px;
    background: #9d080d;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.8);
    transition: all 0.3s ease;
    z-index: 10;
    touch-action: manipulation;
    padding: 0;
}

.scroll-down-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.scroll-down-btn:active {
    transform: scale(0.95);
}

.scroll-down-icon {
    width: 24px;
    height: 24px;
    fill: white;
}

/* ==== ИНДИКАТОР ИЗМЕНЕНИЯ РАЗМЕРА ==== */
.resize-indicator {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: rgba(157, 8, 13, 0.3);
    z-index: 99998;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.resize-indicator.active {
    opacity: 1;
}

/* ==== ФАЙЛОВЫЕ КАРТОЧКИ ==== */
.file-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    min-width: 240px;
    max-width: 320px;
}

.file-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex: 0 0 auto;
    margin-top: 2px;
}

.user-message .file-icon {
    background: rgba(255, 255, 255, 0.25);
}

.file-meta.compact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    color: black;
    flex: 1;
}

.file-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 10px;
}

.file-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.file-size {
    font-size: 12px;
    opacity: 0.8;
    flex-shrink: 0;
    white-space: nowrap;
}

.file-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
    flex-shrink: 0;
}

.file-status.uploading {
    background: rgba(40, 209, 76, 0.2);
    color: #1a8c37;
}

.file-status.completed {
    background: rgba(40, 209, 76, 0.2);
    color: #1a8c37;
}

.file-meta-row .file-download-icon {
    position: static;
    opacity: 0;
    visibility: hidden;
    transform: none;
    margin-left: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.file-meta-row .file-download-icon.visible {
    opacity: 1;
    visibility: visible;
}

.file-meta-row .file-download-icon svg {
    width: 16px;
    height: 16px;
    fill: #333;
}

.file-progress {
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
    margin-top: 6px;
    width: 100%;
}

.file-progress-bar {
    height: 100%;
    width: 0%;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 999px;
    transition: width .15s linear;
}

/* ==== ПРЕВЬЮ ИЗОБРАЖЕНИЙ ==== */
.image-preview {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.22);
    cursor: pointer;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.image-preview:hover img {
    transform: scale(1.05);
}

/* ==== ПРЕВЬЮ PDF ==== */
.pdf-preview {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    background: linear-gradient(135deg, #fef8f8, #9d080d);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    text-align: center;
    padding: 5px;
    transition: transform 0.2s;
}

.pdf-preview:hover {
    transform: scale(1.05);
}

.pdf-preview .pdf-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.pdf-preview .pdf-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* ==== МОДАЛЬНЫЕ ОКНА ==== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100002;
    padding: 20px;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalAppear 0.3s ease;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 15px 20px;
    background: var(--grad);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    padding: 0;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 20px;
    overflow: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ==== СТИЛИ ДЛЯ ПРОСМОТРА ФАЙЛОВ В МОДАЛЬНОМ ОКНЕ ==== */
.file-viewer-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.file-viewer-video {
    width: 100%;
    max-height: 70vh;
    border-radius: 8px;
    background: #000;
}

.file-viewer-audio {
    width: 100%;
    max-width: 500px;
    margin: 20px 0;
}

.file-viewer-text {
    width: 100%;
    max-height: 70vh;
    overflow: auto;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;
}

.file-viewer-archive {
    width: 100%;
    max-height: 70vh;
    overflow: auto;
    padding: 20px;
}

.file-viewer-archive ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-viewer-archive li {
    padding: 10px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-viewer-archive li:last-child {
    border-bottom: none;
}

.file-viewer-unsupported {
    text-align: center;
    padding: 40px 20px;
}

.file-viewer-unsupported .unsupported-icon {
    font-size: 64px;
    margin-bottom: 20px;
    color: #6c757d;
}

.file-viewer-unsupported p {
    color: #6c757d;
    margin-bottom: 20px;
}

/* ==== PDF ПРОСМОТР ==== */
#pdfCanvas {
    max-width: 100%;
    max-height: 60vh;
    border: 1px solid #eee;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.pdf-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.pdf-control-btn {
    background: #28d14c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.pdf-control-btn:hover {
    background: #1fa83f;
}

.pdf-control-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.pdf-page-info {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    min-width: 120px;
    text-align: center;
}

/* ==== УВЕДОМЛЕНИЯ ==== */
.upload-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #fdf0f0;
    color: #900;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100001;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.upload-notification.success {
    background: #fff9e6;
}

.upload-notification.error {
    background: #ff3b30;
}

.notification-text {
    font-size: 14px;
    font-weight: 500;
}

/* ==== FALLBACK ДЛЯ ВИДЕО ==== */
.video-fallback {
    display: none;
    width: 100%;
    height: 100%;
    background: var(--grad);
    color: white;
    font-size: 8px;
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 50%;
    padding: 2px;
}

/* ==== АНИМАЦИЯ ЗАГРУЗКИ ==== */
.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==== МЕДИА-ЗАПРОСЫ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ ==== */
@media (max-width: 700px) {
    .chatbot-container {
        width: 65px !important;
        height: 65px;
        bottom: calc(15px + var(--safe-area-inset-bottom)) !important;
        right: 20px;
        left: auto !important;
    }

    .chatbot-toggle {
        width: 65px !important;
        height: 65px !important;
        padding: 0;
        border-radius: 50% !important;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    }

    .toggle-text,
    .status-indicator {
        display: none !important;
    }

    .chatbot-window {
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        height: -webkit-fill-available !important;
        border-radius: 0 !important;
        transform: translateY(100%) !important;
        transition: transform var(--transition), opacity var(--transition) !important;
    }

    .chatbot-window.open {
        transform: translateY(0) !important;
        opacity: 1;
        display: flex !important;
    }

    .chatbot-messages {
        padding: 20px;
        padding-bottom: 150px !important;
        height: auto !important;
    }

    .chatbot-close {
        width: 44px;
        height: 44px;
        font-size: 32px;
        margin-right: 10px;
    }

    .chatbot-close .close-icon {
        line-height: 44px;
        font-size: 36px;
    }

    .scroll-down-btn {
        bottom: 40px;
        right: 20px;
        width: 44px;
        height: 44px;
    }

    .chatbot-input {
        padding-bottom: calc(15px + var(--safe-area-inset-bottom));
        min-height: 140px;
    }

    .emoji-picker {
        width: 280px;
        left: 50%;
        transform: translateX(-50%);
        bottom: 80px;
    }

    .emoji-arrow {
        left: 50%;
        transform: translateX(-50%);
    }

    .file-card {
        max-width: 280px;
    }

    .modal-content {
        width: 95%;
        max-height: 85vh;
    }

    #pdfCanvas {
        max-height: 50vh;
    }

    .file-viewer-image {
        max-height: 60vh;
    }

    .file-viewer-video {
        max-height: 60vh;
    }

    .message-content {
        padding: 10px 12px !important;
        font-size: 15px;
    }

    .message-content pre {
        font-size: 13px;
        padding: 10px !important;
    }
}

/* ==== ОСОБЫЕ СТИЛИ ДЛЯ IPAD ==== */
@media (min-width: 768px) and (max-width: 1024px) {
    .chatbot-close {
        width: 48px;
        height: 48px;
        margin-right: 15px;
    }

    .chatbot-close .close-icon {
        line-height: 48px;
        font-size: 40px;
    }

    .chatbot-container {
        right: 60px;
    }

    .chatbot-window {
        right: 30px;
    }

    .file-card {
        max-width: 300px;
    }

    /* Увеличиваем область клика для файлов на iPad */
    .file-upload-wrapper {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ==== ПЛАНШЕТЫ ==== */
@media (min-width: 701px) and (max-width: 1024px) {
    .chatbot-container {
        right: 60px;
    }

    .chatbot-window {
        right: 15px;
    }

    .chatbot-messages {
        padding-bottom: 120px;
    }
}

/* ==== IOS SAFARI FIXES ==== */
@supports (-webkit-touch-callout: none) {
    .chatbot-window {
        height: -webkit-fill-available;
    }

    .chatbot-messages {
        -webkit-overflow-scrolling: touch;
    }

    .chat-input-editor {
        -webkit-user-select: text;
        user-select: text;
    }

    .chatbot-close {
        -webkit-appearance: none;
    }

    /* Исправление для загрузки файлов в iOS */
    .file-input-hidden {
        font-size: 16px; /* Предотвращает увеличение в Safari */
    }
}

/* ==== PRE ТЕГИ ДЛЯ КОДА ==== */
pre {
    white-space: pre-wrap;
    margin: 12px 0;
    background: #f6f6f6;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e7e7e7;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
    overflow-x: auto;
}