/* ============================================================
   CSS Design Tokens — AgencySync Design System
   License Agency CRM
   ============================================================ */

:root {
    /* ── Brand — AgencySync Palette ── */
    --brand-primary: #22D3EE;
    --brand-primary-hover: #06B6D4;
    --brand-primary-light: rgba(34, 211, 238, 0.12);

    /* ── Structural Colors ── */
    --brand-deep-blue: #2563EB;
    --brand-midnight: #0A1F44;

    /* ── Light Mode (Default) ── */
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F1F5F9;
    --bg-grouped: #F8FAFC;

    --surface: #FFFFFF;
    --surface-hover: #F1F5F9;
    --surface-active: #E2E8F0;
    --surface-elevated: #FFFFFF;

    --text-primary: #111827;
    --text-secondary: #64748B;
    --text-tertiary: #94A3B8;
    --text-on-brand: #0A1F44;

    --separator: rgba(15, 23, 42, 0.08);
    --separator-opaque: #CBD5E1;

    --fill-primary: rgba(15, 23, 42, 0.14);
    --fill-secondary: rgba(15, 23, 42, 0.10);
    --fill-tertiary: rgba(15, 23, 42, 0.06);
    --fill-quaternary: rgba(15, 23, 42, 0.03);

    /* ── System Colors ── */
    --color-red: #EF4444;
    --color-orange: #F59E0B;
    --color-yellow: #EAB308;
    --color-green: #22C55E;
    --color-teal: #14B8A6;
    --color-blue: #2563EB;
    --color-indigo: #6366F1;
    --color-purple: #A855F7;
    --color-pink: #EC4899;
    --color-cyan: #22D3EE;

    /* ── Shadows ── */
    --shadow-sm: 0 1px 2px rgba(10, 31, 68, 0.04), 0 1px 3px rgba(10, 31, 68, 0.06);
    --shadow-md: 0 4px 12px rgba(10, 31, 68, 0.06), 0 1px 4px rgba(10, 31, 68, 0.04);
    --shadow-lg: 0 10px 40px rgba(10, 31, 68, 0.08), 0 2px 8px rgba(10, 31, 68, 0.04);
    --shadow-xl: 0 20px 60px rgba(10, 31, 68, 0.10), 0 4px 16px rgba(10, 31, 68, 0.05);

    /* ── Radius ── */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* ── Typography — General Sans (primary), Inter (secondary) ── */
    --font-sans: "General Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;

    --font-scale: 1;
    --text-xs: calc(11px * var(--font-scale));
    --text-sm: calc(13px * var(--font-scale));
    --text-base: calc(15px * var(--font-scale));
    --text-md: calc(17px * var(--font-scale));
    --text-lg: calc(20px * var(--font-scale));
    --text-xl: calc(24px * var(--font-scale));
    --text-2xl: calc(28px * var(--font-scale));
    --text-3xl: calc(34px * var(--font-scale));

    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    /* ── Spacing ── */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* ── Layout ── */
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 72px;
    --header-height: 56px;
    --content-max-width: 1200px;

    /* ── Easing ──
       One scale, defined once. These were previously split across two :root
       blocks, the second silently redefining --transition-fast. */
    --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out-smooth: cubic-bezier(0.4, 0, 0.2, 1);

    /* The iOS sheet curve. Already the best easing in the codebase — it drove
       the mobile sheet — but it was an inline literal. Use it wherever a
       surface moves into place. */
    --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);

    /* ── Transitions ── */
    --transition-fast: 150ms var(--ease-out-quint);
    --transition-normal: 250ms var(--ease-out-quint);
    --transition-drawer: 320ms var(--ease-out-quint);
    --transition-sidebar: 280ms var(--ease-sheet);
    --transition-native: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);

    /* ── Gradient ── */
    --gradient-primary: linear-gradient(135deg, #2563EB, #22D3EE);

    /* ── Glassmorphism surfaces ── */
    --surface-translucent: rgba(255, 255, 255, 0.72);

    /* ── Z-index layers ── */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-overlay: 300;
    --z-modal: 400;
    --z-toast: 500;
}


/* ============================================================
   Dark Mode — Midnight Navy (AgencySync)
   ============================================================ */

[data-theme="dark"] {
    --bg-primary: #070E1A;
    --bg-secondary: #0A1F44;
    --bg-tertiary: #111827;
    --bg-grouped: #070E1A;

    --surface: #0D1830;
    --surface-hover: #142240;
    --surface-active: #1E3055;
    --surface-elevated: #111827;

    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-tertiary: rgba(148, 163, 184, 0.4);
    --text-on-brand: #0A1F44;

    --separator: rgba(148, 163, 184, 0.08);
    --separator-opaque: rgba(148, 163, 184, 0.12);

    --fill-primary: rgba(148, 163, 184, 0.18);
    --fill-secondary: rgba(148, 163, 184, 0.12);
    --fill-tertiary: rgba(148, 163, 184, 0.08);
    --fill-quaternary: rgba(148, 163, 184, 0.04);

    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(148, 163, 184, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(148, 163, 184, 0.04);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(148, 163, 184, 0.04);
    --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(148, 163, 184, 0.05);

    --gradient-primary: linear-gradient(135deg, #2563EB, #22D3EE);
    --brand-primary-glow: 0 0 20px rgba(34, 211, 238, 0.25);
}

/* ============================================================
   Fluid Motion System & View Transitions API
   ============================================================ */

/* Easing and transition tokens are defined once, in the :root block above. */

@view-transition {
    navigation: auto;
}

/* Only the page content cross-fades between navigations.
   The shell is excluded below via view-transition-name, so the sidebar and
   topbar stay put instead of fading with everything else — which is what makes
   a multi-page app feel like a single one. */
::view-transition-old(root) {
    animation: 180ms var(--ease-out-quint) both fade-out-slide;
}

::view-transition-new(root) {
    animation: 240ms var(--ease-out-quint) both fade-in-slide;
}

/* Named so they are lifted out of the root snapshot and persist across
   navigation rather than being part of the cross-fade. */
.sidebar     { view-transition-name: app-sidebar; }
.top-header  { view-transition-name: app-topbar; }

::view-transition-old(app-sidebar),
::view-transition-new(app-sidebar),
::view-transition-old(app-topbar),
::view-transition-new(app-topbar) {
    animation: none;
    mix-blend-mode: normal;
}

@keyframes fade-out-slide {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-3px); }
}

@keyframes fade-in-slide {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
