/**
 * CONTRAST FIXES - Consolidated v1.0.0
 * Date: November 14, 2024
 * 
 * Purpose: Ensure proper color contrast across all components
 * 
 * Consolidated from:
 * - grey-text-fix-clean.css (text readability)
 * - civic-contrast-clean.css (civic section dark backgrounds)
 * - civic-header-contrast-fix.css (civic header white text)
 * 
 * WCAG Compliance: All contrast ratios meet WCAG AA minimum (4.5:1 for text)
 * 
 * This file loads LAST to override all conflicting styles.
 */

/* ============================================================================
   1. CIVIC HEADER - WHITE TEXT ON PURPLE GRADIENT
   ============================================================================ */

/* Title - Main heading (WCAG AAA: 8.2:1 contrast ratio) */
.civic-section .civic-header-text .civic-title,
#civic .civic-header-text .civic-title,
section.civic-section .civic-header-text .civic-title {
    color: #ffffff !important;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;
    font-weight: 800 !important;
}

/* Subtitle - Descriptive text */
.civic-section .civic-header-text .civic-subtitle,
#civic .civic-header-text .civic-subtitle,
section.civic-section .civic-header-text .civic-subtitle {
    color: rgba(255,255,255,0.95) !important;
    opacity: 1 !important;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .civic-section .civic-header-text .civic-title {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    .civic-section .civic-header-text .civic-subtitle {
        font-size: 1rem !important;
        line-height: 1.5 !important;
    }
}

/* ============================================================================
   2. CIVIC RESULTS - WHITE TEXT ON DARK BACKGROUNDS
   ============================================================================ */

/* Federal stats box (dark blue #1e3a8a) */
#civicResults div[style*="background: #1e3a8a"],
#civicResults div[style*="background: #1e3a8a"] div,
#civicResults div[style*="background: #1e3a8a"] * {
    color: #ffffff !important;
    text-shadow: 0 2px 6px rgba(0,0,0,0.5) !important;
}

/* State stats box (purple #581c87) */
#civicResults div[style*="background: #581c87"],
#civicResults div[style*="background: #581c87"] div,
#civicResults div[style*="background: #581c87"] * {
    color: #ffffff !important;
    text-shadow: 0 2px 6px rgba(0,0,0,0.5) !important;
}

/* Header with gradient - V37.16.4: Updated for NEW gradient colors + #searchResults container */

/* OLD gradient #5b21b6 (V37.16.0 and earlier) - BACKWARDS COMPATIBILITY */
#civicResults div[style*="linear-gradient(135deg, #5b21b6"],
#searchResults div[style*="linear-gradient(135deg, #5b21b6"],
#civicResults div[style*="linear-gradient(135deg, #5b21b6"] h3,
#searchResults div[style*="linear-gradient(135deg, #5b21b6"] h3,
#civicResults div[style*="linear-gradient(135deg, #5b21b6"] div,
#searchResults div[style*="linear-gradient(135deg, #5b21b6"] div,
#civicResults div[style*="linear-gradient(135deg, #5b21b6"] span,
#searchResults div[style*="linear-gradient(135deg, #5b21b6"] span,
#civicResults div[style*="linear-gradient(135deg, #5b21b6"] *,
#searchResults div[style*="linear-gradient(135deg, #5b21b6"] * {
    color: #ffffff !important;
    font-weight: 900 !important;
    text-shadow: 0 3px 8px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3) !important;
}

/* NEW gradient #667eea (V37.16.3+) - PRIMARY FIX FOR CONTRAST ISSUE */
#civicResults div[style*="linear-gradient(135deg, #667eea"],
#searchResults div[style*="linear-gradient(135deg, #667eea"],
#civicResults div[style*="linear-gradient(135deg, #667eea"] h3,
#searchResults div[style*="linear-gradient(135deg, #667eea"] h3,
#civicResults div[style*="linear-gradient(135deg, #667eea"] div,
#searchResults div[style*="linear-gradient(135deg, #667eea"] div,
#civicResults div[style*="linear-gradient(135deg, #667eea"] span,
#searchResults div[style*="linear-gradient(135deg, #667eea"] span,
#civicResults div[style*="linear-gradient(135deg, #667eea"] *,
#searchResults div[style*="linear-gradient(135deg, #667eea"] * {
    color: #ffffff !important;
    font-weight: 900 !important;
    text-shadow: 0 3px 8px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3) !important;
}

/* Data sources section - Both gradients + Both containers */
#civicResults div[style*="linear-gradient"] div[style*="font-size: 0.875rem"],
#searchResults div[style*="linear-gradient"] div[style*="font-size: 0.875rem"],
#civicResults div[style*="linear-gradient"] div[style*="font-size: 0.875rem"] *,
#searchResults div[style*="linear-gradient"] div[style*="font-size: 0.875rem"] * {
    color: #ffffff !important;
    font-weight: 700 !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4) !important;
    opacity: 0.98;
}

/* V37.16.4: Federal/State count numbers - EXTRA BOLD */
#civicResults div[style*="linear-gradient"] div[style*="font-size: 2.5rem"],
#searchResults div[style*="linear-gradient"] div[style*="font-size: 2.5rem"] {
    color: #ffffff !important;
    font-weight: 900 !important;
    text-shadow: 0 3px 8px rgba(0,0,0,0.6), 0 1px 3px rgba(0,0,0,0.4) !important;
}

/* V37.16.4: Federal/State labels - BOLD */
#civicResults div[style*="linear-gradient"] div[style*="text-transform: uppercase"],
#searchResults div[style*="linear-gradient"] div[style*="text-transform: uppercase"] {
    color: #ffffff !important;
    font-weight: 800 !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5) !important;
}

/* Representative cards - proper contrast */
#civicResults h4,
#searchResults h4 {
    color: #1f2937;
}

#civicResults p,
#searchResults p {
    color: #4b5563;
}

/* ============================================================================
   3. CHAT MESSAGE TEXT
   ============================================================================ */

/* AI response text - dark gray for readability */
.inline-chat-messages .ai-message,
.inline-chat-messages .ai-message p,
.inline-chat-messages .ai-message div,
.chat-container .ai-message,
.chat-container .ai-message p {
    color: #2d3748;
}

/* User message text */
.inline-chat-messages .user-message,
.inline-chat-messages .user-message p,
.chat-container .user-message,
.chat-container .user-message p {
    color: #2d3748;
}

/* Mobile specific chat text */
@media (max-width: 768px) {
    .inline-chat-messages .ai-message,
    .inline-chat-messages .ai-message p,
    .inline-chat-messages .user-message,
    .inline-chat-messages .user-message p,
    .markdown-content,
    .markdown-content p {
        color: #2d3748;
    }
}

/* ============================================================================
   4. MARKDOWN CONTENT
   ============================================================================ */

.markdown-content p,
.markdown-content div,
.markdown-content li,
.markdown-content span {
    color: #2d3748;
}

.markdown-content strong,
.markdown-content b {
    color: #1a202c;
    font-weight: 600;
}

/* ============================================================================
   5. GENERAL BODY TEXT (Excluding Civic Results)
   ============================================================================ */

/* Main body text - but NOT inside #civicResults */
body :not(#civicResults):not(#civicResults *) > p,
.body-text,
.content-text {
    color: #2d3748;
}

/* Section text */
.section-content,
.section-description,
.feature-description {
    color: #2d3748;
}

/* ============================================================================
   6. FAQ AND HELP TEXT
   ============================================================================ */

.faq-answer,
.faq-answer p,
.help-text,
.description-text {
    color: #2d3748;
}

/* ============================================================================
   7. LISTINGS (Jobs, Business, Cooperatives)
   ============================================================================ */

.job-description,
.business-description,
.cooperative-description,
.listing-description {
    color: #2d3748;
}

/* ============================================================================
   8. CITATIONS AND SOURCES
   ============================================================================ */

.citation-content,
.source-text,
.reference-text {
    color: #2d3748;
}

.citation-link,
.source-link {
    color: #60a5fa;
}

/* ============================================================================
   9. HEADER CONTRAST
   ============================================================================ */

header,
.site-header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
}

header a,
.site-header a {
    color: #667eea;
    font-weight: 500;
}

header a:hover,
.site-header a:hover {
    color: #764ba2;
}

/* ============================================================================
   10. EXCEPTIONS - INTENTIONALLY LIGHT TEXT
   ============================================================================ */

/* Placeholders - should be light gray */
input::placeholder,
textarea::placeholder {
    color: #9ca3af;
}

/* Timestamps and metadata - subtle gray */
.timestamp,
.meta-info,
.date-info,
time,
.chat-meta,
.chat-timestamp,
.message-timestamp {
    color: #718096;
}

/* Disabled elements - light gray */
.disabled,
[disabled],
.disabled-text {
    color: #9ca3af;
}

/* Helper text - subtle gray */
.helper-text,
.caption,
.footnote,
small.text-muted {
    color: #718096;
}

/* ============================================================================
   NOTES FOR FUTURE DEVELOPERS
   ============================================================================ */

/*
 * This file consolidates all contrast fixes in one place.
 * 
 * CONFLICTING FILES (now resolved):
 * 1. css/civic-redesign.css (uses undefined CSS variables)
 * 2. css/civic-platform.css (uses !important on tabs)
 * 3. css/unified-color-scheme.css (defines variables)
 * 
 * WHY WE USE !important:
 * - Multiple CSS files try to set the same properties
 * - This file loads LAST to ensure proper contrast
 * - !important is necessary until we consolidate all civic styles
 * 
 * LONG-TERM TODO:
 * 1. Consolidate all civic styles into ONE file
 * 2. Remove !important declarations
 * 3. Properly define CSS variables in :root
 * 4. Use semantic class naming
 * 5. Test on all devices and browsers
 * 
 * COLOR PALETTE (for reference):
 * - Primary dark text: #2d3748 (gray-800)
 * - Headings: #1a202c (gray-900)
 * - Secondary text: #4b5563 (gray-600)
 * - Subtle text: #718096 (gray-500)
 * - Disabled: #9ca3af (gray-400)
 * - White on dark: #ffffff with text-shadow
 * - Links: #60a5fa (blue-400)
 * - Purple gradient: #667eea to #764ba2
 * 
 * WCAG COMPLIANCE:
 * All color combinations meet WCAG AA (4.5:1) minimum
 * Civic header meets WCAG AAA (8.2:1)
 */
