~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
Fix hardcoded colors in JS and remaining templates for theme support
LearningCircuit2fa0c8326ffc
diff --git a/src/local_deep_research/web/static/css/custom_dropdown.css b/src/local_deep_research/web/static/css/custom_dropdown.cssindex 3cca2adb98..ad842f9502 100644--- a/src/local_deep_research/web/static/css/custom_dropdown.css+++ b/src/local_deep_research/web/static/css/custom_dropdown.css@@ -187,7 +187,7 @@ body.dropdown-active {justify-content: space-between;margin-bottom: 1.5rem;padding: 0.8rem 1rem;- background-color: var(--bg-tertiary, rgba(40, 45, 60, 0.7));+ background-color: var(--bg-tertiary);border-radius: 6px;cursor: pointer;transition: background-color 0.2s;diff --git a/src/local_deep_research/web/static/css/news.css b/src/local_deep_research/web/static/css/news.cssindex a10b1083bb..22ac01d4cb 100644--- a/src/local_deep_research/web/static/css/news.css+++ b/src/local_deep_research/web/static/css/news.css@@ -48,7 +48,7 @@background-color: var(--bg-tertiary) !important;border-color: var(--accent-primary) !important;color: var(--text-primary) !important;- box-shadow: 0 0 0 0.2rem rgba(110, 79, 246, 0.25) !important;+ box-shadow: 0 0 0 0.2rem rgba(var(--accent-primary-rgb), 0.25) !important;}/* Layout - Two column without left sidebar */@@ -282,7 +282,7 @@.ldr-search-input-group:focus-within {border-color: var(--accent-primary);- box-shadow: 0 0 0 3px rgba(100, 108, 255, 0.1);+ box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb), 0.1);}.ldr-search-icon {@@ -474,7 +474,7 @@.ldr-news-search-box:focus-within {border-color: var(--accent-primary);- box-shadow: 0 0 0 3px rgba(110, 79, 246, 0.1);+ box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb), 0.1);}.ldr-news-search-box .ldr-search-icon {@@ -682,9 +682,9 @@/* Active research card */.ldr-active-research-card {- background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(110, 79, 246, 0.1) 100%);+ background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(var(--accent-primary-rgb), 0.1) 100%);border: 2px solid var(--accent-primary);- box-shadow: 0 0 20px rgba(110, 79, 246, 0.2);+ box-shadow: 0 0 20px rgba(var(--accent-primary-rgb), 0.2);position: relative;overflow: hidden;}@@ -844,8 +844,8 @@/* New item styling */.ldr-news-item.ldr-is-new {- background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(100, 108, 255, 0.05) 100%);- border-color: rgba(100, 108, 255, 0.3);+ background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(var(--accent-primary-rgb), 0.05) 100%);+ border-color: rgba(var(--accent-primary-rgb), 0.3);position: relative;overflow: hidden;}@@ -857,7 +857,7 @@left: 0;width: 4px;height: 100%;- background: linear-gradient(to bottom, var(--accent-primary), rgba(100, 108, 255, 0.3));+ background: linear-gradient(to bottom, var(--accent-primary), rgba(var(--accent-primary-rgb), 0.3));animation: newItemPulse 2s ease-in-out infinite;}@@ -1113,7 +1113,7 @@.ldr-subscription-card:hover {border-color: var(--accent-primary);- box-shadow: 0 2px 8px rgba(110, 79, 246, 0.1);+ box-shadow: 0 2px 8px rgba(var(--accent-primary-rgb), 0.1);}.ldr-subscription-actions {diff --git a/src/local_deep_research/web/static/js/components/progress.js b/src/local_deep_research/web/static/js/components/progress.jsindex 498dbb2a1c..4a2cf1e039 100644--- a/src/local_deep_research/web/static/js/components/progress.js+++ b/src/local_deep_research/web/static/js/components/progress.js@@ -1063,13 +1063,13 @@const ctx = canvas.getContext('2d');- // Get theme colors from CSS variables+ // Get theme colors from CSS variables (fallbacks match LDR dark theme)const style = getComputedStyle(document.documentElement);- const bgColor = style.getPropertyValue('--bg-tertiary').trim() || '#343a40';- const errorColor = style.getPropertyValue('--error-color').trim() || '#dc3545';- const successColor = style.getPropertyValue('--success-color').trim() || '#28a745';- const accentColor = style.getPropertyValue('--accent-primary').trim() || '#007bff';- const textColor = style.getPropertyValue('--text-primary').trim() || '#ffffff';+ const bgColor = style.getPropertyValue('--bg-tertiary').trim() || '#2a2a3a';+ const errorColor = style.getPropertyValue('--error-color').trim() || '#fa5c7c';+ const successColor = style.getPropertyValue('--success-color').trim() || '#0acf97';+ const accentColor = style.getPropertyValue('--accent-primary').trim() || '#6e4ff6';+ const textColor = style.getPropertyValue('--text-primary').trim() || '#f5f5f5';// Draw backgroundctx.fillStyle = bgColor;diff --git a/src/local_deep_research/web/static/js/components/settings.js b/src/local_deep_research/web/static/js/components/settings.jsindex 862ffec0d0..b4dc3ccd78 100644--- a/src/local_deep_research/web/static/js/components/settings.js+++ b/src/local_deep_research/web/static/js/components/settings.js@@ -1594,11 +1594,11 @@}.security-status.encrypted {- color: var(--success-color, #28a745);+ color: var(--success-color);}.security-status.unencrypted {- color: var(--warning-color, #ffc107);+ color: var(--warning-color);}.data-path {@@ -1715,11 +1715,11 @@.migration-warning {margin-top: 0.75rem;padding: 0.5rem;- background: rgba(255, 193, 7, 0.1);+ background: rgba(var(--warning-color-rgb), 0.1);border-radius: 4px;font-size: 0.8rem;- color: var(--warning-color, #ffc107);- border: 1px solid rgba(255, 193, 7, 0.3);+ color: var(--warning-color);+ border: 1px solid rgba(var(--warning-color-rgb), 0.3);}.migration-warning i {@@ -3758,15 +3758,15 @@width: 16px;height: 16px;margin-top: -8px;- border: 2px solid rgba(0, 123, 255, 0.1);- border-top-color: #007bff;+ border: 2px solid rgba(var(--accent-primary-rgb), 0.1);+ border-top-color: var(--accent-primary);border-radius: 50%;animation: spinner 0.8s linear infinite;z-index: 10;}.save-success {- border-color: #28a745 !important;+ border-color: var(--success-color) !important;transition: border-color 0.3s;}@@ -3777,7 +3777,7 @@.spinner {width: 40px;height: 40px;- border: 3px solid rgba(255, 255, 255, 0.1);+ border: 3px solid rgba(var(--border-color-rgb), 0.3);border-radius: 50%;border-top-color: var(--accent-primary);animation: spin 1s ease-in-out infinite;@@ -4659,8 +4659,8 @@refreshBtn.style.justifyContent = 'center';refreshBtn.style.width = '38px';refreshBtn.style.height = '38px';- refreshBtn.style.backgroundColor = 'var(--bg-tertiary, #2a2a3a)';- refreshBtn.style.border = '1px solid var(--border-color, #343452)';+ refreshBtn.style.backgroundColor = 'var(--bg-tertiary)';+ refreshBtn.style.border = '1px solid var(--border-color)';refreshBtn.style.borderRadius = '6px';refreshBtn.style.cursor = 'pointer';refreshBtn.style.marginLeft = '8px';diff --git a/src/local_deep_research/web/static/js/pdf_upload_handler.js b/src/local_deep_research/web/static/js/pdf_upload_handler.jsindex 29fb2edbaf..bdd4091364 100644--- a/src/local_deep_research/web/static/js/pdf_upload_handler.js+++ b/src/local_deep_research/web/static/js/pdf_upload_handler.js@@ -190,7 +190,7 @@ class PDFUploadHandler {highlight() {if (!this.isDragOver) {this.queryTextarea.style.backgroundColor = 'rgba(var(--accent-primary-rgb), 0.1)';- this.queryTextarea.style.border = '2px dashed var(--accent-primary, #6e4ff6)';+ this.queryTextarea.style.border = '2px dashed var(--accent-primary)';this.queryTextarea.style.transition = 'all 0.2s ease';this.isDragOver = true;}diff --git a/src/local_deep_research/web/static/js/services/ui.js b/src/local_deep_research/web/static/js/services/ui.jsindex efbab6ada2..c4a1d66527 100644--- a/src/local_deep_research/web/static/js/services/ui.js+++ b/src/local_deep_research/web/static/js/services/ui.js@@ -458,27 +458,27 @@ function addAlertStyles() {}.alert-success {- background-color: rgba(40, 167, 69, 0.15);- color: var(--success-color, #28a745);- border-left: 4px solid var(--success-color, #28a745);+ background-color: rgba(var(--success-color-rgb), 0.15);+ color: var(--success-color);+ border-left: 4px solid var(--success-color);}.alert-error, .alert-danger {- background-color: rgba(220, 53, 69, 0.15);- color: var(--danger-color, #dc3545);- border-left: 4px solid var(--danger-color, #dc3545);+ background-color: rgba(var(--error-color-rgb), 0.15);+ color: var(--error-color);+ border-left: 4px solid var(--error-color);}.alert-info {- background-color: rgba(23, 162, 184, 0.15);- color: var(--info-color, #17a2b8);- border-left: 4px solid var(--info-color, #17a2b8);+ background-color: rgba(var(--accent-tertiary-rgb), 0.15);+ color: var(--accent-tertiary);+ border-left: 4px solid var(--accent-tertiary);}.alert-warning {- background-color: rgba(255, 193, 7, 0.15);- color: var(--warning-color, #ffc107);- border-left: 4px solid var(--warning-color, #ffc107);+ background-color: rgba(var(--warning-color-rgb), 0.15);+ color: var(--warning-color);+ border-left: 4px solid var(--warning-color);}.alert-close {@@ -502,8 +502,8 @@ function addAlertStyles() {left: 0;right: 0;padding: 14px 20px;- background: var(--bg-secondary, #1e1e2d);- color: var(--text-primary, #f5f5f5);+ background: var(--bg-secondary);+ color: var(--text-primary);text-align: center;z-index: ${UI_CONFIG.NOTIFICATION_Z_INDEX};font-weight: 500;@@ -512,7 +512,7 @@ function addAlertStyles() {align-items: center;justify-content: center;gap: 12px;- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(110, 79, 246, 0.15);+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(var(--accent-primary-rgb), 0.15);transform: translateY(-100%);transition: transform 0.3s ease;word-wrap: break-word;diff --git a/src/local_deep_research/web/templates/components/delete_confirmation_modal.html b/src/local_deep_research/web/templates/components/delete_confirmation_modal.htmlindex 0e14c04f7d..a4a1e491e4 100644--- a/src/local_deep_research/web/templates/components/delete_confirmation_modal.html+++ b/src/local_deep_research/web/templates/components/delete_confirmation_modal.html@@ -39,7 +39,7 @@<style>/* Delete confirmation modal specific styles */#deleteConfirmModal .modal-header.bg-danger {- background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;+ background: var(--error-color) !important;}#deleteConfirmModal .ldr-btn-close-white {diff --git a/src/local_deep_research/web/templates/components/storage_mode_modal.html b/src/local_deep_research/web/templates/components/storage_mode_modal.htmlindex 6903fd851b..0fd735d79b 100644--- a/src/local_deep_research/web/templates/components/storage_mode_modal.html+++ b/src/local_deep_research/web/templates/components/storage_mode_modal.html@@ -59,11 +59,11 @@<style>/* Storage Mode Modal */#storage-mode-modal .modal-content {- color: var(--text-primary, #e4e4e4);+ color: var(--text-primary);}#storage-mode-modal .modal-body p {- color: var(--text-primary, #e4e4e4);+ color: var(--text-primary);}#storage-mode-modal .ldr-close {@@ -71,13 +71,13 @@border: none;font-size: 24px;cursor: pointer;- color: var(--text-secondary, #aaa);+ color: var(--text-secondary);padding: 0;line-height: 1;}#storage-mode-modal .ldr-close:hover {- color: var(--text-primary, #fff);+ color: var(--text-primary);}/* Storage Mode Modal Options */@@ -91,22 +91,22 @@display: flex;align-items: flex-start;padding: 15px;- border: 2px solid var(--border-color, #3a3a3a);+ border: 2px solid var(--border-color);border-radius: 8px;cursor: pointer;transition: all 0.2s ease;- color: var(--text-primary, #e4e4e4);- background: var(--card-bg, #2a2a2a);+ color: var(--text-primary);+ background: var(--card-bg);}.ldr-storage-mode-option:hover {- border-color: var(--primary-color, #4a9eff);- background: rgba(74, 158, 255, 0.05);+ border-color: var(--primary-color);+ background: rgba(var(--accent-primary-rgb), 0.05);}.ldr-storage-mode-option:has(input:checked) {- border-color: var(--primary-color, #4a9eff);- background: rgba(74, 158, 255, 0.1);+ border-color: var(--primary-color);+ background: rgba(var(--accent-primary-rgb), 0.1);}.ldr-storage-mode-option input[type="radio"] {diff --git a/src/local_deep_research/web/templates/pages/benchmark.html b/src/local_deep_research/web/templates/pages/benchmark.htmlindex b28fe8dc11..979e48599f 100644--- a/src/local_deep_research/web/templates/pages/benchmark.html+++ b/src/local_deep_research/web/templates/pages/benchmark.html@@ -105,6 +105,67 @@/* Alert styles now use global themed styles from styles.css */+/* Theme-aware utility classes for benchmark page */+.ldr-text-success { color: var(--success-color); }+.ldr-text-info { color: var(--accent-tertiary); }+.ldr-text-warning { color: var(--warning-color); }+.ldr-text-error { color: var(--error-color); }+.ldr-text-muted { color: var(--text-muted); }+.ldr-link { color: var(--accent-tertiary); text-decoration: underline; font-size: 0.85rem; margin-left: 5px; }+.ldr-link:hover { filter: brightness(1.2); }++/* Dataset highlight boxes */+.ldr-dataset-success {+ border: 1px solid var(--success-color);+}+.ldr-dataset-success h3 { color: var(--success-color); }+.ldr-dataset-success-notice {+ background: rgba(var(--success-color-rgb), 0.1);+ border: 1px solid rgba(var(--success-color-rgb), 0.3);+ color: var(--success-color);+ padding: 8px 10px;+ border-radius: 4px;+ margin-top: 8px;+ font-size: 0.85rem;+}++.ldr-dataset-danger {+ border: 2px solid var(--error-color);+ background: rgba(var(--error-color-rgb), 0.08);+}+.ldr-dataset-danger h3 { color: var(--error-color); }+.ldr-dataset-danger p { color: var(--text-secondary); }+.ldr-dataset-danger-notice {+ background: rgba(var(--error-color-rgb), 0.15);+ border: 1px solid var(--error-color);+ color: var(--error-color);+ padding: 10px 12px;+ border-radius: 4px;+ margin-top: 10px;+ font-size: 0.85rem;+ line-height: 1.4;+}++/* Warning box for context window */+.ldr-warning-notice {+ background: rgba(var(--warning-color-rgb), 0.1);+ border: 1px solid rgba(var(--warning-color-rgb), 0.3);+ border-radius: 6px;+ padding: 0.75rem;+ margin-top: 0.75rem;+}++/* Search quality status */+.ldr-search-quality-status {+ padding: 20px;+ text-align: center;+ color: var(--text-primary);+}+.ldr-search-status-details {+ font-size: 0.9rem;+ color: var(--text-muted);+}+/* Question and Results Display Styles */.ldr-benchmark-section {margin-top: 20px;@@ -562,14 +623,14 @@<h4 style="margin-top: 1rem; margin-bottom: 0.5rem;"><i class="fas fa-search"></i> Search Engine Recommendations</h4><ul style="margin: 0; padding-left: 20px;">- <li><strong style="color: #4caf50;">Tavily:</strong> Recommended - AI-optimized, reliable results</li>- <li><strong style="color: #2196f3;">Brave:</strong> Independent but lower performance</li>- <li><strong style="color: #ff9800;">SearXNG:</strong> Aggregates multiple sources - shared resource, use moderate counts</li>- <li><strong style="color: #f44336;">Specialized (ArXiv, PubMed, Wikipedia):</strong> Not useful for general SimpleQA</li>+ <li><strong class="ldr-text-success">Tavily:</strong> Recommended - AI-optimized, reliable results</li>+ <li><strong class="ldr-text-info">Brave:</strong> Independent but lower performance</li>+ <li><strong class="ldr-text-warning">SearXNG:</strong> Aggregates multiple sources - shared resource, use moderate counts</li>+ <li><strong class="ldr-text-error">Specialized (ArXiv, PubMed, Wikipedia):</strong> Not useful for general SimpleQA</li></ul>{{ help_tip("<strong>Shared Resources:</strong> When using SearXNG, reduce iterations and questions per iteration to minimize load.") }}- <div id="context-window-warning" style="display: none; margin-top: 0.75rem; padding: 0.75rem; background: rgba(255, 152, 0, 0.1); border: 1px solid rgba(255, 152, 0, 0.3); border-radius: 6px;">- <strong style="color: #ff9800;">⚠️ Context Window:</strong> "Focused Iteration" strategy requires 15k+ token context window.+ <div id="context-window-warning" class="ldr-warning-notice" style="display: none;">+ <strong class="ldr-text-warning">⚠️ Context Window:</strong> "Focused Iteration" strategy requires 15k+ token context window.</div>{% endcall %}@@ -617,12 +678,12 @@</div><!-- xbench-DeepSearch Dataset -->- <div class="ldr-dataset-config" style="border: 1px solid #4caf50;">+ <div class="ldr-dataset-config ldr-dataset-success"><div class="ldr-dataset-header"><div>- <h3 style="color: #4caf50;">xbench-DeepSearch</h3>+ <h3>xbench-DeepSearch</h3><p>100 deep research questions requiring multi-step information seeking</p>- <div style="background: rgba(76, 175, 80, 0.1); border: 1px solid rgba(76, 175, 80, 0.3); color: #4caf50; padding: 8px 10px; border-radius: 4px; margin-top: 8px; font-size: 0.85rem;">+ <div class="ldr-dataset-success-notice"><i class="fas fa-info-circle"></i> <strong>New:</strong> Advanced benchmark for testing deep research capabilities</div></div>@@ -642,12 +703,12 @@</div><!-- BrowseComp Dataset -->- <div class="ldr-dataset-config" style="border: 2px solid #f44336; background: #2a1e1e;">+ <div class="ldr-dataset-config ldr-dataset-danger"><div class="ldr-dataset-header"><div>- <h3 style="color: #f44336;">BrowseComp</h3>- <p style="color: #ccc;">Complex browsing and comparison tasks</p>- <div style="background: #3a1e1e; border: 1px solid #f44336; color: #f44336; padding: 10px 12px; border-radius: 4px; margin-top: 10px; font-size: 0.85rem; line-height: 1.4;">+ <h3>BrowseComp</h3>+ <p>Complex browsing and comparison tasks</p>+ <div class="ldr-dataset-danger-notice"><i class="fas fa-exclamation-triangle"></i> <strong>Poor Performance Warning:</strong> We currently achieve close to 0% accuracy on BrowseComp.<br><strong>For testing only:</strong> Limited to 20 examples max to see what this benchmark is about.</div>@@ -663,7 +724,7 @@name="browsecomp_count" value="0"min="0" max="20"class="ldr-form-control" disabled>- <span class="ldr-input-help" style="color: #f44336;">Restricted to max 20 examples due to poor performance - for curiosity testing only</span>+ <span class="ldr-input-help ldr-text-error">Restricted to max 20 examples due to poor performance - for curiosity testing only</span></div></div></fieldset>@@ -933,14 +994,14 @@</div><div class="ldr-chart-container"><div class="ldr-chart-title">Search Quality Alert</div>- <div id="search-quality-status" style="padding: 20px; text-align: center; color: #e0e0e0;">+ <div id="search-quality-status" class="ldr-search-quality-status"><div id="search-status-icon" style="font-size: 2rem; margin-bottom: 10px;"><i class="fas fa-search"></i></div><div id="search-status-text" style="font-size: 1.1rem; margin-bottom: 10px;">Waiting for data...</div>- <div id="search-status-details" style="font-size: 0.9rem; color: #a0a0a0;">+ <div id="search-status-details" class="ldr-search-status-details">Search result monitoring will begin when benchmark starts</div></div>@@ -1758,7 +1819,7 @@ function displayRecentResults(results) {return `<span id="truncated-${id}" style="display: ${isExpanded ? 'none' : 'inline'};">${truncated}</span><span id="full-${id}" style="display: ${isExpanded ? 'inline' : 'none'};">${text}</span>- <a href="#" onclick="toggleText('${id}'); return false;" id="toggle-${id}" style="color: #2196f3; font-size: 0.85rem; margin-left: 5px; text-decoration: underline;">${isExpanded ? 'Show less' : 'Show more'}</a>+ <a href="#" onclick="toggleText('${id}'); return false;" id="toggle-${id}" class="ldr-link">${isExpanded ? 'Show less' : 'Show more'}</a>`;};diff --git a/src/local_deep_research/web/templates/pages/collection_details.html b/src/local_deep_research/web/templates/pages/collection_details.htmlindex 1272902f99..7767c29d51 100644--- a/src/local_deep_research/web/templates/pages/collection_details.html+++ b/src/local_deep_research/web/templates/pages/collection_details.html@@ -99,7 +99,7 @@</p><p class="ldr-form-text ldr-text-muted" style="margin-top: 10px;"><i class="fas fa-info-circle"></i> Default embedding settings for new collections can be changed in- <a href="/library/embedding-settings" style="color: #667eea;">Embedding Settings</a>.+ <a href="/library/embedding-settings" style="color: var(--accent-primary);">Embedding Settings</a>.</p></div></div>diff --git a/src/local_deep_research/web/templates/pages/collection_upload.html b/src/local_deep_research/web/templates/pages/collection_upload.htmlindex d6f838de57..8af892f78c 100644--- a/src/local_deep_research/web/templates/pages/collection_upload.html+++ b/src/local_deep_research/web/templates/pages/collection_upload.html@@ -16,22 +16,22 @@display: flex;align-items: flex-start;padding: 15px;- border: 2px solid var(--border-color, #3a3a3a);+ border: 2px solid var(--border-color);border-radius: 8px;cursor: pointer;transition: all 0.2s ease;- color: var(--text-primary, #e4e4e4);- background: var(--card-bg, #2a2a2a);+ color: var(--text-primary);+ background: var(--card-bg);}.ldr-storage-mode-option:hover {- border-color: var(--primary-color, #4a9eff);- background: rgba(74, 158, 255, 0.05);+ border-color: var(--primary-color);+ background: rgba(var(--accent-primary-rgb), 0.05);}.ldr-storage-mode-option:has(input:checked) {- border-color: var(--primary-color, #4a9eff);- background: rgba(74, 158, 255, 0.1);+ border-color: var(--primary-color);+ background: rgba(var(--accent-primary-rgb), 0.1);}.ldr-storage-mode-option input[type="radio"] {@@ -51,7 +51,7 @@}.ldr-storage-mode-option .ldr-option-header strong {- color: var(--text-primary, #e4e4e4);+ color: var(--text-primary);}.ldr-storage-mode-option .ldr-option-header i {@@ -59,7 +59,7 @@}.ldr-storage-mode-option .ldr-option-description {- color: var(--text-secondary, #aaa);+ color: var(--text-secondary);font-size: 0.9em;margin: 0;}@@ -119,7 +119,7 @@</div><!-- Upload Section -->- <div class="ldr-rag-section" style="background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%); border: 2px solid #667eea;">+ <div class="ldr-rag-section" style="background: linear-gradient(135deg, rgba(var(--accent-primary-rgb), 0.1) 0%, rgba(var(--accent-secondary-rgb), 0.1) 100%); border: 2px solid var(--accent-primary);"><div class="ldr-section-header"><h2><i class="fas fa-upload"></i> 📁 Upload Documents</h2></div>@@ -151,7 +151,7 @@<!-- PDF Storage Mode Selection --><div class="ldr-form-group" style="margin-top: 1.5rem;"><label><strong>PDF Storage Option</strong></label>- <p style="color: var(--text-secondary, #aaa); font-size: 0.9rem; margin-bottom: 1rem;">+ <p style="color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1rem;">Choose how to store uploaded PDF files:</p>diff --git a/src/local_deep_research/web/templates/pages/context_overflow.html b/src/local_deep_research/web/templates/pages/context_overflow.htmlindex 3d56ce7beb..3e1cae91f4 100644--- a/src/local_deep_research/web/templates/pages/context_overflow.html+++ b/src/local_deep_research/web/templates/pages/context_overflow.html@@ -103,8 +103,8 @@}.ldr-warning-banner {- background: rgba(255, 193, 7, 0.1);- border: 1px solid rgba(255, 193, 7, 0.3);+ background: rgba(var(--warning-color-rgb), 0.1);+ border: 1px solid rgba(var(--warning-color-rgb), 0.3);border-radius: 0.375rem;padding: 1rem;margin-bottom: 1rem;diff --git a/src/local_deep_research/web/templates/pages/cost_analytics.html b/src/local_deep_research/web/templates/pages/cost_analytics.htmlindex 7dccb6203e..b59141ad42 100644--- a/src/local_deep_research/web/templates/pages/cost_analytics.html+++ b/src/local_deep_research/web/templates/pages/cost_analytics.html@@ -30,7 +30,7 @@.ldr-cost-title h1 {margin: 0;- background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);+ background: linear-gradient(135deg, var(--success-color) 0%, var(--success-color) 100%);-webkit-background-clip: text;-webkit-text-fill-color: transparent;background-clip: text;@@ -108,7 +108,7 @@display: flex;align-items: center;justify-content: center;- background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);+ background: var(--success-color);color: white;border-radius: 50%;font-size: 1.25rem;@@ -221,15 +221,15 @@}.ldr-cost-optimization {- background: linear-gradient(135deg, #e8f5e8 0%, #f1f8f1 100%);- border: 1px solid #4CAF50;+ background: rgba(var(--success-color-rgb), 0.1);+ border: 1px solid var(--success-color);border-radius: 0.5rem;padding: 1.5rem;margin-bottom: 2rem;}.ldr-cost-optimization h3 {- color: #2e7d32;+ color: var(--success-color);margin: 0 0 1rem 0;display: flex;align-items: center;@@ -246,7 +246,7 @@margin-bottom: 0.75rem;padding-left: 1.5rem;position: relative;- color: #2e7d32;+ color: var(--success-color);}.ldr-cost-optimization li::before {@@ -426,16 +426,7 @@color: var(--text-primary);}- /* Dark theme adjustments */- [data-theme="dark"] .ldr-cost-optimization {- background: linear-gradient(135deg, #1a3a1a 0%, #2d4a2d 100%);- border-color: #4CAF50;- }-- [data-theme="dark"] .ldr-cost-optimization h3,- [data-theme="dark"] .ldr-cost-optimization li {- color: #81c784;- }+ /* Theme adjustments are now handled by CSS variables automatically */@media (max-width: 768px) {.ldr-cost-header {@@ -467,7 +458,7 @@<!-- Header --><div class="ldr-cost-header"><div class="ldr-cost-title">- <h1><i class="fas fa-dollar-sign"></i> Cost Analytics <span style="color: var(--warning-color, #f39c12); font-size: 0.75em; font-weight: normal;">(Experimental)</span></h1>+ <h1><i class="fas fa-dollar-sign"></i> Cost Analytics <span style="color: var(--warning-color); font-size: 0.75em; font-weight: normal;">(Experimental)</span></h1><a href="/metrics" class="ldr-back-button"><i class="fas fa-arrow-left"></i> Back to Metrics</a>@@ -752,9 +743,9 @@</div><!-- Local Model Pricing Disclaimer -->- <div class="ldr-info-note" style="margin-top: 1rem; border-left-color: #FF9800;">+ <div class="ldr-info-note" style="margin-top: 1rem; border-left-color: var(--warning-color);"><p>- <i class="fas fa-home" style="color: #FF9800; margin-right: 0.5rem;"></i>+ <i class="fas fa-home" style="color: var(--warning-color); margin-right: 0.5rem;"></i><strong>Local Model Savings Disclaimer:</strong> The "Local Models Savings" calculation is a rough estimate comparing your local model usage to hypothetical commercial API costs.This estimate uses conservative baseline pricing (~$0.0015 per 1K tokens) and should be viewed as an approximation only.<br><br>diff --git a/src/local_deep_research/web/templates/pages/details.html b/src/local_deep_research/web/templates/pages/details.htmlindex 10c37ba802..9cb0293700 100644--- a/src/local_deep_research/web/templates/pages/details.html+++ b/src/local_deep_research/web/templates/pages/details.html@@ -156,11 +156,11 @@}.ldr-search-status-success {- color: #22c55e;+ color: var(--success-color);}.ldr-search-status-error {- color: #ef4444;+ color: var(--error-color);}.ldr-loading-spinner {@@ -171,7 +171,7 @@.ldr-error-message {text-align: center;padding: 2rem;- color: var(--error-color, #dc3545);+ color: var(--error-color);}.ldr-charts-grid {@@ -263,13 +263,13 @@}.ldr-data-table .badge-success {- background-color: rgba(34, 197, 94, 0.2);- color: #22c55e;+ background-color: rgba(var(--success-color-rgb), 0.2);+ color: var(--success-color);}.ldr-data-table .badge-danger {- background-color: rgba(239, 68, 68, 0.2);- color: #ef4444;+ background-color: rgba(var(--error-color-rgb), 0.2);+ color: var(--error-color);}</style>{% endblock %}diff --git a/src/local_deep_research/web/templates/pages/document_details.html b/src/local_deep_research/web/templates/pages/document_details.htmlindex 27b15f287d..367c093d37 100644--- a/src/local_deep_research/web/templates/pages/document_details.html+++ b/src/local_deep_research/web/templates/pages/document_details.html@@ -176,11 +176,11 @@<i class="fas fa-folder-open"></i><span>{{ collection.name }}</span>{% if collection.indexed %}- <span style="background: #28a745; color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem;">+ <span class="ldr-badge ldr-badge-success">Indexed ({{ collection.chunk_count }})</span>{% else %}- <span style="background: #ffc107; color: #333; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem;">+ <span class="ldr-badge ldr-badge-warning">Not indexed</span>{% endif %}@@ -201,13 +201,13 @@{% if document.has_rag_indexed %}<a href="/library/document/{{ document.id }}/chunks" style="text-decoration: none; color: inherit;"><div class="ldr-rag-status" style="cursor: pointer;">- <i class="fas fa-check-circle" style="color: var(--ldr-success-color, #28a745);"></i>+ <i class="fas fa-check-circle" style="color: var(--success-color);"></i><span>Yes ({{ document.rag_chunk_count }} chunks) <i class="fas fa-external-link-alt" style="font-size: 0.8em; margin-left: 5px;"></i></span></div></a>{% else %}<div class="ldr-rag-status">- <i class="fas fa-times-circle" style="color: var(--ldr-warning-color, #ffc107);"></i>+ <i class="fas fa-times-circle" style="color: var(--warning-color);"></i><span>Not indexed</span></div>{% endif %}@@ -226,7 +226,7 @@<div class="ldr-metadata-label">Text Content</div><div class="ldr-metadata-value"><div class="ldr-rag-status">- <i class="fas fa-file-alt" style="color: var(--ldr-success-color, #28a745);"></i>+ <i class="fas fa-file-alt" style="color: var(--success-color);"></i><span>Available ({{ document.word_count or 0 }} words)</span></div></div>diff --git a/src/local_deep_research/web/templates/pages/document_text.html b/src/local_deep_research/web/templates/pages/document_text.htmlindex f31987406b..40c5afa490 100644--- a/src/local_deep_research/web/templates/pages/document_text.html+++ b/src/local_deep_research/web/templates/pages/document_text.html@@ -4,28 +4,28 @@<style>body {font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;- background-color: var(--ldr-bg-color, #f8f9fa);+ background-color: var(--bg-primary);}.ldr-text-container {max-width: 900px;margin: 40px auto;padding: 20px;- background: white;+ background: var(--bg-secondary);border-radius: 8px;- box-shadow: 0 1px 3px rgba(0,0,0,0.1);+ box-shadow: var(--card-shadow);}.ldr-text-header {- border-bottom: 2px solid #007bff;+ border-bottom: 2px solid var(--accent-primary);padding-bottom: 15px;margin-bottom: 25px;}.ldr-text-header h1 {margin: 0 0 10px 0;font-size: 28px;- color: #212529;+ color: var(--text-primary);}.ldr-text-meta {- color: #6c757d;+ color: var(--text-muted);font-size: 14px;margin-bottom: 15px;}@@ -48,27 +48,29 @@transition: all 0.2s;}.ldr-btn-primary {- background-color: #007bff;+ background-color: var(--accent-primary);color: white;}.ldr-btn-primary:hover {- background-color: #0056b3;+ background-color: var(--accent-primary);+ filter: brightness(0.85);color: white;}.ldr-btn-secondary {- background-color: #6c757d;- color: white;+ background-color: var(--bg-tertiary);+ color: var(--text-primary);}.ldr-btn-secondary:hover {- background-color: #545b62;- color: white;+ background-color: var(--bg-tertiary);+ filter: brightness(0.9);+ color: var(--text-primary);}.ldr-text-content {white-space: pre-wrap;word-wrap: break-word;font-family: inherit;line-height: 1.6;- color: #212529;+ color: var(--text-primary);font-size: 16px;}</style>diff --git a/src/local_deep_research/web/templates/pages/download_manager.html b/src/local_deep_research/web/templates/pages/download_manager.htmlindex 3bf648d1e7..ad23e7ca6c 100644--- a/src/local_deep_research/web/templates/pages/download_manager.html+++ b/src/local_deep_research/web/templates/pages/download_manager.html@@ -24,7 +24,7 @@</button></div><div class="ldr-collection-selector" style="margin: 0 15px;">- <label for="target-collection" style="font-size: 0.9em; color: var(--text-secondary, #999); margin-right: 8px;">+ <label for="target-collection" style="font-size: 0.9em; color: var(--text-secondary); margin-right: 8px;"><i class="fas fa-folder"></i> Target Collection:</label><select id="target-collection" class="form-control" style="width: 200px; display: inline-block;">diff --git a/src/local_deep_research/web/templates/pages/library.html b/src/local_deep_research/web/templates/pages/library.htmlindex d3ca71dc49..0f3e07613e 100644--- a/src/local_deep_research/web/templates/pages/library.html+++ b/src/local_deep_research/web/templates/pages/library.html@@ -421,8 +421,8 @@<li>Periodically to ensure database integrity</li></ul>- <div class="sync-warning" style="background: var(--warning-bg, #3d3313); padding: 10px; border-radius: 5px; margin-top: 15px; border: 1px solid var(--warning-border, #5a4a1a);">- <i class="fas fa-info-circle" style="color: var(--warning-text, #ffc107);"></i>+ <div class="sync-warning ldr-alert ldr-alert-warning" style="margin-top: 15px;">+ <i class="fas fa-info-circle"></i><strong>Note:</strong> This operation only checks files - it doesn't modify or delete any PDFs. Missing files can be re-downloaded using the Download Manager.</div></div>@@ -437,16 +437,16 @@<div id="sync-results" style="display: none; margin-top: 20px;"><h3>Sync Results</h3><div class="sync-stats" style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px;">- <div style="background: var(--success-bg, #1a3a1f); padding: 10px; border-radius: 5px; border: 1px solid var(--success-border, #28a745);">- <i class="fas fa-check-circle" style="color: var(--success-text, #28a745);"></i>+ <div class="ldr-alert ldr-alert-success" style="padding: 10px;">+ <i class="fas fa-check-circle"></i><strong>Files Found:</strong> <span id="files-found">0</span></div>- <div style="background: var(--danger-bg, #3a1a1f); padding: 10px; border-radius: 5px; border: 1px solid var(--danger-border, #dc3545);">- <i class="fas fa-exclamation-circle" style="color: var(--danger-text, #dc3545);"></i>+ <div class="ldr-alert ldr-alert-danger" style="padding: 10px;">+ <i class="fas fa-exclamation-circle"></i><strong>Files Missing:</strong> <span id="files-missing">0</span></div></div>- <div id="missing-files-action" style="display: none; margin-top: 15px; padding: 10px; background: var(--info-bg, #1a2a3a); border-radius: 5px; border: 1px solid var(--info-border, #17a2b8);">+ <div id="missing-files-action" class="ldr-alert ldr-alert-info" style="display: none; margin-top: 15px;"><p><strong>Missing files detected!</strong> These files have been marked in the database and can be re-downloaded.</p><button class="btn btn-primary" onclick="goToDownloadManager()">Go to Download Manager</button></div>@@ -1705,7 +1705,7 @@ function cancelDownloads() {// Update UI to show cancellationconst progressBar = document.getElementById('overall-progress');- progressBar.style.backgroundColor = '#f44336';+ progressBar.style.backgroundColor = 'var(--error-color)';// Close modal after a delaysetTimeout(() => {diff --git a/src/local_deep_research/web/templates/pages/link_analytics.html b/src/local_deep_research/web/templates/pages/link_analytics.htmlindex a0428bea85..086a279fee 100644--- a/src/local_deep_research/web/templates/pages/link_analytics.html+++ b/src/local_deep_research/web/templates/pages/link_analytics.html@@ -166,13 +166,13 @@}.ldr-metric-badge.ldr-frequency {- background: linear-gradient(135deg, #6b46c1, #9061f9);+ background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));color: white;border: none;}.ldr-metric-badge.ldr-diversity {- background: linear-gradient(135deg, #3b82f6, #60a5fa);+ background: linear-gradient(135deg, var(--accent-tertiary), var(--accent-tertiary));color: white;border: none;}@@ -244,19 +244,19 @@}.ldr-source-type-fill.ldr-academic {- background: linear-gradient(90deg, #6b46c1, #9061f9);+ background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));}.ldr-source-type-fill.ldr-news {- background: linear-gradient(90deg, #f59e0b, #fbbf24);+ background: linear-gradient(90deg, var(--warning-color), var(--warning-color));}.ldr-source-type-fill.ldr-reference {- background: linear-gradient(90deg, #3b82f6, #60a5fa);+ background: linear-gradient(90deg, var(--accent-tertiary), var(--accent-tertiary));}.ldr-source-type-fill.ldr-general {- background: linear-gradient(90deg, #10b981, #34d399);+ background: linear-gradient(90deg, var(--success-color), var(--success-color));}.ldr-source-type-count {@@ -424,7 +424,7 @@.ldr-progress-fill {height: 100%;- background: linear-gradient(90deg, var(--accent-primary), #9061f9);+ background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));transition: width 0.3s ease;display: flex;align-items: center;@@ -453,17 +453,17 @@}.ldr-log-entry.ldr-success {- color: #22c55e;+ color: var(--success-color);}.ldr-log-entry.ldr-error {- color: #ef4444;+ color: var(--error-color);}.ldr-classified-badge {display: inline-block;padding: 0.2rem 0.5rem;- background: linear-gradient(135deg, #22c55e, #34d399);+ background: var(--success-color);color: white;border-radius: 0.25rem;font-size: 0.75rem;@@ -609,7 +609,7 @@<div style="font-size: 0.875rem; color: var(--text-secondary);">Total Domains</div></div><div style="background: var(--bg-tertiary); padding: 1rem; border-radius: 0.5rem;">- <div style="font-size: 1.5rem; font-weight: bold; color: #22c55e;" id="classified-count">0</div>+ <div style="font-size: 1.5rem; font-weight: bold; color: var(--success-color);" id="classified-count">0</div><div style="font-size: 0.875rem; color: var(--text-secondary);">Already Classified</div></div></div>@@ -639,13 +639,13 @@<!-- Log entries will be added here --></div>- <button id="stop-classification" class="btn" style="width: 100%; background: #ef4444; color: white; padding: 0.75rem; border-radius: 0.5rem; border: none; cursor: pointer; font-size: 1rem; margin-top: 1rem;">+ <button id="stop-classification" class="btn" style="width: 100%; background: var(--error-color); color: white; padding: 0.75rem; border-radius: 0.5rem; border: none; cursor: pointer; font-size: 1rem; margin-top: 1rem;"><i class="fas fa-stop"></i> Stop Classification</button></div><div id="classification-complete" style="display: none; text-align: center;">- <i class="fas fa-check-circle" style="font-size: 3rem; color: #22c55e; margin-bottom: 1rem;"></i>+ <i class="fas fa-check-circle" style="font-size: 3rem; color: var(--success-color); margin-bottom: 1rem;"></i><h3>Classification Complete!</h3><p style="color: var(--text-secondary); margin: 1rem 0;">Successfully classified <span id="final-classified">0</span> domains.@@ -1107,7 +1107,7 @@ async function loadClassificationProgress() {const statusText = document.getElementById('classification-status');if (progress.classified > 0) {statusText.textContent = `${progress.classified}/${progress.total_domains} domains classified`;- statusText.style.color = '#22c55e';+ statusText.style.color = 'var(--success-color)';}}} catch (error) {diff --git a/src/local_deep_research/web/templates/pages/star_reviews.html b/src/local_deep_research/web/templates/pages/star_reviews.htmlindex 2d6ce7460d..a9e1880196 100644--- a/src/local_deep_research/web/templates/pages/star_reviews.html+++ b/src/local_deep_research/web/templates/pages/star_reviews.html@@ -778,7 +778,7 @@ function updateRecentRatings(recentRatings) {container.innerHTML = '';if (recentRatings.length === 0) {- container.innerHTML = '<div style="text-align: center; padding: 20px; color: #718096;">No recent ratings found</div>';+ container.innerHTML = '<div style="text-align: center; padding: 20px; color: var(--text-muted);">No recent ratings found</div>';return;}diff --git a/tests/theme_tests/test_theme_system.py b/tests/theme_tests/test_theme_system.pynew file mode 100644index 0000000000..1bf8b845ad--- /dev/null+++ b/tests/theme_tests/test_theme_system.py@@ -0,0 +1,1076 @@+"""+Tests for the multi-theme system.++These tests ensure:+1. All themes define all required CSS variables+2. No hardcoded colors exist in critical template/CSS/JS files+3. Theme switching works correctly+4. RGB variants are defined for rgba() usage+"""++import re+from pathlib import Path++import pytest++# Base paths+WEB_DIR = (+ Path(__file__).parent.parent.parent / "src" / "local_deep_research" / "web"+)+STATIC_DIR = WEB_DIR / "static"+TEMPLATES_DIR = WEB_DIR / "templates"+CSS_DIR = STATIC_DIR / "css"+JS_DIR = STATIC_DIR / "js"+++# Required CSS variables that every theme must define+REQUIRED_VARIABLES = [+ # Background colors+ "--bg-primary",+ "--bg-secondary",+ "--bg-tertiary",+ # Accent colors+ "--accent-primary",+ "--accent-secondary",+ "--accent-tertiary",+ # Text colors+ "--text-primary",+ "--text-secondary",+ "--text-muted",+ # Border+ "--border-color",+ # Status colors+ "--success-color",+ "--warning-color",+ "--error-color",+]++# RGB variants required for rgba() usage+REQUIRED_RGB_VARIANTS = [+ "--bg-primary-rgb",+ "--bg-secondary-rgb",+ "--bg-tertiary-rgb",+ "--accent-primary-rgb",+ "--accent-secondary-rgb",+ "--accent-tertiary-rgb",+ "--text-primary-rgb",+ "--text-secondary-rgb",+ "--text-muted-rgb",+ "--border-color-rgb",+ "--success-color-rgb",+ "--warning-color-rgb",+ "--error-color-rgb",+]++# All 20 themes that should be defined+ALL_THEMES = [+ "dark",+ "light",+ "sepia",+ "high-contrast",+ "midnight",+ "ocean",+ "forest",+ "sunset",+ "rose",+ "lavender",+ "nord",+ "dracula",+ "monokai",+ "solarized-dark",+ "solarized-light",+ "gruvbox-dark",+ "gruvbox-light",+ "tokyo-night",+ "catppuccin",+ "one-dark",+]++# Hex color pattern (matches #fff, #ffffff, #FFFFFF)+HEX_COLOR_PATTERN = re.compile(r"#[0-9a-fA-F]{3,8}\b")++# RGB/RGBA color pattern (matches rgb(x,x,x) and rgba(x,x,x,x))+RGBA_LITERAL_PATTERN = re.compile(+ r"rgba?\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)"+)++# Files that are allowed to have some hardcoded colors (brand colors, intentional)+ALLOWED_HARDCODED_FILES = [+ "pdf-viewer.css", # PDF viewer needs light background for readability+ "details.js", # Chart colors may need to be fixed for data visualization+]++# Brand colors that are intentionally hardcoded (provider logos, etc.)+BRAND_COLOR_EXCEPTIONS = [+ "#10a37f", # OpenAI green+ "#d97706", # Anthropic orange+ "#4285f4", # Google blue+ "#000000", # Pure black (often intentional)+ "#ffffff", # Pure white (often intentional)+ "#fff", # Pure white shorthand+ "#000", # Pure black shorthand+]+++class TestThemeDefinitions:+ """Test that all themes are properly defined in themes.css."""++ @pytest.fixture+ def themes_css_content(self):+ """Load themes.css content."""+ themes_css = CSS_DIR / "themes.css"+ assert themes_css.exists(), f"themes.css not found at {themes_css}"+ return themes_css.read_text()++ def test_themes_css_exists(self):+ """Verify themes.css file exists."""+ themes_css = CSS_DIR / "themes.css"+ assert themes_css.exists(), "themes.css file is missing"++ def test_all_themes_defined(self, themes_css_content):+ """Check that all 20 themes are defined."""+ for theme in ALL_THEMES:+ if theme == "dark":+ # Dark theme is defined in :root+ assert ":root" in themes_css_content, (+ "Default dark theme (:root) not found"+ )+ else:+ theme_selector = f'[data-theme="{theme}"]'+ assert theme_selector in themes_css_content, (+ f"Theme '{theme}' not defined in themes.css"+ )++ def test_required_variables_in_root(self, themes_css_content):+ """Check that :root defines all required variables."""+ # Extract :root block+ root_match = re.search(+ r":root[^{]*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}", themes_css_content+ )+ assert root_match, ":root block not found in themes.css"+ root_content = root_match.group(1)++ for var in REQUIRED_VARIABLES:+ assert var in root_content, (+ f"Required variable '{var}' not defined in :root"+ )++ def test_rgb_variants_in_root(self, themes_css_content):+ """Check that :root defines RGB variants for rgba() usage."""+ root_match = re.search(+ r":root[^{]*\{([^}]+(?:\{[^}]*\}[^}]*)*)\}", themes_css_content+ )+ assert root_match, ":root block not found"+ root_content = root_match.group(1)++ for var in REQUIRED_RGB_VARIANTS:+ assert var in root_content, (+ f"RGB variant '{var}' not defined in :root"+ )++ @pytest.mark.parametrize("theme", ALL_THEMES[1:]) # Skip dark (uses :root)+ def test_theme_has_required_variables(self, themes_css_content, theme):+ """Check each theme defines all required variables."""+ theme_pattern = (+ rf'\[data-theme="{theme}"\]\s*\{{([^}}]+(?:\{{[^}}]*\}}[^}}]*)*)\}}'+ )+ theme_match = re.search(theme_pattern, themes_css_content)+ assert theme_match, f"Theme '{theme}' block not found"+ theme_content = theme_match.group(1)++ for var in REQUIRED_VARIABLES:+ assert var in theme_content, (+ f"Theme '{theme}' missing required variable '{var}'"+ )++ @pytest.mark.parametrize("theme", ALL_THEMES[1:])+ def test_theme_has_rgb_variants(self, themes_css_content, theme):+ """Check each theme defines RGB variants."""+ theme_pattern = (+ rf'\[data-theme="{theme}"\]\s*\{{([^}}]+(?:\{{[^}}]*\}}[^}}]*)*)\}}'+ )+ theme_match = re.search(theme_pattern, themes_css_content)+ assert theme_match, f"Theme '{theme}' block not found"+ theme_content = theme_match.group(1)++ for var in REQUIRED_RGB_VARIANTS:+ assert var in theme_content, (+ f"Theme '{theme}' missing RGB variant '{var}'"+ )+++class TestHardcodedColors:+ """Test for hardcoded colors that should use theme variables."""++ def _get_files(self, directory: Path, pattern: str) -> list[Path]:+ """Get files matching pattern in directory."""+ if not directory.exists():+ return []+ return list(directory.rglob(pattern))++ def _extract_hardcoded_colors(+ self, content: str, file_path: Path+ ) -> list[tuple[str, int, str]]:+ """Extract hardcoded colors from content.++ Returns list of (color, line_number, line_content) tuples.+ """+ colors = []+ lines = content.split("\n")++ for i, line in enumerate(lines, 1):+ # Skip comments+ if line.strip().startswith("//") or line.strip().startswith("/*"):+ continue++ # Skip lines that use CSS variables correctly+ if "var(--" in line:+ continue++ # Find hex colors+ for match in HEX_COLOR_PATTERN.finditer(line):+ color = match.group().lower()+ if color not in [c.lower() for c in BRAND_COLOR_EXCEPTIONS]:+ colors.append((color, i, line.strip()))++ return colors++ def _extract_literal_rgba(+ self, content: str, file_path: Path+ ) -> list[tuple[str, int, str]]:+ """Extract literal rgba() colors that should use CSS variables.++ Returns list of (color, line_number, line_content) tuples.+ """+ colors = []+ lines = content.split("\n")++ for i, line in enumerate(lines, 1):+ # Skip if already using CSS variable pattern: rgba(var(--xxx-rgb), 0.5)+ if "rgba(var(--" in line:+ continue++ # Skip comments+ if line.strip().startswith("//") or line.strip().startswith("/*"):+ continue++ # Find literal rgba() calls+ for match in RGBA_LITERAL_PATTERN.finditer(line):+ color = match.group()+ # Allow black/white rgba as they're often intentional+ if not any(+ x in color+ for x in [+ "0, 0, 0",+ "255, 255, 255",+ "0,0,0",+ "255,255,255",+ ]+ ):+ colors.append((color, i, line.strip()))++ return colors++ def test_templates_no_hardcoded_hex_colors(self):+ """Check HTML templates don't have hardcoded hex colors in style attributes."""+ templates = self._get_files(TEMPLATES_DIR, "*.html")+ issues = []++ for template in templates:+ if any(+ allowed in template.name for allowed in ALLOWED_HARDCODED_FILES+ ):+ continue++ content = template.read_text()++ # Focus on style attributes and inline styles+ style_pattern = re.compile(+ r'style\s*=\s*["\'][^"\']*#[0-9a-fA-F]{3,8}[^"\']*["\']'+ )+ for i, line in enumerate(content.split("\n"), 1):+ if style_pattern.search(line):+ # Extract the actual color+ colors = HEX_COLOR_PATTERN.findall(line)+ for color in colors:+ if color.lower() not in [+ c.lower() for c in BRAND_COLOR_EXCEPTIONS+ ]:+ issues.append(+ f"{template.name}:{i} - hardcoded color {color}"+ )++ if issues:+ issue_sample = issues[:10]+ pytest.fail(+ f"Found {len(issues)} hardcoded colors in templates:\n"+ + "\n".join(issue_sample)+ + ("\n..." if len(issues) > 10 else "")+ )++ def test_css_files_no_literal_rgba(self):+ """Check CSS files don't have literal rgba() that should use variables."""+ css_files = self._get_files(CSS_DIR, "*.css")+ issues = []++ for css_file in css_files:+ # Skip themes.css (it defines the colors)+ if css_file.name == "themes.css":+ continue++ if any(+ allowed in css_file.name for allowed in ALLOWED_HARDCODED_FILES+ ):+ continue++ content = css_file.read_text()+ colors = self._extract_literal_rgba(content, css_file)++ for color, line_num, line in colors:+ issues.append(f"{css_file.name}:{line_num} - {color}")++ if issues:+ issue_sample = issues[:15]+ pytest.fail(+ f"Found {len(issues)} literal rgba() colors that should use CSS variables:\n"+ + "\n".join(issue_sample)+ + ("\n..." if len(issues) > 15 else "")+ )++ def test_js_files_no_inline_style_colors(self):+ """Check JS files don't set inline style colors directly."""+ js_files = self._get_files(JS_DIR, "*.js")+ issues = []++ # Pattern to find style.color = '#xxx' or style.backgroundColor = '#xxx'+ js_color_pattern = re.compile(+ r'\.style\.\w+\s*=\s*["\']#[0-9a-fA-F]{3,8}["\']'+ )++ for js_file in js_files:+ if any(+ allowed in js_file.name for allowed in ALLOWED_HARDCODED_FILES+ ):+ continue++ content = js_file.read_text()++ for i, line in enumerate(content.split("\n"), 1):+ if js_color_pattern.search(line):+ issues.append(f"{js_file.name}:{i} - {line.strip()[:80]}")++ if issues:+ issue_sample = issues[:10]+ pytest.fail(+ f"Found {len(issues)} inline style color assignments in JS:\n"+ + "\n".join(issue_sample)+ + ("\n..." if len(issues) > 10 else "")+ )+++class TestThemeVariableUsage:+ """Test that theme variables are used correctly throughout the codebase."""++ def test_styles_css_uses_variables(self):+ """Verify main styles.css uses theme variables."""+ styles_css = CSS_DIR / "styles.css"+ assert styles_css.exists(), "styles.css not found"++ content = styles_css.read_text()++ # Should use theme variables+ assert "var(--bg-primary)" in content, (+ "styles.css should use --bg-primary"+ )+ assert "var(--text-primary)" in content, (+ "styles.css should use --text-primary"+ )+ assert "var(--accent-primary)" in content, (+ "styles.css should use --accent-primary"+ )++ def test_base_html_has_theme_attribute(self):+ """Verify base.html supports data-theme attribute."""+ base_html = TEMPLATES_DIR / "base.html"+ assert base_html.exists(), "base.html not found"++ content = base_html.read_text()++ # Should have data-theme or theme initialization+ assert "data-theme" in content or "theme" in content.lower(), (+ "base.html should support theme attribute"+ )++ def test_theme_toggle_exists(self):+ """Verify theme toggle functionality exists."""+ # Check for theme-related JavaScript+ js_files = list(JS_DIR.rglob("*.js"))+ theme_js_found = False++ for js_file in js_files:+ content = js_file.read_text()+ if (+ "setTheme" in content+ or "data-theme" in content+ or "theme" in content.lower()+ ):+ theme_js_found = True+ break++ assert theme_js_found, (+ "No theme toggle functionality found in JavaScript"+ )+++class TestDarkLightThemes:+ """Test that dark and light themes have appropriate brightness levels."""++ # Themes that should have dark backgrounds+ DARK_THEMES = [+ "dark",+ "midnight",+ "ocean",+ "forest",+ "sunset",+ "nord",+ "dracula",+ "monokai",+ "solarized-dark",+ "gruvbox-dark",+ "tokyo-night",+ "catppuccin",+ "one-dark",+ "high-contrast",+ "rose",+ "lavender",+ ]++ # Themes that should have light backgrounds+ LIGHT_THEMES = ["light", "sepia", "solarized-light", "gruvbox-light"]++ @pytest.fixture+ def themes_css_content(self):+ """Load themes.css content."""+ return (CSS_DIR / "themes.css").read_text()++ def _get_luminance(self, hex_color: str) -> float:+ """Calculate relative luminance of a color (0-1 scale)."""+ r = int(hex_color[1:3], 16) / 255+ g = int(hex_color[3:5], 16) / 255+ b = int(hex_color[5:7], 16) / 255+ return 0.299 * r + 0.587 * g + 0.114 * b++ def _extract_theme_bg_primary(+ self, themes_css_content: str, theme: str+ ) -> str | None:+ """Extract --bg-primary value for a theme."""+ if theme == "dark":+ pattern = r":root[^{]*\{[^}]*--bg-primary:\s*(#[0-9a-fA-F]{6})"+ else:+ pattern = rf'\[data-theme="{theme}"\][^{{]*\{{[^}}]*--bg-primary:\s*(#[0-9a-fA-F]{{6}})'+ match = re.search(pattern, themes_css_content, re.DOTALL)+ return match.group(1) if match else None++ @pytest.mark.parametrize("theme", DARK_THEMES)+ def test_dark_theme_has_dark_background(self, themes_css_content, theme):+ """Dark themes should have low luminance backgrounds."""+ bg_color = self._extract_theme_bg_primary(themes_css_content, theme)+ assert bg_color, f"Could not extract --bg-primary for theme '{theme}'"+ luminance = self._get_luminance(bg_color)+ assert luminance < 0.35, (+ f"Dark theme '{theme}' has too bright background {bg_color} "+ f"(luminance: {luminance:.2f}, expected < 0.35)"+ )++ @pytest.mark.parametrize("theme", LIGHT_THEMES)+ def test_light_theme_has_light_background(self, themes_css_content, theme):+ """Light themes should have high luminance backgrounds."""+ bg_color = self._extract_theme_bg_primary(themes_css_content, theme)+ assert bg_color, f"Could not extract --bg-primary for theme '{theme}'"+ luminance = self._get_luminance(bg_color)+ assert luminance > 0.5, (+ f"Light theme '{theme}' has too dark background {bg_color} "+ f"(luminance: {luminance:.2f}, expected > 0.5)"+ )+++class TestTextContrast:+ """Test that text colors have sufficient contrast against backgrounds."""++ @pytest.fixture+ def themes_css_content(self):+ """Load themes.css content."""+ return (CSS_DIR / "themes.css").read_text()++ def _get_luminance(self, hex_color: str) -> float:+ """Calculate relative luminance."""+ r = int(hex_color[1:3], 16) / 255+ g = int(hex_color[3:5], 16) / 255+ b = int(hex_color[5:7], 16) / 255+ return 0.299 * r + 0.587 * g + 0.114 * b++ def _contrast_ratio(self, l1: float, l2: float) -> float:+ """Calculate contrast ratio between two luminance values."""+ lighter = max(l1, l2)+ darker = min(l1, l2)+ return (lighter + 0.05) / (darker + 0.05)++ def test_root_text_contrast(self, themes_css_content):+ """Test that :root has adequate text-to-background contrast."""+ # Extract colors from :root+ bg_match = re.search(+ r":root[^{]*\{[^}]*--bg-primary:\s*(#[0-9a-fA-F]{6})",+ themes_css_content,+ re.DOTALL,+ )+ text_match = re.search(+ r":root[^{]*\{[^}]*--text-primary:\s*(#[0-9a-fA-F]{6})",+ themes_css_content,+ re.DOTALL,+ )++ assert bg_match and text_match, (+ "Could not find bg-primary or text-primary in :root"+ )++ bg_lum = self._get_luminance(bg_match.group(1))+ text_lum = self._get_luminance(text_match.group(1))+ ratio = self._contrast_ratio(bg_lum, text_lum)++ # WCAG AA requires 4.5:1 for normal text+ assert ratio >= 4.5, (+ f"Insufficient contrast ratio in :root: {ratio:.2f} "+ f"(bg: {bg_match.group(1)}, text: {text_match.group(1)})"+ )+++class TestComponentCoverage:+ """Test that key CSS files properly use theme variables."""++ CSS_FILES_REQUIRING_THEME_VARS = [+ "styles.css",+ "collections.css",+ "settings.css",+ "news-enhanced.css",+ ]++ REQUIRED_VAR_USAGE = [+ "var(--bg-",+ "var(--text-",+ "var(--accent-",+ "var(--border-color)",+ ]++ @pytest.mark.parametrize("css_file", CSS_FILES_REQUIRING_THEME_VARS)+ def test_css_file_uses_theme_vars(self, css_file):+ """Check that critical CSS files use theme variables."""+ file_path = CSS_DIR / css_file+ if not file_path.exists():+ pytest.skip(f"{css_file} not found")++ content = file_path.read_text()+ missing_vars = []++ for var_pattern in self.REQUIRED_VAR_USAGE:+ if var_pattern not in content:+ missing_vars.append(var_pattern)++ assert not missing_vars, (+ f"{css_file} is missing theme variable usage: {missing_vars}"+ )+++class TestSemanticColorUsage:+ """Test that semantic colors (success, warning, error) are used correctly."""++ @pytest.fixture+ def all_css_content(self):+ """Load all CSS files content."""+ content = {}+ for css_file in CSS_DIR.rglob("*.css"):+ content[css_file.name] = css_file.read_text()+ return content++ def test_success_uses_success_color(self, all_css_content):+ """Classes with 'success' should use --success-color."""+ issues = []+ for filename, content in all_css_content.items():+ if filename == "themes.css":+ continue+ # Find .success or -success classes+ success_classes = re.findall(+ r"\.([\w-]*success[\w-]*)\s*\{([^}]+)\}", content+ )+ for class_name, class_content in success_classes:+ if (+ "color:" in class_content+ and "var(--success-color)" not in class_content+ ):+ # Check if it's using success-color-rgb variant+ if "var(--success-color-rgb)" not in class_content:+ issues.append(f"{filename}: .{class_name}")++ # Allow a few exceptions but flag if too many+ if len(issues) > 3:+ pytest.fail(+ f"Success classes not using --success-color: {issues[:5]}"+ )++ def test_error_uses_error_color(self, all_css_content):+ """Classes with 'error' or 'danger' should use --error-color."""+ issues = []+ for filename, content in all_css_content.items():+ if filename == "themes.css":+ continue+ # Find .error or .danger classes+ error_classes = re.findall(+ r"\.([\w-]*(?:error|danger)[\w-]*)\s*\{([^}]+)\}", content+ )+ for class_name, class_content in error_classes:+ if "color:" in class_content:+ if (+ "var(--error-color)" not in class_content+ and "var(--error-color-rgb)" not in class_content+ ):+ issues.append(f"{filename}: .{class_name}")++ if len(issues) > 3:+ pytest.fail(+ f"Error/danger classes not using --error-color: {issues[:5]}"+ )++ def test_warning_uses_warning_color(self, all_css_content):+ """Classes with 'warning' should use --warning-color."""+ issues = []+ for filename, content in all_css_content.items():+ if filename == "themes.css":+ continue+ warning_classes = re.findall(+ r"\.([\w-]*warning[\w-]*)\s*\{([^}]+)\}", content+ )+ for class_name, class_content in warning_classes:+ if "color:" in class_content:+ if (+ "var(--warning-color)" not in class_content+ and "var(--warning-color-rgb)" not in class_content+ ):+ issues.append(f"{filename}: .{class_name}")++ if len(issues) > 3:+ pytest.fail(+ f"Warning classes not using --warning-color: {issues[:5]}"+ )+++class TestCSSVariableFallbacks:+ """Test that CSS variable fallbacks are appropriate."""++ # Bootstrap colors that should NOT be used as fallbacks+ BOOTSTRAP_COLORS = [+ "#007bff", # Bootstrap primary blue+ "#28a745", # Bootstrap success green+ "#dc3545", # Bootstrap danger red+ "#ffc107", # Bootstrap warning yellow+ "#17a2b8", # Bootstrap info+ "#6c757d", # Bootstrap secondary+ "#343a40", # Bootstrap dark+ "#f8f9fa", # Bootstrap light+ ]++ def test_no_bootstrap_fallbacks_in_css(self):+ """CSS files should not use Bootstrap colors as fallbacks."""+ issues = []+ fallback_pattern = re.compile(r"var\([^,]+,\s*(#[0-9a-fA-F]{6})\)")++ for css_file in CSS_DIR.rglob("*.css"):+ if css_file.name == "themes.css":+ continue++ content = css_file.read_text()+ for match in fallback_pattern.finditer(content):+ fallback_color = match.group(1).lower()+ if fallback_color in [c.lower() for c in self.BOOTSTRAP_COLORS]:+ issues.append(+ f"{css_file.name}: Bootstrap color {fallback_color} as fallback"+ )++ if issues:+ pytest.fail(+ "Found Bootstrap colors used as fallbacks:\n"+ + "\n".join(issues[:10])+ )++ def test_no_bootstrap_fallbacks_in_js(self):+ """JS files should not use Bootstrap colors as fallbacks."""+ issues = []+ fallback_pattern = re.compile(+ r"var\([^,]+,\s*['\"]?(#[0-9a-fA-F]{6})['\"]?\)"+ )++ for js_file in JS_DIR.rglob("*.js"):+ content = js_file.read_text()+ for match in fallback_pattern.finditer(content):+ fallback_color = match.group(1).lower()+ if fallback_color in [c.lower() for c in self.BOOTSTRAP_COLORS]:+ issues.append(+ f"{js_file.name}: Bootstrap color {fallback_color}"+ )++ if issues:+ pytest.fail(+ "Found Bootstrap colors in JS fallbacks:\n"+ + "\n".join(issues[:10])+ )+++class TestGradientTheming:+ """Test that gradients use theme variables."""++ def test_gradients_use_theme_vars(self):+ """Gradients should use theme variables, not hardcoded colors."""+ issues = []+ # Pattern for gradients with hardcoded colors (not var())+ gradient_pattern = re.compile(+ r"(?:linear|radial)-gradient\s*\([^)]*#[0-9a-fA-F]{3,8}[^)]*\)"+ )++ for css_file in CSS_DIR.rglob("*.css"):+ if css_file.name == "themes.css":+ continue++ content = css_file.read_text()+ for i, line in enumerate(content.split("\n"), 1):+ # Skip if using CSS variables+ if "var(--" in line:+ continue+ if gradient_pattern.search(line):+ issues.append(f"{css_file.name}:{i}")++ # Allow a small number for intentional gradients+ if len(issues) > 5:+ pytest.fail(+ f"Found {len(issues)} gradients with hardcoded colors:\n"+ + "\n".join(issues[:10])+ )+++class TestBorderColorTheming:+ """Test that border colors use theme variables."""++ def test_borders_use_theme_colors(self):+ """Border declarations should use theme variables."""+ issues = []+ # Pattern for border with hardcoded color (not CSS custom property definitions)+ border_color_pattern = re.compile(+ r"border(?:-(?:top|right|bottom|left))?(?:-color)?:\s*[^;]*#[0-9a-fA-F]{3,8}"+ )++ for css_file in CSS_DIR.rglob("*.css"):+ if css_file.name == "themes.css":+ continue++ content = css_file.read_text()+ for i, line in enumerate(content.split("\n"), 1):+ # Skip lines using CSS variables+ if "var(--" in line:+ continue+ # Skip CSS custom property definitions (theme-specific values)+ if line.strip().startswith("--"):+ continue+ if border_color_pattern.search(line):+ # Exclude black/white borders (often intentional)+ if (+ "#000" not in line.lower()+ and "#fff" not in line.lower()+ ):+ issues.append(+ f"{css_file.name}:{i}: {line.strip()[:60]}"+ )++ if len(issues) > 10:+ pytest.fail(+ f"Found {len(issues)} borders with hardcoded colors:\n"+ + "\n".join(issues[:15])+ )+++class TestJSThemeIntegration:+ """Test JavaScript files properly integrate with theme system."""++ def test_js_uses_css_variables_for_colors(self):+ """JS that sets colors should use CSS variables."""+ issues = []++ # Patterns that indicate proper CSS variable usage+ good_patterns = [+ "var(--",+ "getPropertyValue",+ "getComputedStyle",+ ]++ # Pattern for direct color assignment+ bad_pattern = re.compile(+ r'\.style\.\w*[Cc]olor\s*=\s*["\']#[0-9a-fA-F]{3,8}["\']'+ )++ for js_file in JS_DIR.rglob("*.js"):+ if "details.js" in js_file.name: # Chart colors exception+ continue++ content = js_file.read_text()+ for i, line in enumerate(content.split("\n"), 1):+ if bad_pattern.search(line):+ # Check if the line also uses CSS variables+ if not any(p in line for p in good_patterns):+ issues.append(f"{js_file.name}:{i}")++ if issues:+ pytest.fail(+ f"Found {len(issues)} JS lines setting colors directly:\n"+ + "\n".join(issues[:10])+ )++ def test_js_reads_css_variables_correctly(self):+ """JS should read CSS variables using getComputedStyle."""+ js_files_using_colors = []++ for js_file in JS_DIR.rglob("*.js"):+ content = js_file.read_text()+ if "getPropertyValue" in content and "--" in content:+ js_files_using_colors.append(js_file.name)++ # We should have at least some files reading CSS variables+ assert len(js_files_using_colors) >= 2, (+ "Expected at least 2 JS files to read CSS variables with getPropertyValue"+ )+++class TestTemplateInlineStyles:+ """Extended tests for inline styles in templates."""++ def test_no_inline_background_colors(self):+ """Templates should not have inline background-color with hex values."""+ issues = []+ pattern = re.compile(+ r'style\s*=\s*["\'][^"\']*background(?:-color)?:\s*#[0-9a-fA-F]{3,8}'+ )++ for template in TEMPLATES_DIR.rglob("*.html"):+ content = template.read_text()+ for i, line in enumerate(content.split("\n"), 1):+ if "var(--" in line:+ continue+ if pattern.search(line):+ issues.append(f"{template.name}:{i}")++ if issues:+ pytest.fail(+ f"Found {len(issues)} inline background colors:\n"+ + "\n".join(issues[:10])+ )++ def test_no_inline_text_colors(self):+ """Templates should not have inline color with hex values."""+ issues = []+ # More specific pattern to avoid matching background-color+ pattern = re.compile(+ r'style\s*=\s*["\'][^"\']*(?<!background-)color:\s*#[0-9a-fA-F]{3,8}'+ )++ for template in TEMPLATES_DIR.rglob("*.html"):+ content = template.read_text()+ for i, line in enumerate(content.split("\n"), 1):+ if "var(--" in line:+ continue+ if pattern.search(line):+ issues.append(f"{template.name}:{i}")++ if issues:+ pytest.fail(+ f"Found {len(issues)} inline text colors:\n"+ + "\n".join(issues[:10])+ )+++class TestThemeNamingConventions:+ """Test that theme names follow conventions."""++ @pytest.fixture+ def themes_css_content(self):+ """Load themes.css content."""+ return (CSS_DIR / "themes.css").read_text()++ def test_theme_names_are_lowercase_kebab(self, themes_css_content):+ """Theme names should be lowercase with hyphens."""+ theme_pattern = re.compile(r'\[data-theme="([^"]+)"\]')+ themes = theme_pattern.findall(themes_css_content)++ for theme in themes:+ assert theme == theme.lower(), (+ f"Theme '{theme}' should be lowercase"+ )+ assert "_" not in theme, (+ f"Theme '{theme}' should use hyphens, not underscores"+ )+ assert " " not in theme, (+ f"Theme '{theme}' should not contain spaces"+ )++ def test_theme_count(self, themes_css_content):+ """Should have exactly 20 themes defined with data-theme attribute."""+ theme_pattern = re.compile(r'\[data-theme="([^"]+)"\]')+ themes = set(theme_pattern.findall(themes_css_content))++ # All 20 themes should have data-theme definitions+ assert len(themes) == 20, (+ f"Expected 20 data-theme themes, found {len(themes)}: {themes}"+ )+++class TestAdditionalRGBVariants:+ """Additional tests for RGB variant correctness."""++ @pytest.fixture+ def themes_css_content(self):+ """Load themes.css content."""+ return (CSS_DIR / "themes.css").read_text()++ def test_all_required_rgb_variants_exist(self, themes_css_content):+ """Every required variable should have an RGB variant."""+ required_base_vars = [+ "bg-primary",+ "bg-secondary",+ "bg-tertiary",+ "accent-primary",+ "accent-secondary",+ "accent-tertiary",+ "text-primary",+ "text-secondary",+ "text-muted",+ "border-color",+ "success-color",+ "warning-color",+ "error-color",+ ]++ for var in required_base_vars:+ rgb_var = f"--{var}-rgb"+ assert rgb_var in themes_css_content, (+ f"Missing RGB variant: {rgb_var}"+ )++ def test_rgb_format_is_correct(self, themes_css_content):+ """RGB values should be in 'R, G, B' format (no parentheses)."""+ rgb_pattern = re.compile(r"--([\w-]+)-rgb:\s*([^;]+);")++ for match in rgb_pattern.finditer(themes_css_content):+ var_name = match.group(1)+ value = match.group(2).strip()++ # Should be three numbers separated by commas+ parts = value.split(",")+ assert len(parts) == 3, (+ f"--{var_name}-rgb should have 3 components: {value}"+ )++ for part in parts:+ try:+ num = int(part.strip())+ assert 0 <= num <= 255, (+ f"--{var_name}-rgb component out of range: {num}"+ )+ except ValueError:+ pytest.fail(+ f"--{var_name}-rgb has non-numeric component: {part}"+ )+++class TestColorConsistency:+ """Test color value consistency across themes."""++ @pytest.fixture+ def themes_css_content(self):+ """Load themes.css content."""+ return (CSS_DIR / "themes.css").read_text()++ def test_success_color_is_greenish(self, themes_css_content):+ """Success colors should be in the green spectrum."""+ # Extract success colors from all themes+ success_pattern = re.compile(r"--success-color:\s*(#[0-9a-fA-F]{6})")+ success_colors = success_pattern.findall(themes_css_content)++ for color in success_colors:+ # Green component should be relatively high+ r = int(color[1:3], 16)+ g = int(color[3:5], 16)++ # For success colors, green should generally be prominent+ # (allowing for some exceptions like high-contrast yellow-green)+ assert g >= r // 2 or g >= 100, (+ f"Success color {color} doesn't look greenish enough"+ )++ def test_error_color_is_reddish(self, themes_css_content):+ """Error colors should be in the red spectrum."""+ error_pattern = re.compile(r"--error-color:\s*(#[0-9a-fA-F]{6})")+ error_colors = error_pattern.findall(themes_css_content)++ for color in error_colors:+ r = int(color[1:3], 16)+ g = int(color[3:5], 16)+ b = int(color[5:7], 16)++ # Red component should be prominent+ assert r >= 150 or (r > g and r > b), (+ f"Error color {color} doesn't look reddish enough"+ )++ def test_rgb_values_match_hex(self, themes_css_content):+ """RGB variants should match their hex counterparts."""+ # Find pairs like --bg-primary: #121212 and --bg-primary-rgb: 18, 18, 18+ hex_pattern = re.compile(r"--(\w+(?:-\w+)*):\s*(#[0-9a-fA-F]{6})")+ rgb_pattern = re.compile(+ r"--(\w+(?:-\w+)*)-rgb:\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)"+ )++ hex_colors = {}+ rgb_colors = {}++ for match in hex_pattern.finditer(themes_css_content):+ var_name = match.group(1)+ hex_value = match.group(2)+ if var_name not in hex_colors:+ hex_colors[var_name] = []+ hex_colors[var_name].append(hex_value)++ for match in rgb_pattern.finditer(themes_css_content):+ var_name = match.group(1)+ rgb_value = (+ int(match.group(2)),+ int(match.group(3)),+ int(match.group(4)),+ )+ if var_name not in rgb_colors:+ rgb_colors[var_name] = []+ rgb_colors[var_name].append(rgb_value)++ # Check a sample of variables+ for var_name in ["bg-primary", "accent-primary", "success-color"]:+ if var_name in hex_colors and var_name in rgb_colors:+ for i, hex_val in enumerate(+ hex_colors[var_name][:3]+ ): # Check first 3+ expected_r = int(hex_val[1:3], 16)+ expected_g = int(hex_val[3:5], 16)+ expected_b = int(hex_val[5:7], 16)++ if i < len(rgb_colors[var_name]):+ actual = rgb_colors[var_name][i]+ assert actual == (expected_r, expected_g, expected_b), (+ f"RGB mismatch for {var_name}: "+ f"hex {hex_val} != rgb {actual}"+ )+++if __name__ == "__main__":+ pytest.main([__file__, "-v"])