@media (prefers-color-scheme: dark) {
  [style*="background-color: #e0f7fa"], [style*="background-color:#e0f7fa"],
  [style*="background-color: rgb(224, 247, 250)"] {
    background-color: #0e2d33 !important;
    color: #e8f6f9 !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
  }
  [style*="background-color: #e0f7fa"] strong,
  [style*="background-color:#e0f7fa"] strong,
  [style*="background-color: rgb(224, 247, 250)"] strong {
    color: #ffffff !important;
  }
  [style*="background-color: #e0f7fa"] a,
  [style*="background-color:#e0f7fa"] a,
  [style*="background-color: rgb(224, 247, 250)"] a {
    color: #9fd8ff !important;
    text-decoration: underline;
    text-underline-offset: 2px;
  }
}
@media (prefers-color-scheme: light) {
  [style*="background-color: #e0f7fa"], [style*="background-color:#e0f7fa"],
  [style*="background-color: rgb(224, 247, 250)"] { color: #0f1f24; }
}


/* v1.4.7 — Dark listings/page overrides for 'all-products' and 'all-posts' */

:root {
  --dm-bg: #0c1216;
  --dm-surface: #0f1820;
  --dm-text: #e6edf3;
  --dm-muted: #b3c0c8;
  --dm-link: #9fd8ff;
  --dm-border: rgba(255,255,255,.10);
}

/* Recognize many dark-mode activators */
html.dark, body.dark, .dark, .darkmode--activated, .night, .night-mode,
html[data-theme="dark"], body[data-theme="dark"], [data-theme="dark"],
.wp-dark-mode-active, .wp-night-mode-active {
  /* Page canvas */
  background-color: var(--dm-bg) !important;
  color: var(--dm-text) !important;
}

/* Archive & listing containers used by WordPress/Elementor/Gutenberg */
html.dark .site, .dark .site,
html.dark .site-content, .dark .site-content,
html.dark .content-area, .dark .content-area,
html.dark .entry-content, .dark .entry-content,
html.dark .wp-block-group, .dark .wp-block-group,
html.dark .wp-block-query, .dark .wp-block-query,
html.dark .wp-block-post-template, .dark .wp-block-post-template,
html.dark .wp-block-post, .dark .wp-block-post,
html.dark .post, .dark .post,
html.dark .hentry, .dark .hentry,
html.dark .archive .site-main article, .dark .archive .site-main article,
html.dark .blog .site-main article, .dark .blog .site-main article,
html.dark .elementor-section, .dark .elementor-section,
html.dark .elementor-container, .dark .elementor-container,
html.dark .elementor-widget-container, .dark .elementor-widget-container {
  background-color: transparent !important;
  color: var(--dm-text) !important;
}

/* Card-like wrappers frequently used on listings */
html.dark .card, .dark .card,
html.dark .post-card, .dark .post-card,
html.dark .product-card, .dark .product-card,
html.dark .elementor-post, .dark .elementor-post,
html.dark .elementor-post__card, .dark .elementor-post__card,
html.dark .elementor-post__text, .dark .elementor-post__text,
html.dark .elementor-widget-posts .elementor-post, .dark .elementor-widget-posts .elementor-post,
html.dark .woocommerce ul.products li.product, .dark .woocommerce ul.products li.product,
html.dark .archive article, .dark .archive article {
  background-color: var(--dm-surface) !important;
  color: var(--dm-text) !important;
  border: 1px solid var(--dm-border) !important;
}

/* Override common hardcoded light backgrounds (inline or CSS) */
html.dark [style*="background:#fff"], .dark [style*="background:#fff"],
html.dark [style*="background: #fff"], .dark [style*="background: #fff"],
html.dark [style*="background-color:#fff"], .dark [style*="background-color:#fff"],
html.dark [style*="background-color: #fff"], .dark [style*="background-color: #fff"],
html.dark [style*="background-color:#ffffff"], .dark [style*="background-color:#ffffff"],
html.dark [style*="background-color: #ffffff"], .dark [style*="background-color: #ffffff"],
html.dark [style*="background-color:rgb(255,255,255)"], .dark [style*="background-color:rgb(255,255,255)"] {
  background-color: var(--dm-surface) !important;
  color: var(--dm-text) !important;
}

/* Ensure headings/links/excerpts are legible */
html.dark h1, .dark h1, html.dark h2, .dark h2, html.dark h3, .dark h3,
html.dark .entry-title a, .dark .entry-title a,
html.dark .elementor-post__title a, .dark .elementor-post__title a {
  color: var(--dm-text) !important;
}
html.dark a, .dark a { color: var(--dm-link) !important; }
html.dark .entry-summary, .dark .entry-summary,
html.dark .excerpt, .dark .excerpt { color: var(--dm-muted) !important; }

/* Previous v1.4.6 rule for info boxes like #e0f7fa kept intact but generalized */
html.dark [style*="background-color: #e0f7fa"],
.dark [style*="background-color: #e0f7fa"],
html.dark [style*="background-color:#e0f7fa"],
.dark [style*="background-color:#e0f7fa"],
html.dark [style*="background-color: rgb(224, 247, 250)"],
.dark [style*="background-color: rgb(224, 247, 250)"] {
  background-color: #0e2d33 !important;
  color: #e8f6f9 !important;
  border: 1px solid var(--dm-border) !important;
}
html.dark [style*="#e0f7fa"] strong, .dark [style*="#e0f7fa"] strong { color: #fff !important; }
html.dark [style*="#e0f7fa"] a, .dark [style*="#e0f7fa"] a {
  color: var(--dm-link) !important; text-decoration: underline; text-underline-offset: 2px;
}

/* Footer widgets and meta areas */
html.dark .site-footer, .dark .site-footer,
html.dark .widget, .dark .widget {
  background-color: var(--dm-bg) !important;
  color: var(--dm-muted) !important;
}

/* v1.4.10 — Add robust fix for inline light-gray boxes (#f0f0f0) in dark mode */

/* 1) System dark mode */
@media (prefers-color-scheme: dark) {
  [style*="background-color: #f0f0f0"],
  [style*="background-color:#f0f0f0"],
  [style*="background: #f0f0f0"],
  [style*="background:#f0f0f0"],
  [style*="background-color: rgb(240, 240, 240)"],
  [style*="background: rgb(240, 240, 240)"] {
    background-color: var(--dm-surface) !important;
    color: var(--dm-text) !important;
    border: 1px solid var(--dm-border) !important;
  }
  [style*="#f0f0f0"] strong { color: #ffffff !important; }
  [style*="#f0f0f0"] a {
    color: var(--dm-link) !important;
    text-decoration: underline;
    text-underline-offset: 2px;
  }
}

/* 2) Class-based dark mode toggles used by popular plugins/themes */
html.dark [style*="background-color: #f0f0f0"],
.dark [style*="background-color: #f0f0f0"],
html.dark [style*="background-color:#f0f0f0"],
.dark [style*="background-color:#f0f0f0"],
html.dark [style*="background-color: rgb(240, 240, 240)"],
.dark [style*="background-color: rgb(240, 240, 240)"],
body.dark [style*="#f0f0f0"],
body.dark-mode [style*="#f0f0f0"],
.wp-dark-mode-active [style*="#f0f0f0"],
[data-theme="dark"] [style*="#f0f0f0"],
.is-dark-mode [style*="#f0f0f0"] {
  background-color: var(--dm-surface) !important;
  color: var(--dm-text) !important;
  border: 1px solid var(--dm-border) !important;
}

html.dark [style*="#f0f0f0"] strong, .dark [style*="#f0f0f0"] strong { color: #ffffff !important; }
html.dark [style*="#f0f0f0"] a, .dark [style*="#f0f0f0"] a,
body.dark [style*="#f0f0f0"] a, body.dark-mode [style*="#f0f0f0"] a,
.wp-dark-mode-active [style*="#f0f0f0"] a, [data-theme="dark"] [style*="#f0f0f0"] a,
.is-dark-mode [style*="#f0f0f0"] a {
  color: var(--dm-link) !important;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* === Extend dark-mode override to ai-dark / dark-mode classes (Ahan Sazeh – 2025-11-03) === */

/* تیترها و لینک‌ها در تمام حالت‌های دارک (ai-dark، body.dark-mode و ...) */
html.ai-dark h1, html.ai-dark h2, html.ai-dark h3,
html.ai-dark h4, html.ai-dark h5, html.ai-dark h6,
html.ai-dark-by-clock h1, html.ai-dark-by-clock h2, html.ai-dark-by-clock h3,
html.ai-dark-by-clock h4, html.ai-dark-by-clock h5, html.ai-dark-by-clock h6,
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3,
body.dark-mode h4, body.dark-mode h5, body.dark-mode h6,
body.dark h1, body.dark h2, body.dark h3,
body.dark h4, body.dark h5, body.dark h6,
.wp-dark-mode-active h1, .wp-dark-mode-active h2, .wp-dark-mode-active h3,
.wp-dark-mode-active h4, .wp-dark-mode-active h5, .wp-dark-mode-active h6,
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6,
.is-dark-mode h1, .is-dark-mode h2, .is-dark-mode h3,
.is-dark-mode h4, .is-dark-mode h5, .is-dark-mode h6 {
  color: var(--dm-text) !important;
}

/* عناوین پست/محصول در لیست‌ها که کلاس entry-title دارند */
html.ai-dark .entry-title a,
html.ai-dark-by-clock .entry-title a,
body.dark-mode .entry-title a,
body.dark .entry-title a,
.wp-dark-mode-active .entry-title a,
[data-theme="dark"] .entry-title a,
.is-dark-mode .entry-title a {
  color: var(--dm-text) !important;
}

/* خلاصه/اکسرپت‌ها در حالت شب کمی روشن‌تر شوند */
html.ai-dark .entry-summary,
html.ai-dark .excerpt,
html.ai-dark-by-clock .entry-summary,
html.ai-dark-by-clock .excerpt,
body.dark-mode .entry-summary,
body.dark-mode .excerpt,
body.dark .entry-summary,
body.dark .excerpt,
.wp-dark-mode-active .entry-summary,
.wp-dark-mode-active .excerpt,
[data-theme="dark"] .entry-summary,
[data-theme="dark"] .excerpt,
.is-dark-mode .entry-summary,
.is-dark-mode .excerpt {
  color: var(--dm-muted) !important;
}

/* --- Fix: Mobile table header hidden in dark mode (v1.4.10) --- */
@media (max-width: 820px) {
  /* Ensure thead stays visible on mobile when dark mode is active */
  html.wp-dark-mode-active table thead,
  .wp-dark-mode-active table thead,
  [data-wp-dark-mode-active] table thead {
    display: table-header-group !important;
    visibility: visible !important;
    height: auto !important;
  }
  .wp-dark-mode-active table thead tr,
  [data-wp-dark-mode-active] table thead tr {
    mix-blend-mode: normal !important;
    filter: none !important;
  }
  .wp-dark-mode-active table thead th,
  [data-wp-dark-mode-active] table thead th {
    background: var(--adf-d-surface, #15171a) !important;
    color: var(--adf-d-text, #e8e9ee) !important;
    border-color: var(--adf-d-border, #2a2e34) !important;
  }

  /* For responsive tables that hide <thead> and use cell labels via td::before */
  .wp-dark-mode-active table td::before,
  [data-wp-dark-mode-active] table td::before {
    color: var(--adf-d-muted, #c8ccd2) !important;
    mix-blend-mode: normal !important;
    opacity: 1 !important;
  }

  /* Common WP classes */
  .wp-dark-mode-active .wp-block-table thead,
  [data-wp-dark-mode-active] .wp-block-table thead,
  .wp-dark-mode-active .tablepress thead,
  [data-wp-dark-mode-active] .tablepress thead,
  .wp-dark-mode-active .tie-responsive-table thead,
  [data-wp-dark-mode-active] .tie-responsive-table thead {
    display: table-header-group !important;
  }
}

/* --- Fix v1.4.11: Stronger mobile header visibility for tables in dark mode --- */
@media (max-width: 860px) {
  html.wp-dark-mode-active body table thead,
  html.wp-dark-mode-active table thead,
  body.wp-dark-mode-active table thead,
  .wp-dark-mode-active table thead,
  [data-wp-dark-mode-active] table thead,
  .wp-dark-mode-active .wp-block-table thead,
  [data-wp-dark-mode-active] .wp-block-table thead,
  .wp-dark-mode-active .tablepress thead,
  [data-wp-dark-mode-active] .tablepress thead,
  .wp-dark-mode-active .tie-responsive-table table thead,
  [data-wp-dark-mode-active] .tie-responsive-table table thead {
    display: table-header-group !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
  }

  /* Ensure header cells are readable, not blended */
  html.wp-dark-mode-active body table thead th,
  html.wp-dark-mode-active table thead th,
  body.wp-dark-mode-active table thead th,
  .wp-dark-mode-active table thead th,
  [data-wp-dark-mode-active] table thead th {
    background: var(--adf-d-surface, #15171a) !important;
    color: var(--adf-d-text, #e8e9ee) !important;
    -webkit-text-fill-color: var(--adf-d-text, #e8e9ee) !important; /* iOS Safari */
    border-color: var(--adf-d-border, #2a2e34) !important;
    mix-blend-mode: normal !important;
    filter: none !important;
  }

  /* Captions / sticky heads that might be used as row 0 */
  .wp-dark-mode-active table caption,
  [data-wp-dark-mode-active] table caption {
    color: var(--adf-d-muted, #c8ccd2) !important;
    background: transparent !important;
  }

  /* If theme sets sticky header, keep it visible */
  .wp-dark-mode-active table thead th[style*="position:sticky"],
  [data-wp-dark-mode-active] table thead th[style*="position:sticky"],
  .wp-dark-mode-active .tablepress thead th,
  [data-wp-dark-mode-active] .tablepress thead th {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  /* If theme uses stacked layout with td::before as labels, ensure labels contrast */
  .wp-dark-mode-active table td::before,
  [data-wp-dark-mode-active] table td::before {
    color: var(--adf-d-muted, #c8ccd2) !important;
    mix-blend-mode: normal !important;
    opacity: 1 !important;
  }
}

/* v1.4.25: Ensure .tmcpt-phone link is purple in dark mode across engines */
:where(html[class*="dark"], html.wp-dark-mode-active, body.dark, body.dark-mode, [data-theme="dark"], [data-wp-dark-mode-active]) a.tmcpt-phone{
  color:#8b5cf6 !important;
  -webkit-text-fill-color:#8b5cf6 !important; /* iOS Safari */
  text-decoration:none !important;
  font-weight:800 !important;
}
:where(html[class*="dark"], html.wp-dark-mode-active, body.dark, body.dark-mode, [data-theme="dark"], [data-wp-dark-mode-active]) a.tmcpt-phone:hover,
:where(html[class*="dark"], html.wp-dark-mode-active, body.dark, body.dark-mode, [data-theme="dark"], [data-wp-dark-mode-active]) a.tmcpt-phone:focus{
  color:#a78bfa !important;
  -webkit-text-fill-color:#a78bfa !important;
}

/* Day mode safety: do not force phone color */
html:not([class*="dark"]).not-wp-dark a.tmcpt-phone,
html:not(.wp-dark-mode-active) a.tmcpt-phone{
  color:inherit !important;
}