/* Общие стили */
* {
    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 {
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #ffffff;
}

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

.file-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.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;
}

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

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

.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;
}

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

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

.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;
}

.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;
}

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

.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;
}

/* Результаты поиска */
.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;
}
