/* --- CSS-Variablen für Light & Dark Theme --- */
:root {
    /* Bootstrap Light Theme Colors */
    --bs-blue: #0d6efd;
    --bs-indigo: #6610f2;
    --bs-purple: #6f42c1;
    --bs-pink: #d63384;
    --bs-red: #dc3545;
    --bs-orange: #fd7e14;
    --bs-yellow: #ffc107;
    --bs-green: #198754;
    --bs-teal: #20c997;
    --bs-cyan: #0dcaf0;
    --bs-gray: #6c757d;
    --bs-gray-dark: #343a40;
    --bs-primary: #0d6efd;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-info: #0dcaf0;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-light: #f8f9fa;
    --bs-dark: #212529;

    /* App-specific mappings to Bootstrap colors */
    --background-color: #fff;
    --app-background: #f8f9fa;
    --sidebar-background: #ffffff;
    --sidebar-hover-bg: #e9ecef;
    --primary-text-color: #212529;
    --secondary-text-color: #6c757d;
    --input-background: #e9ecef;
    --user-message-bg: #cfe2ff;
    --user-message-text: #052c65;
    --bot-message-bg: #ffffff;
    --border-color: #dee2e6;
    --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif;
    --icon-color: #6c757d;
    --accent-color: #0d6efd;
}

:root[data-theme='dark'] {
    /* Bootstrap Dark Theme Colors */
    --bs-blue: #0d6efd;
    --bs-indigo: #6610f2;
    --bs-purple: #6f42c1;
    --bs-pink: #d63384;
    --bs-red: #dc3545;
    --bs-orange: #fd7e14;
    --bs-yellow: #ffc107;
    --bs-green: #198754;
    --bs-teal: #20c997;
    --bs-cyan: #0dcaf0;
    --bs-gray: #6c757d;
    --bs-gray-dark: #343a40;
    --bs-primary: #6ea8fe;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-info: #0dcaf0;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-light: #f8f9fa;
    --bs-dark: #212529;

    /* App-specific mappings to Bootstrap dark colors */
    --background-color: #212529;
    --app-background: #212529;
    --sidebar-background: #2b3035;
    --sidebar-hover-bg: #343a40;
    --primary-text-color: #dee2e6;
    --secondary-text-color: #adb5bd;
    --input-background: #343a40;
    --user-message-bg: #031633;
    --user-message-text: #6ea8fe;
    --bot-message-bg: #2b3035;
    --border-color: #495057;
    --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.3);
    --icon-color: #adb5bd;
    --accent-color: #6ea8fe;
}

/* --- Globale Stile --- */
* {
    box-sizing: border-box;

}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--primary-text-color);
    margin: 0;
    height: 100vh;
}

.hidden {
    display: none !important;
}

/* --- App-Struktur & Layout --- */
#app-container {
    width: 100%;
    height: 100%;
    display: flex;
    background-color: var(--app-background);
    /*overflow: hidden;    vwyer */ 
    transition: margin-left 0.3s ease; /* For sidebar toggle */
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-background);
    flex-shrink: 0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: margin-left 0.3s ease;
}

#app-container.sidebar-hidden .sidebar {
    margin-left: -260px;
}


/* The main view container now sets up the layout boundaries */
#documentation-view {
    height: 100%;
    overflow: hidden; /* Prevents the whole view from scrolling */
    background-color: var(--doc-bg);
}

.doc-container {
    display: flex; /* Key change: use Flexbox for the layout */
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.doc-nav {
    width: 280px;
    flex-shrink: 0; /* Prevents the nav from shrinking */
    background-color: var(--doc-nav-bg);
    border-right: 1px solid var(--doc-border-color);
    padding: 32px;
    /* Allows the nav to scroll ONLY if its own content is taller than the screen */
    overflow-y: auto;
}

.doc-nav h1 {
    font-size: 1.4rem;
    margin-top: 0;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--doc-border-color);
    color: var(--doc-text-primary);
}

.doc-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.doc-nav ul li a {
    display: block;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--doc-text-secondary);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: background-color 0.2s, color 0.2s;
    border-left: 3px solid transparent;
}

.doc-nav ul li a:hover {
    background-color: var(--doc-nav-hover-bg);
    color: var(--doc-text-primary);
}

.doc-nav ul li a.active {
    background-color: var(--doc-nav-active-bg);
    color: var(--doc-nav-active-text);
    font-weight: 500;
    border-left-color: var(--doc-accent-color);
}

.doc-nav ul ul {
    margin-left: 16px;
    margin-top: 8px;
    border-left: 1px solid var(--doc-border-color);
}

.doc-content {
    flex-grow: 1; /* Allows the content to take up the remaining space */
    min-width: 0;
    padding: 40px 60px;
    overflow-y: auto; /* KEY CHANGE: This element is now the scrolling container */
    scroll-behavior: smooth;
    color: var(--doc-text-primary);
    line-height: 1.7;
}

.doc-content section {
    margin-bottom: 60px;
    padding-top: 20px;
}

.doc-content h2, .doc-content h3 {
    color: var(--doc-text-primary);
}

.doc-content h2 {
    font-size: 2.2rem;
    border-bottom: 1px solid var(--doc-border-color);
    padding-bottom: 12px;
    margin-bottom: 24px;
}

.doc-content h3 {
    font-size: 1.5rem;
    margin-top: 40px;
    margin-bottom: 16px;
}

.doc-content p {
    font-size: 1.1rem;
    color: var(--doc-text-secondary);
}

.doc-content code {
    background-color: var(--doc-code-bg);
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95em;
    color: var(--doc-text-primary);
}

.doc-content strong {
    color: var(--doc-text-primary);
    font-weight: 500;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    position: relative;
    overflow-y: auto; /* <-- DIESE ZEILE HINZUFÜGEN (macht diesen Bereich scrollbar)  vwyer*/
}

/* --- Header --- */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

#header-logo {
    height: 30px;
    display: block;
    filter: none;
    transition: filter 0.3s ease;
}

:root[data-theme='dark'] #header-logo {
    filter: brightness(0) invert(1);
}

.header-title h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}















/* --- Knowledge Base View --- */
#knowledge-base-view {
    padding: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#admin-qdrant-view {
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.kb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    background-color: var(--background-color);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.kb-header h2 {
    font-size: 1.5rem;
    margin: 0;
}


/* In your main CSS file */

.document-card .card-header {
    display: block;
    position: relative;
    margin-bottom: 0.5rem;
}

.document-card .card-header h4 {
    margin: 0;
    word-break: break-word;
}

.status-icon {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 1.3rem;
    z-index: 10;
    background: var(--bot-message-bg);
    padding: 2px;
    border-radius: 4px;
}

.status-icon.completed { color: #28a745; } /* Green */
.status-icon.processing { color: #007bff; animation: spin 2s linear infinite; } /* Blue + Spin */
.status-icon.failed { color: #dc3545; } /* Red */
.status-icon.pending { color: #6c757d; } /* Grey */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


.kb-group-header {
    font-size: 1.2rem;
    color: var(--primary-text-color);
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Erste Überschrift hat keinen extra Abstand nach oben */
.kb-group-header:first-child {
    margin-top: 0;
}

/* TomSelect KB Group Create Option */
.create-option {
    padding: 8px 12px;
    color: var(--primary-color);
    font-weight: 500;
}

.create-option i {
    margin-right: 8px;
}

.no-results {
    padding: 8px 12px;
    color: var(--secondary-text-color);
    font-style: italic;
}

/* Context size indicator next to KB group title */
.kb-context-size {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    color: var(--primary-color);
    white-space: nowrap;
    cursor: help;
    transition: all 0.2s ease;
}

.kb-context-size:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}

.kb-context-size i {
    font-size: 0.9rem;
    opacity: 0.8;
}

.kb-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 25px;
    transition: all 0.2s ease-in-out;
    background-color: var(--app-background);
    border: 1px solid var(--border-color);
    color: var(--secondary-text-color);
}

.kb-action-btn.main-action {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.kb-action-btn.main-action:hover {
    background-color: #3b7ad6;
    border-color: #3b7ad6;
}

.kb-action-btn:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--primary-text-color);
    border-color: var(--secondary-text-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.kb-action-btn i {
    font-size: 1rem;
}

/* Upload Modal */
.kb-upload-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.kb-upload-modal.hidden {
    display: none;
}

.kb-upload-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.kb-upload-modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    background: var(--background-color);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

.kb-upload-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(168, 85, 247, 0.05));
    flex-shrink: 0;
}

.kb-upload-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-text-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.kb-upload-modal-header h2 i {
    color: var(--primary-color);
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--secondary-text-color);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--hover-bg);
    color: var(--primary-text-color);
}

.kb-upload-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kb-upload-container {
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Upload modal drop area styling */
.kb-upload-modal .drop-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    background: var(--input-background);
    transition: all 0.2s ease;
}

.kb-upload-modal .drop-area:hover,
.kb-upload-modal .drop-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.drop-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--secondary-text-color);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.drop-area:hover,
.drop-area.drag-over {
    border-color: var(--accent-color);
    background-color: #f0f4f9;
}

:root[data-theme='dark'] .drop-area:hover,
:root[data-theme='dark'] .drop-area.drag-over {
    background-color: #2b2e32;
}

.drop-area p {
    color: var(--secondary-text-color);
    margin: 0;
}

.drop-area input[type="file"] {
    display: none;
}

.kb-form-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.document-form {
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--app-background);
    box-shadow: var(--shadow);
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.form-header h4 {
    margin: 0;
    font-size: 1rem;
}

/* File Type Warning Notices */
.file-type-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.file-type-notice.file-indexable {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

:root[data-theme='dark'] .file-type-notice.file-indexable {
    background-color: #1a3d2e;
    color: #75b798;
    border-color: #2d5a44;
}

.file-type-notice.file-not-indexable {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffe69c;
}

:root[data-theme='dark'] .file-type-notice.file-not-indexable {
    background-color: #3d3416;
    color: #ffda6a;
    border-color: #594920;
}

.file-type-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.file-type-message {
    flex-grow: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--secondary-text-color);
    margin-bottom: 0.25rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--input-background);
    color: var(--primary-text-color);
    font-size: 1rem;
}

.form-group input:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

.form-group.field-references {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 1rem;
}

.kb-upload-action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Bulk Metadata Editor */
.bulk-editor {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

:root[data-theme='dark'] .bulk-editor {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

.bulk-editor-header {
    color: white;
    margin-bottom: 1.5rem;
}

.bulk-editor-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bulk-editor-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

.bulk-editor-content {
    background-color: var(--background-color);
    border-radius: 8px;
    padding: 1.5rem;
}

.bulk-field-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.bulk-field-wrapper input,
.bulk-field-wrapper select {
    flex: 1;
}

.apply-to-all-btn {
    padding: 0.6rem 1rem;
    background-color: var(--bs-primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s ease;
}

.apply-to-all-btn:hover {
    background-color: #0b5ed7;
    transform: translateY(-1px);
}

.apply-to-all-btn.applied {
    background-color: var(--bs-success);
}

.individual-forms-header {
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.individual-forms-header h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
    color: var(--primary-text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.individual-forms-header p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--secondary-text-color);
}

/* Upload Progress Indicator */
.upload-progress-container {
    background-color: var(--app-background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.upload-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.upload-progress-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.upload-progress-summary {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.upload-progress-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.upload-progress-bar {
    flex: 1;
    height: 24px;
    background-color: var(--input-background);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--bs-primary), var(--bs-info));
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
}

#upload-progress-percentage {
    font-weight: 600;
    color: var(--primary-text-color);
    min-width: 45px;
    text-align: right;
}

.upload-file-statuses {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.file-upload-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--background-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.file-status-icon {
    font-size: 1.2rem;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-status-icon.waiting {
    color: var(--bs-gray);
}

.file-status-icon.uploading {
    color: var(--bs-primary);
}

.file-status-icon.success {
    color: var(--bs-success);
}

.file-status-icon.error {
    color: var(--bs-danger);
}

.file-status-name {
    flex: 1;
    font-weight: 500;
    color: var(--primary-text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-status-message {
    font-size: 0.85rem;
    color: var(--secondary-text-color);
}

#kb-document-list-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.document-search-bar {
    padding: 1rem 1.5rem;
    background-color: var(--background-color);
    position: sticky;
    top: 0;
    z-index: 90;
    flex-shrink: 0;
}

.document-search-bar input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--input-background);
    color: var(--primary-text-color);
    font-size: 1rem;
}

#kb-document-list {
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.document-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.document-card {
    background-color: var(--bot-message-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 180px;
    position: relative;
    transition: all 0.2s ease;
}

.document-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.document-card h4 {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.4;
    /* Limit title to 3 lines with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    max-height: 4.2em; /* 1.4 line-height × 3 lines */
    padding-right: 2rem; /* Space for status icon */
}

/* Card sections */
.card-main-info {
    flex-shrink: 0;
}

.card-meta-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.card-actions-info {
    margin-top: auto;
    padding-top: 0.5rem;
}

.document-meta-item {
    font-size: 0.8rem;
    color: var(--secondary-text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.document-meta-item i {
    min-width: 14px;
    text-align: center;
}

.document-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}


/* --- Sidebar --- */
.sidebar-main-content {
    flex-grow: 1;
    overflow-y: auto;
}

.new-chat-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 15px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 20px;
    text-align: left;
    color: var(--primary-text-color);
}

.new-chat-button:hover {
    background-color: var(--sidebar-hover-bg);
}

.sidebar-header {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--secondary-text-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding: 0 5px;
}

.chat-history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: auto;
}

.chat-history-list li {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.chat-history-list li:hover {
    background-color: var(--sidebar-hover-bg);
}

.chat-history-list li.active {
    background-color: var(--user-message-bg);
    color: var(--user-message-text);
    font-weight: 500;
}

:root[data-theme='dark'] .chat-history-list li.active {
     color: #fff;
}

.chat-history-list li .chat-title {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-list li .chat-actions {
    display: flex;
    flex-shrink: 0;
    padding-left: 10px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.chat-history-list li:hover .chat-actions {
    visibility: visible;
    opacity: 1;
}

.chat-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text-color);
}

.chat-action-btn:hover {
    background-color: rgba(0,0,0,0.1);
}

:root[data-theme='dark'] .chat-action-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

.rename-input {
    width: 100%;
    border: 1px solid var(--accent-color);
    background-color: var(--app-background);
    color: var(--primary-text-color);
    border-radius: 4px;
    padding: 8px;
    font-size: 0.9rem;
    outline: none;
}

.sidebar-footer {
    flex-shrink: 0;
    padding-top: 15px;
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--secondary-text-color);
    font-size: 0.9rem;
}

.sidebar-footer-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--primary-text-color);
}

.sidebar-footer-link > i.fa-solid {
    width: 20px;
    text-align: center;
    font-size: 18px;
}

.sidebar-footer-link.delete-all {
    color: #ef4444;
}

.sidebar-footer-link.delete-all:hover {
    background-color: #fee2e2;
    color: #b91c1c;
}

:root[data-theme='dark'] .sidebar-footer-link.delete-all:hover {
    background-color: #450a0a;
    color: #fca5a5;
}

/* --- Dark Mode Toggle & Profile Dropdown --- */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.theme-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #4A90E2;
}
input:checked + .slider:before {
    transform: translateX(20px);
}

.profile-container {
    position: relative;
}

.profile-activator {
    background-color: var(--input-background);
    color: var(--primary-text-color);
    border: 1px solid transparent;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
}
.profile-activator:hover {
    border-color: var(--secondary-text-color);
}

.profile-dropdown {
    position: absolute;
    top: 120%;
    right: 0;
    background-color: var(--app-background);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    width: 280px;
    padding: 12px;
    z-index: 100;
}
.profile-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 10px 0;
}
.user-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
}
#user-fullname {
    font-weight: 500;
}
#user-email, #user-groups-container {
    color: var(--secondary-text-color);
}
.logout-button {
    background: none;
    border: none;
    color: var(--secondary-text-color);
    padding: 8px;
    width: 100%;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
}
.logout-button:hover {
    background-color: var(--input-background);
}

/* --- Chat Area --- */
.chat-box {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    scrollbar-width: none;
    -ms-overflow-style: none;

    /* Add this line to prevent the last message from being hidden */
    padding-bottom: 120px; /* ✨ Adjust this value as needed */
}


.chat-box::-webkit-scrollbar {
    display: none;
}

.message {
    max-width: 85%;
    width: fit-content;
    margin-bottom: 20px;
    border-radius: 18px;
    padding: 12px 18px;
    box-shadow: var(--shadow);
    line-height: 1.6;
    position: relative;
}

.message.user {
    margin-left: auto;
    background-color: var(--user-message-bg);
    color: var(--user-message-text);
    border-bottom-right-radius: 4px;
}

.message.bot {
    background-color: var(--bot-message-bg);
    border-bottom-left-radius: 4px;
}

/* --- Message Attachments --- */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.attachment-item {
    position: relative;
}

.attachment-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: background-color 0.2s, transform 0.2s;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.attachment-link:hover {
    background-color: rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

:root[data-theme='dark'] .attachment-link {
    background-color: rgba(255, 255, 255, 0.05);
}

:root[data-theme='dark'] .attachment-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.attachment-link i {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.attachment-link .fa-file-pdf {
    color: #e53935;
}

.attachment-link .fa-file-image {
    color: #4caf50;
}

.attachment-name {
    font-size: 0.9rem;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- File Viewer Modal --- */
.file-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.file-viewer-container {
    background-color: var(--app-background);
    border-radius: 12px;
    width: 90vw;
    height: 90vh;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.file-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.file-viewer-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
}

.file-viewer-title i.fa-file-pdf {
    color: #e53935;
    font-size: 1.2rem;
}

.file-viewer-title i.fa-file-image {
    color: #4caf50;
    font-size: 1.2rem;
}

.file-viewer-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.file-viewer-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

:root[data-theme='dark'] .file-viewer-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.file-viewer-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    background-color: #525659;
}

.file-viewer-content.image-viewer {
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.file-viewer-embed {
    width: 100%;
    height: 100%;
    border: none;
}

.file-viewer-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* --- Download UI for non-renderable files --- */
.file-download-container {
    background-color: var(--app-background);
}

.file-download-content {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--app-background);
}

.download-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
    padding: 40px;
    max-width: 500px;
}

.download-icon {
    font-size: 4rem;
    color: var(--primary-color);
    opacity: 0.8;
}

.download-info h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.download-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 1rem;
}

.file-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 16px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

:root[data-theme='dark'] .file-meta {
    background-color: rgba(255, 255, 255, 0.05);
}

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

.file-meta i {
    width: 16px;
    text-align: center;
    color: var(--primary-color);
}

.download-file-btn {
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.download-file-btn:hover {
    background-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.download-file-btn:active {
    transform: translateY(0);
}

.download-file-btn i {
    font-size: 1.1rem;
}

/* --- Sources Modal --- */
.sources-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.sources-modal-content {
    background-color: var(--app-background);
    border-radius: 12px;
    width: 90vw;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sources-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    /*border-bottom: 1px solid var(--border-color);*/
    flex-shrink: 0;
}

.sources-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sources-modal-header h3 i {
    color: var(--primary-color);
}

.sources-modal-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.sources-modal-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

:root[data-theme='dark'] .sources-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sources-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}


/* Split layout for bot response + sources */
.sources-modal-split {
    max-width: 1400px;
    width: 95vw;
}

.sources-modal-body-split {
    flex: 1;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.sources-modal-left,
.sources-modal-right {
    overflow-y: auto;
    padding: 20px 24px;
}

.sources-modal-left {
    /*border-right: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.02);*/
}

:root[data-theme='dark'] .sources-modal-left {
    /* background-color: rgba(255, 255, 255, 0.02); */
}

.sources-modal-left h4,
.sources-modal-right h4 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
    /* position: sticky; */
    top: 0;
    /* background-color: inherit; */
    padding-bottom: 12px;
    z-index: 10;
}

.sources-modal-left h4 i {
    color: var(--primary-color);
}

.sources-modal-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bot-response-display {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-color);
}

/* Highlight matched text */
.source-highlight,
mark.source-highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

:root[data-theme='dark'] .source-highlight,
:root[data-theme='dark'] mark.source-highlight {
    background-color: #ffc107;
    color: #000;
}

/* Clickable highlights */
.source-highlight.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.source-highlight.clickable:hover {
    background-color: #ffd700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

:root[data-theme='dark'] .source-highlight.clickable:hover {
    background-color: #ffb300;
}

/* Grouped Sources Structure */
.source-kb-group {
    margin-bottom: 24px;
}

.source-kb-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary-color), #667eea);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 600;
}

.source-document-group {
    margin-bottom: 16px;
    border-left: 3px solid var(--primary-color);
    padding-left: 12px;
}

.source-document-header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.source-document-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    flex: 1;
}

.source-document-header.clickable {
    cursor: pointer;
    user-select: none;
}

.source-document-header.clickable:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

:root[data-theme='dark'] .source-document-header.clickable:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.source-view-btn {
    padding: 8px 12px;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    animation: subtlePulse 2s ease-in-out infinite;
}

.source-view-btn:not(:disabled):hover {
    background-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: none;
}

.source-view-btn:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.5;
    animation: none;
}

.source-view-btn i {
    font-size: 1rem;
}

@keyframes subtlePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(116, 103, 239, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(116, 103, 239, 0);
    }
}

.chevron-icon {
    transition: transform 0.3s ease;
    font-size: 0.85rem;
    color: var(--primary-color);
}

.chunk-count {
    font-size: 0.8rem;
    font-weight: normal;
    color: var(--secondary-text-color);
    margin-left: 4px;
}

.source-document-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--secondary-text-color);
    margin-bottom: 12px;
}

.source-document-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Collapsible chunks container */
.source-chunks-container {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.source-chunks-container.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.source-chunks-container.expanded {
    max-height: 10000px; /* Large enough to accommodate any content */
    opacity: 1;
    margin-top: 8px;
}

.source-chunk-item {
    background-color: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

:root[data-theme='dark'] .source-chunk-item {
    background-color: rgba(255, 255, 255, 0.03);
}

.source-chunk-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Flash animation for scrolling */
@keyframes chunk-flash {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(255, 235, 59, 0.3); }
}

.chunk-flash {
    animation: chunk-flash 2s ease;
}

:root[data-theme='dark'] .chunk-flash {
    animation: chunk-flash-dark 2s ease;
}

@keyframes chunk-flash-dark {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(255, 193, 7, 0.2); }
}

.chunk-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.chunk-number {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.85rem;
}

.chunk-text {
    line-height: 1.6;
    color: var(--text-color);
}

/* Responsive: Stack columns on smaller screens */
@media (max-width: 1024px) {
    .sources-modal-body-split {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .sources-modal-left {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sources-modal-left h4,
    .sources-modal-right h4 {
        position: static;
    }
}

/* Enhanced three-column modal layout */
.sources-modal-enhanced {
    max-width: 1800px;
    width: 98vw;
}

/* Two-column layout (default) */
.sources-modal-body-double {
    grid-template-columns: 1fr 1fr;
    gap: 0;
    transition: grid-template-columns 0.3s ease;
}

/* Three-column layout (when preview is shown) */
.sources-modal-body-triple {
    grid-template-columns: 1fr 1.2fr 1.3fr;
    gap: 0;
    transition: grid-template-columns 0.3s ease;
}

.sources-modal-middle {
    overflow-y: auto;
    padding: 20px 24px;
    /* border-right: 1px solid var(--border-color); */
}

.sources-modal-middle h4 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
    /* position: sticky; */
    top: 0;
    background-color: var(--app-background);
    padding-bottom: 12px;
    z-index: 10;
}

.sources-modal-preview {
    overflow-y: auto;
    padding: 20px 24px;
    /*background-color: rgba(0, 0, 0, 0.02);*/
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.sources-modal-preview.hidden-preview {
    display: none;
    opacity: 0;
    transform: translateX(20px);
}

:root[data-theme='dark'] .sources-modal-preview {
 /*   background-color: rgba(255, 255, 255, 0.02);*/
}

/* Enhanced header */
.sources-modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sources-modal-title h3 {
    margin: 0;
}

.sources-count {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Preview Panel Styles */
.preview-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-secondary);
    text-align: center;
    padding: 40px 20px;
}

.preview-placeholder i {
    font-size: 4rem;
    opacity: 0.3;
}

.preview-placeholder p {
    font-size: 0.95rem;
    margin: 0;
}

.preview-placeholder .fa-eye {
    color: var(--primary-color);
}

.preview-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.preview-loading p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.preview-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #dc3545;
    text-align: center;
    padding: 40px 20px;
}

.preview-error i {
    font-size: 3rem;
}

.error-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 12px;
    gap: 12px;
}

.preview-title-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.preview-title-section i {
    font-size: 2rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

.preview-title-text {
    min-width: 0;
    flex: 1;
}

.preview-title-text h5 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-file-size {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.preview-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.preview-action-btn,
.preview-close-btn {
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.preview-action-btn:hover,
.preview-close-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.preview-close-btn {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.preview-close-btn:hover {
    background: #c82333;
    border-color: #bd2130;
}

.preview-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.preview-metadata span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-metadata i {
    color: var(--primary-color);
}

.preview-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.preview-iframe {
    width: 100%;
    height: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    flex: 1;
}

.preview-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.preview-no-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 20px;
}

.preview-no-preview i {
    font-size: 4rem;
    opacity: 0.3;
    color: var(--text-secondary);
}

.preview-no-preview p {
    color: var(--text-secondary);
    margin: 0;
}

/* Responsive: Stack columns on smaller screens */
@media (max-width: 1600px) {
    .sources-modal-body-triple {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

@media (max-width: 1400px) {
    .sources-modal-enhanced {
        max-width: 1400px;
    }

    .sources-modal-body-triple {
        grid-template-columns: 0.8fr 1fr 1fr;
    }
}

@media (max-width: 1200px) {
    .sources-modal-body-triple,
    .sources-modal-body-double {
        grid-template-columns: 1fr 1fr;
    }

    .sources-modal-preview {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    .sources-modal-body-triple,
    .sources-modal-body-double {
        grid-template-columns: 1fr;
    }

    .sources-modal-left {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sources-modal-middle {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

.source-item {
    background-color: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    transition: box-shadow 0.2s;
}

:root[data-theme='dark'] .source-item {
    background-color: rgba(255, 255, 255, 0.03);
}

.source-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.source-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.source-number {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 12px;
    flex-shrink: 0;
}

.source-metadata {
    flex: 1;
}

.source-title {
    display: block;
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: 6px;
}

.source-details {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.source-details-extended {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.source-kb,
.source-score,
.source-version,
.source-origin,
.source-uploader,
.source-access {
    font-size: 0.85rem;
    color: var(--secondary-text-color);
    display: flex;
    align-items: center;
    gap: 5px;
}

.source-kb i {
    color: var(--primary-color);
}

.source-score i {
    color: #4caf50;
}

.source-version i {
    color: #ff9800;
}

.source-origin i {
    color: #03a9f4;
}

.source-uploader i {
    color: #9c27b0;
}

.source-access i {
    color: #00bcd4;
}

.source-content {
    background-color: rgba(0, 0, 0, 0.02);
    border-left: 3px solid var(--primary-color);
    padding: 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-color);
    white-space: pre-wrap;
    word-wrap: break-word;
}

:root[data-theme='dark'] .source-content {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Code Block Wrapper */
.code-block-wrapper {
    position: relative;
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #0d1117;
}

/* Code Block Header */
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #161b22, #1f2937);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-language-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #58a6ff;
    font-family: Arial;
}

/* Code Copy Button */
.code-copy-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.code-copy-btn.copied {
    background: rgba(46, 160, 67, 0.15);
    border-color: rgba(46, 160, 67, 0.3);
    color: #3fb950;
}

.code-copy-btn i {
    font-size: 0.85rem;
}

/* Pre and Code Elements */
.message pre {
    margin: 0;
    padding: 1rem;
    background-color: #0d1117;
    border-radius: 0;
    overflow-x: auto;
    position: relative;
    border: none;
}

.message pre code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre;
    display: block;
}

/* Default color for non-highlighted code */
.message pre code:not(.hljs) {
    color: #c9d1d9;
}

/* Syntax Highlighting - Let highlight.js theme define colors */
.message pre code.hljs {
    background: transparent;
    padding: 0;
    /* Colors will be set by highlight.js theme (github-dark or github) */
}

/* Dark theme adjustments */
:root[data-theme='dark'] .message pre {
    background-color: #0d1117;
}

:root[data-theme='dark'] .code-block-wrapper {
    background: #0d1117;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Light theme for code blocks */
:root[data-theme='light'] .code-block-wrapper {
    background: #f6f8fa;
    border-color: rgba(0, 0, 0, 0.1);
}

:root[data-theme='light'] .code-block-header {
    background: linear-gradient(135deg, #ffffff, #f3f4f6);
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

:root[data-theme='light'] .code-language-label {
    color: #0969da;
}

:root[data-theme='light'] .message pre {
    background-color: #f6f8fa;
}

:root[data-theme='light'] .message pre code:not(.hljs) {
    color: #24292f;
}

:root[data-theme='light'] .code-copy-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #24292f;
}

:root[data-theme='light'] .code-copy-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.15);
}

/* Inline code styling (not in pre blocks) */
.message code:not(pre code) {
    background: rgba(110, 118, 129, 0.2);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

/* --- Quick Actions under Bot Messages --- */
.quick-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-left: 8px;
}

.action-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--secondary-text-color);
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.action-btn:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--primary-text-color);
}

.action-btn.favourited {
    color: #f59e0b;
}

.feedback-group {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    border-left: 1px solid var(--border-color);
    padding-left: 8px;
}

.feedback-group .action-btn.selected {
    color: var(--user-message-text);
}

/* --- Input Area --- */
.footer-container {
    position: absolute; /* ✨ Lifts the footer */
    bottom: 0;          /* ✨ Pins it to the bottom */
    left: 0;            /* ✨ Stretches it across the width */
    right: 0;           /* ✨ Stretches it across the width */
    
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-top: 1px solid var(--border-color);
    background-color: transparent;
    /* Optional: Add a subtle backdrop blur for readability */
    backdrop-filter: blur(4px); 
}

.chat-input-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    align-items: center;
    background-color: var(--input-background);
    border-radius: 15px;
    box-shadow: var(--shadow);
}

#user-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 12px 20px;
    font: 1rem/1.5 var(--font-family);
    outline: none;
    color: var(--primary-text-color);
    resize: none;
    overflow-y: hidden;
    min-height: 24px;
    max-height: 200px;
}

#send-btn, #file-btn {
    background-color: var(--input-background);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: var(--secondary-text-color);
}

#send-btn:hover, #file-btn:hover {
    background-color: #d8dcdf;
}

:root[data-theme='dark'] #send-btn:hover,
:root[data-theme='dark'] #file-btn:hover {
    background-color: #555;
}

.footer-note {
    font-size: 0.75rem;
    color: var(--secondary-text-color);
    margin-top: 12px;
    text-align: center;
}

/* --- File Preview --- */
.file-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    max-height: 240px;
    overflow-y: auto;
    transition: all 0.3s ease-in-out;
}

.file-preview-container::-webkit-scrollbar { width: 4px; }
.file-preview-container::-webkit-scrollbar-thumb {
    background: var(--border-color, #ccc);
    border-radius: 4px;
}

.file-preview {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 12px;
    border: 1px solid var(--border-color, #e0e0e0);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.file-preview:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.file-preview .remove-file-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font: bold 14px/1 sans-serif;
    z-index: 10;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.file-preview:hover .remove-file-btn {
    opacity: 1;
    transform: scale(1);
}

.file-preview .remove-file-btn:hover {
    background-color: #e53935;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.file-preview .file-icon {
    font-size: 32px;
    color: var(--primary-color, #555);
    margin-bottom: 8px;
}

.file-preview span {
    font-size: 12px;
    color: var(--text-secondary-color, #666);
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Utility & Component Styles --- */

/* Buttons */
.copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--input-background);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.message.bot:hover .copy-button { opacity: 1; }
.copy-button:hover { background-color: #d8dcdf; }
:root[data-theme='dark'] .copy-button:hover { background-color: #555; }
.copy-button.copied { color: #4caf50; }
.copy-button svg { width: 16px; height: 16px; }

pre .copy-code-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #4e4e4e;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

pre:hover .copy-code-button { opacity: 1; }
pre .copy-code-button:hover { background-color: #6a6a6a; }

/* Top Controls - Main Container */
.top-controls-container {
    padding: 10px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 24px;
}

/* --- Unified Style for Selector Groups (Model & KB) --- */
.model-selector-container,
.kb-selector-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1; /* Allow both selectors to grow and share available space */
    min-width: 180px;
    color: var(--secondary-text-color);
    font-size: 0.9rem;
}

/* --- Unified Style for the Actual Controls (native <select> and TomSelect) --- */
#model-selector,
.kb-selector-container .ts-control {
    background-color: var(--input-background); /* CORRECTED: Use defined variable */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--primary-text-color); /* CORRECTED: Use defined variable */
    outline: none;
    cursor: pointer;
    padding: 6px 10px;
    box-sizing: border-box;
    transition: background-color 0.2s, border-color 0.2s;
}



.kb-header .header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.view-mode-toggle {
    display: flex;
    background-color: var(--input-background);
    border-radius: 20px;
    padding: 4px;
    border: 1px solid var(--border-color);
}

.view-mode-btn {
    background: transparent;
    border: none;
    color: var(--secondary-text-color);
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    transition: all 0.2s ease-in-out;
}

.view-mode-btn.active {
    background-color: var(--app-background);
    color: var(--primary-text-color);
    box-shadow: var(--shadow);
}

/* Stile für die Listenansicht */
.list-view-active .document-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* Geringerer Abstand in der Listenansicht */
}

.list-view-active .document-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1.5rem;
    min-height: auto;
    gap: 1rem;
}

.list-view-active .document-card:hover {
    transform: translateY(0);
}

/* Flexbox-Aufteilung für die Spalten */
.list-view-active .card-main-info {
    flex: 3;
    min-width: 0;
}

.list-view-active .card-meta-info {
    flex: 4;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    gap: 1rem;
}

.list-view-active .card-actions-info {
    flex: 1;
    margin-top: 0;
    padding-top: 0;
}

.list-view-active .card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0;
}

.list-view-active .card-header h4 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 0;
    max-height: none;
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
}

.list-view-active .status-icon {
    position: static;
    background: none;
    padding: 0;
}

.list-view-active .document-meta-item {
    min-width: 120px;
    justify-content: center;
}

.list-view-active .document-actions {
    margin-top: 0;
}




.document-meta-item .fa-lock,
.document-meta-item .fa-users {
    width: 14px; /* Sorgt für einheitliche Ausrichtung mit den anderen Icons */
    text-align: center;
}

.document-meta-item.sharing-private .fa-lock {
    color: #f59e0b; /* Ein warmer Gelbton für "Privat" */
}

.document-meta-item.sharing-public .fa-users {
    color: #10b981; /* Ein klares Grün für "Geteilt" */
}

/* Anpassungen für den Dark Mode für bessere Sichtbarkeit */
:root[data-theme='dark'] .document-meta-item.sharing-private .fa-lock {
    color: #facc15; /* Helleres Gelb */
}

:root[data-theme='dark'] .document-meta-item.sharing-public .fa-users {
    color: #34d399; /* Helleres Grün */
}

/* --- TomSelect Specific Styles --- */
/* Style for the selected items ("pills") inside the KB selector */
.kb-selector-container .ts-control .item {
    background-color: var(--accent-color);
    color: #ffffff;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.85rem;
}

/* Dropdown style for TomSelect */
.kb-selector-container .ts-dropdown {
    background-color: var(--app-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* Style for options within the TomSelect dropdown */
.kb-selector-container .ts-dropdown .option {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--primary-text-color); /* ADDED: Ensures text is readable in both modes */
}

/* Style for the hovered or active (keyboard-selected) option */
.kb-selector-container .ts-dropdown .option:hover,
.kb-selector-container .ts-dropdown .option.active {
    background-color: var(--sidebar-hover-bg); /* CORRECTED: Replaced blue with neutral hover color */
}

/* --- Token Counter (Unchanged) --- */
#token-counter-container {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 250px;
    flex-shrink: 0;
}

#token-count-text {
    font-size: 0.8rem;
    color: var(--secondary-text-color);
    white-space: nowrap;
    font-weight: 500;
}

.token-progress-bar {
    flex-grow: 1;
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

#token-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4CAF50, #81C784);
    border-radius: 3px;
    transition: width 0.4s ease-out;
}


/* Scroll to End Button */
#scroll-to-end-btn {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%) translateY(15px);
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(var(--background-color-rgb), 0.85); /* Requires --background-color-rgb variable */
    backdrop-filter: blur(4px);
    color: var(--primary-text-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

#scroll-to-end-btn:not(.hidden) {
    opacity: 0.8;
    transform: translateX(-50%) translateY(0);
    pointer-events: all;
}

#scroll-to-end-btn:hover {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1.05);
}


/* --- Views (Documentation, Toolbox, Favourites) --- */

.view-title {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.empty-view-message {
    color: var(--secondary-text-color);
    text-align: center;
    margin-top: 2rem;
}

/* Documentation View */
#documentation-view {
    height: 100%;
    overflow-y: auto;
    padding: 0rem 2.5rem;
}

.doc-container {
    display: flex;
    gap: 2.5rem;
}

.doc-nav {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 2rem;
}

.doc-nav h1 {
    font-size: 1.4rem;
    margin: 0 0 1.5rem 0;
    color: var(--primary-text-color);
}

.doc-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.doc-nav ul li a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--secondary-text-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: background-color 0.2s, color 0.2s;
}

.doc-nav ul li a:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--primary-text-color);
}

.doc-nav ul ul {
    margin-left: 20px;
    margin-top: 8px;
}

.doc-content {
    flex-grow: 1;
    min-width: 0;
}

.doc-content section {
    margin-bottom: 4rem;
    padding-top: 2rem;
}

#documentation-view h1, #documentation-view h2, #documentation-view h3,
.doc-content h2, .doc-content h3 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}
.doc-content h2 { font-size: 1.8rem; padding-bottom: 1rem; margin-bottom: 1.5rem; }
.doc-content h3 { font-size: 1.3rem; margin-top: 2.5rem; }

#documentation-view code, .doc-content code {
    background-color: var(--input-background);
    color: var(--primary-text-color);
    padding: 0.2em 0.4em;
    border-radius: 4px;
}
#documentation-view code { font-size: 0.9em; }
.doc-content p { font-size: 1rem; }
.doc-content code { font-family: 'Courier New', Courier, monospace; }

.search-container {
    display: flex;
    align-items: center;
    background-color: var(--input-background);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 15px;
    gap: 8px;
}

.search-container svg {
    stroke: var(--secondary-text-color);
    flex-shrink: 0;
}

#search-input {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    color: var(--primary-text-color);
    font-size: 0.9rem;
}

#search-input::placeholder {
    color: var(--secondary-text-color);
}

/* Favourites View */
.favourites-list {
    list-style: none;
    padding: 0;
}

.favourite-item {
    background-color: var(--bot-message-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.favourite-item-content p:first-child { margin-top: 0; }
.favourite-item-content p:last-child { margin-bottom: 0; }

.favourite-item-meta {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--secondary-text-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Toolbox View */
#toolbox-view {
    padding: 1rem 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.toolbox-card {
    background-color: var(--app-background);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toolbox-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: var(--secondary-text-color);
}

.toolbox-textarea-wrapper {
    position: relative;
    width: 100%;
    flex-grow: 1;
    display: flex;
}

#toolbox-view textarea,
.toolbox-output-div {
    width: 100%;
    resize: vertical;
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    background-color: var(--background-color);
    color: var(--primary-text-color);
}

#toolbox-view textarea { resize: vertical; }
#toolbox-view textarea:focus { outline: none; border-color: var(--secondary-text-color); }
.toolbox-output-div { overflow-y: auto; min-height: 160px; }

.toolbox-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.toolbox-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 25px;
    transition: all 0.2s ease-in-out;
    background-color: var(--app-background);
    border: 1px solid var(--border-color);
    color: var(--secondary-text-color);
}

.toolbox-action-btn:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--primary-text-color);
    border-color: var(--secondary-text-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.toolbox-action-btn i { font-size: 1rem; }
.toolbox-actions .toolbox-action-btn.loading { opacity: 0.5; cursor: not-allowed; }

.field-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.toolbox-textarea-wrapper:hover .field-actions { opacity: 1; }
.field-actions .action-btn {
    width: 32px;
    height: 32px;
    background-color: var(--input-background);
    border: 1px solid var(--border-color);
}
.field-actions .action-btn i { font-size: 0.9rem; }
#toolbox-transfer-container { display: flex; justify-content: center; padding: 0.5rem 0; }
#toolbox-transfer-container .action-btn { width: 40px; height: 40px; border: 1px solid var(--border-color); }

#admin-qdrant-section {
    margin-top: 2.5rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background-color: var(--input-background);
    position: relative;
}


#admin-log-section {
    margin-top: 2.5rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background-color: var(--input-background);
    position: relative;
}

#admin-qdrant-section.loading {
    opacity: 0.7;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.admin-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary-text-color);
}

.admin-summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-summary-card {
    flex: 1 1 160px;
    min-width: 140px;
    background-color: var(--app-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.admin-summary-card .label {
    font-size: 0.8rem;
    color: var(--secondary-text-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-summary-card .value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-text-color);
}

.admin-collection-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-collection-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--app-background);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-light);
}

.admin-collection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.admin-collection-header h4 {
    margin: 0;
    font-size: 1.05rem;
}

.admin-collection-meta {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    font-size: 0.9rem;
}

.admin-collection-meta div {
    color: var(--primary-text-color);
}

.admin-error {
    margin-bottom: 1rem;
    color: #dc3545;
    font-weight: 500;
}

#admin-qdrant-loader {
    position: absolute;
    inset: 0;
    margin: auto;
}


.admin-log-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.admin-log-entry {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--app-background);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-light);
}

.admin-log-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.admin-log-entry-header .log-level {
    font-weight: 600;
    text-transform: uppercase;
}

.admin-log-entry-header .log-time {
    font-size: 0.85rem;
    color: var(--secondary-text-color);
}

.admin-log-entry-meta {
    font-size: 0.8rem;
    color: var(--secondary-text-color);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.admin-log-message {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.admin-log-extra {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-family: var(--font-family-monospace, 'Courier New', monospace);
    background-color: var(--input-background);
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    white-space: pre-wrap;
}

.admin-log-entry .status-badge {
    align-self: flex-start;
}
.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background-color: var(--sidebar-hover-bg);
    color: var(--secondary-text-color);
}

.status-badge.status-green,
.status-badge.status-green_active,
.status-badge.status-ok {
    color: #0f5132;
    background-color: #d1e7dd;
}

.status-badge.status-yellow,
.status-badge.status-warning {
    color: #664d03;
    background-color: #fff3cd;
}

.status-badge.status-red,
.status-badge.status-error {
    color: #842029;
    background-color: #f8d7da;
}

.status-badge.status-missing {
    color: #374151;
    background-color: #e5e7eb;
}

.status-badge.status-unreachable {
    color: #512e05;
    background-color: #ffe8bb;
}

.status-badge.status-unknown {
    color: #1f2a37;
    background-color: #e5e7eb;
}

/* Loader */
.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 4px solid var(--border-color);
    border-left-color: var(--accent-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}


/* --- Responsive Anpassungen --- */
@media (max-width: 768px) {
    /* Example: Hide sidebar on small screens by default if needed */
    /* .sidebar { display: none; } */
}

.admin-log-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-log-input {
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--input-background);
    color: var(--primary-text-color);
}

.admin-log-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.admin-log-controls .kb-action-btn.delete {
    background-color: #ffe6e6;
    border-color: #f5b5b5;
    color: #c0392b;
}

.admin-log-controls .kb-action-btn.delete:hover {
    background-color: #f8d7da;
    border-color: #e5989b;
}
