/**
 * ============================================================
 * OMSP Document Tracking / Monitoring
 * Main CSS - Design tokens, reset, base, utilities
 * ============================================================
 * This is the foundation CSS file. It defines:
 * - CSS custom properties (design tokens) for colors, typography, spacing
 * - CSS reset for cross-browser consistency
 * - Base element styles
 * - Utility classes used across the application
 * ============================================================
 */

/* ============================================================
   DESIGN TOKENS (CSS Custom Properties)
   ============================================================ */
:root {
  /* --- Primary Blue --- */
  --primary-50: #EFF6FF;
  --primary-100: #DBEAFE;
  --primary-200: #BFDBFE;
  --primary-300: #93C5FD;
  --primary-400: #60A5FA;
  --primary-500: #3B82F6;
  --primary-600: #2563EB;
  --primary-700: #1D4ED8;
  --primary-800: #1E40AF;
  --primary-900: #1E3A8A;

  /* --- Secondary Teal --- */
  --secondary-50: #F0FDFA;
  --secondary-100: #CCFBF1;
  --secondary-200: #99F6E4;
  --secondary-500: #14B8A6;
  --secondary-600: #0D9488;
  --secondary-700: #0F766E;

  /* --- Accent Amber --- */
  --accent-50: #FFFBEB;
  --accent-100: #FEF3C7;
  --accent-200: #FDE68A;
  --accent-400: #FBBF24;
  --accent-500: #F59E0B;
  --accent-600: #D97706;
  --accent-700: #B45309;

  /* --- Danger Red --- */
  --danger-50: #FEF2F2;
  --danger-100: #FEE2E2;
  --danger-200: #FECACA;
  --danger-500: #EF4444;
  --danger-600: #DC2626;
  --danger-700: #B91C1C;

  /* --- Success Green --- */
  --success-50: #F0FDF4;
  --success-100: #DCFCE7;
  --success-500: #22C55E;
  --success-600: #16A34A;
  --success-700: #15803D;

  /* --- Neutral Gray --- */
  --neutral-50: #F8FAFC;
  --neutral-100: #F1F5F9;
  --neutral-200: #E2E8F0;
  --neutral-300: #CBD5E1;
  --neutral-400: #94A3B8;
  --neutral-500: #64748B;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1E293B;
  --neutral-900: #0F172A;

  /* --- Typography --- */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.8125rem;  /* 13px */
  --text-base: 0.875rem; /* 14px */
  --text-lg: 1rem;       /* 16px */
  --text-xl: 1.125rem;   /* 18px */
  --text-2xl: 1.375rem;  /* 22px */
  --text-3xl: 1.75rem;   /* 28px */
  --text-4xl: 2.25rem;   /* 36px */

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

  --leading-tight: 1.2;
  --leading-snug: 1.3;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* --- Spacing Scale --- */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */

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

  /* --- Shadows --- */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);

  /* --- Transitions --- */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* --- Layout --- */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 64px;
  --max-content-width: 1280px;
  --page-padding: var(--space-6);

  /* --- Z-Index Scale --- */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-sidebar: 300;
  --z-overlay: 400;
  --z-modal: 500;
  --z-toast: 600;
  --z-tooltip: 700;
}

/* ============================================================
   CSS RESET
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-family);
  font-size: 16px;
  line-height: var(--leading-normal);
  color: var(--neutral-800);
  background-color: var(--neutral-100);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  font-size: var(--text-base);
}

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

/* Links */
a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--primary-800); }
a.btn { color: unset; }
a.btn:hover { color: unset; }

/* Images */
img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Form elements inherit font */
button, input, select, textarea {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
}

button { cursor: pointer; }

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
}

/* ============================================================
   BASE TYPOGRAPHY
   ============================================================ */
h1 { font-size: var(--text-3xl); font-weight: var(--font-bold); line-height: var(--leading-tight); }
h2 { font-size: var(--text-2xl); font-weight: var(--font-semibold); line-height: var(--leading-snug); }
h3 { font-size: var(--text-xl); font-weight: var(--font-semibold); line-height: var(--leading-snug); }
h4 { font-size: var(--text-lg); font-weight: var(--font-semibold); line-height: var(--leading-snug); }
h5 { font-size: var(--text-base); font-weight: var(--font-semibold); line-height: var(--leading-normal); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

small { font-size: var(--text-sm); }

strong { font-weight: var(--font-semibold); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--neutral-100);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
/* Screen-reader only */
.sr-only {
  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 */
:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

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

/* Selection color */
::selection {
  background-color: var(--primary-100);
  color: var(--primary-900);
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-700);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  z-index: var(--z-tooltip);
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: var(--space-2);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

/* --- Display --- */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex,
.d-flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* --- Flexbox --- */
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.items-center,
.align-center { align-items: center; }
.items-start,
.align-start { align-items: flex-start; }
.items-end,
.align-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Semantic spacing aliases (used in JS-rendered templates) */
.gap-xs  { gap: var(--space-1); }
.gap-sm  { gap: var(--space-2); }
.gap-md  { gap: var(--space-4); }
.gap-lg  { gap: var(--space-6); }
.gap-xl  { gap: var(--space-8); }

/* --- Text --- */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }
.uppercase { text-transform: uppercase; }
.capitalize { text-transform: capitalize; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.leading-tight { line-height: var(--leading-tight); }

/* --- Colors --- */
.text-primary { color: var(--primary-700); }
.text-secondary { color: var(--neutral-500); }
.text-muted { color: var(--neutral-400); }
.text-success { color: var(--success-600); }
.text-danger { color: var(--danger-600); }
.text-warning { color: var(--accent-600); }
.text-white { color: #fff; }

/* --- Spacing Utilities --- */
.m-0 { margin: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

/* Semantic margin aliases */
.mt-xs  { margin-top: var(--space-1); }
.mt-sm  { margin-top: var(--space-2); }
.mt-md  { margin-top: var(--space-4); }
.mt-lg  { margin-top: var(--space-6); }
.mt-xl  { margin-top: var(--space-8); }
.mb-xs  { margin-bottom: var(--space-1); }
.mb-sm  { margin-bottom: var(--space-2); }
.mb-md  { margin-bottom: var(--space-4); }
.mb-lg  { margin-bottom: var(--space-6); }
.mb-xl  { margin-bottom: var(--space-8); }
.ml-2 { margin-left: var(--space-2); }
.ml-auto { margin-left: auto; }
.mr-2 { margin-right: var(--space-2); }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

/* --- Sizing --- */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* --- Borders & Radius --- */
.border { border: 1px solid var(--neutral-200); }
.border-t { border-top: 1px solid var(--neutral-200); }
.border-b { border-bottom: 1px solid var(--neutral-200); }
.rounded { border-radius: var(--radius); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* --- Shadows --- */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Extra padding */
.p-xl { padding: var(--space-8); }

/* --- Overflow --- */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }

/* --- Position --- */
.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }

/* --- Cursor --- */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* --- Opacity --- */
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

/* --- Transitions --- */
.transition { transition: all var(--transition-base); }
.transition-fast { transition: all var(--transition-fast); }

/* --- Scrollbar styling (Webkit) --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neutral-400); }

/* --- Container --- */
.container {
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0 var(--page-padding);
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--neutral-200);
  margin: var(--space-4) 0;
  border: none;
}

/* --- Label (uppercase small text) --- */
.label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--neutral-500);
  line-height: var(--leading-snug);
}

/* ============================================================
   INLINE SVG ICON SYSTEM
   ============================================================ */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
  color: inherit;
  line-height: 0;
  /* Safari/iOS fix — ensure SVGs respect dimensions */
  -webkit-flex-shrink: 0;
  overflow: visible;
}

.icon-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral-200);
  color: var(--neutral-500);
  border-radius: var(--radius);
  font-size: var(--text-xs);
}

/* Icon sizes */
.icon-xs  { width: 14px; height: 14px; }
.icon-sm  { width: 16px; height: 16px; }
.icon-md  { width: 20px; height: 20px; }
.icon-lg  { width: 24px; height: 24px; }
.icon-xl  { width: 32px; height: 32px; }

/* Icon colors */
.icon-primary   { color: var(--primary-600); }
.icon-secondary { color: var(--secondary-600); }
.icon-accent    { color: var(--accent-500); }
.icon-success   { color: var(--success-600); }
.icon-danger    { color: var(--danger-600); }
.icon-muted     { color: var(--neutral-400); }

/* Spinning icon (for loaders) */
.icon-spin {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================================
   AVATAR COLOR PRESETS (shared across profile picker & sidebar)
   ============================================================ */
.avatar-color-0 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.avatar-color-1 { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.avatar-color-2 { background: linear-gradient(135deg, #14b8a6, #06b6d4); }
.avatar-color-3 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.avatar-color-4 { background: linear-gradient(135deg, #22c55e, #10b981); }
.avatar-color-5 { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.avatar-color-6 { background: linear-gradient(135deg, #a855f7, #ec4899); }
.avatar-color-7 { background: linear-gradient(135deg, #f97316, #facc15); }

/* Switch Profile link in sidebar */
.sidebar-switch-profile {
  font-size: 0.85rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.sidebar-switch-profile:hover {
  opacity: 1;
}
