/* ============================================================
   CRM Design System — Design Tokens
   Modern enterprise SaaS palette inspired by Linear, Notion, Attio
   ============================================================ */

:root {
    /* ── Brand Colors ── */
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-300: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1; /* Main primary */
    --primary-600: #4f46e5;
    --primary-700: #4338ca;
    --primary-800: #3730a3;
    --primary-900: #312e81;

    /* ── Neutral / Slate ── */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --slate-950: #090e1a;

    /* ── Semantic Colors ── */
    --color-success: #10b981;
    --color-success-bg: rgba(16, 185, 129, 0.12);
    --color-success-border: rgba(16, 185, 129, 0.25);

    --color-warning: #f59e0b;
    --color-warning-bg: rgba(245, 158, 11, 0.12);
    --color-warning-border: rgba(245, 158, 11, 0.25);

    --color-danger: #ef4444;
    --color-danger-bg: rgba(239, 68, 68, 0.12);
    --color-danger-border: rgba(239, 68, 68, 0.25);

    --color-info: #06b6d4;
    --color-info-bg: rgba(6, 182, 212, 0.12);
    --color-info-border: rgba(6, 182, 212, 0.25);

    /* ── Lead Status Colors ── */
    --status-new: #6366f1;
    --status-contacted: #06b6d4;
    --status-qualified: #10b981;
    --status-follow_later: #f59e0b;
    --status-low_budget: #f97316;
    --status-no_answer: #94a3b8;
    --status-junk: #ef4444;

    /* ── Background Layers (Dark) ── */
    --bg-base: #0d1117; /* Deepest — page background */
    --bg-surface: #161b22; /* Cards, panels */
    --bg-elevated: #1c2128; /* Modals, dropdowns */
    --bg-overlay: #21262d; /* Hover states, inputs */
    --bg-muted: #30363d; /* Borders, dividers */

    /* ── Text ── */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #7d8590;
    --text-inverse: #0d1117;

    /* ── Border ── */
    --border-default: rgba(240, 246, 252, 0.1);
    --border-muted: rgba(240, 246, 252, 0.06);
    --border-primary: rgba(99, 102, 241, 0.4);
    --border-focus: rgba(99, 102, 241, 0.8);

    /* ── Typography ── */
    --font-sans:
        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "Fira Code", "Cascadia Code", monospace;

    --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 */

    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* ── Spacing (4px base) ── */
    --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 */

    /* ── Border Radius ── */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;

    /* ── Shadows ── */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.6);
    --shadow-primary: 0 4px 16px rgba(99, 102, 241, 0.3);
    --shadow-primary-lg: 0 8px 32px rgba(99, 102, 241, 0.4);

    /* ── Layout ── */
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
    --header-height: 60px;

    /* ── Transitions ── */
    --transition-fast: 0.1s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
    --transition-layout: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* ── Z-Index ── */
    --z-sidebar: 100;
    --z-header: 200;
    --z-overlay: 300;
    --z-modal: 400;
    --z-tooltip: 500;

    /* ── Primary Button (Default Dark) ── */
    --btn-primary-bg: rgba(99, 102, 241, 0.15);
    --btn-primary-color: var(--primary-400);
    --btn-primary-border: rgba(99, 102, 241, 0.3);
    --btn-primary-shadow: 0 8px 24px rgba(99, 102, 241, 0.1);
    --btn-primary-hover-bg: rgba(99, 102, 241, 0.25);
    --btn-primary-hover-border: rgba(99, 102, 241, 0.45);
    --btn-primary-hover-shadow: 0 8px 32px rgba(99, 102, 241, 0.2);
}

/* ═══════════════════════════════════════
   LIGHT MODE OVERRIDES
   ═══════════════════════════════════════ */
[data-theme="light"] {
    /* ── Background Layers (Light) ── */
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-overlay: #f1f5f9;
    --bg-muted: #cbd5e1;

    /* ── Text (Light) ── */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    /* ── Border (Light) ── */
    --border-default: rgba(15, 23, 42, 0.08);
    --border-muted: rgba(15, 23, 42, 0.04);
    --border-primary: rgba(99, 102, 241, 0.2);
    --border-focus: rgba(99, 102, 241, 0.5);

    /* ── Button Primary Overrides (Light) ── */
    --btn-primary-bg: var(--primary-50);
    --btn-primary-color: var(--primary-600);
    --btn-primary-border: var(--primary-200);
    --btn-primary-shadow: 0 4px 12px rgba(99, 102, 241, 0.05);
    --btn-primary-hover-bg: var(--primary-100);
    --btn-primary-hover-border: var(--primary-300);
    --btn-primary-hover-shadow: 0 4px 16px rgba(99, 102, 241, 0.1);

    /* ── Custom/Semantic adjustments for Light mode ── */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.1);
}

/* ── View Transitions API: Shine Ripple Reveal Effect ── */
::view-transition-group(root) {
    animation-duration: 500ms;
}
::view-transition-image-pair(root) {
    isolation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
    mix-blend-mode: normal !important;
    animation-fill-mode: both;
}

/* Keyframes */
@keyframes reveal-light {
    from {
        clip-path: circle(0px at var(--click-x, 50%) var(--click-y, 50%));
    }
    to {
        clip-path: circle(
            var(--click-r, 150%) at var(--click-x, 50%) var(--click-y, 50%)
        );
    }
}

@keyframes reveal-dark {
    from {
        clip-path: circle(
            var(--click-r, 150%) at var(--click-x, 50%) var(--click-y, 50%)
        );
    }
    to {
        clip-path: circle(0px at var(--click-x, 50%) var(--click-y, 50%));
    }
}

/* Theme-specific animation rules */
[data-theme="light"]::view-transition-new(root) {
    animation: 500ms cubic-bezier(0.4, 0, 0.2, 1) reveal-light both;
    z-index: 9999;
}
[data-theme="light"]::view-transition-old(root) {
    animation: none;
    z-index: 1;
}

[data-theme="dark"]::view-transition-old(root) {
    animation: 500ms cubic-bezier(0.4, 0, 0.2, 1) reveal-dark both;
    z-index: 9999;
}
[data-theme="dark"]::view-transition-new(root) {
    animation: none;
    z-index: 1;
}
