/* ===========================
   CSS Custom Properties (Theme System)
=========================== */
:root {
  /* Light Theme Colors */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --bg-tertiary: #FFFFFF;
  --bg-quaternary: #F3F4F6;
  --bg-lighter: #f8fafc;
  --bg-light-gray: #f8f9fa;
  --bg-hover: #F3F4F6;
  --bg-overlay: rgba(161, 65, 65, 0.8);
  --chart-bg: var(--bg-primary);  /* Charts match primary backgrounds by default */

  /* Container-specific chart backgrounds for automatic inheritance */
  --chart-bg-primary: var(--bg-primary);    /* Charts in primary containers */
  --chart-bg-secondary: var(--bg-secondary); /* Charts in secondary containers */

  /* Page grid background (spreadsheet-style rectangular cells) */
  --grid-line-color: rgba(180, 100, 255, 0.08);
  --grid-size-x: 80px;
  --grid-size-y: 28px;

  /* Layout - sidebar width (13.125rem = 210px at 16px root) */
  --sidebar-width: 13.125rem;

  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-tertiary: #111827;
  --text-muted: #6B7280;
  --text-light: #b464ff;
  --text-dark: #111827;
  --text-semi-dark: #374151;
  --text-medium: #374151;
  --text-gray: #6B7280;
  --text-slate: #9CA3AF;
  --text-ui-muted: #9CA3AF;

  --border-primary: #E5E7EB;
  --border-secondary: #E5E7EB;
  --border-light: #E5E7EB;
  --border-ui: #E5E7EB;
  --border-dashed: #E5E7EB;
  --border-subtle: #F3F4F6;  /* PostHog-style: almost invisible for flat cards */

  /* AI Insight sub-cards: stronger contrast in light mode (light grey vs white) */
  --insight-subcard-bg: #E8EBEF;
  --insight-action-bg: rgba(5, 150, 105, 0.12);
  --insight-action-border: rgba(5, 150, 105, 0.25);

  /* Simulation preset cards: distinct from page background in light mode */
  --simulation-preset-card-bg: #E8EBEF;
  --simulation-preset-card-border: #D1D5DB;

  /* One-Time Events accordion: income/expense card tints (theme-dependent) */
  --simulation-income-boost-bg: rgba(5, 150, 105, 0.08);
  --simulation-expense-card-bg: rgba(220, 38, 38, 0.08);

  /* Canadian Retirement side popout callouts (light mode) */
  --canadian-recommendation-bg: rgba(245, 158, 11, 0.08);
  --canadian-recommendation-border: rgba(245, 158, 11, 0.25);
  --canadian-breakeven-bg: rgba(111, 66, 193, 0.06);
  --canadian-warning-callout-bg: rgba(245, 158, 11, 0.08);
  --canadian-warning-callout-border: rgba(245, 158, 11, 0.25);
  --canadian-fi-impact-bg: rgba(40, 167, 69, 0.08);
  --canadian-fi-impact-border: rgba(40, 167, 69, 0.2);

  --shadow-light: rgba(0,0,0,0);
  --shadow-medium: rgba(0,0,0,0.08);
  --shadow-none: none;  /* Flat design: no card shadows by default */

  /* Brand Colors (original Prosperi purple) */
  --brand-purple: #b464ff;
  --brand-purple-dark: #be4afc;
  --brand-purple-hover: #a13ad8;
  --brand-purple-light: #ebd4ff;
  --brand-purple-active: rgb(180, 41, 255);
  --brand-green: #059669;
  --brand-green-hover: #047857;
  --brand-red: #DC2626;
  --brand-red-hover: #b91c1c;
  --brand-yellow: #D97706;
  --brand-purple-alt: #b464ff;
  --brand-purple-alt-hover: rgb(180, 100, 255);

  /* Date preset / Recurring-style button (default state) */
  --preset-btn-bg: #F8F8F8;
  --preset-btn-text: #825ABE;
  --preset-btn-border: #C8B4E6;

  /* Additional Common Colors */
  --white: #fff;
  --success-green: #059669;
  --error-red: #DC2626;
  --warning-yellow: #D97706;
  --info-blue: #3B82F6;
  --gray-100: #f8f9fa;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Specific Use Colors */
  --table-header: #f1d6ff;
  --bracket-highlight-bg: rgba(180, 100, 255, 0.12);
  --gradient-primary: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
  --gradient-secondary: linear-gradient(135deg, #c04bff 0%, #a429ff 100%);

  /* ===========================
     Card System (Prosperi card theme)
  ============================ */
  --card-border-radius: 0px;
  --card-padding: 1.25rem 1.5rem;        /* was 20px 24px */
  --card-padding-compact: 0.75rem 1rem;   /* was 12px 16px */
  --card-padding-spacious: 1.75rem 2rem; /* was 28px 32px */
  --card-hover-shadow: 0 0 0 1px rgba(180, 100, 255, 0.18), 0 8px 28px rgba(180, 100, 255, 0.16);
  --gradient-accent-border: linear-gradient(135deg, #b464ff 0%, #8b5cf6 50%, #6366f1 100%);
  /* Change pill badges (percentage up/down/neutral) */
  --change-pill-up-bg: rgba(239, 68, 68, 0.1);
  --change-pill-up-text: #EF4444;
  --change-pill-down-bg: rgba(34, 197, 94, 0.1);
  --change-pill-down-text: #22C55E;
  --change-pill-neutral-bg: rgba(107, 114, 128, 0.1);
  --change-pill-neutral-text: var(--text-gray);

  /* AG Grid Confidence Highlighting */
  --confidence-low-bg: #FFDDD6;  /* Pale red for low confidence */
  --confidence-medium-bg: #FFF1D6;  /* Pale yellow for medium confidence */

  /* Chart/Data Colors */
  --chart-purple: #6f42c1;
  --chart-orange: #ff6b35;
  --chart-blue: #007bff;
  --chart-amber: #f59e0b;
  --chart-violet: #8b5cf6;
  --chart-cyan: #06b6d4;
  --chart-indigo: #6366f1;
  --chart-pink: #ec4899;
  --chart-green: #059669;
  --chart-red: #DC2626;
  --chart-lime: #84cc16;
  --chart-slate: #64748b;

  /* Hover/Tooltip Colors */
  --hover-bg: rgba(255, 255, 255, 0.95);
  --hover-border: #E5E7EB;

  /* ===========================
     Spacing Scale (8px base grid)
  ============================ */
  --spacing-xs: 0.25rem;    /* 4px - Tight spacing */
  --spacing-sm: 0.5rem;     /* 8px - Compact elements */
  --spacing-md: 0.75rem;    /* 12px - Default spacing */
  --spacing-lg: 1rem;       /* 16px - Cards, sections */
  --spacing-xl: 1.5rem;     /* 24px - Page sections */
  --spacing-2xl: 2rem;      /* 32px - Major sections */
  --spacing-3xl: 2.5rem;    /* 40px - Large sections */
  --spacing-4xl: 3.75rem;   /* 60px - Extra large sections */

  /* ===========================
     Font Family (single source of truth for app typography)
  ============================ */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* ===========================
     Typography Scale (rem-based)
  ============================ */
  --font-size-xs: 0.75rem;      /* 12px */
  --font-size-sm: 0.875rem;     /* 14px */
  --font-size-base: 1rem;       /* 16px */
  --font-size-lg: 1.125rem;     /* 18px */
  --font-size-xl: 1.25rem;      /* 20px */
  --font-size-2xl: 1.5rem;      /* 24px */
  --font-size-3xl: 2rem;        /* 32px */
  --font-size-4xl: 2.25rem;     /* 36px */

  /* ===========================
     Font Weights
  ============================ */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* ===========================
     Line Heights (PostHog-style: tighter UI)
  ============================ */
  --line-height-tight: 1.35;
  --line-height-nav: 1.4;
  --line-height-body: 1.5;

  /* ===========================
     Modal System Variables
  ============================ */
  --modal-border-radius: 16px;
  --modal-padding: 24px;
  --modal-header-padding: 20px 24px;
  --modal-body-padding: 20px 24px;
  --modal-footer-padding: 16px 24px;
  --modal-backdrop-opacity: 0.5;
  --modal-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.15);
  --modal-animation-duration: 0.3s;
}

/* ===========================
   Dark Theme Colors
=========================== */
[data-theme="dark"] {
  --bg-primary: #1a1d2e;
  --bg-secondary: #13161f;
  --bg-tertiary: #252938;
  --bg-quaternary: #2d3142;
  --bg-lighter: #1e2238;
  --bg-light-gray: #252938;
  --bg-hover: #2a2d3e;
  --bg-overlay: rgba(0, 0, 0, 0.9);
  --chart-bg: #1a1d2e;

  --chart-bg-primary: #1a1d2e;
  --chart-bg-secondary: #13161f;

  --grid-line-color: rgba(192, 132, 252, 0.07);
  --grid-size-x: 80px;
  --grid-size-y: 28px;

  --text-primary: #e8eaed;
  --text-secondary: #bdc1c6;
  --text-tertiary: #9aa0a6;
  --text-muted: #80868b;
  --text-light: #c084fc;
  --text-dark: #e8eaed;
  --text-semi-dark: #d4d6da;
  --text-medium: #bdc1c6;
  --text-gray: #a8aab0;
  --text-slate: #9aa0a6;
  --text-ui-muted: #9095a0;

  --border-primary: #3d4153;
  --border-secondary: #484d5e;
  --border-light: #505565;
  --border-ui: #3d4153;
  --border-dashed: #3d4153;
  --border-subtle: #252938;

  /* AI Insight sub-cards: dark mode (use tertiary for contrast) */
  --insight-subcard-bg: var(--bg-tertiary);
  --insight-action-bg: rgba(52, 211, 153, 0.14);
  --insight-action-border: rgba(52, 211, 153, 0.3);

  /* Simulation preset cards: dark mode */
  --simulation-preset-card-bg: var(--bg-tertiary);
  --simulation-preset-card-border: var(--border-primary);

  /* One-Time Events accordion: dark mode tints */
  --simulation-income-boost-bg: rgba(52, 211, 153, 0.12);
  --simulation-expense-card-bg: rgba(248, 113, 113, 0.12);

  /* Canadian Retirement side popout callouts (dark mode) */
  --canadian-recommendation-bg: rgba(251, 191, 36, 0.12);
  --canadian-recommendation-border: rgba(251, 191, 36, 0.25);
  --canadian-breakeven-bg: rgba(167, 139, 250, 0.12);
  --canadian-warning-callout-bg: rgba(251, 191, 36, 0.12);
  --canadian-warning-callout-border: rgba(251, 191, 36, 0.25);
  --canadian-fi-impact-bg: rgba(52, 211, 153, 0.12);
  --canadian-fi-impact-border: rgba(52, 211, 153, 0.25);

  --shadow-light: rgba(0, 0, 0, 0.3);
  --shadow-medium: rgba(0, 0, 0, 0.5);

  --brand-purple: #c084fc;
  --brand-purple-dark: #a855f7;
  --brand-purple-hover: #d8b4fe;
  --brand-purple-light: #2d1b45;
  --brand-purple-active: #c084fc;
  --brand-green: #34d399;
  --brand-green-hover: #6ee7b7;
  --brand-red: #f87171;
  --brand-red-hover: #fca5a5;
  --brand-yellow: #fbbf24;
  --brand-purple-alt: #9d4edd;
  --brand-purple-alt-hover: #b565f0;

  /* Date preset / Recurring-style button (dark mode) */
  --preset-btn-bg: var(--bg-tertiary);
  --preset-btn-text: var(--brand-purple);
  --preset-btn-border: rgba(192, 132, 252, 0.4);

  --white: #1a1d2e;
  --success-green: #34d399;
  --error-red: #f87171;
  --warning-yellow: #fbbf24;
  --info-blue: #60a5fa;
  --gray-100: #2a2d3e;
  --gray-200: #3d4153;
  --gray-300: #484d5e;
  --gray-400: #6b7280;
  --gray-500: #9ca3af;
  --gray-600: #d1d5db;
  --gray-700: #e5e7eb;
  --gray-800: #f3f4f6;
  --gray-900: #f9fafb;

  --table-header: #4c3d5c;
  --bracket-highlight-bg: rgba(192, 132, 252, 0.2);
  --gradient-primary: linear-gradient(135deg, #1a1d2e 0%, #252938 100%);
  --gradient-secondary: linear-gradient(135deg, #9d4edd 0%, #7c3aed 100%);

  --card-hover-shadow: 0 0 0 1px rgba(192, 132, 252, 0.22), 0 8px 28px rgba(192, 132, 252, 0.18);
  --change-pill-up-bg: rgba(248, 113, 113, 0.15);
  --change-pill-up-text: #f87171;
  --change-pill-down-bg: rgba(52, 211, 153, 0.15);
  --change-pill-down-text: #34d399;
  --change-pill-neutral-bg: rgba(154, 160, 166, 0.15);
  --change-pill-neutral-text: var(--text-gray);

  --confidence-low-bg: #4A2C2C;
  --confidence-medium-bg: #4A3F2C;

  --chart-purple: #a78bfa;
  --chart-orange: #fb923c;
  --chart-blue: #60a5fa;
  --chart-amber: #fbbf24;
  --chart-violet: #c084fc;
  --chart-cyan: #22d3ee;
  --chart-indigo: #818cf8;
  --chart-pink: #f472b6;
  --chart-green: #34d399;
  --chart-red: #f87171;
  --chart-lime: #a3e635;
  --chart-slate: #94a3b8;

  --hover-bg: rgba(26, 29, 46, 0.95);
  --hover-border: #3d4153;

  --modal-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.35);
  --btn-close-filter: invert(1) grayscale(100%) brightness(200%);
}
