/**
 * KLIMOV RED Design System — Design Tokens
 *
 * Единственный источник правды для всех переменных.
 * НЕ РЕДАКТИРОВАТЬ напрямую — все изменения через этот файл.
 */

:root {
  color-scheme: light dark;

  /* ========================================
     BRAND COLORS
     ======================================== */
  --primary: #f24c3f;
  --primary-hover: #d63f33;
  --primary-dark: #b93c35;
  --primary-rgb: 242, 76, 63;
  --primary-muted: rgba(242, 76, 63, 0.1);

  /* ========================================
     SEMANTIC COLORS
     ======================================== */
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --info: #3b82f6;
  --purple: #8b5cf6;
  --cyan: #06b6d4;

  /* Status backgrounds */
  --success-bg: rgba(22, 163, 74, 0.1);
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger-bg: rgba(220, 38, 38, 0.1);
  --info-bg: rgba(59, 130, 246, 0.1);

  /* Search highlight */
  --highlight-bg: #fde68a;
  --highlight-bg-dark: #f59e0b;
  --highlight-text-dark: #1a1a1a;

  /* Premium gradient (for "All folders" icon etc.) */
  --gradient-premium: linear-gradient(135deg, #6b8cff 0%, #8b5cf6 50%, #d946ef 100%);

  /* ========================================
     TEXT COLORS
     ======================================== */
  --text-primary: #000000;
  --text-secondary: #2d2d2d;
  --text-muted: #6b7280;
  --text-success: #16a34a;
  --text-warning: #d97706;
  --text-danger: #dc2626;
  --text-info: #3b82f6;
  --text-purple: var(--purple);

  /* ========================================
     SURFACES & BACKGROUNDS
     ======================================== */
  --background: #ffffff;
  --foreground: #2d2d2d;
  --surface-primary: #ffffff;
  --surface-secondary: #f9fafb;
  --surface-tertiary: #f3f4f6;
  --surface-elevated: #ffffff;

  /* Aliases (for backwards compatibility) */
  --bg-white: #ffffff;
  --bg-secondary: #f3f4f6;
  --background-secondary: #f3f4f6;
  --background-hover: #f3f4f6;
  --card-bg: #ffffff;
  --dropdown-bg: #ffffff;
  --input-bg: #ededed;
  --primary-bg: rgba(242, 76, 63, 0.1);
  --black: #000000;
  --secondary: #6b7280;
  --destructive: #b93c35;
  --error: #dc2626;

  /* Accent colors */
  --accent-primary: #f24c3f;
  --accent-primary-muted: rgba(242, 76, 63, 0.1);
  --accent-warning: #f59e0b;

  /* Color aliases (legacy naming) */
  --color-primary: #f24c3f;
  --color-primary-50: rgba(242, 76, 63, 0.05);
  --color-primary-100: rgba(242, 76, 63, 0.1);
  --color-primary-200: rgba(242, 76, 63, 0.2);
  --color-primary-light: rgba(242, 76, 63, 0.1);
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-surface-elevated: #ffffff;
  --color-surface-hover: #f3f4f6;
  --color-border: rgba(45, 45, 45, 0.1);
  --color-text: #000000;
  --color-text-muted: #6b7280;
  --color-neutral-200: #e5e7eb;
  --color-neutral-400: #9ca3af;
  --color-neutral-500: #6b7280;
  --color-neutral-700: #374151;
  --color-neutral-900: #111827;

  /* ========================================
     BORDERS
     ======================================== */
  --border: rgba(45, 45, 45, 0.1);
  --border-color: rgba(45, 45, 45, 0.1);
  --border-secondary: rgba(45, 45, 45, 0.05);

  /* ========================================
     INTERACTIVE STATES
     ======================================== */
  --row-hover: #f1f5f9;
  --cell-hover: #e2e8f0;
  --cell-active: #cbd5e1;
  --editing-bg: rgba(242, 76, 63, 0.15);
  --hover-bg: #f3f4f6;

  /* ========================================
     SPACING (4pt/8pt grid)
     ======================================== */
  --spacing-0: 0;
  --spacing-1: 4px;
  --spacing-2: 8px;
  --spacing-3: 12px;
  --spacing-4: 16px;
  --spacing-5: 20px;
  --spacing-6: 24px;
  --spacing-8: 32px;
  --spacing-10: 40px;
  --spacing-12: 48px;

  /* Spacing aliases (legacy naming) */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* ========================================
     TYPOGRAPHY
     ======================================== */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --font-size-2xs: 10px;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 28px;
  --font-size-4xl: 32px;

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

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

  /* ========================================
     BORDER RADIUS
     ======================================== */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;

  /* ========================================
     SHADOWS
     ======================================== */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.2);
  --shadow-primary: 0 2px 8px rgba(220, 38, 38, 0.3);

  /* ========================================
     TRANSITIONS
     ======================================== */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ========================================
     Z-INDEX SCALE
     ======================================== */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-popover: 400;
  --z-tooltip: 500;
  --z-toast: 600;
}

/* ========================================
   DARK MODE
   ======================================== */

html[data-theme="dark"] {
  --primary: #ff6b5e;
  --primary-hover: #ff8578;
  --primary-dark: #ff5243;
  --primary-muted: rgba(255, 107, 94, 0.15);

  --text-primary: #f5f5f5;
  --text-secondary: #e5e5e5;
  --text-muted: #9ca3af;
  --text-success: #4ade80;
  --text-warning: #fbbf24;
  --text-danger: #f87171;
  --text-info: #60a5fa;
  --text-purple: #c4b5fd;

  --background: #0f0f0f;
  --foreground: #1a1a1a;
  --surface-primary: #1a1a1a;
  --surface-secondary: #262626;
  --surface-tertiary: #333333;
  --surface-elevated: #2a2a2a;

  --bg-white: #1a1a1a;
  --bg-secondary: #262626;
  --background-secondary: #262626;
  --background-hover: #1f1f1f;
  --card-bg: #1a1a1a;
  --dropdown-bg: #1a1a1a;
  --input-bg: #1a1a1a;
  --secondary: #2a2a2a;
  --destructive: #ff5243;

  --border: rgba(255, 255, 255, 0.1);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-secondary: rgba(255, 255, 255, 0.05);

  /* Accent colors - dark mode */
  --accent-primary: #ff6b5e;
  --accent-primary-muted: rgba(255, 107, 94, 0.15);

  /* Shadow - dark mode */
  --shadow-primary: 0 2px 8px rgba(255, 107, 94, 0.4);

  --row-hover: rgba(255, 255, 255, 0.05);
  --cell-hover: rgba(255, 255, 255, 0.1);
  --cell-active: rgba(255, 255, 255, 0.15);
  --hover-bg: rgba(255, 255, 255, 0.05);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

  /* Search highlight (dark mode) */
  --highlight-bg: rgba(255, 160, 60, 0.3);
}

/* ========================================
   AUTO MODE (follows system preference)
   ======================================== */

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --primary: #ff6b5e;
    --primary-hover: #ff8578;
    --primary-dark: #ff5243;
    --primary-muted: rgba(255, 107, 94, 0.15);

    --text-primary: #f5f5f5;
    --text-secondary: #e5e5e5;
    --text-muted: #9ca3af;
    --text-success: #4ade80;
    --text-warning: #fbbf24;
    --text-danger: #f87171;
    --text-info: #60a5fa;
    --text-purple: #c4b5fd;

    --background: #0f0f0f;
    --foreground: #1a1a1a;
    --surface-primary: #1a1a1a;
    --surface-secondary: #262626;
    --surface-tertiary: #333333;
    --surface-elevated: #2a2a2a;

    --bg-white: #1a1a1a;
    --bg-secondary: #262626;
    --background-secondary: #262626;
    --background-hover: #1f1f1f;
    --card-bg: #1a1a1a;
    --dropdown-bg: #1a1a1a;
    --input-bg: #1a1a1a;
    --secondary: #2a2a2a;
    --destructive: #ff5243;

    --border: rgba(255, 255, 255, 0.1);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-secondary: rgba(255, 255, 255, 0.05);

    --accent-primary: #ff6b5e;
    --accent-primary-muted: rgba(255, 107, 94, 0.15);

    --row-hover: rgba(255, 255, 255, 0.05);
    --cell-hover: rgba(255, 255, 255, 0.1);
    --cell-active: rgba(255, 255, 255, 0.15);
    --hover-bg: rgba(255, 255, 255, 0.05);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-primary: 0 2px 8px rgba(255, 107, 94, 0.4);

    --highlight-bg: rgba(255, 160, 60, 0.3);
  }
}
