/**
 * Dark-mode contrast fixes (plain CSS — NOT processed by Tailwind).
 * Loaded after app.min.css so unlayered rules beat Tailwind layers,
 * and @layer base !important beats components-layer !important.
 * Light mode is untouched (all selectors require html.dark).
 */
@layer base {
  /* Inline TextColor ink → readable near-white; accents keep their own color */
  html.dark [data-theme-color="text"] {
    color: #f5f5f5 !important;
  }
  html.dark [data-theme-color="muted"] {
    color: #d1d5db !important;
  }

  /* Rich-editor hardcoded dark colors inside article body */
  html.dark .article-prose :is(p, span, li, td, th, div, h1, h2, h3, h4, h5, h6, strong, em, b, i)[style*="color"]:not(.news-tag):not([class*="badge"]):not([class*="btn"]) {
    color: #e5e7eb !important;
  }
  html.dark .prose :is(p, span, li, td, th, div, h1, h2, h3, h4, h5, h6, strong, em, b, i)[style*="color"]:not(.news-tag):not([class*="badge"]):not([class*="btn"]) {
    color: #e5e7eb !important;
  }
  /* Common rich-editor dark inks (any element) */
  html.dark .article-prose [style*="color:#1e293b"],
  html.dark .article-prose [style*="color:#1E293B"],
  html.dark .article-prose [style*="color:#0f172a"],
  html.dark .article-prose [style*="color:#0F172A"],
  html.dark .article-prose [style*="color:#111"],
  html.dark .article-prose [style*="color:#111111"],
  html.dark .article-prose [style*="color:#334155"],
  html.dark .article-prose [style*="color:#475569"],
  html.dark .prose [style*="color:#1e293b"],
  html.dark .prose [style*="color:#1E293B"],
  html.dark .prose [style*="color:#0f172a"],
  html.dark .prose [style*="color:#0F172A"],
  html.dark .prose [style*="color:#111111"],
  html.dark .prose [style*="color:#334155"],
  html.dark .prose [style*="color:#475569"] {
    color: #e5e7eb !important;
  }
}

/* —— Unlayered: beats all Tailwind utility/component color utilities —— */
html.dark {
  color-scheme: dark;
  --dm-bg: #070707;
  --dm-surface: #121212;
  --dm-elevated: #1a1a1a;
  --dm-border: #2a2a2a;
  --dm-text: #f5f5f5;
  --dm-body: #e5e7eb;
  --dm-muted: #b0b8c4;
  --dm-faint: #a1a1aa;
  --dm-accent: #fb923c;
  --dm-link: #fb923c;
}

html.dark body {
  color: var(--dm-body);
  background-color: var(--dm-bg);
}

html.dark h1,
html.dark h2,
html.dark h3,
html.dark h4,
html.dark .section-title,
html.dark .news-sidebar__title {
  color: #ffffff;
}

/* Card / listing titles (often carry inline #111 via TextColor) */
html.dark .news-capa__title,
html.dark .news-capa__title a,
html.dark .news-destaque__title,
html.dark .news-destaque__title a,
html.dark .news-grid-card__title,
html.dark .news-grid-card__title a,
html.dark .news-lateral-item__title,
html.dark .news-lateral-item__title a,
html.dark .news-list-row__title,
html.dark .news-list-row__title a,
html.dark .card-post h2,
html.dark .card-post h2 a,
html.dark .card-post h3,
html.dark .card-post h3 a {
  color: #ffffff;
}

html.dark .news-capa__title a:hover,
html.dark .news-destaque__title a:hover,
html.dark .news-grid-card__title a:hover,
html.dark .news-lateral-item__title a:hover,
html.dark .news-list-row__title a:hover,
html.dark .card-post a:hover {
  color: var(--dm-accent);
}

html.dark .news-capa__lead,
html.dark .news-list-row__excerpt,
html.dark .article-header p.text-slate-600,
html.dark .article-header .text-slate-600,
html.dark .article-header .text-slate-700 {
  color: var(--dm-body);
}

html.dark .news-meta,
html.dark .section-kicker,
html.dark .article-header .text-slate-500,
html.dark .article-header ul.text-slate-500,
html.dark .article-header li,
html.dark .text-slate-500,
html.dark .text-slate-400,
html.dark .text-slate-600,
html.dark .dark\:text-slate-400,
html.dark .dark\:text-slate-500 {
  color: var(--dm-muted);
}

html.dark .text-slate-700,
html.dark .text-slate-800,
html.dark .text-slate-900,
html.dark .text-news-black,
html.dark .dark\:text-slate-100,
html.dark .dark\:text-slate-200,
html.dark .text-slate-100,
html.dark .text-slate-200,
html.dark .text-slate-300 {
  color: var(--dm-body);
}

html.dark .article-header {
  color: var(--dm-body);
  background: var(--dm-surface);
  border-color: var(--dm-border);
}

html.dark .article-header h1 {
  color: #ffffff;
}

html.dark .article-prose,
html.dark .article-body,
html.dark .article-print-area,
html.dark .prose {
  color: var(--dm-body);
  background: var(--dm-surface);
  border-color: var(--dm-border);
  --tw-prose-body: #e5e7eb;
  --tw-prose-headings: #ffffff;
  --tw-prose-lead: #d1d5db;
  --tw-prose-links: #fb923c;
  --tw-prose-bold: #ffffff;
  --tw-prose-counters: #9ca3af;
  --tw-prose-bullets: #9ca3af;
  --tw-prose-hr: #2a2a2a;
  --tw-prose-quotes: #e5e7eb;
  --tw-prose-quote-borders: #ea580c;
  --tw-prose-captions: #9ca3af;
  --tw-prose-code: #f5f5f5;
  --tw-prose-pre-code: #e5e7eb;
  --tw-prose-pre-bg: #0c0c0c;
  --tw-prose-th-borders: #2a2a2a;
  --tw-prose-td-borders: #2a2a2a;
}

html.dark .prose :where(p, li, td, th),
html.dark .article-prose :where(p, li, td, th) {
  color: var(--dm-body);
}

html.dark .prose :where(h1, h2, h3, h4),
html.dark .article-prose :where(h1, h2, h3, h4) {
  color: #ffffff;
}

html.dark .prose :where(a),
html.dark .article-prose :where(a),
html.dark .article-prose a {
  color: var(--dm-link);
}

html.dark .prose :where(blockquote),
html.dark .article-prose :where(blockquote) {
  color: var(--dm-body);
  border-color: #ea580c;
}

html.dark .prose :where(code),
html.dark .article-prose :where(code) {
  color: #f5f5f5;
}

html.dark .prose :where(thead th),
html.dark .article-prose :where(thead th) {
  color: #ffffff;
}

/* Buttons */
html.dark .btn-outline {
  border-color: #525252;
  background: rgba(255, 255, 255, 0.04);
  color: #f5f5f5;
}

html.dark .btn-outline:hover {
  border-color: #737373;
  background: var(--dm-elevated);
  color: #ffffff;
}

html.dark .btn-whatsapp {
  border-color: rgba(37, 211, 102, 0.45);
  background: rgba(37, 211, 102, 0.12);
  color: #bbf7d0;
}

/* Sidebar / cards */
html.dark .news-sidebar,
html.dark .news-list-row,
html.dark .news-capa__body,
html.dark .news-destaque__body,
html.dark .news-grid-card,
html.dark .card-public,
html.dark .card-post {
  border-color: var(--dm-border);
  background: var(--dm-surface);
  color: var(--dm-body);
}

html.dark .news-lateral-item {
  border-color: var(--dm-border);
  color: var(--dm-body);
}

/* Breadcrumbs, footer, forms, comments, pagination */
html.dark .breadcrumbs-bar,
html.dark .breadcrumbs-bar a,
html.dark nav[aria-label="Breadcrumb"],
html.dark nav[aria-label="Breadcrumb"] a {
  color: var(--dm-muted);
}

html.dark .breadcrumbs-bar a:hover,
html.dark nav[aria-label="Breadcrumb"] a:hover {
  color: var(--dm-accent);
}

html.dark footer,
html.dark .site-footer {
  background: var(--dm-surface);
  border-color: var(--dm-border);
  color: var(--dm-body);
}

html.dark footer a,
html.dark .site-footer a {
  color: #d1d5db;
}

html.dark footer a:hover,
html.dark .site-footer a:hover {
  color: var(--dm-accent);
}

html.dark .form-label,
html.dark label {
  color: #d1d5db;
}

html.dark .form-input,
html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
html.dark textarea,
html.dark select {
  color: var(--dm-text);
  background: var(--dm-elevated);
  border-color: var(--dm-border);
}

html.dark #comentarios,
html.dark .post-share,
html.dark .article-toc {
  background: var(--dm-surface);
  border-color: var(--dm-border);
  color: var(--dm-body);
}

html.dark .article-toc a {
  color: var(--dm-body);
}

html.dark .pagination a,
html.dark .pagination span,
html.dark nav[aria-label*="agina"] a,
html.dark nav[aria-label*="agina"] span {
  color: var(--dm-body);
  border-color: var(--dm-border);
}

html.dark .pagination a:hover {
  color: #ffffff;
  border-color: var(--dm-accent);
}

/* Search */
html.dark input[type="search"],
html.dark #q {
  color: var(--dm-text);
}

html.dark main p,
html.dark #main p:not(.news-meta):not(.section-kicker):not(.news-tag) {
  color: var(--dm-body);
}

html.dark .article-prose a,
html.dark .prose a,
html.dark .article-print-area a {
  color: var(--dm-link);
}

/* Keep tag/badge chips readable without flattening brand fills */
html.dark .news-tag {
  color: #ffffff;
}

/* Meta / muted: force readable floor */
html.dark .news-meta,
html.dark .article-header ul.text-slate-500,
html.dark .article-header .text-slate-500,
html.dark .section-kicker {
  color: #b0b8c4;
}
html.dark .news-grid-card .news-meta,
html.dark .news-meta.text-xs {
  color: #b0b8c4;
}

/* ===== v2: ad slots, reading bar, logo, leftover light cards ===== */

/* --- Ad / promo slots (containers only; iframe contents untouched) --- */
html.dark .promo-unit__html,
html.dark .promo-unit__image-link,
html.dark .ad-slot__html,
html.dark .ad-slot__image-link,
html.dark aside[data-promo-slot],
html.dark aside[data-ad-slot],
html.dark .ad-slot {
  background: var(--dm-elevated, #171717) !important;
  border-color: var(--dm-border, #404040) !important;
  color: var(--dm-body, #e5e5e5) !important;
}

html.dark .promo-unit__html,
html.dark .ad-slot__html {
  /* Avoid a glowing white pad around AdSense while it loads */
  background: transparent !important;
  border-color: var(--dm-border, #404040) !important;
}

html.dark .promo-unit__html ins.adsbygoogle,
html.dark .ad-slot__html ins.adsbygoogle,
html.dark ins.adsbygoogle {
  background: transparent !important;
}

/* Collapse unfilled AdSense units so they don't leave a white rectangle */
html.dark ins.adsbygoogle[data-ad-status="unfilled"] {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

html.dark .promo-unit:has(ins.adsbygoogle[data-ad-status="unfilled"]),
html.dark .ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) {
  display: none !important;
  margin: 0 !important;
  min-height: 0 !important;
}

html.dark .promo-unit__placeholder,
html.dark .ad-slot__placeholder {
  background: var(--dm-elevated, #171717) !important;
  border-color: var(--dm-border, #404040) !important;
  color: #a3a3a3 !important;
}

/* --- LEITURA reading-controls (injected by article-ux.js; dark: utilities often purged) --- */
html.dark .reading-controls {
  background: var(--dm-elevated, #171717) !important;
  border-color: var(--dm-border, #404040) !important;
  color: #e5e5e5 !important;
}

html.dark .reading-controls > span,
html.dark .reading-controls .text-slate-500,
html.dark .reading-controls .text-xs {
  color: #d4d4d4 !important;
}

html.dark .reading-controls .btn-outline,
html.dark .reading-controls button[data-read-font] {
  border-color: #a3a3a3 !important;
  background: rgba(255, 255, 255, 0.08) !important;
  color: #fafafa !important;
  box-shadow: none !important;
}
html.dark .reading-controls .btn-outline *,
html.dark .reading-controls button[data-read-font] * {
  color: #fafafa !important;
}

html.dark .reading-controls .btn-outline:hover,
html.dark .reading-controls button[data-read-font]:hover,
html.dark .reading-controls button[data-read-font].is-active {
  border-color: #a3a3a3 !important;
  background: rgba(255, 255, 255, 0.12) !important;
  color: #ffffff !important;
}

/* --- Header/footer logo: keep admin size; knock out white padding in dark --- */
/* invert+hue-rotate turns white→black and keeps red/orange in the warm range;
   mix-blend-mode:screen then drops the black (white padding) over the navy header. */
html.dark .header-main__logo-img,
html.dark a.header-main__logo img,
html.dark .header-main__logo img,
html.dark .site-footer img[src*="uploads/media"],
html.dark .site-footer .footer-logo img,
html.dark footer img.site-logo,
html.dark img.site-logo {
  filter: invert(1) hue-rotate(180deg);
  mix-blend-mode: screen;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  /* Do NOT override height/max-width — keep admin-set inline size (same as light). */
}

html.dark .header-main__logo,
html.dark a.header-main__logo,
html.dark .site-footer .footer-logo,
html.dark .site-footer a:has(> img[src*="uploads/media"]) {
  background: transparent !important;
  isolation: auto;
}

/* Ensure header itself is the blend backdrop (no isolated opaque wrapper around the logo) */
html.dark #site-header,
html.dark #site-header .header-main {
  isolation: auto;
}

/* --- Leftover light cards / empty states / modals / tools --- */
html.dark .modal-panel,
html.dark .modal-panel > .sticky {
  background: var(--dm-surface, #0a0a0a) !important;
  border-color: var(--dm-border, #404040) !important;
  color: var(--dm-body, #e5e5e5) !important;
}

html.dark #compound-bars,
html.dark .card-soft,
html.dark .newsletter-card,
html.dark .newsletter-article-cta {
  background: var(--dm-elevated, #171717) !important;
  border-color: var(--dm-border, #404040) !important;
  color: var(--dm-body, #e5e5e5) !important;
}

html.dark .card-soft--legal button {
  background: var(--dm-elevated, #171717) !important;
  border-color: var(--dm-border, #404040) !important;
  color: #e5e5e5 !important;
}

/* Category empty state (blog.php) lacking dark: utilities */
html.dark main .bg-white:not(img):not(svg),
html.dark #main .bg-white:not(img):not(svg),
html.dark .bg-slate-50:not(img) {
  /* Soft override for stray utility-only light backgrounds in content */
  background-color: var(--dm-elevated, #171717) !important;
}

/* Avoid flattening intentionally white chip borders on dark hero CTAs */
html.dark .hero a.border-white\/80,
html.dark a.hover\:bg-white\/10 {
  background-color: transparent !important;
}

html.dark .text-slate-900:not([data-theme-color]),
html.dark .text-gray-900:not([data-theme-color]) {
  color: #f5f5f5 !important;
}

html.dark .text-slate-600:not([data-theme-color]):not(.news-tag),
html.dark .text-slate-500:not([data-theme-color]):not(.news-tag):not(.news-meta) {
  color: #c4c4c4 !important;
}

html.dark .border-slate-200,
html.dark .border-slate-300 {
  border-color: var(--dm-border, #404040) !important;
}

/* Search / category empty panels already often have dark: — reinforce */
html.dark .rounded-xl.border.bg-white,
html.dark .rounded-lg.border.bg-white,
html.dark .rounded-xl.border.bg-slate-50,
html.dark .rounded-lg.border.bg-slate-50 {
  background: var(--dm-elevated, #171717) !important;
  border-color: var(--dm-border, #404040) !important;
  color: var(--dm-body, #e5e5e5) !important;
}


/* Pending / empty AdSense often paints a white rectangle via inline background */
html.dark .promo-unit__html ins.adsbygoogle,
html.dark .ad-slot__html ins.adsbygoogle,
html.dark ins.adsbygoogle {
  background: transparent !important;
  background-color: transparent !important;
}

/* If the unit is still an empty white shell (no iframe child yet), collapse the height */
html.dark .promo-unit__html:not(:has(iframe)):not(:has(img)):has(ins.adsbygoogle),
html.dark .ad-slot__html:not(:has(iframe)):not(:has(img)):has(ins.adsbygoogle) {
  min-height: 0 !important;
  border-color: transparent !important;
}

html.dark .promo-unit__html:not(:has(iframe)):not(:has(img)) ins.adsbygoogle:not([data-ad-status="filled"]),
html.dark .ad-slot__html:not(:has(iframe)):not(:has(img)) ins.adsbygoogle:not([data-ad-status="filled"]) {
  display: block !important;
  width: 100% !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}

html.dark .promo-unit:has(.promo-unit__html ins.adsbygoogle:not([data-ad-status="filled"])):not(:has(iframe)):not(:has(img)),
html.dark aside.promo-unit:has(ins.adsbygoogle:not([data-ad-status="filled"])):not(:has(iframe)):not(:has(.promo-unit__img)) {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  min-height: 0 !important;
}

/* Article placeholder logos (white-bg uploads used as empty-cover fallback) */
html.dark article img[src*="logo"],
html.dark article img.opacity-25,
html.dark .aspect-\[16\/9\] img {
  max-height: 4.5rem !important;
  border-radius: 8px;
}

/* Final reading-controls button force (unlayered) */
html.dark .reading-controls button[data-read-font],
html.dark .reading-controls .btn-outline {
  border-color: #d4d4d4 !important;
  background: #262626 !important;
  color: #fafafa !important;
}
