/**
 * OneMed CRM Design Tokens
 * "Clinical Modern" Design System
 * Version: 1.0.0
 */

:root {
    /* ========================================
     PRIMARY COLORS - OneMed Blue
     ======================================== */
    --primary-50: #e8f4fd;
    --primary-100: #c5e3fa;
    --primary-200: #90c8f5;
    --primary-300: #5badef;
    --primary-400: #3193e8;
    --primary-500: #1E73BE;
    /* Brand color */
    --primary-600: #1a66a8;
    --primary-700: #155a92;
    --primary-800: #104d7c;
    --primary-900: #0d3d5c;

    /* ========================================
     SECONDARY COLORS - Teal (Healthcare)
     ======================================== */
    --secondary-50: #e0f2f1;
    --secondary-100: #b2dfdb;
    --secondary-200: #80cbc4;
    --secondary-300: #4db6ac;
    --secondary-400: #26a69a;
    --secondary-500: #009688;
    --secondary-600: #00897b;
    --secondary-700: #00796b;
    --secondary-800: #00695c;
    --secondary-900: #004d40;

    /* ========================================
     SEMANTIC COLORS - Status
     ======================================== */
    /* Success - Green */
    --success-50: #ecfdf5;
    --success-100: #d1fae5;
    --success-500: #10b981;
    --success-600: #059669;
    --success-700: #047857;

    /* Warning - Amber */
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --warning-700: #b45309;

    /* Error - Red */
    --error-50: #fef2f2;
    --error-100: #fee2e2;
    --error-500: #ef4444;
    --error-600: #dc2626;
    --error-700: #b91c1c;

    /* Info - Blue */
    --info-50: #eff6ff;
    --info-100: #dbeafe;
    --info-500: #3b82f6;
    --info-600: #2563eb;
    --info-700: #1d4ed8;

    /* ========================================
     NEUTRALS - Gray Scale
     ======================================== */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* ========================================
     DARK MODE COLORS
     ======================================== */
    --dark-bg: #0f172a;
    --dark-surface: #1e293b;
    --dark-surface-elevated: #334155;
    --dark-border: #475569;
    --dark-text: #e2e8f0;
    --dark-text-muted: #cbd5e1;

    /* Navigation / Sidebar Dark Colors */
    --nav-bg-dark: #1a2332;
    --nav-bg-medium: #2d3748;
    --nav-text-muted: #a0aec0;
    --nav-border-dark: #4a5568;

    /* ========================================
     TYPOGRAPHY
     ======================================== */
    /* Font Families */
    --font-display: 'Poppins', system-ui, -apple-system, sans-serif;
    --font-body: 'Roboto', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira 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 */
    --text-5xl: 3rem;
    /* 48px */

    /* Line Heights */
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;

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

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

    /* ========================================
     BORDER RADIUS
     ======================================== */
    --radius-none: 0;
    --radius-sm: 0.25rem;
    /* 4px */
    --radius-md: 0.5rem;
    /* 8px */
    --radius-lg: 0.75rem;
    /* 12px */
    --radius-xl: 1rem;
    /* 16px */
    --radius-2xl: 1.5rem;
    /* 24px */
    --radius-full: 9999px;
    /* Pills */

    /* ========================================
     SHADOWS
     ======================================== */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);

    /* Focus ring */
    --ring-width: 3px;
    --ring-color: var(--primary-100);
    --ring-offset: 2px;

    /* ========================================
     TRANSITIONS & ANIMATIONS
     ======================================== */
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 350ms;
    --duration-slower: 500ms;

    --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-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);

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

    /* ========================================
     BREAKPOINTS (for reference)
     ======================================== */
    --bp-sm: 640px;
    --bp-md: 768px;
    --bp-lg: 1024px;
    --bp-xl: 1280px;
    --bp-2xl: 1536px;
}

/* ========================================
   SEMANTIC COLORS - Theme Aware
   Configure these FIRST so they have defaults
   ======================================== */
:root,
.body-light,
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #4b5563;

    /* Semantic app-level tokens (light defaults) */
    --app-bg: #eaeef3;
    --app-surface: #ffffff;
    --app-surface-elevated: #f9fafb;
    --app-text: #626262;
    --app-text-heading: #2c2c2c;
    --app-text-muted: #6b7280;
    --app-border: #e5e7eb;
    --app-header-bg: #ffffff;
    --app-aside-bg: #ffffff;
}

/* Dark mode overrides */
.body-dark,
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --border-color: #475569;
    --text-primary: #e2e8f0;
    --text-secondary: #cbd5e1;

    /* Semantic app-level tokens (dark overrides) */
    --app-bg: var(--dark-bg);
    --app-surface: var(--dark-surface);
    --app-surface-elevated: var(--dark-surface-elevated);
    --app-text: var(--dark-text);
    --app-text-heading: #f7fafc;
    --app-text-muted: #9ca3af;
    --app-border: var(--dark-border);
    --app-header-bg: var(--dark-bg);
    --app-aside-bg: var(--dark-bg);

    /* Adjust shadows for dark mode */
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

/* ========================================
   TOKEN ALIASES — Analytics & Widget vars
   These map legacy var names to design tokens
   ======================================== */
:root {
    --text-muted: var(--app-text-muted);
    --text-color: var(--app-text);
    --box-bg: var(--app-surface);
    --box-bg-alt: var(--app-surface-elevated);
    --primary: var(--primary-500);
    --bg-tertiary: var(--gray-100);
    --bg-secondary: var(--gray-50);

    /* --color-* aliases (198 refs in views, were undefined — P2 audit fix)
       Maps to existing design tokens so Tailwind arbitrary values like
       tw-text-[var(--color-primary)] resolve correctly in both modes. */
    --color-primary: var(--primary-500);
    --color-text: var(--app-text);
    --color-text-muted: var(--app-text-muted);
    --color-bg: var(--app-bg);
    --color-surface: var(--app-surface);
    --color-border: var(--app-border);
    --color-link: var(--primary-500);
    --color-hover: var(--primary-400);
}