* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--window-bg);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

/* Navigation panel (sidebar accordion) */
.nav-section {
    margin-bottom: 2px;
}

.nav-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 8px;
    background: var(--menu-bg);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    text-align: left;
    user-select: none;
}

.nav-section-header:hover {
    background: var(--accent-color);
    color: white;
}

.nav-icon {
    font-size: 10px;
    width: 12px;
}

.nav-section-body {
    border: 1px solid var(--border-color);
    border-top: none;
    background: var(--card-bg);
}

.nav-item {
    display: block;
    width: 100%;
    padding: 6px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    color: var(--text-color);
}

.nav-item:hover {
    background: var(--accent-color);
    color: white;
}

.nav-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 8px;
}

.nav-hint {
    display: block;
    padding: 6px 16px;
    font-size: 12px;
    color: var(--border-color);
}

.nav-item-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: bold;
}

.nav-item-toggle .nav-icon {
    font-size: 10px;
    width: 12px;
}

.nav-sublist {
    padding-left: 8px;
}

.nav-item-sub {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 16px;
    font-size: 12px;
}

.nav-item-text {
    flex: 1;
    background: none;
    border: none;
    cursor: pointer;
    font-size: inherit;
    text-align: left;
    color: inherit;
    padding: 0;
}

.nav-item-text:hover {
    color: var(--accent-color);
}

/* Settings context badge */
.settings-context {
    margin-bottom: 16px;
}

.settings-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 3px;
    font-weight: bold;
}

.settings-badge-project {
    background: var(--accent-color);
    color: white;
}

.settings-badge-user {
    background: var(--border-color);
    color: var(--text-color);
}

/* Status bar */
.status-bar {
    background: var(--status-bar-bg);
    border-top: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 12px;
    min-height: 28px;
    gap: 8px;
}

.status-bar .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-bar .status-dot.connected {
    background: #00cc00;
}

.status-bar .status-dot.disconnected {
    background: #cc0000;
}

.status-bar .status-text {
    flex: 1;
}

.status-bar progress {
    width: 80px;
    height: 12px;
}

/* Main content area */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 250px;
    min-width: 150px;
    border-right: 2px solid var(--border-color);
    padding: 4px;
    overflow-y: auto;
    background: var(--window-bg);
}

/* Detail panel */
.detail-panel {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.detail-panel .tab-bar {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 12px;
}

.detail-panel .tab-bar .tab {
    padding: 8px 16px;
    cursor: pointer;
    border: 1px solid transparent;
    margin-bottom: -2px;
}

.detail-panel .tab-bar .tab.active {
    border: 1px solid var(--border-color);
    border-bottom-color: var(--window-bg);
    background: var(--card-bg);
}

.detail-panel .tab-content {
    padding: 8px;
}

/* Cards for RAG facts */
.fact-card {
    background: var(--card-bg);
    border-left: 3px solid var(--accent-color);
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 2px;
    font-size: 14px;
    line-height: 1.5;
}

.fact-similarity {
    font-size: 11px;
    color: var(--accent-color);
    font-weight: bold;
    margin-bottom: 4px;
}

.fact-path {
    font-size: 11px;
    color: var(--border-color);
    margin-bottom: 6px;
    font-family: monospace;
}

.fact-text {
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
}

.fact-extract {
    font-size: 12px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
    white-space: pre-wrap;
    word-break: break-word;
}

.fact-card a {
    color: var(--accent-color);
    text-decoration: none;
}

.fact-card a:hover {
    text-decoration: underline;
}

.fact-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.fact-actions button {
    font-size: 12px;
    padding: 4px 10px;
}

/* Editor page - no scroll */
.editor-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.editor-area {
    flex: 1;
    min-height: 0;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14pt;
    padding: 20px;
    border: none;
    outline: none;
    resize: none;
    background: var(--editor-bg);
    color: var(--text-color);
    line-height: 1.6;
}

.editor-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 16px;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: var(--menu-bg);
    flex-shrink: 0;
}

/* Results area - scrollable box */
.results-area {
    max-height: 140px;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
    background: var(--window-bg);
    flex-shrink: 0;
}

/* Version list */
.version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

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

.version-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.version-date {
    font-weight: bold;
    color: var(--accent-color);
    font-family: monospace;
}

.version-comment {
    color: var(--border-color);
    font-style: italic;
}

/* Buttons */
button {
    padding: 8px 16px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--menu-bg);
    color: var(--text-color);
    font-size: 13px;
}

button:hover {
    background: var(--accent-color);
    color: white;
}

button:disabled {
    background: var(--disabled-bg);
    color: var(--disabled-text);
    cursor: default;
    border-color: var(--border-color);
}

button:disabled:hover {
    background: var(--disabled-bg);
    color: var(--disabled-text);
}

button.primary {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    background: var(--editor-bg);
    color: var(--text-color);
    font-size: 13px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* Project tree */
.tree-node {
    padding: 4px 8px;
    cursor: pointer;
    font-size: 13px;
}

.tree-node:hover {
    background: var(--accent-color);
    color: white;
}

.tree-node .children {
    padding-left: 20px;
}

/* Grid splitter simulation */
.grid-splitter {
    width: 5px;
    cursor: col-resize;
    background: transparent;
}

/* Search section below editor */
.search-section {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px 12px;
    background: var(--menu-bg);
    flex-shrink: 0;
}

.search-section input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: var(--editor-bg);
    color: var(--text-color);
    font-size: 13px;
}

.search-section input::placeholder {
    color: var(--border-color);
}



/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog {
    background: var(--window-bg);
    border: 2px solid var(--border-color);
    min-width: 400px;
    box-shadow: 4px 4px 8px rgba(0,0,0,0.3);
}

.modal-title {
    background: var(--accent-color);
    color: white;
    padding: 6px 12px;
    font-weight: bold;
    font-size: 14px;
}

.modal-body {
    padding: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.modal-dialog .form-group {
    margin-bottom: 12px;
}

.modal-dialog .form-group:last-child {
    margin-bottom: 0;
}

.modal-dialog .form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 13px;
}

.modal-dialog .form-group input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    background: var(--editor-bg);
    color: var(--text-color);
    font-size: 13px;
}

/* File tree in sidebar */
.tree-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 12px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-item:hover {
    background: var(--accent-color);
    color: white;
}

.tree-item.active {
    background: var(--accent-color);
    color: white;
    font-weight: bold;
}

.tree-item.file {
    padding-left: 28px;
}

.tree-item.tree-child {
    padding-left: 44px;
}

.tree-icon {
    flex-shrink: 0;
    font-size: 11px;
}

.tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.tree-rename {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 0 4px;
    opacity: 0.4;
    color: inherit;
    flex-shrink: 0;
}

.tree-rename:hover {
    opacity: 1;
}

.nav-header-actions {
    margin-left: auto;
    display: flex;
    gap: 2px;
}

.nav-item-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    opacity: 0.5;
    color: inherit;
}

.nav-item-icon:hover {
    opacity: 1;
}

.nav-item-sub.active {
    background: var(--accent-color);
    color: white;
}

/* Progress */
.progress-bar {
    width: 100%;
    height: 20px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s;
}

/* Model list */
.model-list {
    display: grid;
    gap: 8px;
}

.model-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 4px;
}

.model-card .model-name {
    font-weight: bold;
    font-size: 14px;
}

.model-card .model-details {
    font-size: 12px;
    color: var(--border-color);
    margin-top: 4px;
}

/* Settings page */
.settings-page {
    width: 100%;
}

.settings-layout {
    display: grid;
    grid-template-columns: 1fr 2fr 2fr;
    gap: 16px;
}

.settings-column {
    min-width: 0;
}

.settings-column .form-group textarea {
    min-height: 120px;
    font-family: monospace;
    font-size: 12px;
    resize: vertical;
}

.settings-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 16px;
}

.settings-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 16px;
    margin-bottom: 12px;
}

.settings-section-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 12px;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.form-hint {
    font-size: 11px;
    color: var(--border-color);
    margin-top: 4px;
}

.settings-status {
    margin-top: 16px;
    padding: 10px;
    background: var(--card-bg);
    border: 1px solid var(--accent-color);
    font-size: 13px;
}

/* Diff view */
.diff-panel {
    border-top: 2px solid var(--border-color);
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.diff-panel h4, .result-panel h4 {
    margin-bottom: 8px;
    font-size: 14px;
}

.diff-view {
    font-family: monospace;
    font-size: 13px;
    line-height: 1.5;
}

.diff-line {
    display: flex;
    gap: 8px;
    padding: 1px 4px;
}

.diff-line-num {
    color: var(--border-color);
    min-width: 32px;
    text-align: right;
    user-select: none;
}

.diff-line-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-inserted {
    background: rgba(0, 200, 0, 0.15);
}

.diff-deleted {
    background: rgba(200, 0, 0, 0.15);
}

.diff-modified {
    background: rgba(200, 200, 0, 0.15);
}

.result-panel {
    border-top: 2px solid var(--border-color);
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.result-text {
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.5;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

/* Assistant page */
.assistant-page {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.assistant-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.assistant-toolbar select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 13px;
}

.assistant-panels {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.assistant-input-panel,
.assistant-output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.assistant-input-panel h4,
.assistant-output-panel h4 {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: bold;
}

.assistant-textarea {
    flex: 1;
    resize: none;
    padding: 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: monospace;
    font-size: 13px;
    min-height: 200px;
}

.assistant-output {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-family: monospace;
    font-size: 13px;
    overflow-y: auto;
    white-space: pre-wrap;
    min-height: 200px;
}

.assistant-output pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
    font-size: inherit;
}

.assistant-error {
    color: red;
}

.assistant-hint {
    color: var(--border-color);
    font-style: italic;
}

::-webkit-scrollbar-track {
    background: var(--window-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Auth pages - logo above card */
.auth-logo {
    text-align: center;
    margin-bottom: 16px;
}

.auth-logo img {
    max-width: 120px;
    height: auto;
}

/* Sidebar logo */
.sidebar-logo {
    text-align: center;
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.sidebar-logo img {
    max-width: 100px;
    height: auto;
}

/* Splash screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    background: var(--window-bg);
}

.splash-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.15;
}

.splash-content {
    position: relative;
    text-align: center;
    z-index: 1;
}

.splash-logo img {
    max-width: 200px;
    height: auto;
    margin-bottom: 32px;
}

.splash-loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: splash-spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes splash-spin {
    to { transform: rotate(360deg); }
}

/* Info overlay content */
.info-content {
    background: var(--card-bg);
    padding: 40px;
    border: 2px solid var(--border-color);
    max-width: 400px;
}

.info-content h1 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--accent-color);
}

.info-version,
.info-copyright {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-color);
}

.info-homepage {
    margin: 16px 0;
}

.info-homepage a {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 14px;
}

.info-homepage a:hover {
    text-decoration: underline;
}

.info-close-btn {
    margin-top: 16px;
    padding: 8px 24px;
}

/* Sidebar info button */
.sidebar {
    display: flex;
    flex-direction: column;
}

.sidebar-spacer {
    flex: 1;
}

.sidebar-info-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--menu-bg);
    color: var(--text-color);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px auto;
    padding: 0;
}

.sidebar-info-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Editor modified badge */
.editor-modified-badge {
    color: #e74c3c;
    font-size: 16px;
    line-height: 1;
}

/* Diff action buttons */
.diff-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

/* Version list */
.version-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
}

.version-item.active {
    border-color: var(--accent-color);
    background: color-mix(in srgb, var(--accent-color) 10%, transparent);
}

.version-item-info {
    display: flex;
    gap: 12px;
    align-items: center;
}

.version-date {
    font-weight: bold;
    white-space: nowrap;
}

.version-comment {
    color: var(--border-color);
    font-size: 12px;
}

.version-item-actions {
    display: flex;
    gap: 4px;
}

.btn-sm {
    font-size: 11px;
    padding: 2px 8px;
}

.btn-danger {
    background: #c0392b;
    color: white;
    border: none;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 3px;
}

.btn-danger:hover {
    background: #e74c3c;
}

/* User management page */
.usermanagement-page {
    padding: 20px;
}

.usermanagement-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.usermanagement-table th,
.usermanagement-table td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.usermanagement-table th {
    font-weight: bold;
    background: var(--menu-bg);
}

.usermanagement-current {
    font-weight: bold;
}

.usermanagement-inactive {
    opacity: 0.5;
}

.usermanagement-status-active {
    color: #27ae60;
    font-weight: bold;
}

.usermanagement-status-inactive {
    color: #e74c3c;
    font-weight: bold;
}

.usermanagement-actions {
    display: flex;
    gap: 4px;
}

.usermanagement-status {
    margin-top: 12px;
    padding: 8px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--accent-color) 15%, transparent);
    font-size: 13px;
}
