/**
 * Apex Micro Design System
 * Inspired by modern fintech (Finrise, Stripe, Mercury)
 * Supports light + dark mode
 */

:root {
  /* ═══ COLOR PALETTE ═══ */
  
  /* Primary Brand Colors */
  --brand-primary: #6366f1;      /* Indigo - main actions */
  --brand-primary-hover: #4f46e5;
  --brand-primary-light: #a5b4fc;
  --brand-primary-bg: #eef2ff;
  
  --brand-secondary: #8b5cf6;    /* Purple - accent */
  --brand-secondary-hover: #7c3aed;
  
  /* Semantic Colors */
  --success: #10b981;
  --success-bg: #d1fae5;
  --success-text: #065f46;
  
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  
  --info: #3b82f6;
  --info-bg: #dbeafe;
  --info-text: #1e40af;
  
  /* ═══ LIGHT MODE (DEFAULT) ═══ */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-elevated: #ffffff;
  
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --text-inverse: #ffffff;
  
  --border-primary: #e5e7eb;
  --border-secondary: #d1d5db;
  --border-hover: #9ca3af;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* ═══ TYPOGRAPHY ═══ */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  
  /* ═══ 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 */
  --space-16: 4rem;    /* 64px */
  
  /* ═══ BORDER RADIUS ═══ */
  --radius-sm: 0.375rem;   /* 6px */
  --radius-md: 0.5rem;     /* 8px */
  --radius-lg: 0.75rem;    /* 12px */
  --radius-xl: 1rem;       /* 16px */
  --radius-2xl: 1.5rem;    /* 24px */
  --radius-full: 9999px;
  
  /* ═══ 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);
  
  /* ═══ Z-INDEX ═══ */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-modal: 1200;
  --z-toast: 1300;
  --z-tooltip: 1400;
}

/* ═══ DARK MODE ═══ */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-elevated: #1e293b;
  
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-inverse: #0f172a;
  
  --border-primary: #334155;
  --border-secondary: #475569;
  --border-hover: #64748b;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
  
  /* Adjust semantic colors for dark mode */
  --success-bg: #064e3b;
  --success-text: #6ee7b7;
  
  --warning-bg: #78350f;
  --warning-text: #fcd34d;
  
  --danger-bg: #7f1d1d;
  --danger-text: #fca5a5;
  
  --info-bg: #1e3a8a;
  --info-text: #93c5fd;
  
  --brand-primary-bg: #312e81;
}

/* ═══ SKIP NAVIGATION ═══ */
.skip-nav {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--brand-primary);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  z-index: calc(var(--z-tooltip) + 1);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-nav:focus {
  top: var(--space-2);
}

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

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

body {
  font-family: var(--font-sans);
  font-size: 0.875rem; /* 14px base */
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: background var(--transition-base), color var(--transition-base);
}

/* ═══ TYPOGRAPHY CLASSES ═══ */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }

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

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

.font-mono { font-family: var(--font-mono); }

/* ═══ LAYOUT ═══ */
.container {
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 640px) { .container { max-width: 640px; } }
@media (min-width: 768px) { .container { max-width: 768px; } }
@media (min-width: 1024px) { .container { max-width: 1024px; } }
@media (min-width: 1280px) { .container { max-width: 1280px; } }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ═══ CARDS ═══ */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-success {
  background: var(--success, #22c55e);
  color: white;
}
.btn-success:hover:not(:disabled) {
  background: #16a34a;
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background: var(--danger, #ef4444);
  color: white;
}
.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: var(--shadow-md);
}

.btn-warning {
  background: var(--warning, #f59e0b);
  color: white;
}
.btn-warning:hover:not(:disabled) {
  background: #d97706;
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
}

/* ═══ INPUTS ═══ */
.input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-primary-bg);
}

.input::placeholder {
  color: var(--text-tertiary);
}

/* ═══ BADGES ═══ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  line-height: 1;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info-text);
}

/* ═══ STATUS INDICATORS ═══ */
.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.online { color: var(--success); }
.status-dot.warning { color: var(--warning); }
.status-dot.offline { color: var(--danger); }

/* ═══ UTILITY CLASSES ═══ */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

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

.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}
