/* =====================================================
   PATDRAW GLOBAL STYLES
   Design tokens, CSS reset, and base styles
   ===================================================== */

/* =====================================================
   CSS RESET & BASE
   ===================================================== */

/* Box sizing reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove default margins and paddings */
html,
body,
h1, h2, h3, h4, h5, h6,
p,
ul, ol,
figure,
blockquote,
dl, dd {
  padding: 0;
  margin: 0;
}

/* Set core root defaults */
html {
  scroll-behavior: smooth;
}

/* Set core body defaults */
body {
  min-height: 100vh;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text-primary);
  background-color: var(--color-bg-main);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Remove list styles */
ul,
ol {
  list-style: none;
}

/* Images and media */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* Inherit fonts for form controls */
input,
button,
textarea,
select {
  font: inherit;
}

/* Remove button styling */
button {
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

/* =====================================================
   DESIGN TOKENS - ROOT VARIABLES
   ===================================================== */

:root {
  /* =========================
     TYPOGRAPHY
     ========================= */
  
  /* Font families */
  --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-family-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  --font-family-serif: Georgia, 'Times New Roman', serif;
  
  /* Font sizes (rem-based scale) */
  --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 */
  --font-size-5xl: 3rem;      /* 48px */
  
  /* Font weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Line heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  --line-height-loose: 2;
  
  /* =========================
     SPACING (4px grid system)
     ========================= */
  
  --spacing-0: 0;
  --spacing-1: 0.25rem;   /* 4px */
  --spacing-2: 0.5rem;    /* 8px */
  --spacing-2-5: 0.625rem; /* 10px */
  --spacing-3: 0.75rem;   /* 12px */
  --spacing-4: 1rem;      /* 16px */
  --spacing-4-5: 1.125rem; /* 18px */
  --spacing-5: 1.25rem;   /* 20px */
  --spacing-6: 1.5rem;    /* 24px */
  --spacing-7: 1.75rem;   /* 28px */
  --spacing-8: 2rem;      /* 32px */
  --spacing-9: 2.25rem;   /* 36px */
  --spacing-10: 2.5rem;   /* 40px */
  --spacing-12: 3rem;     /* 48px */
  --spacing-14: 3.5rem;   /* 56px */
  --spacing-15: 3.75rem;  /* 60px */
  --spacing-16: 4rem;     /* 64px */
  --spacing-20: 5rem;     /* 80px */
  --spacing-24: 6rem;     /* 96px */
  
  /* =========================
     LIGHT MODE COLORS
     ========================= */
  
  /* Primary colors (Patcraft Classic Green/Sage theme) */
  --color-primary-50: #f6faf4;
  --color-primary-100: #edf5e8;
  --color-primary-200: #daebd0;
  --color-primary-300: #c1ddb0;
  --color-primary-400: #C9DDBF;  /* Main sage green accent - patcraft classic */
  --color-primary-500: #a8c896;
  --color-primary-600: #8bb474;
  --color-primary-700: #6f9a58;
  --color-primary-800: #5a7e47;
  --color-primary-900: #4a6a3c;
  
  /* Neutral colors (Warm beige/cream palette) */
  --color-neutral-50: #faf9f7;
  --color-neutral-100: #f5f3ed;
  --color-neutral-200: #e8e1cd;  /* Main beige */
  --color-neutral-300: #d6ccb0;
  --color-neutral-400: #bfb08c;
  --color-neutral-500: #a89670;
  --color-neutral-600: #8e7a5a;
  --color-neutral-700: #6f5f49;
  --color-neutral-800: #5a4e3d;
  --color-neutral-900: #494135;
  
  /* Gray scale */
  --color-gray-50: #f8f9fa;
  --color-gray-100: #f1f3f5;
  --color-gray-200: #e9ecef;
  --color-gray-300: #dee2e6;
  --color-gray-400: #ced4da;
  --color-gray-500: #adb5bd;
  --color-gray-600: #6c757d;
  --color-gray-700: #495057;
  --color-gray-800: #343a40;
  --color-gray-900: #212529;
  
  /* Semantic colors */
  --color-white: #ffffff;
  --color-black: #000000;
  --color-success: #28a745;
  --color-warning: #ffc107;
  --color-error: #dc3545;
  --color-info: #17a2b8;
  
  /* Applied color tokens */
  --color-bg-main: #ffffff;
  --color-bg-canvas: #fff7e2;  /* Light warm background for canvas */
  --color-bg-panel: rgba(232, 225, 205, 1.0);  /* Panel beige */
  --color-bg-panel-light: rgba(232, 225, 205, 0.7);
  --color-bg-tool: rgba(255, 255, 255, 0.7);
  --color-bg-tool-hover: rgba(255, 255, 255, 0.9);
  --color-bg-tool-active: #ffffff;
  
  --color-text-primary: #212529;
  --color-text-secondary: #495057;
  --color-text-muted: #6c757d;
  --color-text-disabled: #adb5bd;
  
  --color-border-default: #ced4da;
  --color-border-light: #e9ecef;
  --color-border-dark: #adb5bd;
  
  --color-accent: #C9DDBF;  /* Sage green accent - patcraft classic */
  --color-accent-light: #daebd0;
  --color-accent-dark: #a8c896;
  --color-accent-bg: rgba(201, 221, 191, 0.3);
  
  /* =========================
     DRAWING-SPECIFIC TOKENS
     ========================= */
  
  /* Canvas */
  --canvas-grid-color: rgba(0, 0, 0, 0.05);
  --canvas-grid-size: 20px;
  --canvas-ruler-bg: #f8f9fa;
  --canvas-ruler-text: #6c757d;
  
  /* Selection and handles */
  --selection-color: #C9DDBF;
  --selection-stroke-width: 2px;
  --handle-size: 8px;
  --handle-color: #ffffff;
  --handle-border: #C9DDBF;
  
  /* Drawing tools */
  --stroke-width-thin: 1px;
  --stroke-width-normal: 2px;
  --stroke-width-medium: 3px;
  --stroke-width-thick: 4px;
  --stroke-width-heavy: 6px;
  
  /* Tool states */
  --tool-outline-active: 2px solid #C9DDBF;
  --tool-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.1);
  --tool-shadow-active: 0 2px 4px rgba(0, 0, 0, 0.1);
  
  /* =========================
     BORDERS & CORNERS
     ========================= */
  
  --border-width-thin: 1px;
  --border-width-normal: 2px;
  --border-width-thick: 3px;
  
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  --border-radius-2xl: 24px;
  --border-radius-full: 9999px;
  
  /* =========================
     SHADOWS
     ========================= */
  
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 8px 12px rgba(0, 0, 0, 0.15);
  --shadow-2xl: 0 16px 24px rgba(0, 0, 0, 0.2);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);
  
  /* =========================
     TRANSITIONS
     ========================= */
  
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;
  
  /* =========================
     Z-INDEX SCALE
     ========================= */
  
  --z-canvas: 1;
  --z-panels: 10;
  --z-toolbar: 20;
  --z-dropdown: 30;
  --z-modal-backdrop: 40;
  --z-modal: 50;
  --z-tooltip: 60;
  --z-toast: 70;
  
  /* =========================
     COMPONENT-SPECIFIC
     ========================= */
  
  /* Panels */
  --panel-padding: var(--spacing-5) var(--spacing-6) var(--spacing-7) var(--spacing-6);
  --panel-border-radius: var(--border-radius-lg);
  --panel-shadow: var(--shadow-sm);
  
  /* Toolbar */
  --toolbar-padding: var(--spacing-3);
  --toolbar-gap: var(--spacing-3);
  --toolbar-button-size: 76px;
  --toolbar-icon-size: 20px;
  
  /* Properties panel */
  --properties-width: 180px;
  --properties-min-height: 500px;
  
  /* =========================
     MODAL & SURFACE COLORS
     Spec-variant theming for patent figure context
     ========================= */
  
  /* Surface colors - Spec variant (sage-cream for patent figures) */
  --color-surface-header-spec: #f6faf4;
  --color-surface-content-spec: #f6faf4;
  --color-surface-panel-spec-frosted: rgba(246, 250, 244, 0.85);
  --color-surface-header-spec-frosted: rgba(246, 250, 244, 0.95);
  
  /* Modal-specific */
  --color-backdrop: rgba(0, 0, 0, 0.3);
  --color-modal-bg: var(--color-surface-content-spec);
  --color-modal-header-bg: var(--color-surface-header-spec);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --border-modal: 1px solid rgba(0, 0, 0, 0.05);
  --border-radius-modal: var(--border-radius-2xl);
  
  /* Scrollbar theming for modals */
  --color-scrollbar-track: rgba(0, 0, 0, 0.02);
  --color-scrollbar-thumb: rgba(0, 0, 0, 0.15);
  --color-scrollbar-thumb-hover: rgba(0, 0, 0, 0.25);
  --color-scrollbar-thumb-active: rgba(0, 0, 0, 0.35);
  
  /* Button variants for modals */
  --color-btn-primary: var(--color-primary-400);
  --color-btn-primary-hover: var(--color-primary-500);
  --color-btn-primary-active: var(--color-primary-600);
  --color-btn-primary-text: #ffffff;
  
  --color-btn-secondary: var(--color-gray-100);
  --color-btn-secondary-hover: var(--color-gray-200);
  --color-btn-secondary-active: var(--color-gray-300);
  --color-btn-secondary-text: var(--color-text-primary);
  
  --color-btn-danger: var(--color-error);
  --color-btn-danger-hover: #c82333;
  --color-btn-danger-text: #ffffff;
  
  /* Form elements in modals */
  --color-input-bg: #ffffff;
  --color-input-border: var(--color-gray-300);
  --color-input-border-focus: var(--color-primary-400);
  --color-input-text: var(--color-text-primary);
  --shadow-input-focus: 0 0 0 3px rgba(201, 221, 191, 0.15);
  
  /* Animation durations */
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

/* =====================================================
   DARK THEME (Future implementation)
   ===================================================== */

[data-theme="dark"] {
  /* =========================
     DARK MODE COLOR OVERRIDES
     ========================= */
  
  /* Primary colors for dark mode (Adjusted sage green theme) */
  --color-primary-50: #1a1f18;
  --color-primary-100: #232a20;
  --color-primary-200: #2d362a;
  --color-primary-300: #3a4536;
  --color-primary-400: #9db891;  /* Muted sage green for dark mode */
  --color-primary-500: #87a87b;
  --color-primary-600: #7a9869;
  --color-primary-700: #6d8858;
  --color-primary-800: #5f7747;
  --color-primary-900: #4f6539;
  
  /* Neutral colors for dark mode */
  --color-neutral-50: #1a1918;
  --color-neutral-100: #242220;
  --color-neutral-200: #2f2c28;
  --color-neutral-300: #3c3730;
  --color-neutral-400: #4a443b;
  --color-neutral-500: #5a5147;
  --color-neutral-600: #6b5f55;
  --color-neutral-700: #7e7165;
  --color-neutral-800: #938477;
  --color-neutral-900: #a99a8b;
  
  /* Gray scale for dark mode */
  --color-gray-50: #111111;
  --color-gray-100: #1a1a1a;
  --color-gray-200: #2a2a2a;
  --color-gray-300: #3a3a3a;
  --color-gray-400: #4a4a4a;
  --color-gray-500: #5a5a5a;
  --color-gray-600: #6a6a6a;
  --color-gray-700: #7a7a7a;
  --color-gray-800: #8a8a8a;
  --color-gray-900: #9a9a9a;
  
  /* Applied color tokens - Dark Mode */
  --color-bg-main: #1a1a1a;
  --color-bg-canvas: #2a2520;  /* Dark warm background for canvas */
  --color-bg-panel: rgba(42, 37, 32, 1.0);  /* Dark panel */
  --color-bg-panel-light: rgba(42, 37, 32, 0.7);
  --color-bg-tool: rgba(58, 58, 58, 0.7);
  --color-bg-tool-hover: rgba(78, 78, 78, 0.9);
  --color-bg-tool-active: #4a4a4a;
  
  --color-text-primary: #e5e5e5;
  --color-text-secondary: #b5b5b5;
  --color-text-muted: #888888;
  --color-text-disabled: #666666;
  
  --color-border-default: #444444;
  --color-border-light: #333333;
  --color-border-dark: #555555;
  
  --color-accent: #9db891;  /* Muted sage green for dark mode */
  --color-accent-light: #b5c7a9;
  --color-accent-dark: #87a87b;
  --color-accent-bg: rgba(157, 184, 145, 0.3);
  
  /* Selection and handles for dark mode */
  --selection-color: #9db891;
  --handle-border: #9db891;
  
  /* Tool states for dark mode */
  --tool-outline-active: 2px solid #9db891;
  
  /* Surface colors for dark mode */
  --color-surface-header-spec: #1a1f18;
  --color-surface-content-spec: #1a1f18;
  --color-surface-panel-spec-frosted: rgba(26, 31, 24, 0.85);
  --color-surface-header-spec-frosted: rgba(26, 31, 24, 0.95);
  
  /* Input focus shadow for dark mode */
  --shadow-input-focus: 0 0 0 3px rgba(157, 184, 145, 0.15);
}

/* =====================================================
   UTILITY STYLES
   ===================================================== */

/* Screen reader only */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Disable focus outline for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* =====================================================
   APP CONTAINER
   ===================================================== */

#app {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}