/**
 * CoreSense Design Tokens
 * =======================
 * Single source of truth for all design values.
 * Import this file first in any page.
 *
 * Usage:
 *   <link rel="stylesheet" href="/design-system/tokens.css">
 */

/* ============================================
   COLOR TOKENS
   ============================================ */

:root {
  /* === COLOR MODE (default: light) === */
  color-scheme: light;

  /* === NEUTRAL GRAYS (Tailwind-inspired) === */
  --gray-50:  #FAFAFA;   /* Subtle backgrounds */
  --gray-100: #F5F5F5;   /* Elevated surfaces */
  --gray-200: #E5E5E5;   /* Borders, dividers */
  --gray-300: #D4D4D4;   /* Stronger borders */
  --gray-400: #A3A3A3;   /* Disabled text */
  --gray-500: #737373;   /* Muted text */
  --gray-600: #525252;   /* Secondary text */
  --gray-700: #404040;   /* Body text */
  --gray-800: #262626;   /* Strong text */
  --gray-900: #171717;   /* Headings */
  --gray-950: #0A0A0A;   /* Maximum contrast */

  /* Legacy gray aliases (for backwards compatibility) */
  --gray-1: #FFFFFF;
  --gray-2: var(--gray-50);
  --gray-3: var(--gray-100);
  --gray-4: var(--gray-200);
  --gray-5: var(--gray-300);
  --gray-6: var(--gray-400);
  --gray-7: #858585;
  --gray-8: var(--gray-500);
  --gray-9: var(--gray-600);
  --gray-10: var(--gray-700);
  --gray-11: var(--gray-800);
  --gray-12: var(--gray-950);

  /* === SEMANTIC SURFACE COLORS === */
  --bg-page: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-elevated: var(--gray-50);
  --bg-hover: var(--gray-100);
  --bg-active: #EBEBEB;
  --bg-surface: var(--bg-card);    /* Opaque surface (modals, overlays) */
  --bg-input: var(--bg-elevated);  /* Form inputs, selects */

  /* === SEMANTIC BORDERS === */
  --border-subtle: #F0F0F0;
  --border-default: var(--gray-200);
  --border-strong: var(--gray-300);

  /* === TEXT HIERARCHY === */
  --text-primary: var(--gray-950);
  --text-secondary: var(--gray-800);
  --text-tertiary: var(--gray-600);
  --text-muted: var(--gray-500);
  --text-disabled: var(--gray-400);

  /* === INVENTORY STATUS === */
  --color-in-stock: #22C55E;
  --color-in-stock-muted: rgba(34, 197, 94, 0.15);
  --color-low-stock: #F59E0B;
  --color-low-stock-muted: rgba(245, 158, 11, 0.15);
  --color-out-of-stock: #EF4444;
  --color-out-of-stock-muted: rgba(239, 68, 68, 0.15);
  --color-backordered: #8B5CF6;
  --color-backordered-muted: rgba(139, 92, 246, 0.15);

  /* === PRICE INDICATORS === */
  --color-price-up: #F97316;
  --color-price-up-muted: rgba(249, 115, 22, 0.15);
  --color-price-down: #06B6D4;
  --color-price-down-muted: rgba(6, 182, 212, 0.15);
  --color-price-neutral: var(--gray-9);

  /* === PRODUCT TYPES (Grayscale) === */
  --color-type-default: var(--gray-600);
  --color-type-default-bg: var(--gray-100);
  --color-type-default-border: var(--gray-200);
  --color-type-internal: var(--gray-700);
  --color-type-internal-bg: #EBEBEB;
  --color-type-internal-border: var(--gray-300);
  --color-type-clearance: var(--gray-800);
  --color-type-clearance-bg: var(--gray-200);
  --color-type-clearance-border: var(--gray-300);
  --color-type-initiator: var(--gray-600);
  --color-type-initiator-bg: transparent;
  --color-type-initiator-border: var(--gray-400);
  --color-type-consignment: var(--gray-600);
  --color-type-consignment-bg: transparent;
  --color-type-consignment-border: var(--gray-400);

  /* Legacy type muted (for backwards compatibility) */
  --color-type-default-muted: var(--gray-100);
  --color-type-internal-muted: #EBEBEB;
  --color-type-clearance-muted: var(--gray-200);
  --color-type-initiator-muted: var(--gray-100);
  --color-type-consignment-muted: var(--gray-100);

  /* === ACCENT (Interactive - Blue) === */
  --color-accent: #2563EB;
  --color-accent-hover: #1D4ED8;
  --color-accent-muted: #EFF6FF;
  --color-accent-strong: #1E40AF;
  --color-accent-10: rgba(59, 130, 246, 0.1);
  --color-accent-5: rgba(59, 130, 246, 0.05);

  /* === FEEDBACK === */
  --color-success: #22C55E;
  --color-success-muted: rgba(34, 197, 94, 0.15);
  --color-success-10: rgba(34, 197, 94, 0.1);
  --color-warning: #F59E0B;
  --color-warning-muted: rgba(245, 158, 11, 0.15);
  --color-warning-10: rgba(245, 158, 11, 0.1);
  --color-error: #EF4444;
  --color-error-muted: rgba(239, 68, 68, 0.15);
  --color-error-10: rgba(239, 68, 68, 0.1);
  --color-danger: var(--color-error);
  --color-danger-bg: var(--color-error-muted);
  --color-info: #3B82F6;
  --color-info-muted: rgba(59, 130, 246, 0.15);

  /* === STATUS BADGE COLORS (workflow states) === */
  --status-draft-bg: #e5e7eb;
  --status-draft-text: #374151;
  --status-in-progress-bg: #dbeafe;
  --status-in-progress-text: #1d4ed8;
  --status-verifying-bg: #fef3c7;
  --status-verifying-text: #b45309;
  --status-completed-bg: #d1fae5;
  --status-completed-text: #047857;
  --status-cancelled-bg: #fee2e2;
  --status-cancelled-text: #b91c1c;

  /* === VERIFICATION RESULT COLORS === */
  --result-success-bg: #dcfce7;
  --result-success-border: #16a34a;
  --result-success-text: #166534;
  --result-warning-bg: #fef3c7;
  --result-warning-border: #d97706;
  --result-warning-text: #92400e;
  --result-error-bg: #fee2e2;
  --result-error-border: #dc2626;
  --result-error-text: #991b1b;

  /* === CHART PALETTE === */
  --chart-1: #3B82F6;
  --chart-2: #8B5CF6;
  --chart-3: #06B6D4;
  --chart-4: #F59E0B;
  --chart-5: #EC4899;
  --chart-6: #14B8A6;
  --chart-comparison: #6B6B6B;

  /* === SCENARIO COLORS (for simulations) === */
  --color-actual: var(--gray-10);
  --color-proposed: #A855F7;
  --color-proposed-muted: rgba(168, 85, 247, 0.15);
  --color-diff-positive: #22C55E;
  --color-diff-negative: #EF4444;
}

/* ============================================
   PRINT MODE
   ============================================ */

@media print {
  :root {
    --gray-1: #FFFFFF;
    --gray-2: #FFFFFF;
    --gray-3: #F5F5F5;
    --gray-4: #E5E5E5;
    --gray-5: #D4D4D4;
    --gray-6: #A3A3A3;
    --gray-7: #858585;
    --gray-8: #6B6B6B;
    --gray-9: #525252;
    --gray-10: #3D3D3D;
    --gray-11: #1F1F1F;
    --gray-12: #000000;
  }
}

/* ============================================
   TYPOGRAPHY TOKENS
   ============================================ */

:root {
  /* === FONT FAMILIES === */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Liberation Mono', monospace;

  /* === FONT SIZES === */
  --text-xs: 0.6875rem;   /* 11px */
  --text-sm: 0.75rem;     /* 12px */
  --text-base: 0.875rem;  /* 14px */
  --text-data: 0.8125rem; /* 13px - for monospace data */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 2rem;       /* 32px */
  --text-display: 2.5rem; /* 40px - hero text */

  /* === FONT WEIGHTS === */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* === LINE HEIGHTS === */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* === LETTER SPACING === */
  --tracking-tighter: -0.03em;
  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.02em;
  --tracking-wider: 0.04em;
  --tracking-widest: 0.08em;
}

/* ============================================
   SPACING TOKENS
   ============================================ */

:root {
  --space-0: 0;
  --space-px: 1px;
  --space-0-5: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-2-5: 10px;
  --space-3: 12px;
  --space-3-5: 14px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
  --space-11: 44px;
  --space-12: 48px;
  --space-14: 56px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
}

/* ============================================
   SIZING TOKENS
   ============================================ */

:root {
  /* === WIDTHS === */
  --width-sidebar: 240px;
  --width-sidebar-collapsed: 64px;
  --width-content-max: 1400px;
  --width-card-sm: 320px;
  --width-card-md: 400px;
  --width-card-lg: 560px;
  --width-modal-sm: 400px;
  --width-modal-md: 560px;
  --width-modal-lg: 720px;

  /* === HEIGHTS === */
  --height-header: 56px;
  --height-row: 44px;
  --height-row-compact: 36px;
  --height-input: 40px;
  --height-input-sm: 32px;
  --height-button: 40px;
  --height-button-sm: 32px;
}

/* ============================================
   BORDER TOKENS
   ============================================ */

:root {
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  --border-width-default: 1px;
  --border-width-thick: 2px;
}

/* ============================================
   SHADOW TOKENS
   ============================================ */

:root {
  /* === SUBTLE FLOATING SHADOWS === */
  --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 rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.05), 0 4px 6px rgba(0,0,0,0.03);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.06), 0 8px 10px rgba(0,0,0,0.04);

  /* === FOCUS RING (blue accent) === */
  --ring-offset: 2px;
  --ring-width: 2px;
  --ring-color: rgba(37, 99, 235, 0.5);

  /* Glow for focus states (legacy) */
  --shadow-focus: 0 0 0 3px var(--color-accent-muted);
  --shadow-focus-error: 0 0 0 3px var(--color-error-muted);
}

/* ============================================
   ANIMATION TOKENS
   ============================================ */

:root {
  /* === DURATIONS === */
  --duration-instant: 75ms;
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
  --duration-slower: 600ms;

  /* === EASING === */
  --ease-linear: linear;
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-bounce: cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 0ms;
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
    --duration-slower: 0ms;
  }
}

/* ============================================
   Z-INDEX TOKENS
   ============================================ */

:root {
  --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;
}
