/* MCP Memory Service Dashboard Styles */

/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Custom Properties */
:root {
    /* Color Palette */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #8b5cf6;
    --accent: #06d6a0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --neutral-50: #f9fafb;
    --neutral-100: #f3f4f6;
    --neutral-200: #e5e7eb;
    --neutral-300: #d1d5db;
    --neutral-400: #9ca3af;
    --neutral-500: #6b7280;
    --neutral-600: #4b5563;
    --neutral-700: #374151;
    --neutral-800: #1f2937;
    --neutral-900: #111827;

    /* Typography */
    --font-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Breakpoints */
    --mobile-max: 768px;
    --tablet-min: 769px;
    --tablet-max: 1024px;
    --desktop-min: 1025px;
}

/* Base Typography */
body {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    line-height: 1.5;
    color: var(--neutral-900);
    background-color: var(--neutral-50);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: var(--space-4);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

/* App Layout */
.app-container {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto auto auto 1fr auto;
    grid-template-areas:
        "header"
        "nav"
        "sync"
        "main"
        "footer";
}

/* Header Styles */
.app-header {
    grid-area: header;
    background: white;
    border-bottom: 1px solid var(--neutral-200);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-4) var(--space-6);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--space-6);
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.app-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.version-badge {
    background: var(--neutral-100);
    color: var(--neutral-600);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    font-weight: 500;
}

/* Search Section */
.search-section {
    flex: 1;
    max-width: 600px;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    padding-right: var(--space-12);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    background: var(--neutral-50);
    transition: var(--transition-base);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.search-btn {
    position: absolute;
    right: var(--space-2);
    padding: var(--space-2);
    background: none;
    border: none;
    color: var(--neutral-500);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: var(--transition-base);
}

.search-btn:hover {
    color: var(--primary);
    background: var(--neutral-100);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

/* Button Components */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-base);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--neutral-200);
    color: var(--neutral-700);
}

.btn-secondary:hover {
    background: var(--neutral-300);
}

.btn-danger {
    background: var(--error);
    color: white;
}

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

/* Navigation */
.main-nav {
    grid-area: nav;
    background: white;
    border-bottom: 1px solid var(--neutral-200);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-6);
    display: flex;
    gap: var(--space-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border: none;
    background: none;
    color: var(--neutral-600);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition-base);
}

.nav-item:hover {
    color: var(--primary);
    background: var(--neutral-50);
}

.nav-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Sync Status Bar */
.sync-status-bar {
    grid-area: sync;
    display: none; /* Hidden by default, shown by JavaScript for hybrid mode */
    background: var(--neutral-50);
    border-bottom: 1px solid var(--neutral-200);
    padding: var(--space-3) var(--space-6);
    transition: all 0.3s ease;
}

.sync-status-bar.visible {
    display: block;
}

.sync-status-bar.synced {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.05) 0%, rgba(34, 197, 94, 0) 100%);
    border-bottom-color: var(--success-light);
}

.sync-status-bar.syncing {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0) 100%);
    border-bottom-color: var(--primary-light);
}

.sync-status-bar.pending {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.1) 0%, rgba(251, 191, 36, 0) 100%);
    border-bottom-color: var(--warning-light);
}

.sync-status-bar.error {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0) 100%);
    border-bottom-color: var(--danger-light);
}

.sync-status-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.sync-status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
}

#syncStatusIcon {
    font-size: var(--text-lg);
    animation: sync-pulse 2s ease-in-out infinite;
}

.sync-status-bar.syncing #syncStatusIcon {
    animation: sync-rotate 1s linear infinite;
}

#syncStatusText {
    font-weight: 600;
    color: var(--neutral-900);
}

.sync-details {
    color: var(--neutral-600);
    margin-left: var(--space-2);
}

.sync-button {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sync-button:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.sync-button:active:not(:disabled) {
    transform: translateY(0);
}

.sync-button:disabled {
    background: var(--neutral-300);
    cursor: not-allowed;
    opacity: 0.6;
}

.sync-button-icon {
    font-size: var(--text-base);
}

@keyframes sync-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes sync-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Main Content */
.main-content {
    grid-area: main;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
    width: 100%;
}

/* View Containers */
.view-container {
    display: none;
}

.view-container.active {
    display: block;
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    grid-template-rows: auto auto;
    gap: var(--space-8);
    grid-template-areas:
        "welcome quick-actions"
        "recent quick-actions";
}

.welcome-card {
    grid-area: welcome;
    background: white;
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.welcome-card h2 {
    color: var(--neutral-900);
    margin-bottom: var(--space-3);
}

.welcome-card p {
    color: var(--neutral-600);
    margin-bottom: var(--space-6);
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--space-1);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--neutral-600);
}

.recent-memories {
    grid-area: recent;
    background: white;
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.quick-actions {
    grid-area: quick-actions;
    background: white;
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.action-grid {
    display: grid;
    gap: var(--space-4);
}

.action-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition-base);
    font-size: var(--text-sm);
    font-weight: 500;
}

.action-card:hover {
    background: var(--neutral-100);
    border-color: var(--primary);
}

/* Compact Sync Control Styles */
.sync-control-compact {
    margin-top: var(--space-4);
    padding: var(--space-3);
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--neutral-400);
}

.sync-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    min-width: 0;
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neutral-400);
    flex-shrink: 0;
}

.sync-text-sm {
    font-size: var(--text-sm);
    color: var(--neutral-700);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sync-progress-sm {
    font-size: var(--text-xs);
    color: var(--neutral-500);
    flex-shrink: 0;
    white-space: nowrap;
}

.sync-buttons-sm {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.btn-icon-sm {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--neutral-500);
    transition: all var(--transition-fast);
}

.btn-icon-sm:hover {
    background: var(--neutral-200);
    color: var(--neutral-700);
}

.btn-icon-sm:active {
    transform: scale(0.95);
}

.btn-icon-sm.btn-icon-primary {
    color: var(--primary);
}

.btn-icon-sm.btn-icon-primary:hover {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-dark);
}

.btn-icon-sm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Sync Control Status States */
.sync-control-compact.synced {
    border-left-color: var(--success);
}

.sync-control-compact.synced .sync-dot {
    background: var(--success);
}

.sync-control-compact.syncing {
    border-left-color: var(--primary);
}

.sync-control-compact.syncing .sync-dot {
    background: var(--primary);
    animation: spinner 1s linear infinite;
}

.sync-control-compact.pending {
    border-left-color: var(--warning);
}

.sync-control-compact.pending .sync-dot {
    background: var(--warning);
}

.sync-control-compact.error {
    border-left-color: var(--error);
}

.sync-control-compact.error .sync-dot {
    background: var(--error);
}

.sync-control-compact.paused {
    border-left-color: var(--neutral-400);
}

.sync-control-compact.paused .sync-dot {
    background: var(--neutral-400);
}

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

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

/* Backup Settings in Modal */
.backup-settings {
    margin-top: var(--space-2);
}

.backup-actions {
    margin-top: var(--space-3);
    display: flex;
    gap: var(--space-2);
}

/* Small button variant */
.btn-sm {
    padding: var(--space-2);
    font-size: var(--text-xs);
    min-width: auto;
}

.btn-sm svg {
    width: 16px;
    height: 16px;
}

/* Memory List/Grid Components */
.memory-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-height: 600px;
    overflow-y: auto;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-6);
}

.memory-card {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: var(--transition-base);
    cursor: pointer;
}

.memory-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.memory-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-3);
}

.memory-meta {
    font-size: var(--text-xs);
    color: var(--neutral-500);
}

.memory-content {
    color: var(--neutral-700);
    line-height: 1.6;
    margin-bottom: var(--space-4);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.memory-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.tag {
    background: var(--neutral-100);
    color: var(--neutral-700);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 500;
}

/* Document Group Styles */
.document-group {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: var(--transition-base);
    cursor: pointer;
    margin-bottom: var(--space-4);
}

.document-group:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.document-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.document-icon {
    font-size: var(--text-xl);
    flex-shrink: 0;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-title {
    font-weight: 600;
    color: var(--neutral-900);
    margin-bottom: var(--space-1);
    word-break: break-word;
}

.document-meta {
    font-size: var(--text-sm);
    color: var(--neutral-500);
}

.document-preview {
    color: var(--neutral-700);
    line-height: 1.6;
    margin-bottom: var(--space-3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.document-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.document-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
}

.document-actions .btn-icon {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: var(--neutral-100);
    color: var(--neutral-700);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    transition: var(--transition-fast);
    cursor: pointer;
}

.document-actions .btn-icon:hover {
    background: var(--neutral-200);
    border-color: var(--neutral-300);
}

.document-actions .btn-remove:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* Document Chunks Modal */
.document-chunks {
    max-height: 70vh;
    overflow-y: auto;
}

.chunk-item {
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.chunk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.chunk-number {
    font-weight: 600;
    color: var(--neutral-900);
}

.chunk-meta {
    font-size: var(--text-sm);
    color: var(--neutral-500);
}

.chunk-content {
    color: var(--neutral-700);
    line-height: 1.6;
    margin-bottom: var(--space-3);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
    padding: var(--space-3);
    background: white;
    border-radius: var(--radius-sm);
}

.chunk-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* Dark mode: Fix white backgrounds in document chunk modals */
body.dark-mode .chunk-item {
    background: #1f2937 !important;
    border-color: #374151 !important;
}

body.dark-mode .chunk-content {
    background: #111827 !important;
    color: #d1d5db !important;
}

body.dark-mode .chunk-number {
    color: #60a5fa !important;
}

body.dark-mode .chunk-meta {
    color: #9ca3af !important;
}

body.dark-mode .chunk-header {
    color: #f3f4f6 !important;
}

/* Search Layout */
.search-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--space-8);
}

.search-filters {
    background: white;
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    height: fit-content;
}

.filter-section {
    margin-bottom: var(--space-5);
}

.filter-section label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--neutral-700);
    margin-bottom: var(--space-2);
}

.filter-section input,
.filter-section select {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.search-results {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.search-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--neutral-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-meta {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.view-options {
    display: flex;
    gap: var(--space-1);
}

.view-btn {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--neutral-300);
    background: white;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: var(--transition-base);
}

.view-btn:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.view-btn:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    border-left: none;
}

.view-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

#searchResultsList {
    padding: var(--space-6);
}

/* Modal Components */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-4);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--neutral-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    padding: var(--space-2);
    cursor: pointer;
    color: var(--neutral-500);
    border-radius: var(--radius-md);
    transition: var(--transition-base);
}

.modal-close:hover {
    background: var(--neutral-100);
    color: var(--neutral-700);
}

.modal-body {
    padding: var(--space-6);
    flex: 1;
    overflow-y: auto;
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--neutral-200);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* Form Components */
.form-group {
    margin-bottom: var(--space-5);
}

.form-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--neutral-700);
    margin-bottom: var(--space-2);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    transition: var(--transition-base);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

/* System Info in Settings Modal */
.system-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--neutral-100);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    font-weight: 500;
}

.info-value {
    font-size: var(--text-sm);
    color: var(--neutral-900);
    font-weight: 600;
    font-family: 'Monaco', 'Courier New', monospace;
}

/* Loading and Status Components */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-4);
    z-index: 2000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--neutral-200);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Connection Status */
.connection-status {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    z-index: 100;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.status-indicator.disconnected {
    background: var(--error);
}

.status-indicator.connecting {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: var(--space-4);
        text-align: center;
    }

    .search-section {
        max-width: none;
    }

    .action-buttons {
        justify-content: center;
    }

    .btn-text {
        display: none;
    }

    .nav-container {
        flex-wrap: wrap;
        justify-content: center;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "welcome"
            "recent"
            "quick-actions";
    }

    .search-layout {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .search-filters {
        order: 2;
    }

    .search-results {
        order: 1;
    }

    .memory-grid {
        grid-template-columns: 1fr;
    }

    .quick-stats {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr 300px;
    }

    .search-layout {
        grid-template-columns: 250px 1fr;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Browse View - Tags Cloud */
.browse-content {
    padding: var(--space-6);
}

.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
    margin-bottom: var(--space-8);
    padding: var(--space-6);
    background: var(--neutral-50);
    border-radius: var(--radius-lg);
}

.tag-bubble {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--neutral-100);
    color: var(--neutral-700);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.tag-bubble:hover {
    background: var(--neutral-200);
    border-color: var(--neutral-300);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tag-bubble .count {
    background: var(--neutral-200);
    color: var(--neutral-700);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
}

.tagged-memories {
    margin-top: var(--space-8);
}

.tagged-memories .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--neutral-200);
}

.tagged-memories h3 {
    color: var(--neutral-800);
    font-size: var(--text-xl);
}

#selectedTagName {
    color: var(--primary);
    font-weight: 600;
}

/* Memory Details Metadata Styles */
.memory-metadata {
    margin-top: var(--space-4);
    border: 1px solid var(--neutral-200);
    border-radius: 8px;
    overflow: hidden;
}

.metadata-toggle {
    background: var(--neutral-50);
    padding: var(--space-3) var(--space-4);
    margin: 0;
    border-bottom: 1px solid var(--neutral-200);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-700);
    transition: background-color 0.2s ease;
}

.metadata-toggle:hover {
    background: var(--neutral-100);
}

.toggle-icon {
    display: inline-block;
    margin-right: var(--space-2);
    transition: transform 0.2s ease;
    font-size: 0.8em;
}

.memory-metadata.expanded .toggle-icon {
    transform: rotate(90deg);
}

.metadata-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.memory-metadata.expanded .metadata-content {
    max-height: 500px;
    padding: var(--space-4);
}

.metadata-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.metadata-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--neutral-50);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}

.metadata-key {
    font-weight: 600;
    color: var(--neutral-700);
    min-width: 120px;
    flex-shrink: 0;
}

.metadata-value {
    color: var(--neutral-600);
    word-break: break-word;
}

.metadata-string {
    color: var(--success);
}

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

.metadata-boolean {
    color: var(--warning);
}

.metadata-array {
    color: var(--secondary);
}

.metadata-object {
    color: var(--neutral-500);
}

.metadata-empty {
    color: var(--neutral-400);
    font-style: italic;
    padding: var(--space-4);
    text-align: center;
}

/* Memory Type Styling */
.memory-meta p {
    margin-bottom: var(--space-2);
}

.memory-meta strong {
    color: var(--neutral-700);
    margin-right: var(--space-2);
}

/* Print Styles */
@media print {
    .app-header,
    .main-nav,
    .modal-overlay,
    .toast-container,
    .connection-status {
        display: none !important;
    }

    .main-content {
        max-width: none;
        padding: 0;
    }
}

/* API Documentation Styles */
#apiDocsView {
    padding: var(--space-6);
}

.api-docs-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.api-docs-header h2 {
    color: var(--neutral-800);
    margin-bottom: var(--space-3);
}

.api-docs-header p {
    color: var(--neutral-600);
    font-size: var(--text-lg);
    margin-bottom: var(--space-6);
}

.api-docs-links {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    flex-wrap: wrap;
}

.api-endpoints-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-6);
    max-width: 1200px;
    margin: 0 auto;
}

.endpoint-section {
    background: var(--neutral-50);
    border-radius: var(--radius-lg);
    border: 1px solid var(--neutral-200);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.endpoint-section:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.endpoint-section h3 {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: var(--space-4);
    margin: 0;
    font-size: var(--text-lg);
}

.endpoint-list {
    padding: var(--space-4);
}

.endpoint-item {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.endpoint-item:last-child {
    margin-bottom: 0;
}

.endpoint-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.endpoint-item .method {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    margin-right: var(--space-3);
    min-width: 60px;
    text-align: center;
}

.endpoint-item .method.get {
    background: var(--success);
    color: white;
}

.endpoint-item .method.post {
    background: var(--primary);
    color: white;
}

.endpoint-item .method.delete {
    background: var(--error);
    color: white;
}

.endpoint-item .path {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--neutral-700);
    font-size: var(--text-sm);
}

.endpoint-item .description {
    display: block;
    color: var(--neutral-600);
    font-size: var(--text-sm);
    margin-top: var(--space-2);
    line-height: 1.5;
}

/* Responsive adjustments for API docs */
@media (max-width: 768px) {
    .api-endpoints-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .api-docs-links {
        flex-direction: column;
        align-items: center;
    }

    .api-docs-links .btn {
        width: 100%;
        max-width: 300px;
    }
}

/* ============================= */
/* Search Filter Enhancements   */
/* ============================= */

/* Tooltips */
.tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    color: var(--neutral-400);
    font-size: var(--text-sm);
    margin-left: var(--space-2);
    transition: all 0.2s ease;
    vertical-align: middle;
}

.tooltip svg {
    display: block;
    transition: all 0.2s ease;
}

.tooltip:hover {
    color: var(--primary);
    transform: scale(1.1);
}

.tooltip:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--neutral-800);
    color: white;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--space-2);
    font-size: var(--text-xs);
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% - 5px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--neutral-800);
    z-index: 1001;
}

/* Help Text */
.help-text {
    display: block;
    font-size: var(--text-xs);
    color: var(--neutral-500);
    margin-top: var(--space-1);
    line-height: 1.4;
}

/* Filter Actions */
.filter-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--neutral-200);
}

.filter-actions .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--space-2);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-actions .btn-primary {
    background: var(--primary);
    color: white;
}

.filter-actions .btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.filter-actions .btn-secondary {
    background: var(--neutral-100);
    color: var(--neutral-700);
    border: 1px solid var(--neutral-300);
}

.filter-actions .btn-secondary:hover {
    background: var(--neutral-200);
}

/* Active Filters Display */
.active-filters {
    margin-top: var(--space-4);
    padding: var(--space-4);
    background: var(--neutral-50);
    border-radius: var(--space-2);
    border: 1px solid var(--neutral-200);
}

.active-filters h4 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-700);
    margin-bottom: var(--space-3);
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--primary);
    color: white;
    font-size: var(--text-xs);
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill:hover {
    background: var(--primary-dark);
}

.filter-pill .remove-filter {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
}

.filter-pill .remove-filter:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Enhanced filter section styling */
.filter-section {
    margin-bottom: var(--space-4);
}

.filter-section label {
    display: flex;
    align-items: center;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--neutral-700);
    margin-bottom: var(--space-2);
}

.filter-section input,
.filter-section select {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--neutral-300);
    border-radius: var(--space-2);
    font-size: var(--text-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-section input:focus,
.filter-section select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Loading states */
.filter-actions .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.filter-actions .btn.loading {
    position: relative;
    color: transparent;
}

.filter-actions .btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Mobile responsiveness for filter improvements */
@media (max-width: 768px) {
    .filter-actions {
        flex-direction: column;
    }

    .filter-pills {
        gap: var(--space-1);
    }

    .filter-pill {
        font-size: 11px;
        padding: var(--space-1) var(--space-2);
    }

    .tooltip:hover::after {
        max-width: 250px;
        font-size: 11px;
    }
}

/* Filters Header with Toggle */
.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--neutral-200);
}

.filters-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
}

.mode-toggle-compact {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.mode-toggle-compact .toggle-switch {
    width: 48px;
    height: 24px;
}

.mode-toggle-compact .slider:before {
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
}

.mode-toggle-compact input:checked + .slider:before {
    transform: translateX(24px);
}

/* Search Mode Indicator */
.search-mode-indicator {
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    background: var(--neutral-50);
    border-radius: var(--space-2);
    border: 1px solid var(--neutral-200);
    text-align: center;
}

.mode-status {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    font-weight: 500;
}

.mode-status #searchModeText {
    color: var(--primary);
    font-weight: 600;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #666;
    transition: .3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2563eb; /* Cache bust: fixed 2025-10-03 */
}

input:checked + .slider:before {
    transform: translateX(32px);
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.mode-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 600;
    color: var(--neutral-700);
}

#searchModeText {
    min-width: 120px;
}


/* ============================================================
   DARK MODE - VARIABLE REDEFINITION APPROACH
   Appended 2025-10-04: Redefine color variables for dark theme
   ============================================================ */

/* Utility Classes */
.hidden {
    display: none !important;
}

.settings-section-heading {
    margin-top: 0;
    color: var(--neutral-600);
}

.settings-divider {
    margin: var(--space-6) 0;
    border: none;
    border-top: 1px solid var(--neutral-200);
}

/* Dark Mode Theme - Redefine Color Variables */
body.dark-mode {
    /* Invert neutral color scale for dark mode */
    --neutral-50: #111827;   /* Darkest background (was lightest) */
    --neutral-100: #1f2937;  /* Surface/card background */
    --neutral-200: #374151;  /* Borders/dividers */
    --neutral-300: #4b5563;  /* Subtle borders */
    --neutral-400: #6b7280;  /* Disabled text */
    --neutral-500: #9ca3af;  /* Muted text */
    --neutral-600: #d1d5db;  /* Body text (was dark, now light) */
    --neutral-700: #e5e7eb;  /* Strong text */
    --neutral-800: #f3f4f6;  /* Stronger text */
    --neutral-900: #f9fafb;  /* Headings/emphasis (was dark, now lightest) */

    /* Apply inverted variables to body */
    background-color: var(--neutral-50);
    color: var(--neutral-600);
}

/* Specific overrides that can't use variables - Cache bust: v8.1.1 fix */
body.dark-mode .app-header,
body.dark-mode .main-nav,
body.dark-mode .sync-status-bar,
body.dark-mode .welcome-card,
body.dark-mode .recent-memories,
body.dark-mode .quick-actions,
body.dark-mode .memory-card,
body.dark-mode .action-card,
body.dark-mode .document-group,
body.dark-mode .search-filters,
body.dark-mode .search-results,
body.dark-mode .modal-content,
body.dark-mode .toast,
body.dark-mode .endpoint-item {
    background: var(--neutral-100) !important;  /* Dark card background */
}

/* Dark mode sync status bar gradients */
body.dark-mode .sync-status-bar.synced {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.15) 0%, rgba(34, 197, 94, 0) 100%) !important;
}

body.dark-mode .sync-status-bar.syncing {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0) 100%) !important;
}

body.dark-mode .sync-status-bar.pending {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.15) 0%, rgba(251, 191, 36, 0) 100%) !important;
}

body.dark-mode .sync-status-bar.error {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0) 100%) !important;
}

body.dark-mode .memory-card,
body.dark-mode .welcome-card,
body.dark-mode .action-card,
body.dark-mode .modal-content,
body.dark-mode .search-filters,
body.dark-mode .search-results {
    border-color: var(--neutral-200) !important;
}

body.dark-mode .memory-card:hover,
body.dark-mode .action-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body.dark-mode .nav-item:hover {
    background: var(--neutral-200);
    color: var(--primary);
}

body.dark-mode .nav-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Override specific element colors that need explicit dark mode values - Cache bust: v8.1.1 */
body.dark-mode .memory-content {
    color: var(--neutral-900) !important;  /* Brightest text for readability */
}

body.dark-mode .memory-meta {
    color: var(--neutral-600) !important;  /* Lighter but still readable for metadata */
}

body.dark-mode .memory-meta strong {
    color: var(--neutral-900) !important;  /* Bright labels for readability */
}

body.dark-mode .action-card h3,
body.dark-mode .action-card p,
body.dark-mode .action-card span {
    color: var(--neutral-900);
}

/* Connection status indicator dark mode */
body.dark-mode .connection-status {
    background: var(--neutral-100) !important;
    border-color: var(--neutral-200) !important;
    color: var(--neutral-900) !important;
}

body.dark-mode .action-card svg {
    color: var(--primary);
}

body.dark-mode h4 {
    color: var(--neutral-600);
}

body.dark-mode .filter-chip.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

body.dark-mode .toast.success {
    border-left-color: var(--success);
}

body.dark-mode .toast.error {
    border-left-color: var(--error);
}

body.dark-mode .toast.info {
    border-left-color: var(--primary);
}

/* Scrollbars (webkit browsers) */
body.dark-mode ::-webkit-scrollbar {
    background: var(--neutral-50);
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: var(--neutral-200);
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-300);
}

/* ===================================
   Footer Styles
   =================================== */

.app-footer {
    grid-area: footer;
    margin-top: 4rem;
    padding: 3rem 2rem 2rem;
    background: var(--neutral-50);
    border-top: 1px solid var(--neutral-100);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
}

.footer-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--neutral-900);
    margin: 0 0 1rem 0;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li {
    margin-bottom: 0.75rem;
}

.footer-links a {
    color: var(--neutral-700);
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--blue-600);
}

.footer-links svg {
    flex-shrink: 0;
}

.footer-description {
    font-size: 0.875rem;
    color: var(--neutral-600);
    margin: 0 0 1.5rem 0;
    line-height: 1.6;
}

.footer-license {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.footer-license svg {
    color: var(--neutral-500);
    flex-shrink: 0;
}

.footer-license a {
    color: var(--neutral-700);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}

.footer-license a:hover {
    color: var(--blue-600);
}

.footer-copyright {
    font-size: 0.75rem;
    color: var(--neutral-500);
}

/* Dark mode footer styles */
body.dark-mode .app-footer {
    background: var(--neutral-100) !important;  /* Dark surface background */
    border-top-color: var(--neutral-200) !important;
}

body.dark-mode .footer-section h4 {
    color: var(--neutral-900) !important;  /* Light text for readability */
}

body.dark-mode .footer-links a {
    color: var(--neutral-700) !important;  /* Medium-light link text */
}

body.dark-mode .footer-links a:hover {
    color: var(--blue-400);
}

body.dark-mode .footer-description {
    color: var(--neutral-600) !important;  /* Readable body text */
}

body.dark-mode .footer-license svg {
    color: var(--neutral-500);
}

body.dark-mode .footer-license a {
    color: var(--neutral-700) !important;  /* Match link colors */
}

body.dark-mode .footer-license a:hover {
    color: var(--blue-400);
}

body.dark-mode .footer-copyright {
    color: var(--neutral-500) !important;  /* Muted text */
}

/* ===================================
   Documents View Styles
   =================================== */

.documents-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    padding: var(--space-6);
}

.documents-section {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}

.documents-section h2 {
    margin: 0 0 var(--space-6) 0;
    color: var(--neutral-900);
    font-size: var(--text-xl);
    font-weight: 600;
}

/* Upload Area */
.upload-area {
    margin-bottom: var(--space-6);
}

.drop-zone {
    border: 2px dashed var(--neutral-300);
    border-radius: var(--radius-lg);
    padding: var(--space-12);
    text-align: center;
    transition: var(--transition-base);
    background: var(--neutral-50);
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.drop-zone-content svg {
    color: var(--neutral-400);
    opacity: 0.7;
}

.drop-zone-content h3 {
    margin: 0;
    color: var(--neutral-900);
    font-size: var(--text-xl);
    font-weight: 500;
}

.drop-zone-content p {
    margin: 0;
    color: var(--neutral-600);
}

.supported-formats {
    font-size: var(--text-sm) !important;
    color: var(--neutral-500) !important;
}

.link-button {
    background: none;
    border: none;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    padding: 0;
}

.link-button:hover {
    color: var(--primary-dark);
}

/* Upload Configuration */
.upload-config {
    margin-bottom: var(--space-6);
}

.config-section {
    margin-bottom: var(--space-4);
}

.config-section label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: 500;
    color: var(--neutral-700);
    font-size: var(--text-sm);
}

.config-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
}

.form-control {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    transition: var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control[type="range"] {
cursor: pointer;
}

/* Processing Mode Toggle */
.processing-mode-toggle {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    background: var(--neutral-50);
    color: var(--neutral-700);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    flex: 1;
    justify-content: center;
}

.mode-btn:hover {
    background: var(--neutral-100);
    border-color: var(--neutral-400);
}

.mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.mode-btn.active:hover {
    background: var(--primary-dark);
}

.mode-description {
    font-size: var(--text-xs);
    color: var(--neutral-500);
    margin-top: var(--space-1);
}

.form-help {
    display: block;
    font-size: var(--text-xs);
    color: var(--neutral-500);
    margin-top: var(--space-1);
}

/* Upload Actions */
.upload-actions {
    text-align: center;
    margin-bottom: var(--space-8);
}

/* Upload History */
.upload-history {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.upload-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    background: var(--neutral-50);
}

.upload-item.success {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.upload-item.error {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}

.upload-item.processing {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.upload-info {
    flex: 1;
}

.upload-filename {
    font-weight: 500;
    color: var(--neutral-900);
    margin-bottom: var(--space-1);
}

.upload-meta {
    font-size: var(--text-sm);
    color: var(--neutral-600);
}

.upload-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
}

.upload-status.success {
    color: var(--success);
}

.upload-status.error {
    color: var(--error);
}

.upload-status.processing {
    color: var(--warning);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--neutral-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-top: var(--space-2);
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-sm);
    transition: width var(--transition-base);
}

/* Dark mode for documents */
body.dark-mode .documents-section {
    background: var(--neutral-100);
    border-color: var(--neutral-200);
}

body.dark-mode .drop-zone {
    border-color: var(--neutral-200);
    background: var(--neutral-100);
}

body.dark-mode .drop-zone:hover,
body.dark-mode .drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

body.dark-mode .drop-zone-content h3 {
    color: var(--neutral-900);
}

body.dark-mode .drop-zone-content p {
    color: var(--neutral-700);
}

body.dark-mode .upload-item {
    background: var(--neutral-200);
    border-color: var(--neutral-300);
}

body.dark-mode .upload-item.success {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

body.dark-mode .upload-item.error {
    border-color: var(--error);
    background: rgba(16, 185, 129, 0.1);
}

body.dark-mode .upload-item.processing {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
}

body.dark-mode .upload-filename {
    color: var(--neutral-900);
}

body.dark-mode .upload-meta {
    color: var(--neutral-600);
}

/* Dark mode - Chunking Help Section */
body.dark-mode .chunking-help {
    background: var(--neutral-100) !important;
    border-color: var(--neutral-200) !important;
}

body.dark-mode .help-header {
    border-bottom-color: var(--neutral-200) !important;
    color: var(--neutral-900) !important;
}

body.dark-mode .help-content {
    color: var(--neutral-700) !important;
}

body.dark-mode .help-note {
    background: rgba(245, 158, 11, 0.15) !important;
    border-left-color: var(--warning) !important;
    color: var(--neutral-900) !important;
}

body.dark-mode .help-option {
    background: var(--neutral-50) !important;
    border-color: var(--neutral-200) !important;
}

body.dark-mode .help-option:hover {
    border-color: var(--primary) !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2) !important;
}

body.dark-mode .help-option-header strong {
    color: var(--neutral-900) !important;
}

body.dark-mode .help-option p {
    color: var(--neutral-700) !important;
}

body.dark-mode .help-option p strong {
    color: var(--neutral-900) !important;
}

body.dark-mode .help-tips {
    background: rgba(59, 130, 246, 0.15) !important;
    border-left-color: var(--primary) !important;
}

body.dark-mode .help-tips strong {
    color: var(--neutral-900) !important;
}

body.dark-mode .help-tips li {
    color: var(--neutral-700) !important;
}

body.dark-mode .help-tips li strong {
    color: var(--primary) !important;
}

body.dark-mode .close-help {
    color: var(--neutral-600) !important;
}

body.dark-mode .close-help:hover {
    color: var(--error) !important;
}

/* Dark mode - Overlap diagram */
body.dark-mode .help-example {
    background: var(--neutral-50) !important;
    border-color: var(--neutral-200) !important;
}

body.dark-mode .help-example strong {
    color: var(--neutral-900) !important;
}

body.dark-mode .chunk-demo {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .chunk-part.unique {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3) 0%, rgba(59, 130, 246, 0.2) 100%) !important;
    color: var(--blue-300) !important;
    border-color: var(--primary) !important;
}

body.dark-mode .chunk-part.overlap {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3) 0%, rgba(245, 158, 11, 0.2) 100%) !important;
    color: #fbbf24 !important;
    border-color: var(--warning) !important;
}

body.dark-mode .chunk-demo:hover .chunk-part.overlap {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.4) 0%, rgba(245, 158, 11, 0.3) 100%) !important;
}

/* Responsive */
@media (max-width: 768px) {
    .documents-layout {
        padding: var(--space-4);
        gap: var(--space-6);
    }

    .documents-section {
        padding: var(--space-4);
    }

    .drop-zone {
        padding: var(--space-8);
    }

    .config-row {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .upload-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
}

/* Responsive footer */
@media (max-width: 768px) {
.footer-content {
grid-template-columns: 1fr;
gap: 2rem;
}

.app-footer {
padding: 2rem 1rem 1.5rem;
margin-top: 3rem;
}
}

/* Manage View Styles */
.manage-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    padding: var(--space-6);
}

.manage-section {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}

.manage-section h2 {
    margin: 0 0 var(--space-6) 0;
    color: var(--neutral-900);
    font-size: var(--text-xl);
    font-weight: 600;
}

.bulk-ops-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-6);
}

.bulk-op-card {
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: var(--transition-base);
}

.bulk-op-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.bulk-op-card h3 {
    margin: 0 0 var(--space-2) 0;
    color: var(--neutral-900);
    font-size: var(--text-lg);
    font-weight: 600;
}

.bulk-op-card p {
    margin: 0 0 var(--space-4) 0;
    color: var(--neutral-600);
    font-size: var(--text-sm);
}

.op-controls {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.op-controls .form-control {
    min-width: 200px;
    flex: 1;
}

.system-ops-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-4);
}

.system-op-card {
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    text-align: center;
}

.system-op-card h3 {
    margin: 0 0 var(--space-2) 0;
    font-size: var(--text-base);
    font-weight: 600;
}

.system-op-card p {
    margin: 0 0 var(--space-4) 0;
    font-size: var(--text-sm);
    color: var(--neutral-600);
}

/* Analytics View Styles */
.analytics-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    padding: var(--space-6);
}

.analytics-section {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}

.analytics-section h2 {
    margin: 0 0 var(--space-6) 0;
    color: var(--neutral-900);
    font-size: var(--text-xl);
    font-weight: 600;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

.metric-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.metric-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    margin-bottom: var(--space-2);
    font-variant-numeric: tabular-nums;
}

.metric-label {
    font-size: var(--text-sm);
    opacity: 0.9;
    font-weight: 500;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: var(--space-6);
}

.chart-card {
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.chart-card h3 {
    margin: 0 0 var(--space-4) 0;
    color: var(--neutral-900);
    font-size: var(--text-lg);
    font-weight: 600;
}

.chart-controls {
    margin-bottom: var(--space-4);
}

.chart-container {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-3);
    color: var(--neutral-500);
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-6);
}

.report-card {
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.report-card h3 {
    margin: 0 0 var(--space-4) 0;
    color: var(--neutral-900);
    font-size: var(--text-lg);
    font-weight: 600;
}

.report-content {
    color: var(--neutral-700);
}

/* Tag Management Styles */
.tag-stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-4);
}

.tag-stats-table th,
.tag-stats-table td {
    padding: var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--neutral-200);
}

.tag-stats-table th {
    background: var(--neutral-100);
    font-weight: 600;
    color: var(--neutral-900);
}

.tag-stats-table .tag-name {
    font-weight: 500;
    color: var(--primary);
}

.tag-stats-table .tag-count {
    font-weight: 600;
    color: var(--neutral-900);
}

.tag-actions {
    display: flex;
    gap: var(--space-2);
}

.tag-action-btn {
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-sm);
    background: var(--neutral-50);
    color: var(--neutral-700);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: var(--transition-base);
}

.tag-action-btn:hover {
    background: var(--neutral-200);
    border-color: var(--neutral-400);
}

.tag-action-btn.danger:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* Dark mode support for Manage/Analytics - Fixed v8.5.5 */
body.dark-mode .manage-section,
body.dark-mode .analytics-section {
    background: var(--neutral-100) !important;  /* Dark card background */
    color: var(--neutral-900) !important;  /* Light text */
}

body.dark-mode .manage-section h2,
body.dark-mode .analytics-section h2 {
    color: var(--neutral-900) !important;
}

body.dark-mode .bulk-op-card,
body.dark-mode .system-op-card,
body.dark-mode .chart-card,
body.dark-mode .report-card {
    background: var(--neutral-50) !important;  /* Darker nested card background */
    border-color: var(--neutral-200) !important;
    color: var(--neutral-900) !important;
}

body.dark-mode .bulk-op-card h3,
body.dark-mode .system-op-card h3,
body.dark-mode .chart-card h3,
body.dark-mode .report-card h3 {
    color: var(--neutral-900) !important;
}

body.dark-mode .bulk-op-card p,
body.dark-mode .system-op-card p,
body.dark-mode .chart-card p,
body.dark-mode .report-card p {
    color: var(--neutral-600) !important;
}

/* Activity Heatmap Styles */
.activity-heatmap {
    font-family: var(--font-mono);
}

.heatmap-stats {
    display: flex;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    color: var(--neutral-600);
}

.heatmap-month {
    margin-bottom: var(--space-4);
}

.month-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--neutral-700);
    margin-bottom: var(--space-2);
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--neutral-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.heatmap-cell {
    aspect-ratio: 1;
    background: var(--neutral-100);
    border: 1px solid var(--neutral-200);
    cursor: pointer;
    transition: var(--transition-base);
}

.heatmap-cell:hover {
    opacity: 0.8;
}

.heatmap-cell.empty {
    background: transparent;
    border: none;
}

.heatmap-cell.level-0 {
    background: var(--neutral-100);
}

.heatmap-cell.level-1 {
    background: #9be9a8;
}

.heatmap-cell.level-2 {
    background: #40c463;
}

.heatmap-cell.level-3 {
    background: #30a14e;
}

.heatmap-cell.level-4 {
    background: #216e39;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-4);
    font-size: var(--text-sm);
    color: var(--neutral-600);
}

.legend-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Enhanced Tags Report */
.enhanced-tags-report .report-period {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--neutral-200);
}

.enhanced-tags-report .tags-list {
    list-style: none;
    padding: 0;
}

.enhanced-tags-report .tags-list li {
    padding: var(--space-3);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
    background: white;
}

.enhanced-tags-report .tag-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.enhanced-tags-report .tag-count {
    font-weight: 600;
    color: var(--primary);
}

.enhanced-tags-report .tag-cooccurrence {
    font-size: var(--text-sm);
    color: var(--neutral-600);
    font-style: italic;
}

/* Activity Breakdown */
.activity-breakdown .activity-summary {
    display: flex;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.activity-breakdown .activity-stat {
    font-size: var(--text-sm);
    color: var(--neutral-600);
}

.activity-breakdown .peak-times {
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    color: var(--neutral-700);
}

.activity-breakdown .activity-chart {
    margin-top: var(--space-4);
}

.activity-bar-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    padding: var(--space-2);
    background: var(--neutral-50);
    border-radius: var(--radius-sm);
}

.activity-label {
    min-width: 60px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--neutral-700);
}

.activity-bar {
    flex: 1;
    height: 8px;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 4px;
    transition: var(--transition-base);
}

.activity-count {
    min-width: 30px;
    text-align: right;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--primary);
}

/* Storage Report */
.storage-report .storage-summary {
    display: flex;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.storage-report .storage-stat {
    font-size: var(--text-sm);
    color: var(--neutral-600);
}

.storage-report h4 {
    margin: var(--space-4) 0 var(--space-2) 0;
    color: var(--neutral-900);
    font-size: var(--text-lg);
    font-weight: 600;
}

.storage-report .largest-memories {
    list-style: none;
    padding: 0;
}

.storage-report .largest-memories li {
    padding: var(--space-3);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
    background: white;
}

.storage-report .memory-size {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: var(--space-1);
}

.storage-report .memory-preview {
    font-size: var(--text-sm);
    color: var(--neutral-700);
    margin-bottom: var(--space-1);
    word-break: break-word;
}

.storage-report .memory-meta {
    font-size: var(--text-xs);
    color: var(--neutral-500);
}

/* Dark mode support for new analytics features */
body.dark-mode .heatmap-cell.level-0 {
    background: var(--neutral-200);
}

body.dark-mode .heatmap-cell.level-1 {
    background: #238636;
}

body.dark-mode .heatmap-cell.level-2 {
    background: #1a7f37;
}

body.dark-mode .heatmap-cell.level-3 {
    background: #0f5132;
}

body.dark-mode .heatmap-cell.level-4 {
    background: #033a16;
}

body.dark-mode .enhanced-tags-report .tags-list li,
body.dark-mode .activity-bar-row,
body.dark-mode .storage-report .largest-memories li {
    background: var(--neutral-100);
    border-color: var(--neutral-300);
    color: var(--neutral-900);
}

/* Form controls in Manage/Analytics dark mode */
body.dark-mode .bulk-op-card input,
body.dark-mode .bulk-op-card select,
body.dark-mode .chart-card input,
body.dark-mode .chart-card select,
body.dark-mode .manage-section .form-control,
body.dark-mode .analytics-section .form-control {
    background: var(--neutral-100) !important;
    border-color: var(--neutral-200) !important;
    color: var(--neutral-900) !important;
}

body.dark-mode .bulk-op-card input:focus,
body.dark-mode .bulk-op-card select:focus,
body.dark-mode .chart-card input:focus,
body.dark-mode .chart-card select:focus {
    border-color: var(--primary) !important;
    background: var(--neutral-50) !important;
}

/* Buttons in Manage/Analytics dark mode */
body.dark-mode .bulk-op-card .btn,
body.dark-mode .system-op-card .btn,
body.dark-mode .chart-card .btn {
    opacity: 1;
}

body.dark-mode .metric-card {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary)) !important;
    color: white !important;
}

body.dark-mode .metric-value,
body.dark-mode .metric-label {
    color: white !important;
}

/* Tag management table dark mode */
body.dark-mode .tag-stats-table {
    color: var(--neutral-900);
}

body.dark-mode .tag-stats-table th {
    background: var(--neutral-200) !important;
    color: var(--neutral-900) !important;
}

body.dark-mode .tag-stats-table td {
    border-bottom-color: var(--neutral-200) !important;
    color: var(--neutral-900) !important;
}

body.dark-mode .tag-stats-table .tag-name {
    color: var(--primary) !important;
}

body.dark-mode .tag-stats-table .tag-count {
    color: var(--neutral-900) !important;
}

/* Tag action buttons dark mode */
body.dark-mode .tag-action-btn {
    background: var(--neutral-200) !important;
    border-color: var(--neutral-300) !important;
    color: var(--neutral-900) !important;
}

body.dark-mode .tag-action-btn:hover {
    background: var(--neutral-300) !important;
    border-color: var(--neutral-400) !important;
}

body.dark-mode .tag-action-btn.danger:hover {
    background: var(--error) !important;
    color: white !important;
    border-color: var(--error) !important;
}

/* Simple Chart Styles */
.simple-chart {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    width: 100%;
    overflow: hidden;
}

.chart-header {
    font-weight: 600;
    margin-bottom: var(--space-4);
    color: var(--neutral-900);
}

.chart-row {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-2);
    gap: var(--space-3);
    min-height: 24px;
    width: 100%;
    max-width: 100%;
}

.chart-bar {
    height: 18px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    transition: width 0.3s ease;
    min-width: 10px;
    max-width: 200px;
    position: relative;
    flex-shrink: 0;
}

.chart-label {
    flex: 1;
    min-width: 0;
    color: var(--neutral-700);
    font-size: var(--text-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
    border-radius: var(--radius-sm);
}

.chart-value {
    min-width: 100px;
    text-align: right;
    color: var(--neutral-900);
    font-weight: 500;
    font-size: 1rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.chart-value small {
    color: var(--neutral-600);
    font-weight: 400;
    font-size: 0.9rem;
}

.tags-list, .activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tags-list li, .activity-list li {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--neutral-200);
}

.tags-list li:last-child, .activity-list li:last-child {
    border-bottom: none;
}

.tags-list li strong {
    color: var(--primary);
}

/* Dark mode for charts - Fixed v8.5.5 contrast */
body.dark-mode .chart-label {
    color: #e5e5e5 !important;  /* Much brighter text for labels */
    font-weight: 500;  /* Slightly bolder for readability */
}

body.dark-mode .chart-value {
    color: #ffffff !important;  /* Pure white for maximum readability */
    font-weight: 600;  /* Slightly bolder in dark mode */
}

body.dark-mode .chart-value small {
    color: var(--neutral-300) !important;  /* Lighter text for small elements */
}

body.dark-mode .chart-bar {
    background: var(--primary) !important;
}

body.dark-mode .chart-container {
    color: var(--neutral-700) !important;  /* Loading/placeholder text */
}

body.dark-mode .tags-list li,
body.dark-mode .activity-list li {
    border-bottom-color: var(--neutral-200) !important;
    color: var(--neutral-900) !important;
}

body.dark-mode .tags-list li strong {
    color: var(--primary) !important;
}

body.dark-mode .activity-list li {
    color: var(--neutral-700) !important;
}

/* Dark mode: Document chunks modal */
body.dark-mode .modal-content .chunk-item {
    background: #1f2937 !important;
    border-color: #374151 !important;
}

body.dark-mode .modal-content .chunk-header {
    color: #f3f4f6 !important;
}

body.dark-mode .modal-content .chunk-content {
    color: #d1d5db !important;
}

body.dark-mode .modal-content .chunk-meta {
    color: #9ca3af !important;
}

body.dark-mode .modal-content .chunk-number {
    color: #60a5fa !important;
}

/* Document Management Features */
.upload-actions-container {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.upload-actions {
    display: flex;
    gap: var(--space-2);
}

.btn-icon {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--neutral-300);
    border-radius: var(--radius-md);
    background: white;
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: var(--text-sm);
    color: var(--neutral-700);
}

.btn-icon:hover {
    background: var(--neutral-50);
    border-color: var(--neutral-400);
    transform: translateY(-1px);
}

.btn-icon svg {
    flex-shrink: 0;
}

.btn-view-memory {
    color: var(--primary);
    border-color: var(--primary-light);
}

.btn-view-memory:hover {
    background: rgba(99, 102, 241, 0.05);
    border-color: var(--primary);
}

.btn-remove {
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.05);
    border-color: var(--error);
}

/* Document Search Section */
.doc-search-container {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.doc-search-container .search-input {
    flex: 1;
}

.doc-search-results {
    margin-top: var(--space-4);
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--neutral-200);
}

.search-results-header h3 {
    margin: 0;
    font-size: var(--text-lg);
    color: var(--neutral-900);
}

.results-count {
    color: var(--neutral-600);
    font-size: var(--text-sm);
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.search-result-item {
    padding: var(--space-4);
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    transition: var(--transition-base);
}

.search-result-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-light);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.result-header strong {
    color: var(--neutral-900);
}

.similarity-score {
    font-size: var(--text-sm);
    color: var(--primary);
    font-weight: 600;
}

.result-content {
    color: var(--neutral-700);
    margin-bottom: var(--space-3);
    line-height: 1.6;
}

.result-tags {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.section-description {
    color: var(--neutral-600);
    margin-bottom: var(--space-4);
}

/* Memory Viewer Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-4);
}

.memory-viewer-content {
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
}

.memory-viewer-content .modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--neutral-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.memory-viewer-content .modal-header h2 {
    margin: 0;
    font-size: var(--text-xl);
    color: var(--neutral-900);
}

.memory-viewer-content .modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--neutral-500);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: var(--transition-base);
}

.memory-viewer-content .modal-close:hover {
    background: var(--neutral-100);
    color: var(--neutral-700);
}

.memory-viewer-content .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
}

.memory-viewer-content .modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--neutral-200);
    display: flex;
    justify-content: flex-end;
}

.document-info {
    margin-bottom: var(--space-6);
}

.document-info h3 {
    margin: 0 0 var(--space-2) 0;
    color: var(--neutral-900);
    font-size: var(--text-lg);
}

.memory-chunks-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.memory-chunk-item {
    padding: var(--space-4);
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
}

.chunk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--neutral-200);
}

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

.chunk-hash {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: var(--text-xs);
    color: var(--neutral-500);
}

.chunk-tags {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* Dark Mode Support for New Components */
body.dark-mode .btn-icon {
    background: var(--neutral-200);
    border-color: var(--neutral-300);
    color: var(--neutral-900);
}

body.dark-mode .btn-icon:hover {
    background: var(--neutral-300);
}

body.dark-mode .search-result-item,
body.dark-mode .memory-chunk-item {
    background: var(--neutral-200);
    border-color: var(--neutral-300);
}

body.dark-mode .memory-viewer-content {
    background: var(--neutral-100);
}

body.dark-mode .section-description,
body.dark-mode .result-content {
    color: var(--neutral-300);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .upload-actions-container {
        flex-direction: column;
        align-items: flex-start;
    }

    .upload-actions {
        width: 100%;
    }

    .btn-icon {
        flex: 1;
        justify-content: center;
    }

    .doc-search-container {
        flex-direction: column;
    }

    .memory-viewer-content {
        max-height: 95vh;
        margin: var(--space-2);
    }
}

/* ============================================
   Chunking Help Section Styles
   ============================================ */

.info-icon {
    cursor: pointer;
    font-size: 1.1em;
    margin-left: var(--space-1);
    opacity: 0.7;
    transition: all var(--transition-base);
    -webkit-user-select: none;
    user-select: none;
}

.info-icon:hover {
    opacity: 1;
    transform: scale(1.2);
}

.chunking-help {
    margin-top: var(--space-3);
    padding: var(--space-3);
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--neutral-200);
    color: var(--neutral-800);
}

.help-header strong {
    font-size: 1.1em;
}

.close-help {
    background: none;
    border: none;
    font-size: 1.5em;
    color: var(--neutral-500);
    cursor: pointer;
    padding: 0 var(--space-2);
    line-height: 1;
    transition: color var(--transition-base);
}

.close-help:hover {
    color: var(--error);
}

.help-content {
    color: var(--neutral-700);
}

.help-note {
    background: var(--warning);
    background: linear-gradient(135deg, #fff3cd 0%, #fcf8e3 100%);
    border-left: 4px solid var(--warning);
    padding: var(--space-2);
    margin-bottom: var(--space-3);
    border-radius: var(--radius-base);
    font-size: 0.95em;
}

.help-recommendations {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.help-option {
    background: white;
    padding: var(--space-3);
    border-radius: var(--radius-base);
    border: 1px solid var(--neutral-200);
    transition: all var(--transition-base);
}

.help-option:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.help-option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.help-option-header strong {
    color: var(--neutral-800);
}

.help-tag {
    background: var(--success);
    color: white;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.help-option p {
    margin: var(--space-1) 0;
    font-size: 0.9em;
    line-height: 1.5;
}

.help-option p strong {
    color: var(--neutral-700);
}

.help-tips {
    background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    padding: var(--space-3);
    border-radius: var(--radius-base);
    border-left: 4px solid var(--primary);
}

.help-tips strong {
    color: var(--neutral-800);
    display: block;
    margin-bottom: var(--space-2);
}

.help-tips ul {
    margin: 0;
    padding-left: var(--space-4);
}

.help-tips li {
    margin: var(--space-1) 0;
    font-size: 0.9em;
    line-height: 1.6;
    color: var(--neutral-700);
}

.help-tips li strong {
    display: inline;
    color: var(--primary-dark);
    font-weight: 600;
}

/* Overlap Visual Diagram */
.help-example {
    margin: var(--space-3) 0;
    padding: var(--space-3);
    background: white;
    border-radius: var(--radius-base);
    border: 1px solid var(--neutral-200);
}

.help-example strong {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--neutral-800);
}

.overlap-diagram {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.chunk-demo {
    display: flex;
    border-radius: var(--radius-base);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chunk-part {
    padding: var(--space-2);
    font-family: monospace;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.chunk-part.unique {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: var(--primary-dark);
    flex: 1;
    border: 2px solid var(--primary);
}

.chunk-part.overlap {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    flex: 0 0 35%;
    border: 2px solid var(--warning);
    font-weight: 600;
}

.chunk-demo:hover .chunk-part.overlap {
    background: linear-gradient(135deg, #fde68a 0%, #fbbf24 100%);
    transform: scale(1.02);
}

/* Mobile responsiveness for help section */
@media (max-width: 768px) {
    .chunking-help {
        padding: var(--space-2);
    }

    .help-option {
        padding: var(--space-2);
    }

    .help-tips {
        padding: var(--space-2);
    }

    .help-example {
        padding: var(--space-2);
    }

    .chunk-part {
        font-size: 0.75em;
        padding: var(--space-1);
    }

    .chunk-part.overlap {
        flex: 0 0 40%;
    }
}
