/**
 * RADEXEL Design System - Design Tokens
 *
 * Complete CSS custom property system for VibeOps.
 * Supports light (default) and dark themes via [data-theme="dark"].
 * All colors in the system MUST reference these tokens.
 *
 * Brand Colors:
 *   Primary Blue:  #2C5CA3
 *   Accent Green:  #20B685
 *   Gray:          #557482
 *   Text:          #444444
 *
 * @see knowledge/10_IMPLEMENTATION_PLAN.md Phase 1.2
 */

/* ==========================================================================
   Light Theme (Default)
   ========================================================================== */

:root {
  /* ----- Brand ----- */
  --rdx-blue: #2C5CA3;
  --rdx-blue-light: #4A7BC4;
  --rdx-blue-dark: #1E4080;
  --rdx-green: #20B685;
  --rdx-green-light: #30D49F;
  --rdx-green-dark: #189068;
  --rdx-gray: #557482;

  /* ----- Surfaces ----- */
  --color-bg: #FFFFFF;
  --color-bg-secondary: #F8F9FA;
  --color-bg-tertiary: #F0F2F5;
  --color-surface: #FFFFFF;
  --color-surface-hover: #F5F7FA;
  --color-surface-active: #EDF0F5;

  /* ----- Text ----- */
  --color-text: #212529;
  --color-text-secondary: #6C757D;
  --color-text-muted: #ADB5BD;
  --color-text-inverse: #FFFFFF;

  /* ----- Borders ----- */
  --color-border: #DEE2E6;
  --color-border-light: #E9ECEF;
  --color-border-focus: var(--rdx-blue);

  /* ----- Semantic Colors ----- */
  --color-success: #20B685;
  --color-success-light: #E6F9F2;
  --color-success-dark: #189068;
  --color-warning: #F0AD4E;
  --color-warning-light: #FFF3E0;
  --color-warning-dark: #C88B3A;
  --color-danger: #DC3545;
  --color-danger-light: #FDEAEA;
  --color-danger-dark: #B02A37;
  --color-info: #2C5CA3;
  --color-info-light: #E8EFF8;
  --color-info-dark: #1E4080;

  /* ----- Shadows ----- */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.15);
  --shadow-focus: 0 0 0 3px rgba(44, 92, 163, 0.2);
  --shadow-bottom-nav: 0 -4px 16px rgba(0, 0, 0, 0.08);

  /* ----- Layout ----- */
  --topbar-height: 56px;
  --left-sidebar-width: 280px;
  --right-sidebar-width: 52px;
  --bottom-nav-height: 56px;
  --content-max-width: 1200px;

  /* ----- Typography ----- */
  --font-sans: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont,
    'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas,
    'Liberation Mono', Menlo, monospace;

  --font-size-xs: 0.75rem;     /* 12px */
  --font-size-sm: 0.8125rem;   /* 13px */
  --font-size-base: 0.875rem;  /* 14px */
  --font-size-md: 1rem;        /* 16px */
  --font-size-lg: 1.125rem;    /* 18px */
  --font-size-xl: 1.25rem;     /* 20px */
  --font-size-2xl: 1.5rem;     /* 24px */
  --font-size-3xl: 2rem;       /* 32px */

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

  --line-height-tight: 1.25;
  --line-height-base: 1.5;
  --line-height-relaxed: 1.75;

  --letter-spacing-tight: -0.01em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.02em;

  /* ----- Spacing (8px grid) ----- */
  --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;

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

  /* ----- Transitions ----- */
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.27, 1.55);
  --duration-fast: 150ms;
  --duration-base: 200ms;
  --duration-slow: 300ms;

  /* ----- Z-index Scale ----- */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 150;
  --z-modal-backdrop: 200;
  --z-modal: 210;
  --z-toast: 300;
  --z-tooltip: 400;

  /* ----- Skeleton Loading ----- */
  --skeleton-base: #E9ECEF;
  --skeleton-shine: #F8F9FA;

  /* ----- Chat Bubbles ----- */
  --chat-user-bg: var(--rdx-blue);
  --chat-user-text: #FFFFFF;
  --chat-ai-bg: var(--color-bg-secondary);
  --chat-ai-text: var(--color-text);

  /* ----- Scrollbar ----- */
  --scrollbar-width: 6px;
  --scrollbar-track: transparent;
  --scrollbar-thumb: #CED4DA;
  --scrollbar-thumb-hover: #ADB5BD;

  /* ----- Compatibility Aliases ----- */
  --color-primary: var(--rdx-blue);
  --color-primary-hover: var(--rdx-blue-dark);
  --color-primary-light: var(--color-info-light);
  --color-error: var(--color-danger);
  --color-error-light: var(--color-danger-light);
  --font-family: var(--font-sans);
  --font-family-mono: var(--font-mono);
  --header-height: var(--topbar-height);
  --sidebar-width: var(--left-sidebar-width);
  --transition-fast: var(--duration-fast) var(--ease-default);
  --transition-normal: var(--duration-base) var(--ease-default);
  --transition-slow: var(--duration-slow) var(--ease-default);
}


/* ==========================================================================
   Dark Theme (Explicit)
   ========================================================================== */

:root[data-theme="dark"] {
  /* Surfaces */
  --color-bg: #1A1A2E;
  --color-bg-secondary: #16213E;
  --color-bg-tertiary: #0F3460;
  --color-surface: #1E2746;
  --color-surface-hover: #253255;
  --color-surface-active: #2C3B64;

  /* Text */
  --color-text: #E8E8EC;
  --color-text-secondary: #A0A4B0;
  --color-text-muted: #6B7080;
  --color-text-inverse: #1A1A2E;

  /* Borders */
  --color-border: #2C3550;
  --color-border-light: #222D45;
  --color-border-focus: var(--rdx-blue-light);

  /* Semantic - slightly brighter for dark bg */
  --color-success-light: rgba(32, 182, 133, 0.15);
  --color-warning-light: rgba(240, 173, 78, 0.15);
  --color-danger-light: rgba(220, 53, 69, 0.15);
  --color-info-light: rgba(44, 92, 163, 0.15);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --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 48px rgba(0, 0, 0, 0.6);
  --shadow-focus: 0 0 0 3px rgba(74, 123, 196, 0.3);
  --shadow-bottom-nav: 0 -4px 16px rgba(0, 0, 0, 0.3);

  /* Skeleton */
  --skeleton-base: #2C3550;
  --skeleton-shine: #354060;

  /* Chat */
  --chat-ai-bg: var(--color-surface);

  /* Scrollbar */
  --scrollbar-thumb: #3A4566;
  --scrollbar-thumb-hover: #4A5880;

  /* Compatibility */
  --color-primary-light: rgba(44, 92, 163, 0.2);
  --color-error-light: rgba(220, 53, 69, 0.15);
}


/* ==========================================================================
   System Preference Fallback
   When no explicit data-theme is set, respect OS dark mode preference.
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --color-bg: #1A1A2E;
    --color-bg-secondary: #16213E;
    --color-bg-tertiary: #0F3460;
    --color-surface: #1E2746;
    --color-surface-hover: #253255;
    --color-surface-active: #2C3B64;
    --color-text: #E8E8EC;
    --color-text-secondary: #A0A4B0;
    --color-text-muted: #6B7080;
    --color-text-inverse: #1A1A2E;
    --color-border: #2C3550;
    --color-border-light: #222D45;
    --color-border-focus: var(--rdx-blue-light);
    --color-success-light: rgba(32, 182, 133, 0.15);
    --color-warning-light: rgba(240, 173, 78, 0.15);
    --color-danger-light: rgba(220, 53, 69, 0.15);
    --color-info-light: rgba(44, 92, 163, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --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 48px rgba(0, 0, 0, 0.6);
    --shadow-focus: 0 0 0 3px rgba(74, 123, 196, 0.3);
    --shadow-bottom-nav: 0 -4px 16px rgba(0, 0, 0, 0.3);
    --skeleton-base: #2C3550;
    --skeleton-shine: #354060;
    --chat-ai-bg: var(--color-surface);
    --scrollbar-thumb: #3A4566;
    --scrollbar-thumb-hover: #4A5880;
    --color-primary-light: rgba(44, 92, 163, 0.2);
    --color-error-light: rgba(220, 53, 69, 0.15);
  }
}


/* ==========================================================================
   Theme Transition (Smooth 300ms switch)
   Applied temporarily by JS when toggling themes.
   ========================================================================== */

html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color 0.3s var(--ease-default),
    color 0.3s var(--ease-default),
    border-color 0.3s var(--ease-default),
    box-shadow 0.3s var(--ease-default),
    fill 0.3s var(--ease-default),
    stroke 0.3s var(--ease-default) !important;
}
