/* =============================================================================
   CAN Diagnostics Suite — Web Edition v7.0
   Design System Tokens
   ============================================================================= */

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

:root {
  /* --- Color Palette (Dark Theme) --- */
  --color-bg-primary:      #0a0e17;
  --color-bg-secondary:    #111827;
  --color-bg-tertiary:     #1a2234;
  --color-bg-elevated:     #1e293b;
  --color-bg-surface:      #243044;
  --color-bg-hover:        #2a3a52;
  --color-bg-active:       #334866;

  --color-border:          #2d3f5a;
  --color-border-light:    #374a6a;
  --color-border-focus:    #3b82f6;

  --color-text-primary:    #f1f5f9;
  --color-text-secondary:  #94a3b8;
  --color-text-muted:      #64748b;
  --color-text-inverse:    #0a0e17;
}

[data-theme="light"] {
  --color-bg-primary:      #f8fafc;
  --color-bg-secondary:    #f1f5f9;
  --color-bg-tertiary:     #e2e8f0;
  --color-bg-elevated:     #ffffff;
  --color-bg-surface:      #f8fafc;
  --color-bg-hover:        #f1f5f9;
  --color-bg-active:       #e2e8f0;

  --color-border:          #cbd5e1;
  --color-border-light:    #94a3b8;
  --color-border-focus:    #3b82f6;

  --color-text-primary:    #0f172a;
  --color-text-secondary:  #334155;
  --color-text-muted:      #64748b;
  --color-text-inverse:    #ffffff;
}

:root {

  /* Accent Colors */
  --color-accent:          #3b82f6;
  --color-accent-hover:    #2563eb;
  --color-accent-glow:     rgba(59, 130, 246, 0.25);
  --color-accent-subtle:   rgba(59, 130, 246, 0.1);

  /* Status Colors */
  --color-success:         #22c55e;
  --color-success-bg:      rgba(34, 197, 94, 0.1);
  --color-warning:         #f59e0b;
  --color-warning-bg:      rgba(245, 158, 11, 0.1);
  --color-error:           #ef4444;
  --color-error-bg:        rgba(239, 68, 68, 0.1);
  --color-info:            #06b6d4;
  --color-info-bg:         rgba(6, 182, 212, 0.1);

  /* ARC Protocol Colors (matching existing CDS) */
  --color-arc1:            #ef4444;
  --color-arc2:            #3b82f6;
  --color-arc3:            #6b7280;

  /* CAN Feed Colors */
  --color-feed-tx:         #22c55e;
  --color-feed-rx:         #3b82f6;
  --color-feed-error:      #ef4444;

  /* Session/Sharing Colors */
  --color-spectate:        #a855f7;
  --color-spectate-bg:     rgba(168, 85, 247, 0.1);
  --color-collab:          #f97316;
  --color-collab-bg:       rgba(249, 115, 22, 0.1);
  --color-admin:           #ec4899;
  --color-admin-bg:        rgba(236, 72, 153, 0.1);

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

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

  --leading-tight:         1.25;
  --leading-normal:        1.5;
  --leading-relaxed:       1.625;

  /* --- Spacing --- */
  --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 */

  /* --- Border Radius --- */
  --radius-sm:  0.25rem;
  --radius-md:  0.5rem;
  --radius-lg:  0.75rem;
  --radius-xl:  1rem;
  --radius-full: 9999px;

  /* --- Shadows --- */
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:   0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg:   0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
  --shadow-xl:   0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 20px var(--color-accent-glow);

  /* --- Transitions --- */
  --transition-fast:    150ms ease;
  --transition-normal:  250ms ease;
  --transition-slow:    350ms ease;

  /* --- Z-Index --- */
  --z-dropdown:  100;
  --z-sticky:    200;
  --z-overlay:   300;
  --z-modal:     400;
  --z-toast:     500;

  /* --- Layout --- */
  --sidebar-width:     260px;
  --sidebar-collapsed: 64px;
  --header-height:     56px;
  --panel-gap:         var(--space-4);
}

/* =============================================================================
   Reset & Base
   ============================================================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); }

code, pre, .mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--color-bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--color-border-light); }

/* Selection */
::selection {
  background: var(--color-accent);
  color: white;
}

/* =============================================================================
   Utility Classes
   ============================================================================= */

.hidden     { display: none !important; }
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.flex-1     { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.text-center { text-align: center; }
.text-muted  { color: var(--color-text-muted); }
.text-sm     { font-size: var(--text-sm); }
.text-xs     { font-size: var(--text-xs); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =============================================================================
   Animations
   ============================================================================= */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px var(--color-accent-glow); }
  50%      { box-shadow: 0 0 20px var(--color-accent-glow), 0 0 40px rgba(59, 130, 246, 0.1); }
}

.animate-fade-in  { animation: fadeIn 0.3s ease forwards; }
.animate-slide-up { animation: slideUp 0.4s ease forwards; }
.animate-pulse    { animation: pulse 2s infinite; }
.animate-spin     { animation: spin 1s linear infinite; }
.animate-glow     { animation: glow 2s ease-in-out infinite; }
