/* 
==============================================================================
 BLACK ELM COFFEE - UNIFIED THEME SYSTEM
 Consolidates all CSS variables and theming for consistent design
==============================================================================
*/

/* 
 * Color Palette - Coffee-inspired design with proper contrast ratios
 * Following WCAG guidelines and avoiding pure black/white
 */
:root {
  /* ===== LIGHT THEME (DEFAULT) ===== */
  
  /* Background Colors */
  --bg-primary: #FEFBF7;      /* Main background - warm white */
  --bg-secondary: #FFF8F3;    /* Secondary background */
  --bg-tertiary: #FFFFFF;     /* Pure white for contrast */
  
  /* Text Colors */
  --text-primary: #1C1917;    /* Main text - dark warm gray */
  --text-secondary: #57534E;  /* Secondary text */
  --text-muted: #78716C;      /* Muted text for less important content */
  
  /* Accent Colors - Clean indigo instead of coffee orange */
  --accent-primary: #6366f1;  /* Primary accent - indigo */
  --accent-secondary: #5856eb; /* Secondary accent */
  --accent-hover: #4f46e5;    /* Hover state */
  
  /* Surface Elevation System */
  --surface-0: #FFFFFF;       /* Base surface */
  --surface-1: #FAFAF9;       /* Elevated 1 level */
  --surface-2: #F5F5F4;       /* Elevated 2 levels */
  --surface-3: #E7E5E4;       /* Elevated 3 levels */
  
  /* Border Colors */
  --border-light: #E7E5E4;    /* Light borders */
  --border-medium: #D6D3D1;   /* Medium borders */
  --border-dark: #A8A29E;     /* Dark borders */
  
  /* Status Colors */
  --success: #22C55E;         /* Green for success states */
  --warning: #F59E0B;         /* Amber for warning states */
  --danger: #EF4444;          /* Red for error/danger states */
  --info: #3B82F6;            /* Blue for info states */
  
  /* Shadow System */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  
  /* Button Theme Variables */
  --button-bg: #ffffff;
  --button-text: #1C1917;
  --button-border: #e5e5e5;
  --button-hover-bg: #f8f9fa;
  --button-hover-border: #000000;
  --button-hover-text: #000000;
}

/* 
 * ===== DARK THEME =====
 * Avoiding pure black, using warm dark grays for better UX
 */
[data-theme="dark"] {
  /* Background Colors - Warm dark grays */
  --bg-primary: #1A1816;      /* Slightly warm dark instead of pure black */
  --bg-secondary: #242220;    /* Secondary background */
  --bg-tertiary: #2E2B29;     /* Tertiary background */
  
  /* Text Colors - Off-white instead of pure white */
  --text-primary: #FAF9F8;    /* Slightly warm white */
  --text-secondary: #D6D3D1;  /* Secondary text */
  --text-muted: #A8A29E;      /* Muted text */
  
  /* Accent Colors - Muted for dark mode */
  --accent-primary: #818cf8;  /* Softer indigo */
  --accent-secondary: #6366f1; /* Secondary accent */
  --accent-hover: #a5b4fc;    /* Lighter hover state */
  
  /* Surface Elevation - Communicating depth through lighter surfaces */
  --surface-0: #1A1816;       /* Base level */
  --surface-1: #242220;       /* Elevated 1 level */
  --surface-2: #2E2B29;       /* Elevated 2 levels */
  --surface-3: #3A3634;       /* Elevated 3 levels */
  
  /* Border Colors */
  --border-light: #3A3634;    /* Light borders */
  --border-medium: #44403C;   /* Medium borders */
  --border-dark: #57534E;     /* Dark borders */
  
  /* Status Colors - Desaturated for dark mode */
  --success: #4ADE80;         /* Softer green */
  --warning: #FBBF24;         /* Softer amber */
  --danger: #F87171;          /* Softer red */
  --info: #60A5FA;            /* Softer blue */
  
  /* Shadow System - Minimal shadows in dark mode */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 8px 16px rgba(0, 0, 0, 0.5);
  
  /* Button Theme Variables for Dark Mode */
  --button-bg: #000000;
  --button-text: #ffffff;
  --button-border: #333333;
  --button-hover-bg: #1a1a1a;
  --button-hover-border: #ffffff;
  --button-hover-text: #ffffff;
}

/* 
 * ===== TYPOGRAPHY SCALE =====
 */
:root {
  /* Font Families */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'Monaco', 'Cascadia Code', monospace;
  
  /* Font Sizes */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  
  /* Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  
  /* Line Heights */
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;
}

/* 
 * ===== SPACING SCALE =====
 */
:root {
  --spacing-0: 0;
  --spacing-1: 0.25rem;   /* 4px */
  --spacing-2: 0.5rem;    /* 8px */
  --spacing-3: 0.75rem;   /* 12px */
  --spacing-4: 1rem;      /* 16px */
  --spacing-5: 1.25rem;   /* 20px */
  --spacing-6: 1.5rem;    /* 24px */
  --spacing-8: 2rem;      /* 32px */
  --spacing-10: 2.5rem;   /* 40px */
  --spacing-12: 3rem;     /* 48px */
  --spacing-16: 4rem;     /* 64px */
  --spacing-20: 5rem;     /* 80px */
  --spacing-24: 6rem;     /* 96px */
}

/* 
 * ===== BORDER RADIUS SCALE =====
 */
:root {
  --radius-none: 0;
  --radius-sm: 0.125rem;   /* 2px */
  --radius-base: 0.25rem;  /* 4px */
  --radius-md: 0.375rem;   /* 6px */
  --radius-lg: 0.5rem;     /* 8px */
  --radius-xl: 0.75rem;    /* 12px */
  --radius-2xl: 1rem;      /* 16px */
  --radius-full: 9999px;   /* Full circle */
}

/* 
 * ===== TRANSITION SYSTEM =====
 */
:root {
  --transition-fast: 150ms ease-in-out;
  --transition-base: 200ms ease-in-out;
  --transition-slow: 300ms ease-in-out;
  
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
}

/* 
 * ===== BREAKPOINTS =====
 */
:root {
  --breakpoint-sm: 640px;   /* Small devices */
  --breakpoint-md: 768px;   /* Medium devices */
  --breakpoint-lg: 1024px;  /* Large devices */
  --breakpoint-xl: 1280px;  /* Extra large devices */
  --breakpoint-2xl: 1536px; /* 2X large devices */
}

/* 
 * ===== Z-INDEX SCALE =====
 */
:root {
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;
}

/* 
 * ===== COMPREHENSIVE LEGACY SUPPORT =====
 * Maintaining compatibility with ALL existing CSS variables
 */
:root {
  /* Legacy theme variables - mapped to new system */
  --bg: var(--bg-primary);
  --panel: var(--surface-1);
  --accent: var(--accent-primary);
  --accent-solid: var(--accent-primary);
  --text: var(--text-primary);
  --subtext: var(--text-secondary);
  --border: var(--border-light);
  --input-bg: var(--surface-1);
  --input-text: var(--text-primary);
  --hover-bg: var(--surface-2);
  --card-bg: var(--surface-1);
  --shadow: var(--shadow-md);
  --shadow-hover: var(--shadow-lg);
  --surface: var(--surface-0);
  
  /* Additional legacy variables for components */
  --text-muted: var(--text-muted);
  --text-secondary: var(--text-secondary);
  --border-color: var(--border-light);
  --border-subtle: var(--border-light);
  --sidebar-bg: #0a0a0a;
  --accent-light: rgba(99, 102, 241, 0.1);
  --hover: var(--surface-2);
  --primary: var(--accent-primary);
  --primary-hover: var(--accent-hover);
  
  /* Shopify integration specific variables */
  --card-background: var(--surface-1);
  --primary-color: var(--accent-primary);
  --success-light: rgba(34, 197, 94, 0.1);
  --success-dark: #15803d;
  --success-color: var(--success);
  --warning-light: rgba(245, 158, 11, 0.1);
  --warning-dark: #92400e;
  --error-light: rgba(239, 68, 68, 0.1);
  --error-dark: #991b1b;
  --error-color: var(--danger);
  --disabled-color: #6b7280;
}

[data-theme="dark"] {
  /* Legacy dark theme variables */
  --bg: var(--bg-primary);
  --panel: var(--surface-1);
  --accent: var(--accent-primary);
  --accent-solid: var(--accent-primary);
  --text: var(--text-primary);
  --text-muted: var(--text-muted);
  --text-secondary: var(--text-secondary);
  --subtext: var(--text-secondary);
  --border: var(--border-light);
  --border-color: var(--border-light);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --input-bg: var(--surface-2);
  --input-text: var(--text-primary);
  --hover-bg: var(--surface-2);
  --hover: var(--surface-2);
  --card-bg: var(--surface-1);
  --shadow: var(--shadow-md);
  --shadow-hover: var(--shadow-lg);
  --surface: var(--surface-1);
  --sidebar-bg: #0a0a0a;
  --accent-light: rgba(129, 140, 248, 0.1);
  --primary: var(--accent-primary);
  --primary-hover: var(--accent-hover);
  
  /* Shopify integration specific variables - dark theme */
  --card-background: var(--surface-1);
  --primary-color: var(--accent-primary);
  --success-light: rgba(74, 222, 128, 0.1);
  --success-dark: #22c55e;
  --success-color: var(--success);
  --warning-light: rgba(251, 191, 36, 0.1);
  --warning-dark: #f59e0b;
  --error-light: rgba(248, 113, 113, 0.1);
  --error-dark: #f87171;
  --error-color: var(--danger);
  --disabled-color: #6b7280;
}

[data-theme="light"] {
  /* Light theme legacy variables */
  --bg: var(--bg-primary);
  --panel: var(--surface-1);
  --accent: var(--accent-primary);
  --accent-solid: var(--accent-primary);
  --text: var(--text-primary);
  --text-muted: var(--text-muted);
  --text-secondary: var(--text-secondary);
  --subtext: var(--text-secondary);
  --border: var(--border-light);
  --border-color: var(--border-light);
  --border-subtle: var(--border-light);
  --input-bg: var(--surface-1);
  --input-text: var(--text-primary);
  --hover-bg: var(--surface-2);
  --hover: var(--surface-2);
  --card-bg: var(--surface-1);
  --shadow: var(--shadow-md);
  --shadow-hover: var(--shadow-lg);
  --surface: var(--surface-0);
  --sidebar-bg: #ffffff;
  --accent-light: rgba(99, 102, 241, 0.1);
  --primary: var(--accent-primary);
  --primary-hover: var(--accent-hover);
}

/* 
 * ===== GLOBAL THEME APPLICATION =====
 */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-primary);
  line-height: var(--leading-normal);
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* Color scheme hint for browsers */
:root {
  color-scheme: light;
}

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

/* 
 * ===== SMOOTH TRANSITIONS FOR THEME SWITCHING =====
 */
*,
*::before,
*::after {
  transition-property: background-color, border-color, color, fill, stroke, box-shadow;
  transition-duration: var(--transition-base);
  transition-timing-function: var(--ease-in-out);
}

/* Disable transitions during theme switching to prevent flash */
body.theme-switching * {
  transition: none !important;
}

/* 
 * ===== ACCESSIBILITY IMPROVEMENTS =====
 */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-light: var(--border-dark);
    --border-medium: var(--text-muted);
  }
  
  [data-theme="dark"] {
    --border-light: var(--border-medium);
    --border-medium: var(--text-muted);
  }
}

/* Print styles */
@media print {
  :root {
    --bg-primary: white;
    --bg-secondary: white;
    --text-primary: black;
    --text-secondary: #333;
    --border-light: #ccc;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }
} 