/* === Dark mode: public site === */
/* Bootstrap 5.3 handles most components via [data-bs-theme="dark"]. */
/* These rules cover our custom .st-* classes and the admin panel. */

[data-bs-theme="dark"] {
    color-scheme: dark;
}

/* Legacy app.css design tokens - used by tier-tools.css (cron builder,
   diff checker, etc). Without dark variants, those tools render white
   panels on a dark page. */
[data-bs-theme="dark"], [data-theme="dark"] {
    --color-bg:             #0F172A;
    --color-surface:        #1E293B;
    --color-text:           #E2E8F0;
    --color-text-muted:     #94A3B8;
    --color-border:         #334155;
    --color-border-hover:   #475569;
    --color-primary-light:  rgba(37, 99, 235, .18);
}

/* Cron builder: per-field tinted backgrounds were tuned for a white page.
   In dark mode the focus rule forced background:#fff which broke the look. */
[data-theme="dark"] .cron-cell-input:focus {
    background: var(--cell-bg);
}
[data-theme="dark"] .cron-cell-input.is-error {
    background: rgba(220, 38, 38, .18) !important;
    color: #FCA5A5 !important;
}

/* ─────────────────────────────────────────────────────────────
   wave1-dev-tools.css - hardcoded palette, no theme switching.
   Tools: Cron to English, curl Converter, JSON Schema Diff,
   Regex from Examples. Overrides below cover all .wd-* classes.
   ───────────────────────────────────────────────────────────── */
[data-theme="dark"] .wd-section {
    background: #1E293B;
    border-color: #334155;
}
[data-theme="dark"] .wd-section__title { color: #94A3B8; }
[data-theme="dark"] .wd-copy-bar__label { color: #E2E8F0; }
[data-theme="dark"] .wd-cron-cell {
    background: #0F172A;
    border: 1px solid #334155;
}
[data-theme="dark"] .wd-cron-cell__label { color: #94A3B8; }
[data-theme="dark"] .wd-cron-cell__value { color: #F1F5F9; }
[data-theme="dark"] .wd-cron-english { color: #F1F5F9; }
[data-theme="dark"] .wd-next-list li { border-bottom-color: #334155; }
[data-theme="dark"] .wd-next-list__index { color: #94A3B8; }
[data-theme="dark"] .wd-next-list__rel { color: #818CF8; }
[data-theme="dark"] .wd-error {
    background: rgba(220, 38, 38, .15);
    border-color: rgba(220, 38, 38, .35);
    color: #FCA5A5;
}
[data-theme="dark"] .wd-diff-table th {
    background: #0F172A;
    color: #94A3B8;
}
[data-theme="dark"] .wd-diff-table th,
[data-theme="dark"] .wd-diff-table td { border-bottom-color: #334155; }
[data-theme="dark"] .wd-diff-row--added   { background: rgba(34, 197, 94, .12); }
[data-theme="dark"] .wd-diff-row--removed { background: rgba(220, 38, 38, .12); }
[data-theme="dark"] .wd-diff-row--changed { background: rgba(245, 158, 11, .12); }
[data-theme="dark"] .wd-path { color: #E2E8F0; }
[data-theme="dark"] .wd-detail { color: #94A3B8; }
[data-theme="dark"] .wd-regex-output {
    background: #0F172A;
    border-color: #334155;
    color: #E2E8F0;
}
[data-theme="dark"] .wd-line-status--ok {
    background: rgba(34, 197, 94, .15);
    border-color: rgba(34, 197, 94, .35);
    color: #86EFAC;
}
[data-theme="dark"] .wd-line-status--bad {
    background: rgba(220, 38, 38, .15);
    border-color: rgba(220, 38, 38, .35);
    color: #FCA5A5;
}
/* Diff badges keep their bright pastel BGs (they're status indicators -
   readable on either theme), but darken text slightly for dark mode. */
[data-theme="dark"] .wd-input-type-pill {
    background: rgba(139, 92, 246, .25);
    color: #C4B5FD;
}

[data-bs-theme="dark"] body {
    background-color: #0f172a;
    color: #e2e8f0;
}

/* === Public site overrides === */
[data-bs-theme="dark"] .st-navbar { background: #1e293b; border-bottom-color: #334155; }
[data-bs-theme="dark"] .st-brand-text { color: #f8fafc; }
[data-bs-theme="dark"] .st-nav-link { color: #cbd5e1; }
[data-bs-theme="dark"] .st-nav-link:hover,
[data-bs-theme="dark"] .st-nav-link.active { color: #fff; }
[data-bs-theme="dark"] .st-search-input { background: #0f172a; color: #e2e8f0; border-color: #334155; }
[data-bs-theme="dark"] .st-search-input::placeholder { color: #64748b; }
[data-bs-theme="dark"] .st-search-icon { background: #0f172a; border-color: #334155; color: #94a3b8; }

[data-bs-theme="dark"] .st-cat-dropdown-menu { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .st-cat-dropdown-item { color: #e2e8f0; }
[data-bs-theme="dark"] .st-cat-dropdown-item:hover { background: #334155; }
[data-bs-theme="dark"] .st-cat-dropdown-name { color: #f1f5f9; }
[data-bs-theme="dark"] .st-cat-dropdown-count { color: #94a3b8; }
[data-bs-theme="dark"] .st-cat-dropdown-icon { background: #334155; color: #cbd5e1; }
[data-bs-theme="dark"] .st-cat-dropdown-footer { background: #1e293b; border-top-color: #334155; }

[data-bs-theme="dark"] .st-hero { background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
[data-bs-theme="dark"] .st-hero-title { color: #f8fafc; }
[data-bs-theme="dark"] .st-hero-subtitle { color: #cbd5e1; }
[data-bs-theme="dark"] .st-hero-stat { background: rgba(255, 255, 255, 0.05); color: #cbd5e1; }
[data-bs-theme="dark"] .st-hero-eyebrow { background: rgba(37, 99, 235, 0.15); color: #93c5fd; }

[data-bs-theme="dark"] .st-cat-pill { background: #1e293b; border-color: #334155; color: #cbd5e1; }
[data-bs-theme="dark"] .st-cat-pill:hover { background: #334155; color: #fff; }
[data-bs-theme="dark"] .st-category-bar { background: #0f172a; border-bottom-color: #334155; }

[data-bs-theme="dark"] .st-tool-card { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-bs-theme="dark"] .st-tool-card:hover { background: #283548; border-color: #475569; }
[data-bs-theme="dark"] .st-tool-name { color: #f1f5f9; }
[data-bs-theme="dark"] .st-tool-desc { color: #94a3b8; }
[data-bs-theme="dark"] .st-tool-icon { background: rgba(37, 99, 235, 0.18); color: #93c5fd; }

[data-bs-theme="dark"] .st-section-title { color: #f1f5f9; }
[data-bs-theme="dark"] .st-section-count { color: #94a3b8; }
[data-bs-theme="dark"] .st-view-all { color: #93c5fd; }
[data-bs-theme="dark"] .st-cat-icon { background: rgba(37, 99, 235, 0.18); color: #93c5fd; }

[data-bs-theme="dark"] .st-featured-section,
[data-bs-theme="dark"] .st-category-section { background: transparent; }
[data-bs-theme="dark"] .st-featured-title,
[data-bs-theme="dark"] .st-featured-subtitle { color: #f1f5f9; }
[data-bs-theme="dark"] .st-featured-subtitle { color: #94a3b8; }
[data-bs-theme="dark"] .st-featured-badge { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

[data-bs-theme="dark"] .st-pro-badge { background: linear-gradient(135deg, #f59e0b, #d97706); color: #1e293b; }

[data-bs-theme="dark"] .st-footer { background: #0f172a; border-top-color: #1e293b; }
[data-bs-theme="dark"] .st-footer-brand { color: #f1f5f9; }
[data-bs-theme="dark"] .st-footer-desc { color: #94a3b8; }
[data-bs-theme="dark"] .st-footer-heading { color: #cbd5e1; }
[data-bs-theme="dark"] .st-footer-links a { color: #94a3b8; }
[data-bs-theme="dark"] .st-footer-links a:hover { color: #fff; }
[data-bs-theme="dark"] .st-footer-bottom { color: #64748b; border-top-color: #1e293b; }

/* Tool result panels, copy bars */
[data-bs-theme="dark"] .st-copy-bar { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .st-copy-label { color: #94a3b8; }

/* CMS / generic content (account, page show) */
[data-bs-theme="dark"] .bg-white { background-color: #1e293b !important; color: #e2e8f0; }
[data-bs-theme="dark"] .border { border-color: #334155 !important; }

/* Bulk tool result tables */
[data-bs-theme="dark"] .bulk-summary-item { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .bulk-summary-item strong { color: #94a3b8; }
[data-bs-theme="dark"] .bulk-summary-item span { color: #f1f5f9; }
[data-bs-theme="dark"] .bulk-result-table { border-color: #334155; }
[data-bs-theme="dark"] .bulk-result-table thead th { background: #1e293b; color: #cbd5e1; border-bottom-color: #334155; }

/* === Admin panel overrides === */
[data-bs-theme="dark"] body.admin-body { background: #020617; }
[data-bs-theme="dark"] .admin-topbar { background: #0f172a; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .admin-page-title { color: #f1f5f9; }
[data-bs-theme="dark"] .admin-content { color: #e2e8f0; }

[data-bs-theme="dark"] .admin-card,
[data-bs-theme="dark"] .form-section,
[data-bs-theme="dark"] .seo-panel { background: #0f172a; border-color: #1e293b; }
[data-bs-theme="dark"] .admin-card-header,
[data-bs-theme="dark"] .seo-panel-header { background: #0a0f1d; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .admin-card-title,
[data-bs-theme="dark"] .form-section-title { color: #f1f5f9; }
[data-bs-theme="dark"] .form-section-title { border-bottom-color: #1e293b; }

[data-bs-theme="dark"] .admin-stat-card { background: #0f172a; border-color: #1e293b; }
[data-bs-theme="dark"] .admin-stat-card .stat-value { color: #f1f5f9; }
[data-bs-theme="dark"] .admin-stat-card .stat-label { color: #94a3b8; }

[data-bs-theme="dark"] .admin-table thead th { background: #0a0f1d; color: #cbd5e1; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .admin-table tbody tr { background: transparent; }
[data-bs-theme="dark"] .admin-table tbody td { border-color: #1e293b; color: #e2e8f0; }

[data-bs-theme="dark"] .admin-tool-icon { background: rgba(79, 70, 229, 0.18); color: #a5b4fc; }

[data-bs-theme="dark"] .seo-preview { background: #0a0f1d; border-color: #1e293b; }
[data-bs-theme="dark"] .seo-preview-title { color: #93c5fd; }
[data-bs-theme="dark"] .seo-preview-url { color: #86efac; }
[data-bs-theme="dark"] .seo-preview-desc { color: #cbd5e1; }

[data-bs-theme="dark"] .faq-row { background: #0a0f1d; border-color: #1e293b; }

[data-bs-theme="dark"] .settings-nav .nav-link { color: #cbd5e1; }
[data-bs-theme="dark"] .settings-nav .nav-link:not(.active):hover { background: #1e293b; }

[data-bs-theme="dark"] .bulk-tool-help { background: #0a0f1d; border-color: #1e293b; color: #cbd5e1; }
[data-bs-theme="dark"] .bulk-tool-help code { background: #1e293b; border-color: #334155; color: #e2e8f0; }

/* === Home redesign - dark mode === */
[data-bs-theme="dark"] .st-popular-chip { background: rgba(255, 255, 255, .04); border-color: #334155; color: #cbd5e1; }
[data-bs-theme="dark"] .st-popular-chip:hover { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
[data-bs-theme="dark"] .st-popular-chips-label { color: #94a3b8; }

[data-bs-theme="dark"] .st-trust-band { background: #0f172a; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .st-trust-title { color: #f1f5f9; }
[data-bs-theme="dark"] .st-trust-desc { color: #94a3b8; }

[data-bs-theme="dark"] .st-trending-section { background: linear-gradient(180deg, #0f172a 0%, #131c30 100%); }

[data-bs-theme="dark"] .st-cat-overview { background: #0f172a; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .st-cat-overview-card { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-bs-theme="dark"] .st-cat-overview-card:hover { background: #283548; border-color: #93c5fd; }
[data-bs-theme="dark"] .st-cat-overview-name { color: #f1f5f9; }
[data-bs-theme="dark"] .st-cat-overview-count { color: #94a3b8; }
[data-bs-theme="dark"] .st-cat-overview-arrow { color: #94a3b8; }
[data-bs-theme="dark"] .st-cat-overview-card:hover .st-cat-overview-arrow { color: #93c5fd; }

/* FAQ - shared between home (wrapped in .st-faq-band) and tool pages */
[data-bs-theme="dark"] .st-faq-band { background: #0f172a; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .st-faq-header h2 { color: #f1f5f9; }
[data-bs-theme="dark"] .st-faq-header p { color: #94a3b8; }
[data-bs-theme="dark"] .st-faq-item { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .st-faq-item[open] { border-color: #93c5fd; }
[data-bs-theme="dark"] .st-faq-question { color: #f1f5f9; }
[data-bs-theme="dark"] .st-faq-item[open] .st-faq-question { color: #93c5fd; }
[data-bs-theme="dark"] .st-faq-icon { background: #0f172a; color: #93c5fd; }
[data-bs-theme="dark"] .st-faq-answer { color: #cbd5e1; border-top-color: #334155; }

/* Navbar CTAs */
[data-bs-theme="dark"] .st-nav-cta-signin { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-bs-theme="dark"] .st-nav-cta-signin:hover { background: rgba(37, 99, 235, .15); border-color: #93c5fd; color: #93c5fd; }
[data-bs-theme="dark"] .st-nav-cta-register { background: #2563EB; border-color: #2563EB; }
[data-bs-theme="dark"] .st-nav-cta-register:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* Footer link-button */
[data-bs-theme="dark"] .st-footer-link-btn { color: #94a3b8; }
[data-bs-theme="dark"] .st-footer-link-btn:hover { color: #fff; }

/* Auth pages */
[data-bs-theme="dark"] .st-auth-page { background: linear-gradient(180deg, #1e293b 0%, #0f172a 35%, #0f172a 100%); }
[data-bs-theme="dark"] .st-auth-card { background: #1e293b; border-color: #334155; box-shadow: 0 12px 36px -12px rgba(0,0,0,.6); }
[data-bs-theme="dark"] .st-auth-card-header h1 { color: #f1f5f9; }
[data-bs-theme="dark"] .st-auth-card-header p { color: #94a3b8; }
[data-bs-theme="dark"] .st-auth-form label { color: #e2e8f0; }
[data-bs-theme="dark"] .st-auth-form .form-control { background: #0f172a; border-color: #334155; color: #e2e8f0; }
[data-bs-theme="dark"] .st-auth-form .form-control:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(147, 197, 253, .2); }
[data-bs-theme="dark"] .st-auth-form .form-control[readonly] { background: #1e293b; color: #94a3b8; }
[data-bs-theme="dark"] .st-auth-help { color: #94a3b8; }
[data-bs-theme="dark"] .st-auth-label-link { color: #93c5fd; }
[data-bs-theme="dark"] .st-auth-pw-toggle { color: #94a3b8; }
[data-bs-theme="dark"] .st-auth-pw-toggle:hover { color: #93c5fd; background: rgba(147, 197, 253, .1); }
[data-bs-theme="dark"] .st-auth-footer { color: #94a3b8; border-top-color: #334155; }
[data-bs-theme="dark"] .st-auth-footer a { color: #93c5fd; }
[data-bs-theme="dark"] .st-auth-alert--error { background: rgba(220, 38, 38, .15); border-color: rgba(220, 38, 38, .35); color: #fca5a5; }
[data-bs-theme="dark"] .st-auth-alert--info  { background: rgba(37, 99, 235, .15); border-color: rgba(37, 99, 235, .35); color: #93c5fd; }

/* Search page */
[data-bs-theme="dark"] .st-search-query { color: #93c5fd; }
[data-bs-theme="dark"] .st-search-form .input-group { background: #1e293b; border-color: #334155; }
[data-bs-theme="dark"] .st-search-form .input-group:focus-within { border-color: #93c5fd; }
[data-bs-theme="dark"] .st-search-form .form-control { color: #e2e8f0; }
[data-bs-theme="dark"] .st-search-form .form-control::placeholder { color: #64748b; }
[data-bs-theme="dark"] .st-search-form .input-group-text { color: #94a3b8; }

[data-bs-theme="dark"] .st-search-filters { background: #0f172a; border-bottom-color: #1e293b; }
[data-bs-theme="dark"] .st-search-chip { background: #1e293b; border-color: #334155; color: #cbd5e1; }
[data-bs-theme="dark"] .st-search-chip:hover { background: rgba(37, 99, 235, .18); border-color: #93c5fd; color: #93c5fd; }
[data-bs-theme="dark"] .st-search-chip-count { background: rgba(255, 255, 255, .08); }

[data-bs-theme="dark"] .st-search-empty-icon { background: rgba(37, 99, 235, .18); color: #93c5fd; }
[data-bs-theme="dark"] .st-search-empty-title { color: #f1f5f9; }
[data-bs-theme="dark"] .st-search-empty-text { color: #94a3b8; }

[data-bs-theme="dark"] .st-popular-chips--light .st-popular-chips-label { color: #94a3b8; }
[data-bs-theme="dark"] .st-popular-chips--light .st-popular-chip { background: #1e293b; border-color: #334155; color: #cbd5e1; }
[data-bs-theme="dark"] .st-popular-chips--light .st-popular-chip:hover { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* Tool page: about + prose + related row */
[data-bs-theme="dark"] .st-tool-about { border-top-color: #1e293b; }
[data-bs-theme="dark"] .st-tool-about-head h2 { color: #f1f5f9; }
[data-bs-theme="dark"] .st-tool-about-body { background: #0f172a; border-color: #1e293b; }
[data-bs-theme="dark"] .st-prose { color: #e2e8f0; }
[data-bs-theme="dark"] .st-prose h2,
[data-bs-theme="dark"] .st-prose h3,
[data-bs-theme="dark"] .st-prose h4 { color: #f1f5f9; }
[data-bs-theme="dark"] .st-prose a { color: #93c5fd; }
[data-bs-theme="dark"] .st-prose a:hover { color: #bfdbfe; }
[data-bs-theme="dark"] .st-prose code,
[data-bs-theme="dark"] .st-prose pre { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-bs-theme="dark"] .st-prose blockquote { color: #94a3b8; }
[data-bs-theme="dark"] .st-prose img { border-color: #334155; }
[data-bs-theme="dark"] .st-prose th,
[data-bs-theme="dark"] .st-prose td { border-color: #334155; }
[data-bs-theme="dark"] .st-prose th { background: #1e293b; }
[data-bs-theme="dark"] .st-prose hr { border-top-color: #334155; }
[data-bs-theme="dark"] .st-related-section { border-top-color: #1e293b; }

[data-bs-theme="dark"] .st-seo-block { background: #0f172a; }
[data-bs-theme="dark"] .st-seo-title { color: #f1f5f9; }
[data-bs-theme="dark"] .st-seo-inner p { color: #94a3b8; }
[data-bs-theme="dark"] .st-seo-inner a { color: #93c5fd; }

/* === Theme toggle button === */
.theme-toggle {
    background: none;
    border: 1px solid currentColor;
    color: inherit;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
}

.theme-toggle:hover { opacity: 1; }
.theme-toggle .bi-sun-fill, .theme-toggle .bi-moon-stars-fill, .theme-toggle .bi-circle-half { font-size: 1rem; }
.theme-toggle [data-theme-mode] { display: none; }
[data-theme="light"] .theme-toggle [data-theme-mode="light"] { display: inline-block; }
[data-theme="dark"]  .theme-toggle [data-theme-mode="dark"]  { display: inline-block; }
[data-theme="auto"]  .theme-toggle [data-theme-mode="auto"]  { display: inline-block; }
