/**
 * ResolveVia — niche-themes.css
 *
 * F74: Per-niche visual theming — per-niche palette is now emitted as inline
 *      :root / @media-dark / html.rv-dark / html.rv-light custom-property vars
 *      from rv_themes via resolvevia_build_theme_css() (DRIFT-738). No body class.
 * F75: Dark mode — automatic, OS-driven, no JS, no toggle, no stored pref
 * F77: Mobile UX touch enhancements + safe-area-inset + rv-bottom-nav
 *
 * Section 1 — :root platform-neutral fallback variable definitions
 * Section 2 — RETIRED: per-niche light palette now emitted from rv_themes (DRIFT-738/739)
 * Section 3 — Dark mode base surface tokens only (per-niche dark palette now emitted)
 * Section 4 — Component dark mode overrides (cards, forms, tables, nav)
 * Section 5 — Mobile UX touch enhancements (F77)
 * Section 6 — PWA / safe-area / bottom nav overrides (F77)
 * Section 7 — Class-based forced dark/light base surface + component overrides
 *             (html.rv-dark / html.rv-light); per-niche forced-dark palette now emitted
 *
 * Architecture: One file. One codebase. All 17 niches. No per-site files.
 * Per-niche palette is emitted as inline custom-property vars from rv_themes
 * (DRIFT-738), keyed by the active niche. This file carries only the platform-
 * neutral :root fallback, base surface tokens, components, mobile, and PWA rules.
 *
 * WCAG AA ≥4.5:1 verified for --rv-accent-text vs --rv-accent in all niches.
 * 9 of 17 niches achieve AAA (≥7:1).
 *
 * Path: resolvevia-plugin/assets/css/niche-themes.css
 * @package ResolveVia
 *
 * Schema: v2.37.39 / Migration 110 / 101 active tables
 */

/* ============================================================
   SECTION 1 — BASE CSS VARIABLE DEFINITIONS (platform-neutral fallback)
   (DRIFT-755 Phase 0) The platform-neutral accent family that was defined
   in a :root block here (--rv-accent / -dark / -light / -text, --rv-hero-
   gradient, --rv-badge-bg, --rv-surface-tint) is now defined ONCE, with the
   SAME values, in the canonical token layer assets/css/tokens.css, which
   loads before this file on every public surface. Removing the duplicate
   here makes tokens.css the single defining site (canonical single-home)
   while keeping the computed value identical. The active niche's palette is
   still emitted as an inline :root (+ @media-dark / html.rv-*) block from
   rv_themes via resolvevia_build_theme_css() (DRIFT-738), which prints after
   this file and overrides the fallback per-niche. The dark base-surface
   tokens in Section 3 below remain here.
   ============================================================ */

/* ============================================================
   SECTION 2 — RETIRED (per-niche light palette)
   ============================================================ */

/* Per-niche light palette now emitted from rv_themes via resolvevia_build_theme_css() — DRIFT-738/739. */

/* ============================================================
   SECTION 3 — DARK MODE BASE SURFACE TOKENS + PER-NICHE OVERRIDES
   Rule: darkest bg is #0f1117 — NEVER pure #000000
   ============================================================ */

@media (prefers-color-scheme: dark) {

    /* Base surface tokens — applied at :root */
    :root {
        --rv-bg-primary:   #0f1117;
        --rv-bg-surface:   #1a1d27;
        --rv-bg-elevated:  #22263a;
        --rv-text-primary: #e2e8f0;
        --rv-text-secondary: #94a3b8;
        --rv-border-color: #2d3748;
        --rv-shadow:       0 4px 16px rgba(0,0,0,0.4);
    }

    /* Per-niche dark palette now emitted from rv_themes via resolvevia_build_theme_css() — DRIFT-738/739. */

} /* end @media dark — base surface tokens only; per-niche dark palette now emitted from rv_themes (DRIFT-738/739) */

/* ============================================================
   SECTION 4 — COMPONENT DARK MODE OVERRIDES
   Cards, nav, forms, tables, buttons.
   ============================================================ */

@media (prefers-color-scheme: dark) {

    body {
        background-color: var(--rv-bg-primary, #0f1117);
        color: var(--rv-text-primary, #e2e8f0);
    }

    /* Cards */
    .rv-card {
        background: var(--rv-bg-surface, #1a1d27);
        border-color: var(--rv-border-color, #2d3748);
        color: var(--rv-text-primary, #e2e8f0);
    }

    .rv-card__header,
    .rv-card__footer {
        background: var(--rv-bg-elevated, #22263a);
        border-color: var(--rv-border-color, #2d3748);
    }

    /* Navigation */
    .rv-site-header,
    .rv-nav,
    .rv-sidebar-nav {
        background: var(--rv-bg-surface, #1a1d27);
        border-color: var(--rv-border-color, #2d3748);
    }

    .rv-nav__link,
    .rv-sidebar-nav__link {
        color: var(--rv-text-secondary, #94a3b8);
    }

    .rv-nav__link:hover,
    .rv-nav__link--active,
    .rv-sidebar-nav__link:hover,
    .rv-sidebar-nav__link--active {
        color: var(--rv-accent, #38bdf8);
        background: var(--rv-bg-elevated, #22263a);
    }

    /* Forms */
    .rv-form-input,
    .rv-form-select,
    .rv-form-textarea {
        background: var(--rv-bg-elevated, #22263a);
        border-color: var(--rv-border-color, #2d3748);
        color: var(--rv-text-primary, #e2e8f0);
    }

    .rv-form-input:focus,
    .rv-form-select:focus,
    .rv-form-textarea:focus {
        border-color: var(--rv-accent, #38bdf8);
        box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
    }

    .rv-form-label {
        color: var(--rv-text-secondary, #94a3b8);
    }

    /* Tables */
    .rv-table {
        border-color: var(--rv-border-color, #2d3748);
    }

    .rv-table th {
        background: var(--rv-bg-elevated, #22263a);
        color: var(--rv-text-secondary, #94a3b8);
        border-color: var(--rv-border-color, #2d3748);
    }

    .rv-table td {
        border-color: var(--rv-border-color, #2d3748);
        color: var(--rv-text-primary, #e2e8f0);
    }

    .rv-table tr:nth-child(even) td {
        background: var(--rv-bg-elevated, #22263a);
    }

    /* Stat cards */
    .rv-stat-card {
        background: var(--rv-bg-surface, #1a1d27);
        border-color: var(--rv-border-color, #2d3748);
    }

    .rv-stat-card__label {
        color: var(--rv-text-secondary, #94a3b8);
    }

    .rv-stat-card__value {
        color: var(--rv-text-primary, #e2e8f0);
    }

    /* Badges */
    .rv-badge {
        background: var(--rv-badge-bg, #1e293b);
        color: var(--rv-accent, #94a3b8);
    }

    /* Buttons — primary uses accent */
    .rv-btn--primary {
        background-color: var(--rv-accent);
        color: var(--rv-accent-text);
        border-color: var(--rv-accent);
    }

    .rv-btn--primary:hover {
        background-color: var(--rv-accent-dark);
        border-color: var(--rv-accent-dark);
    }

    /* Dividers */
    hr,
    .rv-divider {
        border-color: var(--rv-border-color, #2d3748);
    }

    /* Footer */
    .rv-footer,
    .rv-partial-footer {
        background: var(--rv-bg-elevated, #22263a);
        border-top-color: var(--rv-border-color, #2d3748);
        color: var(--rv-text-secondary, #94a3b8);
    }

    /* Notifications dropdown */
    .rv-notification-bell__dropdown {
        background: var(--rv-bg-surface, #1a1d27);
        border-color: var(--rv-border-color, #2d3748);
    }

    /* Live call widget ring pulse override */
    .rv-live-call-widget--ringing .rv-live-call-widget__ring {
        animation: rv-ring-pulse-dark 1.5s infinite;
    }

} /* end @media dark — components */

/* ============================================================
   SECTION 5 — MOBILE UX TOUCH ENHANCEMENTS (F77)
   44px touch targets, iOS auto-zoom prevention, smooth scroll.
   ============================================================ */

/* 44px touch targets on all interactive elements (F77-01) */
.rv-btn,
.rv-nav__link,
.rv-sidebar-nav__link,
.rv-notification-bell__btn,
.rv-nav__toggle {
    min-height: 44px;
    min-width: 44px;
}

/* Inline text links remain display: inline */
p a,
.rv-table a,
.rv-card__body a {
    display: inline;
    min-height: unset;
    min-width: unset;
}

/* iOS tap highlight — remove default blue */
a, button, [role="button"] {
    -webkit-tap-highlight-color: transparent;
}

/* iOS auto-zoom prevention (F77-01) — font-size 16px on all inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
select,
textarea {
    font-size: 16px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Lead cards at 768px — F77 sizing (F77-01) */
@media (max-width: 768px) {
    .rv-lead-card {
        padding: 16px;
        min-height: 80px;
    }

    /* Notification dropdown full-screen on mobile */
    .rv-notification-bell__dropdown {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        z-index: 999;
    }

    /* Spending cap bar header stack */
    .rv-cap-bar__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* Stat cards single column at 480px (F77-01) */
@media (max-width: 480px) {
    .rv-stats-row,
    .rv-kpi-row {
        grid-template-columns: 1fr;
    }

    /* Full-width CTA buttons */
    .rv-btn--large {
        width: 100%;
        text-align: center;
    }
}

/* ============================================================
   SECTION 6 — PWA / SAFE-AREA / BOTTOM NAV OVERRIDES (F77)
   ============================================================ */

/* 52px claim button for marketplace — full-width, tall touch target */
.rv-lead-card .rv-claim-btn {
    width: 100%;
    height: 52px;
}

/* Site header — respect notch / status bar (F77-02) */
.rv-site-header {
    padding-top: max(16px, env(safe-area-inset-top));
}

/* Footer and live call widget — respect home indicator (F77-02) */
.rv-site-footer,
.rv-partial-footer,
.rv-live-call-widget {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* PWA install banner — above live call widget (z-index hierarchy) */
.rv-pwa-install-banner {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--rv-bg-surface, #1a1d27);
    border-top: 1px solid var(--rv-border-color, #2d3748);
    z-index: 1001; /* Above live call widget at z-index: 1000 */
    box-shadow: var(--rv-shadow, 0 -4px 16px rgba(0,0,0,0.15));
}

.rv-pwa-install-banner--visible {
    display: flex;
}

.rv-pwa-install-banner__inner {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.rv-pwa-install-banner__text {
    flex: 1;
    min-width: 0;
}

.rv-pwa-install-banner__title {
    display: block;
    font-size: 14px;
    font-weight: var(--rv-weight-semibold);
    color: var(--rv-text-primary, #111827);
}

.rv-pwa-install-banner__subtitle {
    display: block;
    font-size: 12px;
    color: var(--rv-text-secondary, #6b7280);
}

.rv-pwa-install-banner__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Bottom navigation bar skeleton (F77-03) */
.rv-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 64px;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--rv-bg-surface, #ffffff);
    border-top: 1px solid var(--rv-border-color, #e5e7eb);
    display: none; /* Enabled when JS adds body.rv-has-bottom-nav */
}

/* Body padding when bottom nav is present */
body.rv-has-bottom-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

body.rv-has-bottom-nav .rv-bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
}

/* Dark-mode ring pulse animation for live call widget (F77-03) */
@keyframes rv-ring-pulse-dark {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
    50%       { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
}

/* ============================================================
   SECTION 7 — CLASS-BASED DARK/LIGHT MODE OVERRIDES
   html.rv-dark = user forced dark (overrides OS preference)
   html.rv-light = user forced light (overrides OS dark preference)
   Applied by JS display mode toggle before first paint.
   Mirrors Section 3 + Section 4 media query rules as class selectors.
   ============================================================ */

/* ── Forced dark mode ── */
html.rv-dark {

    /* Base surface tokens */
    --rv-bg-primary:     #0f1117;
    --rv-bg-surface:     #1a1d27;
    --rv-bg-elevated:    #22263a;
    --rv-text-primary:   #e2e8f0;
    --rv-text-secondary: #94a3b8;
    --rv-border-color:   #2d3748;
    --rv-shadow:         0 4px 16px rgba(0,0,0,0.4);

    color-scheme: dark;
}

html.rv-dark body {
    background-color: var(--rv-bg-primary, #0f1117);
    color: var(--rv-text-primary, #e2e8f0);
}

/* Per-niche forced-dark palette now emitted from rv_themes via resolvevia_build_theme_css() — DRIFT-738/739. */

/* Component overrides — forced dark (mirrors Section 4) */
html.rv-dark .rv-card {
    background: var(--rv-bg-surface, #1a1d27);
    border-color: var(--rv-border-color, #2d3748);
    color: var(--rv-text-primary, #e2e8f0);
}

html.rv-dark .rv-form-input,
html.rv-dark .rv-form-select,
html.rv-dark .rv-form-textarea {
    background: var(--rv-bg-elevated, #22263a);
    border-color: var(--rv-border-color, #2d3748);
    color: var(--rv-text-primary, #e2e8f0);
}

html.rv-dark .rv-table th {
    background: var(--rv-bg-elevated, #22263a);
    color: var(--rv-text-secondary, #94a3b8);
    border-bottom-color: var(--rv-border-color, #2d3748);
}

html.rv-dark .rv-table td {
    border-bottom-color: var(--rv-border-color, #2d3748);
    color: var(--rv-text-primary, #e2e8f0);
}

html.rv-dark .rv-lang-dropdown,
html.rv-dark .rv-display-mode-menu {
    background: var(--rv-bg-elevated, #22263a);
    border-color: var(--rv-border-color, #2d3748);
}

html.rv-dark .rv-lang-dropdown__item,
html.rv-dark .rv-display-mode-menu__item {
    color: var(--rv-text-primary, #e2e8f0);
}

html.rv-dark .rv-lang-dropdown__item:hover,
html.rv-dark .rv-display-mode-menu__item:hover {
    background: rgba(255,255,255,0.06);
}

/* ── Forced light mode — overrides OS dark preference ── */
html.rv-light {
    --rv-bg-primary:     #ffffff;
    --rv-bg-surface:     #f9fafb;
    --rv-bg-elevated:    #f3f4f6;
    --rv-text-primary:   #111827;
    --rv-text-secondary: #6b7280;
    --rv-border-color:   #e5e7eb;
    --rv-shadow:         0 1px 4px rgba(0,0,0,0.08);

    color-scheme: light;
}

html.rv-light body {
    background-color: #ffffff;
    color: #111827;
}

/* Undo any dark-mode component overrides when light is forced */
html.rv-light .rv-card {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #111827;
}

html.rv-light .rv-form-input,
html.rv-light .rv-form-select,
html.rv-light .rv-form-textarea {
    background: #ffffff;
    border-color: #d1d5db;
    color: #111827;
}

html.rv-light .rv-table th {
    background: #f9fafb;
    color: #374151;
    border-bottom-color: #e5e7eb;
}

html.rv-light .rv-table td {
    border-bottom-color: #e5e7eb;
    color: #111827;
}
