/*
 * Runtime Web – Unified Serverless Framework for Full-Stack TypeScript Applications
 * Documentation: https://runtimeweb.com/docs/getting-started
 *
 * @template: ai-chat
 */

/**
 * Design System Tokens
 *
 * CSS custom properties for the AI Chat UI design system.
 * Provides consistent colors, typography, spacing, shadows, and animations.
 *
 * Usage:
 *   - Import this file before other stylesheets
 *   - Reference tokens via var(--token-name)
 *   - Dark theme automatically applies via prefers-color-scheme
 *
 * @requirements 1.1, 1.2, 1.3, 1.4, 1.5, 1.7
 */

:root {
    /* ============================================
   * COLOR PALETTE
   * Raw color values - use semantic tokens below
   * ============================================ */

    /* Primary (Blue) */
    --color-primary-50: #eff6ff;
    --color-primary-100: #dbeafe;
    --color-primary-200: #bfdbfe;
    --color-primary-300: #93c5fd;
    --color-primary-400: #60a5fa;
    --color-primary-500: #3b82f6;
    --color-primary-600: #2563eb;
    --color-primary-700: #1d4ed8;
    --color-primary-800: #1e40af;
    --color-primary-900: #1e3a8a;

    /* Neutral (Gray) */
    --color-neutral-50: #fafafa;
    --color-neutral-100: #f4f4f5;
    --color-neutral-200: #e4e4e7;
    --color-neutral-300: #d4d4d8;
    --color-neutral-400: #a1a1aa;
    --color-neutral-500: #71717a;
    --color-neutral-600: #52525b;
    --color-neutral-700: #3f3f46;
    --color-neutral-800: #27272a;
    --color-neutral-900: #18181b;
    --color-neutral-950: #09090b;

    /* Success (Green) */
    --color-success-50: #f0fdf4;
    --color-success-100: #dcfce7;
    --color-success-200: #bbf7d0;
    --color-success-300: #86efac;
    --color-success-400: #4ade80;
    --color-success-500: #22c55e;
    --color-success-600: #16a34a;
    --color-success-700: #15803d;

    /* Error (Red) */
    --color-error-50: #fef2f2;
    --color-error-100: #fee2e2;
    --color-error-200: #fecaca;
    --color-error-300: #fca5a5;
    --color-error-400: #f87171;
    --color-error-500: #ef4444;
    --color-error-600: #dc2626;
    --color-error-700: #b91c1c;

    /* Warning (Amber) */
    --color-warning-50: #fffbeb;
    --color-warning-100: #fef3c7;
    --color-warning-200: #fde68a;
    --color-warning-300: #fcd34d;
    --color-warning-400: #fbbf24;
    --color-warning-500: #f59e0b;
    --color-warning-600: #d97706;
    --color-warning-700: #b45309;


    /* ============================================
   * SEMANTIC COLOR TOKENS - LIGHT THEME
   * Use these tokens in components
   * ============================================ */

    /* Background Colors */
    --color-bg-primary: var(--color-neutral-50);
    --color-bg-secondary: #ffffff;
    --color-bg-tertiary: var(--color-neutral-100);
    --color-bg-inverse: var(--color-neutral-900);

    /* Text Colors */
    --color-text-primary: var(--color-neutral-900);
    --color-text-secondary: var(--color-neutral-600);
    --color-text-tertiary: var(--color-neutral-400);
    --color-text-inverse: #ffffff;
    --color-text-link: var(--color-primary-600);
    --color-text-link-hover: var(--color-primary-700);

    /* Border Colors */
    --color-border: var(--color-neutral-200);
    --color-border-hover: var(--color-neutral-300);
    --color-border-focus: var(--color-primary-500);
    --color-border-error: var(--color-error-500);

    /* Interactive Colors */
    --color-interactive-primary: var(--color-primary-600);
    --color-interactive-primary-hover: var(--color-primary-700);
    --color-interactive-primary-active: var(--color-primary-800);
    --color-interactive-disabled: var(--color-neutral-300);

    /* Message Colors */
    --color-msg-user-bg: var(--color-primary-600);
    --color-msg-user-text: #ffffff;
    --color-msg-assistant-bg: var(--color-bg-secondary);
    --color-msg-assistant-text: var(--color-text-primary);
    --color-msg-assistant-border: var(--color-border);

    /* State Colors */
    --color-state-success-bg: var(--color-success-50);
    --color-state-success-text: var(--color-success-700);
    --color-state-success-border: var(--color-success-200);
    --color-state-error-bg: var(--color-error-50);
    --color-state-error-text: var(--color-error-700);
    --color-state-error-border: var(--color-error-200);
    --color-state-warning-bg: var(--color-warning-50);
    --color-state-warning-text: var(--color-warning-700);
    --color-state-warning-border: var(--color-warning-200);

    /* Focus Ring */
    --color-focus-ring: var(--color-primary-500);
    --color-focus-ring-offset: var(--color-bg-secondary);

    /* ============================================
   * TYPOGRAPHY SCALE
   * Based on 16px base with 1.25 ratio
   * ============================================ */

    /* Font Families */
    --font-family-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-family-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Monaco, Consolas, monospace;

    /* Font Sizes */
    --font-size-xs: 0.75rem;
    /* 12px */
    --font-size-sm: 0.875rem;
    /* 14px */
    --font-size-base: 1rem;
    /* 16px */
    --font-size-lg: 1.125rem;
    /* 18px */
    --font-size-xl: 1.25rem;
    /* 20px */
    --font-size-2xl: 1.5rem;
    /* 24px */
    --font-size-3xl: 1.875rem;
    /* 30px */
    --font-size-4xl: 2.25rem;
    /* 36px */

    /* Line Heights */
    --line-height-none: 1;
    --line-height-tight: 1.25;
    --line-height-snug: 1.375;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;
    --line-height-loose: 2;

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

    /* Letter Spacing */
    --letter-spacing-tighter: -0.05em;
    --letter-spacing-tight: -0.025em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.025em;
    --letter-spacing-wider: 0.05em;


    /* ============================================
   * SPACING SCALE
   * Based on 4px (0.25rem) 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 */

    /* ============================================
   * BORDER RADIUS
   * ============================================ */

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

    /* ============================================
   * 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);
    --shadow-none: 0 0 #0000;

    /* Component-specific shadows */
    --shadow-message: 0 1px 3px 0 rgb(0 0 0 / 0.08);
    --shadow-input-focus: 0 0 0 3px rgb(59 130 246 / 0.15);
    --shadow-button-focus: 0 0 0 3px rgb(59 130 246 / 0.25);
    --shadow-dropdown: 0 4px 12px rgb(0 0 0 / 0.15);

    /* ============================================
   * ANIMATION TIMING
   * ============================================ */

    /* Durations */
    --duration-instant: 0ms;
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 350ms;
    --duration-slower: 500ms;

    /* 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-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);

    /* ============================================
   * LAYOUT TOKENS
   * ============================================ */

    --chat-max-width: 800px;
    --chat-min-width: 320px;
    --input-max-height: 200px;
    --input-min-height: 44px;
    --header-height: 64px;
    --footer-min-height: 80px;
    --touch-target-min: 44px;

    /* ============================================
   * Z-INDEX SCALE
   * ============================================ */

    --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;
}


/* ============================================
 * DARK THEME
 * Automatically applied via prefers-color-scheme
 * ============================================ */

@media (prefers-color-scheme: dark) {
    :root {
        /* Background Colors */
        --color-bg-primary: var(--color-neutral-900);
        --color-bg-secondary: var(--color-neutral-800);
        --color-bg-tertiary: var(--color-neutral-700);
        --color-bg-inverse: var(--color-neutral-50);

        /* Text Colors */
        --color-text-primary: var(--color-neutral-50);
        --color-text-secondary: var(--color-neutral-400);
        --color-text-tertiary: var(--color-neutral-500);
        --color-text-inverse: var(--color-neutral-900);
        --color-text-link: var(--color-primary-400);
        --color-text-link-hover: var(--color-primary-300);

        /* Border Colors */
        --color-border: var(--color-neutral-700);
        --color-border-hover: var(--color-neutral-600);
        --color-border-focus: var(--color-primary-400);
        --color-border-error: var(--color-error-400);

        /* Interactive Colors */
        --color-interactive-primary: var(--color-primary-500);
        --color-interactive-primary-hover: var(--color-primary-400);
        --color-interactive-primary-active: var(--color-primary-600);
        --color-interactive-disabled: var(--color-neutral-600);

        /* Message Colors */
        --color-msg-user-bg: var(--color-primary-600);
        --color-msg-user-text: #ffffff;
        --color-msg-assistant-bg: var(--color-neutral-800);
        --color-msg-assistant-text: var(--color-neutral-100);
        --color-msg-assistant-border: var(--color-neutral-700);

        /* State Colors */
        --color-state-success-bg: rgb(34 197 94 / 0.15);
        --color-state-success-text: var(--color-success-400);
        --color-state-success-border: rgb(34 197 94 / 0.3);
        --color-state-error-bg: rgb(239 68 68 / 0.15);
        --color-state-error-text: var(--color-error-400);
        --color-state-error-border: rgb(239 68 68 / 0.3);
        --color-state-warning-bg: rgb(245 158 11 / 0.15);
        --color-state-warning-text: var(--color-warning-400);
        --color-state-warning-border: rgb(245 158 11 / 0.3);

        /* Focus Ring */
        --color-focus-ring: var(--color-primary-400);
        --color-focus-ring-offset: var(--color-bg-secondary);

        /* Shadows - darker for dark mode */
        --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.2);
        --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);
        --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
        --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.5);
        --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.2);

        /* Component-specific shadows */
        --shadow-message: 0 1px 3px 0 rgb(0 0 0 / 0.3);
        --shadow-input-focus: 0 0 0 3px rgb(59 130 246 / 0.25);
        --shadow-button-focus: 0 0 0 3px rgb(59 130 246 / 0.35);
        --shadow-dropdown: 0 4px 12px rgb(0 0 0 / 0.4);
    }
}
