/**
 * ALGORIZMS™ UNIVERSAL THEME CASCADE ENGINE ("THE BIGGER CLASS") [v1.0]
 * Ratified by MR. Vairus | Architected by Pixel (@pixel) & CTO Tiko (@Tiko)
 * 
 * Purpose:
 * Solves the partial theme leak where certain cards, words, or product modules
 * remain obsidian/dark or have white text on light backgrounds.
 * Implements a master scope cascade that dynamically synchronizes all 11 Products
 * and the entire platform in a single browser repaint cycle (<16ms).
 */

/* ==========================================================================
   1. MASTER LIGHT MODE: ALABASTER PHARAONIC & LIQUID BLING
   Triggered by: [data-theme="marble-bling"], [data-theme="light"],
                 html.marble-bling, html.light, .theme-alabaster-pharaonic
   ========================================================================== */

[data-theme="marble-bling"],
[data-theme="light"],
html.marble-bling,
html.light,
.theme-alabaster-pharaonic {
  color-scheme: light;

  /* ── 1. Master Design System Tokens (Alabaster Palette) ─────────────────── */
  --bg-dark: #F4F1EA;
  --bg-surface: #FFFFFF;
  --bg-card: rgba(255, 252, 247, 0.94);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-glass: rgba(244, 241, 234, 0.88);
  --bg-surface-elevated: #FFFFFF;

  --text-main: #0D0B0A;
  --text-primary: #0D0B0A;
  --text-secondary: #27272A;
  --text-muted: #52525B;
  --text-dim: #71717A;
  --text-gold: #D97706;

  --border-subtle: rgba(217, 119, 6, 0.20);
  --border-medium: rgba(20, 18, 16, 0.14);
  --border-highlight: rgba(245, 158, 11, 0.55);

  --shadow-sm: 0 2px 10px rgba(20, 18, 16, 0.05);
  --shadow-md: 0 10px 30px rgba(180, 120, 20, 0.10);
  --shadow-lg: 0 20px 48px rgba(180, 120, 20, 0.14);
  --shadow-gold-glow: 0 0 35px rgba(245, 158, 11, 0.32);

  /* ── 2. Subsystem & Product Variable Aliases ────────────────────────────── */
  /* SaaS Growth Simulator */
  --sim-bg: #F4F1EA !important;
  --sim-surface: #FFFFFF !important;
  --sim-surface-hover: #F8F6F0 !important;
  --sim-surface-active: #EFECE4 !important;
  --sim-border: rgba(217, 119, 6, 0.22) !important;
  --sim-border-gold: rgba(245, 158, 11, 0.45) !important;
  --sim-border-active: rgba(245, 158, 11, 0.75) !important;
  --sim-text-main: #0D0B0A !important;
  --sim-text-muted: #52525B !important;
  --sim-text-dim: #71717A !important;

  /* Brand Harmony Analyzer (BHA) */
  --bha-bg: #F4F1EA !important;
  --bha-card: #FFFFFF !important;
  --bha-card-bg: rgba(255, 252, 247, 0.94) !important;
  --bha-text: #0D0B0A !important;
  --bha-border: rgba(217, 119, 6, 0.22) !important;
  --bha-surface: #FFFFFF !important;

  /* Radars (PropTech, Pharma, Titans, Market Makers, Leads, EGX) */
  --radar-bg: #F4F1EA !important;
  --radar-card: #FFFFFF !important;
  --radar-surface: #FFFFFF !important;
  --radar-text: #0D0B0A !important;
  --card-bg: rgba(255, 252, 247, 0.94) !important;
  --panel-bg: rgba(255, 252, 247, 0.94) !important;
  --item-bg: #FFFFFF !important;

  /* 3D Studios & Builders */
  --studio-bg: #F4F1EA !important;
  --studio-card: #FFFFFF !important;
  --studio-text: #0D0B0A !important;
  --studio-border: rgba(217, 119, 6, 0.22) !important;
}

/* ── 3. The "Bigger Class" Global Surface Cascade ────────────────────────── */

/* Body Surface Background */
[data-theme="marble-bling"] body,
[data-theme="light"] body,
html.marble-bling body,
html.light body,
body.theme-alabaster-pharaonic {
  background-color: #F4F1EA !important;
  color: #0D0B0A !important;
}

/* All Cards, Panels, Drawers, Modules & Containers */
[data-theme="marble-bling"] .card,
[data-theme="marble-bling"] [class*="-card"],
[data-theme="marble-bling"] [class*="card-"],
[data-theme="marble-bling"] .panel,
[data-theme="marble-bling"] [class*="-panel"],
[data-theme="marble-bling"] .box,
[data-theme="marble-bling"] [class*="-box"],
[data-theme="marble-bling"] .modal-content,
[data-theme="marble-bling"] [class*="-modal"],
[data-theme="marble-bling"] .drawer,
[data-theme="marble-bling"] [class*="-drawer"],
[data-theme="marble-bling"] .telemetry-block,
[data-theme="marble-bling"] .hud-container,
[data-theme="marble-bling"] .stage-container,
[data-theme="marble-bling"] .dashboard-section,
html.marble-bling .card,
html.marble-bling [class*="-card"],
html.marble-bling [class*="card-"],
html.marble-bling .panel,
html.marble-bling [class*="-panel"],
html.marble-bling .box,
html.marble-bling [class*="-box"],
html.marble-bling .modal-content,
html.marble-bling [class*="-modal"],
html.marble-bling .drawer,
html.marble-bling [class*="-drawer"],
html.marble-bling .telemetry-block,
html.marble-bling .hud-container,
html.marble-bling .stage-container,
html.marble-bling .dashboard-section {
  background: rgba(255, 252, 247, 0.94) !important;
  border-color: rgba(217, 119, 6, 0.22) !important;
  color: #0D0B0A !important;
  box-shadow: 0 8px 32px rgba(180, 120, 20, 0.08) !important;
}

/* ── 4. The "Bigger Class" Typography & Text Inversion ───────────────────── */

/* Headings & Titles (No More White Text on Light Cards!) */
[data-theme="marble-bling"] h1:not(.gold-gradient-text):not(.keep-bright),
[data-theme="marble-bling"] h2:not(.gold-gradient-text):not(.keep-bright),
[data-theme="marble-bling"] h3:not(.gold-gradient-text):not(.keep-bright),
[data-theme="marble-bling"] h4:not(.gold-gradient-text):not(.keep-bright),
[data-theme="marble-bling"] h5:not(.gold-gradient-text):not(.keep-bright),
[data-theme="marble-bling"] h6:not(.gold-gradient-text):not(.keep-bright),
[data-theme="marble-bling"] [class*="title"]:not(.gold-gradient-text):not(.accent-gold):not(.keep-bright):not([class*="gold"]):not([class*="badge"]),
[data-theme="marble-bling"] [class*="heading"]:not(.gold-gradient-text):not(.keep-bright),
html.marble-bling h1:not(.gold-gradient-text):not(.keep-bright),
html.marble-bling h2:not(.gold-gradient-text):not(.keep-bright),
html.marble-bling h3:not(.gold-gradient-text):not(.keep-bright),
html.marble-bling h4:not(.gold-gradient-text):not(.keep-bright),
html.marble-bling h5:not(.gold-gradient-text):not(.keep-bright),
html.marble-bling h6:not(.gold-gradient-text):not(.keep-bright),
html.marble-bling [class*="title"]:not(.gold-gradient-text):not(.accent-gold):not(.keep-bright):not([class*="gold"]):not([class*="badge"]),
html.marble-bling [class*="heading"]:not(.gold-gradient-text):not(.keep-bright) {
  color: #0D0B0A !important;
  -webkit-text-fill-color: initial;
  text-shadow: none !important;
}

/* Paragraphs, List Items, and Body Copy */
[data-theme="marble-bling"] p:not(.gold-gradient-text):not(.keep-bright):not([class*="gold"]):not([class*="badge"]),
[data-theme="marble-bling"] li:not(.keep-bright),
[data-theme="marble-bling"] label:not(.keep-bright),
[data-theme="marble-bling"] dt,
[data-theme="marble-bling"] dd,
html.marble-bling p:not(.gold-gradient-text):not(.keep-bright):not([class*="gold"]):not([class*="badge"]),
html.marble-bling li:not(.keep-bright),
html.marble-bling label:not(.keep-bright),
html.marble-bling dt,
html.marble-bling dd {
  color: #27272A !important;
}

/* Secondary & Muted Descriptions */
[data-theme="marble-bling"] [class*="subtitle"],
[data-theme="marble-bling"] [class*="desc"],
[data-theme="marble-bling"] [class*="muted"],
[data-theme="marble-bling"] [class*="meta"],
[data-theme="marble-bling"] [class*="caption"],
html.marble-bling [class*="subtitle"],
html.marble-bling [class*="desc"],
html.marble-bling [class*="muted"],
html.marble-bling [class*="meta"],
html.marble-bling [class*="caption"] {
  color: #52525B !important;
}

/* ── 5. Tables, Datagrids & Scroll Wrappers ───────────────────────────────── */
[data-theme="marble-bling"] .table-scroll-wrapper,
[data-theme="marble-bling"] table,
[data-theme="marble-bling"] thead,
[data-theme="marble-bling"] tbody,
[data-theme="marble-bling"] tr,
[data-theme="marble-bling"] th,
[data-theme="marble-bling"] td,
html.marble-bling .table-scroll-wrapper,
html.marble-bling table,
html.marble-bling thead,
html.marble-bling tbody,
html.marble-bling tr,
html.marble-bling th,
html.marble-bling td {
  background-color: rgba(255, 255, 255, 0.96) !important;
  color: #0D0B0A !important;
  border-color: rgba(217, 119, 6, 0.18) !important;
}

[data-theme="marble-bling"] th,
html.marble-bling th {
  background-color: rgba(244, 241, 234, 0.98) !important;
  color: #0D0B0A !important;
  font-weight: 800;
}

/* ── 6. Form Controls & Interactive Inputs ─────────────────────────────────── */
[data-theme="marble-bling"] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
[data-theme="marble-bling"] select,
[data-theme="marble-bling"] textarea,
html.marble-bling input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html.marble-bling select,
html.marble-bling textarea {
  background-color: #FFFFFF !important;
  color: #0D0B0A !important;
  border-color: rgba(217, 119, 6, 0.35) !important;
}

[data-theme="marble-bling"] input::placeholder,
[data-theme="marble-bling"] textarea::placeholder,
html.marble-bling input::placeholder,
html.marble-bling textarea::placeholder {
  color: #948B7C !important;
}

/* ── 7. Explicit Protections & Sacred Brand Accents (Preserve Visual Luxury) ─ */
/* Never invert gold gradients, status badges, or 3D icons */
[data-theme="marble-bling"] .gold-gradient-text,
[data-theme="marble-bling"] .accent-gold,
[data-theme="marble-bling"] .badge-gold,
[data-theme="marble-bling"] .ankh-3d-glyph,
[data-theme="marble-bling"] .brand-logo-mini,
[data-theme="marble-bling"] .product-main-logo-img,
html.marble-bling .gold-gradient-text,
html.marble-bling .accent-gold,
html.marble-bling .badge-gold,
html.marble-bling .ankh-3d-glyph,
html.marble-bling .brand-logo-mini,
html.marble-bling .product-main-logo-img {
  /* Protected from monochrome inversion */
  color: inherit;
  filter: drop-shadow(0 0 14px rgba(245, 158, 11, 0.35));
}
