/**
 * Analysis Results Theme Fix
 * Ensures analysis result boxes follow the selected theme
 */

/* Fix for analysis result boxes with hard-coded backgrounds */
.analysis-box,
.analysis-card,
.result-box,
.result-card,
.report-box,
.report-card,
[class*="analysis"][style*="background: white"],
[class*="analysis"][style*="background:#fff"],
[class*="analysis"][style*="background:#ffffff"],
[class*="result"][style*="background: white"],
[class*="result"][style*="background:#fff"],
[class*="result"][style*="background:#ffffff"],
[class*="report"][style*="background: white"],
[class*="report"][style*="background:#fff"],
[class*="report"][style*="background:#ffffff"] {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Modal overlays and popups */
.modal-overlay,
.popup-overlay,
.analysis-modal,
.result-modal,
.report-modal {
    background: var(--bg-overlay, rgba(0, 0, 0, 0.5)) !important;
}

/* Modal content boxes */
.modal-content,
.popup-content,
.analysis-modal-content,
.result-modal-content,
.report-modal-content,
[style*="position: fixed"][style*="background: white"],
[style*="position: fixed"][style*="background:#fff"],
[style*="position: fixed"][style*="background:#ffffff"] {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-primary) !important;
}

/* Analysis result items */
.analysis-item,
.result-item,
.report-item,
div[style*="background: white"][style*="padding"],
div[style*="background:#fff"][style*="padding"],
div[style*="background:#ffffff"][style*="padding"] {
    background: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-primary) !important;
}

/* Headers in analysis results */
.analysis-header,
.result-header,
.report-header,
h1[style*="color: #"],
h2[style*="color: #"],
h3[style*="color: #"],
h4[style*="color: #"] {
    color: var(--text-primary) !important;
}

/* Fix for numbered analysis boxes */
div[style*="border-radius"][style*="padding"][style*="background: white"],
div[style*="border-radius"][style*="padding"][style*="background:#fff"],
div[style*="border-radius"][style*="padding"][style*="background:#ffffff"] {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-primary) !important;
}

/* Text inside analysis boxes */
p[style*="color: #333"],
p[style*="color: #666"],
span[style*="color: #333"],
span[style*="color: #666"] {
    color: var(--text-secondary) !important;
}

/* Buttons in analysis results */
.analysis-button,
.result-button,
button[style*="background: #007bff"],
button[style*="background: #28a745"] {
    background: var(--primary-600) !important;
    color: white !important;
    border: none !important;
}

.analysis-button:hover,
.result-button:hover,
button[style*="background: #007bff"]:hover,
button[style*="background: #28a745"]:hover {
    background: var(--primary-700) !important;
}

/* Success/info/warning boxes */
.success-box[style*="background"],
.info-box[style*="background"],
.warning-box[style*="background"] {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-primary) !important;
}

/* Progress indicators */
.progress-container[style*="background: white"],
.progress-container[style*="background:#fff"],
.progress-container[style*="background:#ffffff"] {
    background: var(--bg-surface) !important;
}

/* Override inline styles for dark mode compatibility */
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: rgb(255, 255, 255)"] {
    background: var(--bg-card) !important;
}

[data-theme="dark"] [style*="color: black"],
[data-theme="dark"] [style*="color:#000"],
[data-theme="dark"] [style*="color:#000000"],
[data-theme="dark"] [style*="color: rgb(0, 0, 0)"] {
    color: var(--text-primary) !important;
}

/* Specific fix for analysis count boxes like "#1 TOTAL OF ANALYSES" */
div:has(> :first-child:contains("#")) {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Fix for any remaining white backgrounds in modals */
body > div[style*="position: fixed"] div[style*="background: white"],
body > div[style*="position: fixed"] div[style*="background:#fff"],
body > div[style*="position: fixed"] div[style*="background:#ffffff"] {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Ensure proper contrast for all text */
.analysis-content *,
.result-content *,
.report-content * {
    color: inherit !important;
}