/**
 * Glaxfy Design System
 * Premium E-Commerce Design Tokens
 * 
 * This file contains all design tokens (CSS custom properties) that form
 * the foundation of the Glaxfy design system. All components should use
 * these tokens for consistency.
 */

/* ========== CSS Custom Properties ========== */
:root {
    /* ===== Color Palette ===== */
    
    /* Primary - Indigo/Purple (Brand Color) */
    --color-primary-50: #eef2ff;
    --color-primary-100: #e0e7ff;
    --color-primary-200: #c7d2fe;
    --color-primary-300: #a5b4fc;
    --color-primary-400: #818cf8;
    --color-primary-500: #6366f1;
    --color-primary-600: #4f46e5;
    --color-primary-700: #4338ca;
    --color-primary-800: #3730a3;
    --color-primary-900: #312e81;
    
    /* Secondary - Purple */
    --color-secondary-50: #faf5ff;
    --color-secondary-100: #f3e8ff;
    --color-secondary-200: #e9d5ff;
    --color-secondary-300: #d8b4fe;
    --color-secondary-400: #c084fc;
    --color-secondary-500: #a855f7;
    --color-secondary-600: #9333ea;
    --color-secondary-700: #7e22ce;
    --color-secondary-800: #6b21a8;
    --color-secondary-900: #581c87;
    
    /* Neutral - Slate */
    --color-neutral-50: #f8fafc;
    --color-neutral-100: #f1f5f9;
    --color-neutral-200: #e2e8f0;
    --color-neutral-300: #cbd5e1;
    --color-neutral-400: #94a3b8;
    --color-neutral-500: #64748b;
    --color-neutral-600: #475569;
    --color-neutral-700: #334155;
    --color-neutral-800: #1e293b;
    --color-neutral-900: #0f172a;
    --color-neutral-950: #020617;
    
    /* Semantic Colors */
    --color-success-50: #ecfdf5;
    --color-success-100: #d1fae5;
    --color-success-500: #10b981;
    --color-success-600: #059669;
    --color-success-700: #047857;
    
    --color-warning-50: #fffbeb;
    --color-warning-100: #fef3c7;
    --color-warning-500: #f59e0b;
    --color-warning-600: #d97706;
    --color-warning-700: #b45309;
    
    --color-error-50: #fef2f2;
    --color-error-100: #fee2e2;
    --color-error-500: #ef4444;
    --color-error-600: #dc2626;
    --color-error-700: #b91c1c;
    
    --color-info-50: #eff6ff;
    --color-info-100: #dbeafe;
    --color-info-500: #3b82f6;
    --color-info-600: #2563eb;
    --color-info-700: #1d4ed8;
    
    /* Legacy color aliases (for backward compatibility) */
    --color-success: var(--color-success-500);
    --color-warning: var(--color-warning-500);
    --color-error: var(--color-error-500);
    --color-info: var(--color-info-500);
    
    /* Gray aliases (backward compatibility) */
    --color-gray-50: var(--color-neutral-50);
    --color-gray-100: var(--color-neutral-100);
    --color-gray-200: var(--color-neutral-200);
    --color-gray-300: var(--color-neutral-300);
    --color-gray-400: var(--color-neutral-400);
    --color-gray-500: var(--color-neutral-500);
    --color-gray-600: var(--color-neutral-600);
    --color-gray-700: var(--color-neutral-700);
    --color-gray-800: var(--color-neutral-800);
    --color-gray-900: var(--color-neutral-900);
    
    /* ===== Semantic Surface Colors (Light Mode) ===== */
    --surface-primary: #ffffff;
    --surface-secondary: var(--color-neutral-50);
    --surface-tertiary: var(--color-neutral-100);
    --surface-elevated: rgba(255, 255, 255, 0.9);
    --surface-overlay: rgba(0, 0, 0, 0.5);
    --surface-inverse: var(--color-neutral-900);
    
    /* ===== Semantic Text Colors (Light Mode) ===== */
    --text-primary: var(--color-neutral-900);
    --text-secondary: var(--color-neutral-600);
    --text-tertiary: var(--color-neutral-500);
    --text-muted: var(--color-neutral-400);
    --text-inverse: #ffffff;
    --text-link: var(--color-primary-600);
    --text-link-hover: var(--color-primary-700);
    
    /* ===== Semantic Border Colors (Light Mode) ===== */
    --border-default: var(--color-neutral-200);
    --border-muted: var(--color-neutral-100);
    --border-strong: var(--color-neutral-300);
    --border-focus: var(--color-primary-500);
    --border-error: var(--color-error-500);
    --border-success: var(--color-success-500);
    
    /* ===== Gradients ===== */
    --gradient-primary: linear-gradient(135deg, var(--color-primary-500) 0%, var(--color-secondary-500) 100%);
    --gradient-primary-hover: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-secondary-600) 100%);
    --gradient-accent: linear-gradient(135deg, var(--color-warning-500) 0%, var(--color-error-500) 100%);
    --gradient-surface: linear-gradient(180deg, var(--surface-primary) 0%, var(--surface-secondary) 100%);
    
    /* ===== Glass Effect ===== */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-bg-strong: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --glass-blur: blur(12px);

    
    /* ===== Spacing Scale (4px base unit) ===== */
    --space-0: 0;
    --space-px: 1px;
    --space-0-5: 0.125rem;  /* 2px */
    --space-1: 0.25rem;     /* 4px */
    --space-1-5: 0.375rem;  /* 6px */
    --space-2: 0.5rem;      /* 8px */
    --space-2-5: 0.625rem;  /* 10px */
    --space-3: 0.75rem;     /* 12px */
    --space-3-5: 0.875rem;  /* 14px */
    --space-4: 1rem;        /* 16px */
    --space-5: 1.25rem;     /* 20px */
    --space-6: 1.5rem;      /* 24px */
    --space-7: 1.75rem;     /* 28px */
    --space-8: 2rem;        /* 32px */
    --space-9: 2.25rem;     /* 36px */
    --space-10: 2.5rem;     /* 40px */
    --space-11: 2.75rem;    /* 44px */
    --space-12: 3rem;       /* 48px */
    --space-14: 3.5rem;     /* 56px */
    --space-16: 4rem;       /* 64px */
    --space-20: 5rem;       /* 80px */
    --space-24: 6rem;       /* 96px */
    --space-28: 7rem;       /* 112px */
    --space-32: 8rem;       /* 128px */
    
    /* ===== Typography ===== */
    --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-family-display: 'Inter', var(--font-family-sans);
    --font-family-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 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 */
    --text-5xl: 3rem;       /* 48px */
    --text-6xl: 3.75rem;    /* 60px */
    --text-7xl: 4.5rem;     /* 72px */
    
    /* Font Weights */
    --font-thin: 100;
    --font-extralight: 200;
    --font-light: 300;
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --font-extrabold: 800;
    --font-black: 900;
    
    /* Line Heights */
    --leading-none: 1;
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --leading-loose: 2;
    
    /* Letter Spacing */
    --tracking-tighter: -0.05em;
    --tracking-tight: -0.025em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;
    --tracking-wider: 0.05em;
    --tracking-widest: 0.1em;
    
    /* ===== Shadows - Standardized Depth Scale ===== */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-none: none;
    
    /* Colored Shadows */
    --shadow-primary: 0 4px 14px rgba(99, 102, 241, 0.25);
    --shadow-primary-lg: 0 10px 25px rgba(99, 102, 241, 0.3);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);
    --shadow-glow-sm: 0 0 20px rgba(99, 102, 241, 0.2);
    
    /* ===== Border Radius - Standardized Scale ===== */
    --radius-none: 0;
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --radius-3xl: 48px;
    --radius-full: 9999px;
    
    /* ===== Animation & Transitions ===== */
    /* Easing Functions */
    --ease-linear: linear;
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Durations */
    --duration-75: 75ms;
    --duration-100: 100ms;
    --duration-150: 150ms;
    --duration-200: 200ms;
    --duration-300: 300ms;
    --duration-500: 500ms;
    --duration-700: 700ms;
    --duration-1000: 1000ms;
    
    /* Transition Presets */
    --transition-fast: var(--duration-150) var(--ease-out);
    --transition-base: var(--duration-300) var(--ease-out);
    --transition-slow: var(--duration-500) var(--ease-out);
    --transition-bounce: var(--duration-500) var(--ease-bounce);
    --transition-colors: color var(--duration-200) var(--ease-out), 
                         background-color var(--duration-200) var(--ease-out), 
                         border-color var(--duration-200) var(--ease-out);
    --transition-transform: transform var(--duration-200) var(--ease-out);
    --transition-shadow: box-shadow var(--duration-200) var(--ease-out);
    --transition-all: all var(--duration-200) var(--ease-out);
    
    /* ===== Z-Index Scale ===== */
    --z-below: -1;
    --z-base: 0;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-popover: 600;
    --z-tooltip: 700;
    --z-toast: 800;
    --z-max: 9999;
    
    /* ===== Layout ===== */
    --container-xs: 320px;
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1280px;
    --container-2xl: 1400px;
    --container-max-width: var(--container-xl);
    
    /* Component Sizes */
    --header-height: 70px;
    --header-height-mobile: 60px;
    --bottom-nav-height: 64px;
    --sidebar-width: 280px;
    
    /* Touch Target (Accessibility) */
    --touch-target-min: 44px;
    
    /* ===== Focus Ring ===== */
    --focus-ring-width: 3px;
    --focus-ring-color: rgba(99, 102, 241, 0.4);
    --focus-ring: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
    --focus-ring-error: 0 0 0 var(--focus-ring-width) rgba(239, 68, 68, 0.4);
    --focus-ring-success: 0 0 0 var(--focus-ring-width) rgba(16, 185, 129, 0.4);
}


/* ===== Dark Mode Overrides ===== */
[data-theme="dark"] {
    /* Surface Colors */
    --surface-primary: var(--color-neutral-900);
    --surface-secondary: var(--color-neutral-800);
    --surface-tertiary: var(--color-neutral-700);
    --surface-elevated: rgba(30, 41, 59, 0.9);
    --surface-overlay: rgba(0, 0, 0, 0.7);
    --surface-inverse: var(--color-neutral-50);
    
    /* Text Colors */
    --text-primary: var(--color-neutral-50);
    --text-secondary: var(--color-neutral-300);
    --text-tertiary: var(--color-neutral-400);
    --text-muted: var(--color-neutral-500);
    --text-inverse: var(--color-neutral-900);
    --text-link: var(--color-primary-400);
    --text-link-hover: var(--color-primary-300);
    
    /* Border Colors */
    --border-default: var(--color-neutral-700);
    --border-muted: var(--color-neutral-800);
    --border-strong: var(--color-neutral-600);
    
    /* Glass Effect */
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-bg-strong: rgba(30, 41, 59, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    /* Shadows (darker for dark mode) */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    
    /* Colored Shadows */
    --shadow-primary: 0 4px 14px rgba(99, 102, 241, 0.35);
    --shadow-primary-lg: 0 10px 25px rgba(99, 102, 241, 0.4);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.4);
    --shadow-glow-sm: 0 0 20px rgba(99, 102, 241, 0.3);
}

/* ===== Base Reset & Styles ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
    font-size: 16px;
}

/* Smooth theme transitions */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color var(--duration-300) var(--ease-out),
                color var(--duration-300) var(--ease-out),
                border-color var(--duration-300) var(--ease-out),
                box-shadow var(--duration-300) var(--ease-out) !important;
}

body {
    font-family: var(--font-family-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background-color: var(--surface-secondary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Accessibility ===== */

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip to content link */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    z-index: var(--z-max);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-primary);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
    font-weight: var(--font-semibold);
    transition: top var(--duration-200) var(--ease-out);
}

.skip-link:focus {
    top: var(--space-4);
    outline: none;
}

/* Focus visible styles */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Remove focus ring for mouse users */
:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

/* Live region for screen readers */
.live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Typography Base ===== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-display);
    font-weight: var(--font-bold);
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
    margin-bottom: var(--space-4);
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--duration-150) var(--ease-out);
}

a:hover {
    color: var(--text-link-hover);
}

/* ===== Images ===== */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

img[data-src] {
    opacity: 0;
    transition: opacity var(--transition-base);
}

img.loaded {
    opacity: 1;
}

/* ===== Container ===== */
.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

@media (min-width: 768px) {
    .container {
        padding-left: var(--space-6);
        padding-right: var(--space-6);
    }
}

@media (min-width: 1024px) {
    .container {
        padding-left: var(--space-8);
        padding-right: var(--space-8);
    }
}

/* ===== Aspect Ratio Utilities ===== */
.aspect-square { aspect-ratio: 1; }
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-portrait { aspect-ratio: 3 / 4; }
.aspect-wide { aspect-ratio: 21 / 9; }

/* ===== Utility Classes ===== */

/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Font weights */
.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

/* Text colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success-500); }
.text-warning { color: var(--color-warning-500); }
.text-error { color: var(--color-error-500); }

/* Background colors */
.bg-primary { background-color: var(--surface-primary); }
.bg-secondary { background-color: var(--surface-secondary); }

/* Display */
.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* Flexbox */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Spacing */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.my-4 { margin-top: var(--space-4); margin-bottom: var(--space-4); }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

/* Border radius */
.rounded-none { border-radius: var(--radius-none); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadows */
.shadow-none { box-shadow: var(--shadow-none); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Width/Height */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* Opacity */
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-100 { opacity: 1; }

/* Transitions */
.transition { transition: var(--transition-all); }
.transition-colors { transition: var(--transition-colors); }
.transition-transform { transition: var(--transition-transform); }
.transition-shadow { transition: var(--transition-shadow); }

/* Transforms */
.scale-100 { transform: scale(1); }
.scale-105 { transform: scale(1.05); }
.scale-110 { transform: scale(1.1); }
.-translate-y-1 { transform: translateY(-0.25rem); }
.-translate-y-2 { transform: translateY(-0.5rem); }
