/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Верхняя панель */
.top-bar {
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 48px;
    flex-shrink: 0;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 0 0 auto;
}

.logo {
    font-size: 20px;
    cursor: pointer;
}

.menu {
    display: flex;
    gap: 16px;
}

.menu-item {
    color: #333;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.menu-item:hover {
    background-color: #f0f0f0;
}

.top-bar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.project-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background-color: #f0f0f0;
    border-radius: 16px;
    font-size: 14px;
}

.current-project-name {
    color: #333;
    font-weight: 500;
}

.switch-project-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.switch-project-btn:hover {
    background-color: #ddd;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    max-width: 500px;
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: #4a90e2;
}

.search-btn {
    padding: 8px 12px;
    background-color: #4a90e2;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.search-btn:hover {
    background-color: #357abd;
}

/* Основной контейнер */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Левая панель: файлы */
.sidebar-left {
    width: 280px;
    background-color: #fafafa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #ffffff;
}

.sidebar-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.create-folder-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.create-folder-btn:hover {
    background-color: #f0f0f0;
}

.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    transition: background-color 0.2s, border-color 0.2s;
    border: 2px solid transparent;
    border-radius: 4px;
    box-sizing: border-box;
}

.file-tree.root-drag-over {
    background-color: #e3f2fd;
    border-color: #4a90e2;
    border-style: dashed;
}

.file-tree-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.file-tree-item:hover {
    background-color: #f0f0f0;
}

.file-tree-item.active {
    background-color: #e3f2fd;
    color: #1976d2;
}

/* Курсор не изменяется для draggable файлов - остается стандартным */

.file-tree-item.dragging {
    opacity: 0.5;
}

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

.folder-toggle {
    display: inline-block;
    width: 16px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    color: #666;
    font-size: 10px;
    margin-right: 4px;
}

.folder-toggle:hover {
    color: #333;
}

.folder-toggle.empty {
    cursor: default;
    color: transparent;
}

.folder-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    cursor: pointer;
    user-select: none;
    border: 2px solid transparent;
    border-radius: 4px;
    box-sizing: border-box;
}

.folder-item:hover {
    background-color: #f0f0f0;
}

.folder-item.active {
    background-color: #e3f2fd;
}

.folder-item.drag-over {
    background-color: #e3f2fd;
    border-color: #4a90e2;
    border-style: dashed;
}

.folder-item.drag-over .folder-name {
    font-weight: 600;
    color: #1976d2;
}

.folder-item.dragging {
    opacity: 0.5;
}

.folder-icon {
    margin-right: 4px;
}

.folder-name {
    flex: 1;
}

/* Контекстное меню для папок */
.folder-context-menu {
    position: fixed;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    min-width: 180px;
    z-index: 1000;
    font-size: 14px;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    cursor: pointer;
    user-select: none;
    color: #333;
    transition: background-color 0.15s;
}

.context-menu-item:hover {
    background-color: #f5f5f5;
}

.context-menu-item[data-action="delete"]:hover {
    background-color: #ffebee;
    color: #d32f2f;
}

.context-menu-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.file-name {
    flex: 1;
    font-size: 14px;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.loading {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* Центральная панель: просмотр документа */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    border-right: 1px solid #e0e0e0;
    overflow: hidden;
}

.tabs-container {
    background-color: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
}

.tabs {
    display: flex;
    gap: 2px;
    padding: 4px 8px;
}

.tab {
    padding: 8px 16px;
    background-color: #e0e0e0;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.tab:hover {
    background-color: #d0d0d0;
}

.tab.active {
    background-color: #ffffff;
    border-bottom: 2px solid #4a90e2;
}

.tab-icon {
    font-size: 16px;
}

.tab-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-close {
    margin-left: 8px;
    padding: 2px 6px;
    font-size: 18px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.tab-close:hover {
    background-color: #ff4444;
    color: #ffffff;
}

.document-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
}

/* UI v2: Center panel — document-viewer min-height only */
.content-area-v2 .document-viewer {
    min-height: 0;
}

/* v2 drop overlay: inside center column only, shown only when dragging files (scoped) */
.content-area-v2 {
    position: relative;
}
.v2-drop-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    pointer-events: none;
}
.v2-drop-overlay.is-dragging {
    display: flex;
}
.v2-drop-overlay .v2-drop-block {
    width: 100%;
    max-width: 1100px;
    height: 394px;
    flex-shrink: 0;
    min-width: 0;
    background-color: #F3F3F3;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.v2-drop-overlay .v2-drop-block-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 48px 64px;
    box-sizing: border-box;
}
.v2-drop-overlay .v2-drop-block-line1,
.v2-drop-overlay .v2-drop-block-line2 {
    margin: 0;
    padding: 0;
    text-align: center;
    white-space: nowrap;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    font-size: 36px;
    line-height: 1;
    letter-spacing: 0;
    color: #000000;
}

@media (max-width: 600px) {
    .v2-drop-overlay .v2-drop-block-inner {
        padding: 32px 24px;
    }
    .v2-drop-overlay .v2-drop-block-line1,
    .v2-drop-overlay .v2-drop-block-line2 {
        white-space: normal;
    }
}

/* Стили для содержимого папки */
.folder-contents {
    padding: 20px;
}

.folder-contents h2 {
    margin-bottom: 16px;
    color: #333;
    font-size: 20px;
}

.folder-documents-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.folder-content-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.folder-content-item:hover {
    background-color: #f0f0f0;
}

.folder-content-item .file-icon,
.folder-content-item .folder-icon {
    margin-right: 8px;
}

.folder-content-item .file-name,
.folder-content-item .folder-name {
    flex: 1;
    color: #333;
    font-size: 16px;
}

/* Обратная совместимость со старым классом */
.folder-document-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.folder-document-item:hover {
    background-color: #f0f0f0;
}

.folder-document-item .file-icon {
    margin-right: 8px;
}

.folder-document-item .file-name {
    flex: 1;
    color: #333;
    font-size: 16px;
}

/* Модальное окно подтверждения удаления */
.delete-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.delete-confirmation-content {
    background-color: #ffffff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 400px;
    width: 90%;
}

.delete-confirmation-content h3 {
    margin-bottom: 12px;
    color: #d32f2f;
}

.delete-confirmation-content p {
    margin-bottom: 20px;
    color: #666;
}

.delete-confirmation-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.delete-btn-yes {
    background-color: #d32f2f;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.delete-btn-yes:hover {
    background-color: #b71c1c;
}

.delete-btn-no {
    background-color: #f5f5f5;
    color: #333;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.delete-btn-no:hover {
    background-color: #e0e0e0;
}

.document-content {
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.6;
}

.document-content h1 {
    font-size: 24px;
    margin-bottom: 16px;
    color: #333;
}

.document-content h2 {
    font-size: 20px;
    margin-top: 24px;
    margin-bottom: 12px;
    color: #333;
}

.document-content p {
    margin-bottom: 12px;
    color: #555;
}

.document-content mark {
    background-color: #fff59d;
    padding: 2px 4px;
    border-radius: 2px;
}

.document-meta {
    background-color: #f5f5f5;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 14px;
}

.document-meta p {
    margin-bottom: 8px;
}

.document-chunks {
    margin-top: 24px;
}

.chunks-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chunk-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    background-color: #ffffff;
}

.chunk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.chunk-number {
    font-weight: 600;
    font-size: 13px;
    color: #4a90e2;
}

.chunk-summary {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.chunk-text {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chunk-item.highlighted {
    background-color: #fff9c4;
    border: 2px solid #fbc02d;
    box-shadow: 0 0 10px rgba(251, 192, 45, 0.3);
    animation: highlightPulse 2s ease-in-out;
}

@keyframes highlightPulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(251, 192, 45, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(251, 192, 45, 0.6);
    }
}

/* Подсветка релевантного текста внутри чанка */
.chunk-text-highlight {
    background-color: #ffeb3b;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(255, 235, 59, 0.4);
}

/* Правая панель: чат */
.sidebar-right {
    width: 320px;
    background-color: #fafafa;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #4a90e2;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}

.chat-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    flex: 1;
}

/* Иконка истории */
.history-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.history-btn:hover {
    background-color: #f0f0f0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-welcome {
    text-align: center;
    color: #666;
    font-size: 14px;
    padding: 16px;
}

.chat-message {
    padding: 10px 12px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.chat-message.user {
    align-self: flex-end;
    background-color: #4a90e2;
    color: white;
}

.chat-message.louna {
    align-self: flex-start;
    background-color: #ffffff;
    color: #333;
    border: 1px solid #e0e0e0;
}

/* UI v2: Assistant messages container (only when ui_version === "v2") */
.chat-message-v2.louna {
    /* Container dimensions from Figma */
    width: 416px;
    max-width: 416px;
    min-width: 416px;
    /* Height: Hug (adapts to content) */
    height: auto;
    /* No background (transparent) */
    background-color: transparent !important;
    border: none !important;
    /* Padding inside container */
    padding: 20px;
    padding-bottom: 48px; /* Extra space for copy button */
    position: relative;
    box-shadow: none !important;
    /* Flow: Vertical */
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* Typography from Figma spec */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 100%;
    letter-spacing: 0%;
    color: #000000;
}

.chat-message-copy-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    z-index: 1;
    color: #000000;
}

.chat-message-copy-btn svg {
    width: 24px;
    height: 24px;
    display: block;
}

.chat-message-copy-btn:hover {
    opacity: 1;
    color: #000000;
    background-color: rgba(0, 0, 0, 0.06);
}

/* Focus styles only for keyboard navigation, not mouse clicks */
.chat-message-copy-btn:focus-visible {
    opacity: 1;
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Remove focus outline for mouse clicks */
.chat-message-copy-btn:focus:not(:focus-visible) {
    outline: none;
}

/* Active state only during actual click */
.chat-message-copy-btn:active {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
}

.chat-message-copy-btn.copied {
    opacity: 1;
}

.chat-message-copy-tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 4px;
    padding: 4px 8px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

/* Tooltip only shows on hover, not on focus (keyboard navigation can still use it via aria-label) */
.chat-message-copy-btn:hover .chat-message-copy-tooltip {
    opacity: 1;
}

.chat-message.loading {
    align-self: flex-start;
    background-color: #f0f0f0;
    color: #999;
    font-style: italic;
}

/* Контейнер прогресса в сообщении чата */
.chat-message .progress-container {
    margin-top: 8px;
}

.chat-message .progress-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.chat-message .progress-filename {
    font-weight: 500;
    color: #333;
}

.chat-message .progress-status {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
}

.chat-message .progress-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-message .progress-bar {
    flex: 1;
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.chat-message .progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    transition: width 0.3s ease;
    border-radius: 3px;
    width: 0%;
}

.chat-message .progress-percent {
    font-size: 11px;
    font-weight: 500;
    color: #666;
    min-width: 35px;
    text-align: right;
}

/* Анимация пульсации для индикатора загрузки */
.chat-message .progress-loading {
    display: inline-block;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-input-container {
    padding: 12px;
    border-top: 1px solid #e0e0e0;
    background-color: #ffffff;
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #4a90e2;
}

.chat-send-btn {
    padding: 10px 16px;
    background-color: #4a90e2;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

.chat-send-btn:hover {
    background-color: #357abd;
}

.chat-send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Контейнеры чата и истории */
.chat-container,
.history-container {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.chat-container.active,
.history-container.active {
    display: flex;
}

/* UI v2: Empty state layout for chat (only when ui_version === "v2" and chat is empty) */
/* Chat container v2 empty: centers content within the right panel only */
.chat-v2-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    height: 100%;
    gap: 24px;
}

/* Messages container v2 empty: centers text */
.chat-messages-v2-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    gap: 0;
    flex: 0 0 auto;
    width: 100%;
    overflow: visible;
}

/* V2 empty state text */
.chat-messages-v2-empty .chat-welcome {
    text-align: center;
    padding: 0;
    margin: 0;
}

.chat-messages-v2-empty .chat-welcome p {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    font-size: 20px;
    line-height: 20px;
    letter-spacing: 0%;
    color: #000000;
    margin: 0;
    padding: 0;
}

/* V2 empty state input container - positioned below text, centered within right panel */
.chat-input-container-v2-empty {
    position: relative;
    padding: 0;
    border-top: none;
    background-color: transparent;
    width: 382px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    flex-shrink: 0;
    margin: 0 auto;
}

/* Responsive: adjust width on small screens */
@media (max-width: 500px) {
    .chat-input-container-v2-empty {
        width: min(382px, calc(100% - 32px));
    }
}

/* V2 empty state input */
.chat-input-container-v2-empty .chat-input {
    flex: 1;
    height: 50px;
    padding: 0 29px;
    border: 1px solid #000000;
    border-radius: 30px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    margin: 0;
}

.chat-input-container-v2-empty .chat-input:focus {
    border-color: #000000;
}

/* V2 empty state send button - positioned inside input on the right */
.chat-input-container-v2-empty .chat-send-btn {
    position: absolute;
    right: 29px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #000000;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    z-index: 1;
}

.chat-input-container-v2-empty .chat-send-btn:hover {
    background: none;
    opacity: 0.7;
}

.chat-input-container-v2-empty .chat-send-btn:disabled {
    background: none;
    opacity: 0.4;
    cursor: not-allowed;
}

.history-header {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #ffffff;
}

.history-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-empty {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 14px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 4px;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.history-item:hover {
    background-color: #f5f5f5;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item-content {
    flex: 1;
    min-width: 0; /* Для корректной работы text-overflow */
}

.history-item-delete {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    opacity: 0.5;
    flex-shrink: 0;
    color: #666;
    line-height: 1;
    font-weight: bold;
}

.history-item-delete:hover {
    opacity: 1;
    background-color: #ffebee;
    color: #d32f2f;
}

.history-item-query {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-date {
    font-size: 12px;
    color: #999;
}

/* Результаты поиска */
.search-results {
    padding: 16px;
}

.search-result-item {
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: #333;
}

.search-result-snippet {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

/* Скроллбары */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Форма логина */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-large {
    font-size: 64px;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 32px;
    color: #333;
    margin-bottom: 8px;
    font-weight: 600;
}

.login-header p {
    color: #666;
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.form-input {
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.login-button {
    padding: 12px 24px;
    background-color: #4a90e2;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 8px;
}

.login-button:hover {
    background-color: #357abd;
}

.login-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.error-message {
    background-color: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid #fcc;
}

/* Окно выбора проекта */
.project-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
    max-height: 400px;
    overflow-y: auto;
}

.project-item {
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background-color: #fff;
}

.project-item:hover {
    border-color: #4a90e2;
    background-color: #f0f7ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.project-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.project-id {
    font-size: 12px;
    color: #666;
}

/* Стили для XLSX просмотра */
.xlsx-viewer {
    width: 100%;
    overflow-x: auto;
}

.xlsx-sheet {
    margin-bottom: 32px;
}

.sheet-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #4a90e2;
}

.xlsx-table-container {
    overflow-x: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #ffffff;
}

.xlsx-viewer table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.xlsx-viewer table td,
.xlsx-viewer table th {
    border: 1px solid #e0e0e0;
    padding: 8px 12px;
    text-align: left;
    background-color: #ffffff;
}

.xlsx-viewer table th {
    background-color: #f5f5f5;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 1;
}

.xlsx-viewer table tr:nth-child(even) td {
    background-color: #fafafa;
}

.xlsx-viewer table tr:hover td {
    background-color: #f0f7ff;
}

/* Стили для DOCX просмотра */
.docx-viewer {
    width: 100%;
}

.docx-content {
    font-family: Georgia, serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.docx-content p {
    margin-bottom: 12px;
}

.docx-content h1,
.docx-content h2,
.docx-content h3 {
    margin-top: 24px;
    margin-bottom: 12px;
    color: #333;
}

.docx-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.docx-content table td,
.docx-content table th {
    border: 1px solid #e0e0e0;
    padding: 8px;
}

.docx-content table th {
    background-color: #f5f5f5;
    font-weight: 600;
}

/* Подсветка результатов поиска */
.highlight-search {
    background-color: #ffeb3b;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(255, 235, 59, 0.4);
    animation: highlightFlash 1s ease-in-out;
}

@keyframes highlightFlash {
    0% {
        background-color: #fff59d;
        box-shadow: 0 0 10px rgba(255, 235, 59, 0.8);
    }
    100% {
        background-color: #ffeb3b;
        box-shadow: 0 1px 2px rgba(255, 235, 59, 0.4);
    }
}

.document-content-container {
    margin-top: 24px;
}

/* Drag-n-Drop overlay */
.drag-drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

.drag-drop-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* SOURCE OF BLUE: this rule tints full screen; v2 must never add .drag-over to overlay */
.drag-drop-overlay.drag-over {
    background-color: rgba(74, 144, 226, 0.3);
}

.drag-drop-content {
    background-color: #ffffff;
    border-radius: 16px;
    padding: 48px 64px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border: 3px dashed #4a90e2;
    animation: dragDropPulse 1.5s ease-in-out infinite;
}

.drag-drop-overlay.drag-over .drag-drop-content {
    border-color: #357abd;
    background-color: #f0f7ff;
    transform: scale(1.05);
    transition: all 0.2s ease-in-out;
}

@keyframes dragDropPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.drag-drop-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.drag-drop-text {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.drag-drop-hint {
    font-size: 14px;
    color: #666;
}

/* UI v2: No global overlay — no blue screen; indicator is scoped to center column only */
.drag-drop-overlay-v2.active,
.drag-drop-overlay-v2.drag-over {
    background: transparent !important;
    pointer-events: none !important;
}
.drag-drop-overlay-v2.active .drag-drop-content {
    display: none !important;
}

.drag-drop-indicator-v2 {
    display: none;
    position: fixed;
    pointer-events: none;
    box-sizing: border-box;
    border: 2px solid #4a90e2;
    border-radius: 8px;
    z-index: 10001;
}

.drag-drop-indicator-v2.visible {
    display: block;
}

/* UI v2: "Отправить как файл" confirmation modal (Figma specs) */
.send-file-modal-v2 {
    position: fixed;
    inset: 0;
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}
.send-file-modal-v2[aria-hidden="true"] {
    display: none !important;
}
.send-file-modal-v2-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    cursor: pointer;
}
.send-file-modal-v2-box.v2-sendfile-modal {
    position: relative;
    width: 513px;
    min-height: 180px;
    height: auto;
    background: #F3F3F3;
    border-radius: 10px;
    box-sizing: border-box;
    padding: 23px 24px 23px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    outline: none;
}
.v2-sendfile-modal-root .v2-sendfile-modal:focus {
    outline: none;
}
.send-file-modal-v2-header {
    position: relative;
    width: 100%;
    flex-shrink: 0;
    padding-right: 36px;
    box-sizing: border-box;
}
.send-file-modal-v2-close {
    position: absolute;
    top: 0;
    right: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #000000;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.send-file-modal-v2-close:hover {
    background: rgba(0, 0, 0, 0.06);
}
/* v2 modal only: close button no default outline; show only on keyboard focus */
.v2-sendfile-modal-root .v2-sendfile-modal .closeBtn {
    outline: none;
}
.v2-sendfile-modal-root .v2-sendfile-modal .closeBtn:focus-visible {
    outline: 2px solid #2F80ED;
    outline-offset: 2px;
}
.send-file-modal-v2-title {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    font-size: 20px;
    line-height: 1;
    letter-spacing: 0;
    color: #000000;
    margin: 0;
    text-align: center;
}
.send-file-modal-v2-body {
    margin-top: 28px;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}
.v2-sendfile-modal-root .v2-sendfile-modal .fileRowWrapper {
    display: flex;
    justify-content: center;
    width: 100%;
}
.v2-sendfile-modal-root .v2-sendfile-modal .fileRow {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    width: fit-content;
    min-height: 52px;
    text-align: left;
}
.v2-sendfile-modal-root .v2-sendfile-modal .fileMeta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 11px;
    min-width: 0;
}
.send-file-modal-v2-file-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    width: fit-content;
    min-height: 52px;
    text-align: left;
}
.send-file-modal-v2-footer {
    margin-top: 28px;
    flex-shrink: 0;
}
.send-file-modal-v2-footer .send-file-modal-v2-send {
    position: static;
}
.send-file-modal-v2-file-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 11px;
    min-width: 0;
}
.send-file-modal-v2-file-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: #3A3F45;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #ffffff;
    pointer-events: none;
}
.send-file-modal-v2-file-icon-svg {
    width: 28px;
    height: 28px;
    display: block;
}
.send-file-modal-v2-filename {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    font-size: 12px;
    line-height: 1;
    letter-spacing: 0;
    color: #000000;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 320px;
}
.send-file-modal-v2-filesize {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    font-size: 12px;
    line-height: 1;
    letter-spacing: 0;
    color: #000000;
    flex-shrink: 0;
}
.send-file-modal-v2-send {
    position: static;
    width: 148px;
    min-width: 148px;
    max-width: 148px;
    height: 34px;
    min-height: 34px;
    box-sizing: border-box;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 1;
    letter-spacing: 0;
    color: #000000;
    background-color: #E0E0E0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.send-file-modal-v2-send:hover:not(:disabled) {
    background-color: #d0d0d0;
}
.send-file-modal-v2-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Прогресс-бар обработки файла (в левой панели) */
.processing-progress-container {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.processing-progress-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.processing-progress-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.processing-progress-icon {
    font-size: 16px;
    animation: processingPulse 1.5s ease-in-out infinite;
}

@keyframes processingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.processing-progress-filename {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.processing-progress-bar-wrapper {
    width: 100%;
}

.processing-progress-bar {
    width: 100%;
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.processing-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a90e2, #357abd);
    border-radius: 3px;
    transition: width 0.3s ease-out;
    width: 0%;
    animation: processingShimmer 2s ease-in-out infinite;
}

@keyframes processingShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.processing-progress-status {
    font-size: 11px;
    color: #666;
    text-align: left;
}

/* ============================================
   UI v2: Three-column layout
   Only applies when ui_version === "v2"
   ============================================ */

/* Main container v2: three-column flex layout */
.main-container-v2 {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    gap: 0;
}

/* Left panel v2: content-based width (hug, ~220px), must not stretch */
.sidebar-left-v2 {
    width: auto;
    min-width: 200px;
    max-width: 280px;
    flex: 0 0 auto;
    flex-shrink: 0;
    background-color: transparent;
    border-right: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Center panel v2: flexible width, independent column */
.content-area-v2 {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    border-right: 1px solid #e0e0e0;
}

/* Right panel v2: fixed 460px width with original background color, isolated layout */
.sidebar-right-v2 {
    width: 460px;
    min-width: 460px;
    max-width: 460px;
    flex-shrink: 0;
    background-color: #fafafa;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: none;
}

/* Desktop (≥1280px): All three panels visible, right panel never stretches */
@media (min-width: 1280px) {
    .sidebar-left-v2 {
        width: auto;
        flex: 0 0 auto;
    }
    
    .content-area-v2 {
        flex: 1;
    }
    
    .sidebar-right-v2 {
        width: 460px;
        max-width: 460px;
        flex-shrink: 0;
    }
}

/* Tablet / small desktop (768px - 1279px): Center panel primary, sidebars may adjust */
@media (min-width: 768px) and (max-width: 1279px) {
    .sidebar-left-v2 {
        position: fixed;
        top: 48px;
        left: -280px;
        height: calc(100vh - 48px);
        transition: left 0.3s ease;
        background-color: #fafafa;
        border-right: 1px solid #e0e0e0;
        z-index: 100;
    }
    
    .sidebar-left-v2.open {
        left: 0;
    }
    
    .content-area-v2 {
        flex: 1;
    }
    
    .sidebar-right-v2 {
        width: 460px;
        max-width: 460px;
        flex-shrink: 0;
    }
}

/* Mobile (<768px): No three-column layout, chat as overlay */
@media (max-width: 767px) {
    .main-container-v2 {
        flex-direction: column;
    }
    
    .sidebar-left-v2 {
        position: fixed;
        top: 48px;
        left: -100%;
        width: 280px;
        height: calc(100vh - 48px);
        background-color: #fafafa;
        border-right: 1px solid #e0e0e0;
        z-index: 100;
        transition: left 0.3s ease;
    }
    
    .sidebar-left-v2.open {
        left: 0;
    }
    
    .content-area-v2 {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        flex: 1;
    }
    
    .sidebar-right-v2 {
        position: fixed;
        top: 48px;
        right: -100%;
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 48px);
        z-index: 100;
        transition: right 0.3s ease;
    }
    
    .sidebar-right-v2.open {
        right: 0;
    }
}