/* 🎨 Linear 2025 Real Design - 100% Benchmark */

/* ============================================
   1. Design Tokens (Linear.app 2025)
   ============================================ */
:root {
  /* Background Colors */
  --bg-base: #000000;
  --bg-subtle: #0C0C0D;
  --bg-muted: #18181B;
  --bg-elevated: #1F1F23;
  
  /* Text Colors */
  --text-primary: #FCFCFC;
  --text-secondary: #B4B4B8;
  --text-tertiary: #696A6D;
  --text-quaternary: #525256;
  
  /* Border Colors */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-muted: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.15);
  
  /* Brand Colors */
  --brand-primary: #5E6AD2;
  --brand-hover: #4C5CC4;
  --brand-muted: rgba(94, 106, 210, 0.12);
  
  /* Accent Colors */
  --accent-blue: #3B82F6;
  --accent-green: #10B981;
  --accent-purple: #8B5CF6;
  --accent-orange: #F59E0B;
  
  /* Semantic Colors */
  --success: #10B981;
  --success-muted: rgba(16, 185, 129, 0.12);
  --warning: #F59E0B;
  --warning-muted: rgba(245, 158, 11, 0.12);
  --error: #EF4444;
  --error-muted: rgba(239, 68, 68, 0.12);
  
  /* Spacing (8px base) */
  --space-1: 0.125rem;   /* 2px */
  --space-2: 0.25rem;    /* 4px */
  --space-3: 0.5rem;     /* 8px */
  --space-4: 0.75rem;    /* 12px */
  --space-5: 1rem;       /* 16px */
  --space-6: 1.5rem;     /* 24px */
  --space-7: 2rem;       /* 32px */
  --space-8: 2.5rem;     /* 40px */
  --space-9: 3rem;       /* 48px */
  --space-10: 4rem;      /* 64px */
  
  /* Typography */
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Courier New', monospace;
  
  --text-xs: 0.6875rem;  /* 11px */
  --text-sm: 0.8125rem;  /* 13px */
  --text-base: 0.9375rem; /* 15px */
  --text-lg: 1.0625rem;  /* 17px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 2rem;      /* 32px */
  --text-4xl: 2.5rem;    /* 40px */
  
  /* Font Weights */
  --font-regular: 400;
  --font-medium: 500;
  --font-semibold: 600;
  
  /* Border Radius */
  --radius-sm: 0.375rem;  /* 6px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.625rem;  /* 10px */
  --radius-xl: 0.75rem;   /* 12px */
  
  /* Shadows (Linear 2025 exact) */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.24);
  --shadow-sm: 0 2px 8px 0 rgba(0, 0, 0, 0.16);
  --shadow-md: 0 6px 18px 0 rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 12px 32px 0 rgba(0, 0, 0, 0.16);
  --shadow-xl: 0 20px 60px 0 rgba(0, 0, 0, 0.20);
  
  /* Focus Ring */
  --focus-ring: 0 0 0 4px rgba(94, 106, 210, 0.12);
  --focus-ring-error: 0 0 0 4px rgba(239, 68, 68, 0.12);
  
  /* Transitions (Linear 2025 exact) */
  --ease-out: cubic-bezier(0.2, 0.9, 0.24, 1);        /* Spring-like exit */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);              /* Deceleration */
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);        /* Material-like */
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55); /* Subtle bounce */
  --duration-instant: 80ms;
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --duration-slower: 400ms;
  
  /* Layout */
  --header-height: 3.5rem; /* 56px */
  --content-max-width: 75rem; /* 1200px */
}

/* ============================================
   2. Global Reset
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-display);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: 1.5;
  overflow-x: hidden;
  font-weight: var(--font-regular);
}

/* ============================================
   3. Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

/* ============================================
   4. Header (Linear-style)
   ============================================ */
.dashboard-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-inner {
  width: 100%;
  max-width: var(--content-max-width);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.logo-mark {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--accent-purple) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
  overflow: hidden;
}

.logo-mark::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.1) 0%, 
    rgba(255, 255, 255, 0) 100%
  );
  pointer-events: none;
}

.logo-char {
  font-size: 0.875rem;
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}

.logo-primary {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-secondary {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-tertiary);
  letter-spacing: -0.01em;
}

/* Mobile logo optimization */
@media (max-width: 640px) {
  .logo-mark {
    width: 2rem;
    height: 2rem;
  }
  
  .logo-char {
    font-size: 0.75rem;
  }
  
  .logo-primary {
    font-size: var(--text-sm);
  }
  
  .logo-secondary {
    display: none; /* Hide partner name on mobile */
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ============================================
   5. Main Content
   ============================================ */
.dashboard-main {
  margin-top: var(--header-height);
  padding: var(--space-7) var(--space-6);
  max-width: var(--content-max-width);
  margin-left: auto;
  margin-right: auto;
  animation: fadeIn 400ms var(--ease-out);
}

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

@media (max-width: 768px) {
  .dashboard-main {
    padding: var(--space-5) var(--space-5);
  }
}

/* ============================================
   6. Section Styles
   ============================================ */
.dashboard-section {
  margin-bottom: var(--space-9);
}

.section-header {
  margin-bottom: var(--space-6);
}

.section-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  letter-spacing: -0.02em;
}

.section-description {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* ============================================
   7. KPI Grid (No Icons)
   ============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-5);
  }
}

.kpi-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: transform var(--duration-normal) var(--ease-out),
              background-color var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
  cursor: default;
  box-shadow: var(--shadow-xs);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%,
    var(--brand-primary) 50%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(94, 106, 210, 0.03) 0%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  pointer-events: none;
}

.kpi-card:hover {
  background: var(--bg-muted);
  border-color: var(--border-muted);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-card:hover::after {
  opacity: 1;
}

.kpi-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--font-medium);
  margin-bottom: var(--space-4);
  display: block;
}

.kpi-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
  line-height: 1;
}

.kpi-unit {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  font-weight: var(--font-regular);
  margin-left: var(--space-2);
}

.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.kpi-change.up {
  color: var(--success);
  background: var(--success-muted);
}

.kpi-change.down {
  color: var(--error);
  background: var(--error-muted);
}

.kpi-change-icon {
  font-size: 0.625rem;
}

/* ============================================
   8. Chart Grid
   ============================================ */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

@media (min-width: 1024px) {
  .chart-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
  }
}

.chart-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: transform var(--duration-normal) var(--ease-out),
              background-color var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.chart-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%,
    var(--accent-blue) 50%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.chart-card:hover {
  background: var(--bg-muted);
  border-color: var(--border-muted);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.chart-card:hover::before {
  opacity: 1;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.chart-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* ============================================
   8. Alerts Components (New!)
   ============================================ */
.alerts-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.alert-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.alert-card.critical {
  border-left-color: var(--error);
  background: linear-gradient(90deg, 
    var(--error-muted) 0%, 
    var(--bg-subtle) 20%
  );
}

.alert-card.warning {
  border-left-color: var(--warning);
  background: linear-gradient(90deg, 
    var(--warning-muted) 0%, 
    var(--bg-subtle) 20%
  );
}

.alert-card:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}

.alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.alert-type {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.alert-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.alert-badge.critical {
  background: var(--error-muted);
  color: var(--error);
}

.alert-badge.warning {
  background: var(--warning-muted);
  color: var(--warning);
}

.alert-message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.alert-meta {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.alert-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chart-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.chart-meta {
  font-size: var(--text-xs);
  color: var(--text-quaternary);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

@media (min-width: 768px) {
  .chart-container {
    height: 320px;
  }
}

canvas {
  max-width: 100% !important;
  height: auto !important;
}

/* ============================================
   9. Buttons (Linear-style)
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 16px;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform var(--duration-normal) var(--ease-out),
              background-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
  white-space: nowrap;
  line-height: 1.2;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08) 0%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
  pointer-events: none;
}

.btn:hover::before {
  opacity: 1;
}

.btn-primary {
  background: var(--brand-primary);
  color: white;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.24),
              inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
}

.btn-primary:hover {
  background: var(--brand-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px 0 rgba(94, 106, 210, 0.24),
              inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.24),
              inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
}

.btn-secondary {
  background: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--border-muted);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.16);
}

.btn-secondary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-ghost:active {
  background: var(--bg-subtle);
}

@media (max-width: 480px) {
  .btn span:last-child {
    display: none;
  }
  
  .btn {
    padding: var(--space-3);
  }
}

/* ============================================
   10. Loading States
   ============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-subtle) 0%,
    var(--bg-muted) 50%,
    var(--bg-subtle) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   11. Micro Interactions
   ============================================ */
.fade-in {
  animation: fadeIn 400ms var(--ease-out);
}

.slide-up {
  animation: slideUp 400ms var(--ease-out);
}

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

.stagger-children > * {
  animation: slideUpFade var(--duration-slow) var(--ease-out) both;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }

@keyframes slideUpFade {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

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

:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================
   13. Utilities
   ============================================ */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

* {
  max-width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   13. Mobile Responsive Design
   ============================================ */

/* Mobile: Hide sidebar by default, show hamburger menu */
@media (max-width: 768px) {
  /* Sidebar mobile styles */
  .sidebar {
    position: fixed !important;
    left: -240px !important;
    width: 240px !important;
    height: 100vh !important;
    background: var(--bg-subtle) !important;
    border-right: 1px solid var(--border-subtle) !important;
    z-index: 2000 !important;
    transition: left 0.3s var(--ease-out) !important;
  }
  
  .sidebar.open {
    left: 0 !important;
    box-shadow: var(--shadow-xl) !important;
  }
  
  /* Main content takes full width on mobile */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
  
  /* Header adjustments */
  .header {
    padding: 0 12px !important;
  }
  
  .header-title {
    font-size: 13px !important;
  }
  
  /* Content padding */
  .content {
    padding: 16px 12px !important;
  }
  
  /* Hamburger menu button */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background-color var(--duration-fast) var(--ease-out);
  }
  
  .mobile-menu-btn:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
  }
  
  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1999;
  }
  
  .sidebar-overlay.active {
    display: block;
  }
}
