/**
 * MOL-GOD Contrast & Readability Fixes
 * WCAG 2.1 AA compliant (4.5:1 ratio minimum)
 * @version 2.1.0
 */

/* ═══ GLOBAL TEXT — NUCLEAR !important to override 474 inline styles ═══ */
.molgod-acc,
.molgod-acc *,
.molgod-solubility-accordion,
.molgod-solubility-accordion *,
.molgod-hplc-accordion *,
.molgod-atom-wrap *:not(summary):not([style*="background:#0A"]):not([style*="background:#1"]):not(th) { color: #1e293b !important; }

/* Override inline style="color:#7f8c8d" etc */
.molgod-acc [style*="color:#7f8c8d"],
.molgod-acc [style*="color:#6b7280"],
.molgod-acc [style*="color:#94a3b8"],
.molgod-acc [style*="color:#888"],
.molgod-acc [style*="color:#aaa"],
.molgod-acc [style*="color:#ccc"] { color: #475569 !important; }

/* Override light grey text everywhere in accordions */
.molgod-acc p,
.molgod-acc span,
.molgod-acc div,
.molgod-acc td,
.molgod-acc label,
.molgod-acc li { color: #1e293b !important; }

/* Dark backgrounds → white text */
.molgod-acc summary[style*="background:#0A0E27"],
.molgod-atom-wrap summary,
.molgod-atom-wrap .molgod-atom-header,
thead tr,
[style*="background:#1e293b"],
[style*="background:linear-gradient(135deg,#1e293b"] { color: #fff !important; }
thead th { color: #fff !important; }

/* ═══ ACCORDION SUMMARIES — readable, not flat ═══ */
.molgod-acc > summary {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    letter-spacing: -0.01em;
}
.molgod-acc > summary span { color: #0f172a !important; }
.molgod-acc > summary svg polyline { stroke: #475569 !important; }

/* Force all inner text dark */
.molgod-acc h4, .molgod-acc h5, .molgod-acc h6,
.molgod-acc strong, .molgod-acc b { color: #0f172a !important; }

/* Notes/warnings readable but lighter */
.molgod-acc [style*="font-style:italic"],
.molgod-acc .note { color: #475569 !important; }

/* ═══ TABLES — strong header, readable rows ═══ */
table thead tr {
    background: #1e293b !important;
}
table thead th {
    color: #f8fafc !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    padding: 12px 10px !important;
}
table tbody td {
    color: #1e293b !important;
    padding: 10px !important;
    font-size: 13px !important;
    border-bottom: 1px solid #e2e8f0 !important;
}
table tbody tr:hover { background: rgba(59,130,246,0.04) !important; }

/* ═══ BADGES — white text on color ═══ */
[style*="background:#d4edda"] { color: #14532d !important; }
[style*="background:#fff3cd"] { color: #713f12 !important; }
[style*="background:#f8d7da"] { color: #7f1d1d !important; }
[style*="background:#e0f2fe"] { color: #0c4a6e !important; }
[style*="background:#dcfce7"] { color: #14532d !important; }
[style*="background:#ede9fe"] { color: #4c1d95 !important; }
[style*="background:#fef3c7"] { color: #78350f !important; }

/* ═══ BUTTONS — strong blue, readable ═══ */
.molgod-btn-primary,
#molgod-calc-btn,
#molgod-reaction-check,
#molgod-proto-gen,
#generate-ai-method,
#export-methods-pdf,
.molgod-calc-go {
    background: #2563eb !important;
    color: #fff !important;
    border: none !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3) !important;
    cursor: pointer !important;
}
.molgod-btn-primary:hover,
#molgod-calc-btn:hover,
#molgod-reaction-check:hover,
#molgod-proto-gen:hover,
#generate-ai-method:hover,
#export-methods-pdf:hover,
.molgod-calc-go:hover {
    background: #1d4ed8 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37,99,235,0.4) !important;
}
.molgod-btn-primary:disabled,
button:disabled {
    background: #94a3b8 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* ═══ TABS (pill style) — active stands out ═══ */
.molgod-sol-tab {
    color: #334155 !important;
    font-weight: 700 !important;
    font-size: 13px !important;
}
.molgod-sol-tab.active,
.molgod-sol-tab[style*="background:#2563eb"],
.molgod-sol-tab[style*="color:#fff"] {
    background: #2563eb !important;
    color: #fff !important;
    box-shadow: 0 2px 6px rgba(37,99,235,0.3) !important;
}

/* ═══ INPUTS — visible borders ═══ */
input[type="text"],
input[type="number"],
input[type="url"],
input[type="date"],
select,
textarea,
.molgod-calc-input {
    background: #fff !important;
    color: #0f172a !important;
    border: 2px solid #cbd5e1 !important;
    font-size: 14px !important;
}
input:focus, select:focus, textarea:focus {
    border-color: #2563eb !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12) !important;
}
::placeholder { color: #94a3b8 !important; }

/* ═══ SAFETY — red borders, readable ═══ */
[style*="border:1px solid #fca5a5"] { border-color: #dc2626 !important; border-width: 2px !important; }
[style*="background:#fef2f2"] { background: #fef2f2 !important; color: #991b1b !important; }

/* ═══ FAQ items — clear Q&A ═══ */
.molgod-acc details details summary {
    color: #0f172a !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    background: #f8fafc !important;
}
.molgod-acc details details > div {
    color: #334155 !important;
    line-height: 1.7 !important;
    font-size: 13px !important;
}

/* ═══ LINKS — blue, underlined ═══ */
.molgod-acc a,
.molgod-hplc-bib-card__link,
a[style*="color:#3498db"] {
    color: #2563eb !important;
    text-decoration: underline !important;
    text-underline-offset: 2px !important;
}
.molgod-acc a:hover { color: #1d4ed8 !important; }

/* ═══ SPECTRAL LINKS cards ═══ */
.molgod-acc a[style*="border-left:3px"] {
    text-decoration: none !important;
    border: 1px solid #e2e8f0 !important;
}
.molgod-acc a[style*="border-left:3px"]:hover {
    background: #f1f5f9 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
}

/* ═══ MOLECULE INFO CARD ═══ */
[style*="background:linear-gradient(135deg,#eef2f7"] {
    border: 2px solid #cbd5e1 !important;
}
[style*="background:linear-gradient(135deg,#eef2f7"] strong,
[style*="background:linear-gradient(135deg,#eef2f7"] div {
    color: #0f172a !important;
}

/* ═══ GHS PICTOGRAMS ═══ */
[title*="GHS0"] rect { stroke: #dc2626 !important; stroke-width: 2.5 !important; }
[title*="GHS0"] path { fill: #1a1a1a !important; }

/* ═══ HPLC BIB CARDS ═══ */
.molgod-hplc-bib-card { border: 1px solid #cbd5e1 !important; }
.molgod-hplc-bib-card:hover { border-color: #2563eb !important; box-shadow: 0 2px 12px rgba(37,99,235,0.1) !important; }
.molgod-hplc-bib-card__title { color: #0f172a !important; font-weight: 700 !important; }
.molgod-hplc-bib-card__citation { color: #475569 !important; }

/* ═══ CONFIDENCE METER ═══ */
.molgod-hplc-bib-card__tag { font-weight: 700 !important; }

/* ═══ CALCULATOR RESULTS ═══ */
.molgod-calc-result { color: #059669 !important; font-weight: 800 !important; font-size: 15px !important; }

/* ═══ PRICE COMPARISON — our row green ═══ */
tr[style*="background:#f0fdf4"] td { color: #14532d !important; }
tr[style*="background:#f0fdf4"] td strong { color: #059669 !important; }

/* ═══ MOBILE ═══ */
@media (max-width: 768px) {
    button, .molgod-btn-primary, .molgod-calc-go, .molgod-sol-tab { min-height: 44px !important; }
    table { display: block !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
    .molgod-acc > summary { font-size: 14px !important; }
}

/* ═══ PRINT ═══ */
@media print {
    * { background: #fff !important; color: #000 !important; box-shadow: none !important; }
    button, .molgod-btn-primary, .molgod-sol-tab { display: none !important; }
    details { display: block !important; }
    details > summary { display: none !important; }
    table { border: 1px solid #000 !important; }
    th, td { border: 1px solid #666 !important; }
}

/* ═══ HIGH CONTRAST MODE ═══ */
@media (prefers-contrast: high) {
    .molgod-acc, .molgod-acc * { color: #000 !important; }
    button, .molgod-btn-primary { background: #000 !important; color: #fff !important; border: 3px solid #000 !important; }
    thead tr { background: #000 !important; }
    input, select, textarea { border: 3px solid #000 !important; }
}

/* ═══ REDUCED MOTION ═══ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
