/**
 * Purifi Terminal Dynamic Theme Synchronization Stylesheet
 * 
 * Provides CSP-compliant light mode and dynamic palette coordination across
 * the parent Terminal chrome (left rail, header, bottom command bar, inputs, and tabs)
 * in harmony with the Purifi Assistant and Fund Compare workspaces.
 * 
 * Loaded as an external stylesheet from \x27self\x27 to satisfy strict Content Security Policy.
 */

:root {
  --purifi-custom-bg: #f8f9fa;
  --purifi-custom-card: #ffffff;
  --purifi-custom-text: #111827;
  --purifi-custom-muted: #4b5563;
  --purifi-custom-border: rgba(0, 0, 0, 0.12);
  --purifi-custom-accent: #3b82f6;
}

/* ==========================================================================
   14 Curated Palettes (Attribute-based matching for robust CSP compliance)
   ========================================================================== */

/* 1. Warm Cream (#FFFDD0) */
html[data-theme="light"][data-palette="FFFDD0"],
html[data-theme="light"][data-palette="#FFFDD0"],
html[data-theme="light"][data-palette="warm-cream"],
body[data-theme="light"][data-palette="FFFDD0"] {
  --purifi-custom-bg: #FFFDD0 !important;
  --purifi-custom-card: #FFFDE8 !important;
  --purifi-custom-text: #1c1917 !important;
  --purifi-custom-muted: #57534e !important;
  --purifi-custom-border: rgba(161, 98, 7, 0.18) !important;
  --purifi-custom-accent: #ca8a04 !important;
}

/* 2. Off-White / Light Gray (#F8F9FA) */
html[data-theme="light"][data-palette="F8F9FA"],
html[data-theme="light"][data-palette="#F8F9FA"],
html[data-theme="light"][data-palette="off-white"],
body[data-theme="light"][data-palette="F8F9FA"] {
  --purifi-custom-bg: #F8F9FA !important;
  --purifi-custom-card: #FFFFFF !important;
  --purifi-custom-text: #111827 !important;
  --purifi-custom-muted: #4b5563 !important;
  --purifi-custom-border: rgba(0, 0, 0, 0.12) !important;
  --purifi-custom-accent: #3b82f6 !important;
}

/* 3. Platinum (#E5E5E5) */
html[data-theme="light"][data-palette="E5E5E5"],
html[data-theme="light"][data-palette="#E5E5E5"],
html[data-theme="light"][data-palette="platinum"],
body[data-theme="light"][data-palette="E5E5E5"] {
  --purifi-custom-bg: #E5E5E5 !important;
  --purifi-custom-card: #EEEEEE !important;
  --purifi-custom-text: #111827 !important;
  --purifi-custom-muted: #4b5563 !important;
  --purifi-custom-border: rgba(0, 0, 0, 0.14) !important;
  --purifi-custom-accent: #6366f1 !important;
}

/* 4. Cool Gray (#F0F2F5) */
html[data-theme="light"][data-palette="F0F2F5"],
html[data-theme="light"][data-palette="#F0F2F5"],
html[data-theme="light"][data-palette="cool-gray"],
body[data-theme="light"][data-palette="F0F2F5"] {
  --purifi-custom-bg: #F0F2F5 !important;
  --purifi-custom-card: #FFFFFF !important;
  --purifi-custom-text: #0f172a !important;
  --purifi-custom-muted: #475569 !important;
  --purifi-custom-border: rgba(15, 23, 42, 0.12) !important;
  --purifi-custom-accent: #0ea5e9 !important;
}

/* 5. Ice Blue (#F0F8FF) */
html[data-theme="light"][data-palette="F0F8FF"],
html[data-theme="light"][data-palette="#F0F8FF"],
html[data-theme="light"][data-palette="ice-blue"],
body[data-theme="light"][data-palette="F0F8FF"] {
  --purifi-custom-bg: #F0F8FF !important;
  --purifi-custom-card: #FFFFFF !important;
  --purifi-custom-text: #0c2340 !important;
  --purifi-custom-muted: #334155 !important;
  --purifi-custom-border: rgba(59, 130, 246, 0.18) !important;
  --purifi-custom-accent: #0284c7 !important;
}

/* 6. Pale Denim (#E6ECF5) */
html[data-theme="light"][data-palette="E6ECF5"],
html[data-theme="light"][data-palette="#E6ECF5"],
html[data-theme="light"][data-palette="pale-denim"],
body[data-theme="light"][data-palette="E6ECF5"] {
  --purifi-custom-bg: #E6ECF5 !important;
  --purifi-custom-card: #F1F5F9 !important;
  --purifi-custom-text: #0f172a !important;
  --purifi-custom-muted: #334155 !important;
  --purifi-custom-border: rgba(71, 85, 105, 0.2) !important;
  --purifi-custom-accent: #1e40af !important;
}

/* 7. Sky Tint (#E0F2FE) */
html[data-theme="light"][data-palette="E0F2FE"],
html[data-theme="light"][data-palette="#E0F2FE"],
html[data-theme="light"][data-palette="sky-tint"],
body[data-theme="light"][data-palette="E0F2FE"] {
  --purifi-custom-bg: #E0F2FE !important;
  --purifi-custom-card: #F0F9FF !important;
  --purifi-custom-text: #072c4f !important;
  --purifi-custom-muted: #1e3a5f !important;
  --purifi-custom-border: rgba(2, 132, 199, 0.22) !important;
  --purifi-custom-accent: #0ea5e9 !important;
}

/* 8. Ivory / Cream (#FAF9F6) */
html[data-theme="light"][data-palette="FAF9F6"],
html[data-theme="light"][data-palette="#FAF9F6"],
html[data-theme="light"][data-palette="ivory-cream"],
body[data-theme="light"][data-palette="FAF9F6"] {
  --purifi-custom-bg: #FAF9F6 !important;
  --purifi-custom-card: #FFFFFF !important;
  --purifi-custom-text: #1c1917 !important;
  --purifi-custom-muted: #57534e !important;
  --purifi-custom-border: rgba(120, 113, 108, 0.16) !important;
  --purifi-custom-accent: #b45309 !important;
}

/* 9. Soft Sand (#F4F1EA) */
html[data-theme="light"][data-palette="F4F1EA"],
html[data-theme="light"][data-palette="#F4F1EA"],
html[data-theme="light"][data-palette="soft-sand"],
body[data-theme="light"][data-palette="F4F1EA"] {
  --purifi-custom-bg: #F4F1EA !important;
  --purifi-custom-card: #FAF8F5 !important;
  --purifi-custom-text: #1c1917 !important;
  --purifi-custom-muted: #44403c !important;
  --purifi-custom-border: rgba(120, 113, 108, 0.18) !important;
  --purifi-custom-accent: #a16207 !important;
}

/* 10. Classic Beige / Ecru (#F5F5DC) */
html[data-theme="light"][data-palette="F5F5DC"],
html[data-theme="light"][data-palette="#F5F5DC"],
html[data-theme="light"][data-palette="classic-beige"],
html[data-theme="light"][data-palette="ecru"],
body[data-theme="light"][data-palette="F5F5DC"] {
  --purifi-custom-bg: #F5F5DC !important;
  --purifi-custom-card: #FAF8F0 !important;
  --purifi-custom-text: #1c1917 !important;
  --purifi-custom-muted: #44403c !important;
  --purifi-custom-border: rgba(120, 113, 108, 0.18) !important;
  --purifi-custom-accent: #92400e !important;
}

/* 11. Mint Cream (#F5FFFA) */
html[data-theme="light"][data-palette="F5FFFA"],
html[data-theme="light"][data-palette="#F5FFFA"],
html[data-theme="light"][data-palette="mint-cream"],
body[data-theme="light"][data-palette="F5FFFA"] {
  --purifi-custom-bg: #F5FFFA !important;
  --purifi-custom-card: #FFFFFF !important;
  --purifi-custom-text: #064e3b !important;
  --purifi-custom-muted: #334155 !important;
  --purifi-custom-border: rgba(16, 185, 129, 0.2) !important;
  --purifi-custom-accent: #059669 !important;
}

/* 12. Sage Mist (#E8EFE9) */
html[data-theme="light"][data-palette="E8EFE9"],
html[data-theme="light"][data-palette="#E8EFE9"],
html[data-theme="light"][data-palette="sage-mist"],
body[data-theme="light"][data-palette="E8EFE9"] {
  --purifi-custom-bg: #E8EFE9 !important;
  --purifi-custom-card: #F3F7F4 !important;
  --purifi-custom-text: #0f2415 !important;
  --purifi-custom-muted: #3f5244 !important;
  --purifi-custom-border: rgba(22, 101, 52, 0.22) !important;
  --purifi-custom-accent: #166534 !important;
}

/* 13. Lavender Blush (#FDF2F4) */
html[data-theme="light"][data-palette="FDF2F4"],
html[data-theme="light"][data-palette="#FDF2F4"],
html[data-theme="light"][data-palette="lavender-blush"],
body[data-theme="light"][data-palette="FDF2F4"] {
  --purifi-custom-bg: #FDF2F4 !important;
  --purifi-custom-card: #FFFFFF !important;
  --purifi-custom-text: #1f1e24 !important;
  --purifi-custom-muted: #4b5563 !important;
  --purifi-custom-border: rgba(244, 114, 182, 0.22) !important;
  --purifi-custom-accent: #db2777 !important;
}

/* 14. Classic White (#FFFFFF) */
html[data-theme="light"][data-palette="FFFFFF"],
html[data-theme="light"][data-palette="#FFFFFF"],
html[data-theme="light"][data-palette="classic-white"],
body[data-theme="light"][data-palette="FFFFFF"] {
  --purifi-custom-bg: #FFFFFF !important;
  --purifi-custom-card: #FFFFFF !important;
  --purifi-custom-text: #1a1a1a !important;
  --purifi-custom-muted: #5b5b5b !important;
  --purifi-custom-border: rgba(0, 0, 0, 0.12) !important;
  --purifi-custom-accent: #2563eb !important;
}

/* ==========================================================================
   Base Light Theme CSS Variables & Structural Reskinning
   ========================================================================== */

html[data-theme="light"] {
  --bg: var(--purifi-custom-bg, #f8f9fa) !important;
  --bg0: var(--purifi-custom-bg, #f8f9fa) !important;
  --bg1: var(--purifi-custom-bg, #f8f9fa) !important;
  --panel: var(--purifi-custom-card, #ffffff) !important;
  --panel2: var(--purifi-custom-card, #ffffff) !important;
  --text: var(--purifi-custom-text, #111827) !important;
  --muted: var(--purifi-custom-muted, #4b5563) !important;
  --border: var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
  --line: var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
  --accent: var(--purifi-custom-accent, #3b82f6) !important;
  --accent2: var(--purifi-custom-accent, #3b82f6) !important;
}

html[data-theme="light"] body {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
  background-image: none !important;
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] #root,
html[data-theme="light"] .terminalRoot {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

/* Left Rail & Top Header */
html[data-theme="light"] .terminalRoot > header.topBar,
html[data-theme="light"] header.topBar {
  background: var(--purifi-custom-card, #ffffff) !important;
  border-right: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
  border-bottom: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .terminalRoot > header.topBar .status button,
html[data-theme="light"] .terminalRoot > header.topBar .status select {
  color: var(--purifi-custom-text, #111827) !important;
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.15)) !important;
}

html[data-theme="light"] .terminalRoot > header.topBar .status .pill {
  color: var(--purifi-custom-text, #111827) !important;
  background: var(--purifi-custom-card, #ffffff) !important;
  border-color: var(--purifi-custom-border, rgba(0, 0, 0, 0.15)) !important;
}

html[data-theme="light"] .terminalRoot > header.topBar .status .pill.ok {
  color: #059669 !important;
  background: rgba(5, 150, 105, 0.08) !important;
  border-color: rgba(5, 150, 105, 0.25) !important;
}

/* Language selector */
html[data-theme="light"] .terminalRoot > header.topBar .langToggle,
html[data-theme="light"] .langToggle {
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.15)) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

/* Command Prompt Bar */
html[data-theme="light"] footer.cmdBar,
html[data-theme="light"] .cmdBar {
  background: var(--purifi-custom-card, #ffffff) !important;
  border-top: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .cmdInput {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.15)) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .cmdInput::placeholder {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] .prompt {
  color: var(--purifi-custom-accent, #3b82f6) !important;
}

html[data-theme="light"] footer.cmdBar button,
html[data-theme="light"] footer.cmdBar select {
  color: var(--purifi-custom-text, #111827) !important;
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.15)) !important;
}

html[data-theme="light"] footer.cmdBar select option {
  background: var(--purifi-custom-card, #ffffff) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

/* Workspace Frame & Panels */
html[data-theme="light"] .assistantWorkspace,
html[data-theme="light"] .fundCompareWorkspace,
html[data-theme="light"] div[class*="Workspace"],
html[data-theme="light"] div[class*="workspace"],
html[data-theme="light"] .panel {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
}

/* Navigation Tab Bar Outer Container & Collapse Row */
html[data-theme="light"] div:has(> div > .tab-button),
html[data-theme="light"] div:has(> .tab-button),
html[data-theme="light"] .purifi-tab-nav-bar {
  background: var(--purifi-custom-card, #ffffff) !important;
  border-bottom: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] div:has(> div > .tab-button) div,
html[data-theme="light"] .purifi-tab-nav-bar div {
  color: var(--purifi-custom-text, #111827);
}

html[data-theme="light"] div:has(> div > .tab-button) div[style*="uppercase"],
html[data-theme="light"] div:has(> div > .tab-button) div[style*="letterSpacing"],
html[data-theme="light"] div:has(> div > .tab-button) div[style*="letter-spacing"],
html[data-theme="light"] .purifi-tab-nav-bar div[style*="uppercase"] {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

/* Inactive Tab Buttons */
html[data-theme="light"] .tab-button {
  color: var(--purifi-custom-muted, #4b5563) !important;
  background: transparent !important;
  border: 1px solid transparent !important;
}

html[data-theme="light"] .tab-button:hover {
  background: var(--purifi-custom-bg, #f3f4f6) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

/* Active Tab Button */
html[data-theme="light"] .tab-button.active,
html[data-theme="light"] .tab-button[style*="font-weight: 600"],
html[data-theme="light"] .tab-button[style*="fontWeight: 600"],
html[data-theme="light"] .tab-button[style*="font-weight:600"] {
  color: var(--purifi-custom-accent, #3b82f6) !important;
  background: var(--purifi-custom-bg, #f1f5f9) !important;
  border: 1px solid var(--purifi-custom-accent, #3b82f6) !important;
  border-radius: 6px 6px 0 0 !important;
}

/* Ghost buttons & Collapse toggle (☰) */
html[data-theme="light"] button.ghost,
html[data-theme="light"] .ghost {
  color: var(--purifi-custom-text, #111827) !important;
  border-color: var(--purifi-custom-border, rgba(0, 0, 0, 0.15)) !important;
}

html[data-theme="light"] button.ghost:hover,
html[data-theme="light"] .ghost:hover {
  background: var(--purifi-custom-bg, #f1f5f9) !important;
}

/* Terminal Login Page Elements */
html[data-theme="light"] .loginRoot {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .loginGrid {
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] .loginLeft {
  border-right: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .loginRight {
  background: var(--purifi-custom-card, #ffffff) !important;
}

html[data-theme="light"] .wordmark {
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .sub {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] .terminalBrief {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.14)) !important;
  box-shadow: none !important;
}

html[data-theme="light"] .briefKicker {
  color: var(--purifi-custom-accent, #3b82f6) !important;
}

html[data-theme="light"] .briefTitle {
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .briefCopy {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] .briefStats div {
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
}

html[data-theme="light"] .briefStats span {
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .briefStats small {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] .leftBlock {
  border-top: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
}

html[data-theme="light"] .leftTitle {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] .kv {
  border-bottom: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.08)) !important;
}

html[data-theme="light"] .k {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] .v {
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .v.ok {
  color: var(--purifi-custom-accent, #059669) !important;
}

html[data-theme="light"] .notice {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] .terminalModules {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
  border-top: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
}

html[data-theme="light"] .moduleRow {
  border-bottom: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.08)) !important;
}

html[data-theme="light"] .moduleRow:hover {
  background: var(--purifi-custom-card, #ffffff) !important;
}

html[data-theme="light"] .moduleIcon {
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.14)) !important;
  color: var(--purifi-custom-accent, #3b82f6) !important;
}

html[data-theme="light"] .loginRight .card {
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
}

html[data-theme="light"] .loginRight .cardHeader {
  border-bottom: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
}

html[data-theme="light"] .loginRight .cardTitle {
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] .loginRight .cardSubtitle {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] .loginRight .label {
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] .loginRight .input,
html[data-theme="light"] .loginRight .select {
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.16)) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

/* Pricing & Subscription Overlay Light Theme Synchronization */
html[data-theme="light"] #purifi-pricing-overlay .purifi-pricing-backdrop {
  background: rgba(15, 23, 42, 0.45) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-pricing-container {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.15)) !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.12) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-pricing-topbar {
  background: var(--purifi-custom-card, #ffffff) !important;
  border-bottom: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-pricing-brand {
  color: var(--purifi-custom-accent, #0284c7) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-pricing-title {
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-pricing-close {
  background: transparent !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.15)) !important;
  color: var(--purifi-custom-muted, #4b5563) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-pricing-close:hover {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-pricing-back {
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.2)) !important;
  color: var(--purifi-custom-accent, #2563eb) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-checkout-status-panel {
  background: var(--purifi-custom-bg, #f8f9fa) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-checkout-status-card {
  background: var(--purifi-custom-card, #ffffff) !important;
  border: 1px solid var(--purifi-custom-border, rgba(0, 0, 0, 0.12)) !important;
  color: var(--purifi-custom-text, #111827) !important;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-checkout-status-title {
  color: var(--purifi-custom-text, #111827) !important;
}

html[data-theme="light"] #purifi-pricing-overlay .purifi-checkout-status-desc {
  color: var(--purifi-custom-muted, #4b5563) !important;
}
