/* ============================================================
   SHOP SQUIRE - MODERN UI DESIGN SYSTEM 2025
   Inspired by: Linear, Vercel, Figma, Notion
   Principles: Clarity, Density, Subtle Depth, Micro-interactions
   ============================================================ */

/* -----------------------------------------------------------
   1. DESIGN TOKENS - Core Variables
   ----------------------------------------------------------- */
:root {
  /* Color System - Light Theme (Vantage-inspired) */
  --bg-base: #f0f2f5;              /* Light gray page background */
  --bg-primary: #ffffff;           /* Primary surfaces - white */
  --bg-secondary: #ffffff;         /* Secondary surfaces - white */
  --bg-tertiary: #f7f8fa;          /* Tertiary/hover surfaces */
  --bg-elevated: #ffffff;          /* Elevated cards/modals */
  --bg-hover: #f0f2f5;             /* Hover states */
  --bg-active: #e8eaed;            /* Active/pressed states */
  --bg-sidebar: #f7f8fa;           /* Sidebar background */
  
  /* Text Colors - Dark on Light (AA compliant on white) */
  --text-primary: #1a1a2e;         /* Primary text - near black (17:1) */
  --text-secondary: #6b7280;       /* Secondary text - medium gray (4.8:1) */
  --text-tertiary: #6c737b;        /* Tertiary text - dark gray (4.8:1) */
  --text-disabled: #b0b5bd;        /* Disabled text (decorative) */
  
  /* Brand Colors - Vantage Blue */
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #60a5fa;
  --brand-500: #0052cc;            /* Primary brand - Vantage blue */
  --brand-600: #0043a8;
  --brand-700: #003580;
  --brand-800: #002760;
  --brand-900: #001a40;
  
  /* Semantic Colors (AA compliant for text/icons on white) */
  --success-500: #047857;          /* Darker green for text/icons */
  --success-600: #065f46;          /* Even darker for emphasis */
  --warning-500: #b45309;          /* Darker amber for text/icons */
  --warning-600: #92400e;          /* Even darker for emphasis */
  --error-500: #dc2626;            /* Darker red for text/icons */
  --error-600: #b91c1c;            /* Even darker for emphasis */
  --info-500: #2563eb;             /* Darker blue for text/icons */
  --info-600: #1d4ed8;             /* Even darker for emphasis */
  
  /* Border Colors - Subtle gray */
  --border-subtle: #e5e7eb;
  --border-default: #d1d5db;
  --border-strong: #9ca3af;
  
  /* RGBA Utilities - Brand (0, 82, 204) */
  --brand-rgb: 0, 82, 204;
  --brand-alpha-02: rgba(var(--brand-rgb), 0.02);
  --brand-alpha-05: rgba(var(--brand-rgb), 0.05);
  --brand-alpha-10: rgba(var(--brand-rgb), 0.1);
  --brand-alpha-15: rgba(var(--brand-rgb), 0.15);
  --brand-alpha-20: rgba(var(--brand-rgb), 0.2);
  --brand-alpha-30: rgba(var(--brand-rgb), 0.3);
  
  /* RGBA Utilities - Success (4, 120, 87) */
  --success-rgb: 4, 120, 87;
  --success-alpha-10: rgba(var(--success-rgb), 0.1);
  --success-alpha-15: rgba(var(--success-rgb), 0.15);
  --success-alpha-20: rgba(var(--success-rgb), 0.2);
  
  /* RGBA Utilities - Warning (180, 83, 9) */
  --warning-rgb: 180, 83, 9;
  --warning-alpha-10: rgba(var(--warning-rgb), 0.1);
  --warning-alpha-15: rgba(var(--warning-rgb), 0.15);
  --warning-alpha-20: rgba(var(--warning-rgb), 0.2);
  --warning-alpha-30: rgba(var(--warning-rgb), 0.3);
  
  /* RGBA Utilities - Error (220, 38, 38) */
  --error-rgb: 220, 38, 38;
  --error-alpha-10: rgba(var(--error-rgb), 0.1);
  --error-alpha-15: rgba(var(--error-rgb), 0.15);
  --error-alpha-20: rgba(var(--error-rgb), 0.2);
  --error-alpha-30: rgba(var(--error-rgb), 0.3);
  
  /* RGBA Utilities - Info (37, 99, 235) */
  --info-rgb: 37, 99, 235;
  --info-alpha-10: rgba(var(--info-rgb), 0.1);
  
  /* Spacing Scale - 4px base grid */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  
  /* Typography Scale */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 20px;
  --text-3xl: 24px;
  --text-4xl: 30px;
  
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  
  /* Border Radius - Vantage-inspired (large, friendly) */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
  
  /* Shadows - Soft, diffused (light theme) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px var(--brand-alpha-20);
  --shadow-focus: 0 0 0 3px var(--brand-alpha-20);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.06);
  
  /* 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);
  
  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --header-height: 56px;
  --max-content-width: 1400px;
  
  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* -----------------------------------------------------------
   1b. DARK THEME - Dark Mode Variables
   ----------------------------------------------------------- */
[data-theme="dark"] {
  /* Color System - Dark Theme */
  --bg-base: #121212;
  --bg-primary: #1e1e1e;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #2d2d2d;
  --bg-elevated: #252525;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(255, 255, 255, 0.08);
  --bg-sidebar: #1a1a1a;

  /* Text Colors - Light on Dark */
  --text-primary: #e8e8e8;
  --text-secondary: #b0b0b0;
  --text-tertiary: #6c737b;
  --text-disabled: #4a4a4a;

  /* Brand Colors - Slightly brighter for dark mode */
  --brand-50: #1e3a5f;
  --brand-100: #1e4a7f;
  --brand-200: #2563a0;
  --brand-300: #3b82c4;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-800: #1e40af;
  --brand-900: #1e3a8a;

  /* Semantic Colors - Adjusted for dark backgrounds */
  --success-500: #22c55e;
  --success-600: #16a34a;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --error-500: #ef4444;
  --error-600: #dc2626;
  --info-500: #38bdf8;
  --info-600: #0ea5e9;

  /* Border Colors - Darker */
  --border-subtle: #2d2d2d;
  --border-default: #3d3d3d;
  --border-strong: #5a5a5a;

  /* Shadows - Darker for dark mode */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.3);
  --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.3);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.5);

  /* Selection - Dark theme */
  --selection-bg: rgba(59, 130, 246, 0.3);
  --selection-color: #e8e8e8;
}

/* -----------------------------------------------------------
   2. BASE RESET & GLOBAL STYLES
   ----------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

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

/* Smooth scrolling */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Focus styles - accessible and visible */
:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background-color: var(--selection-bg, var(--brand-100));
  color: var(--selection-color, var(--brand-700));
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-base);
  transition: background var(--transition-fast);
}

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

/* -----------------------------------------------------------
   3. TYPOGRAPHY
   ----------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

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); }

p {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.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); }

.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-muted { color: var(--text-tertiary); }
.text-disabled { color: var(--text-disabled); }
.text-brand { color: var(--brand-500); }
.text-success { color: var(--success-500); }
.text-warning { color: var(--warning-500); }
.text-error { color: var(--error-500); }

.tracking-tight { letter-spacing: -0.02em; }
.tracking-wide { letter-spacing: 0.025em; }

/* -----------------------------------------------------------
    4. LAYOUT SYSTEM
    ----------------------------------------------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg-base);
}

/* Main Content Wrapper */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-base);
  background-color: var(--bg-base);
}

@media (max-width: 768px) {
  .main-wrapper {
    margin-left: 0;
  }
}

/* Content Area */
.content {
  flex: 1;
  padding: var(--space-8);
  max-width: var(--max-content-width);
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .content {
    padding: var(--space-4);
  }
}

/* -----------------------------------------------------------
    5. SIDEBAR - Vantage-inspired Navigation
    ----------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: var(--z-fixed);
  transition: width var(--transition-base);
}

/* Brand Header */
.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text-primary);
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
}

.brand-icon {
  width: 28px;
  height: 28px;
  color: var(--brand-500);
  flex-shrink: 0;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
  overflow-x: hidden;
}

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

.nav-section-title {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-3);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background-color: var(--brand-500);
  color: white;
  box-shadow: 0 2px 8px var(--brand-alpha-30);
}

.nav-link.active::before {
  display: none;
}

.nav-link .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.nav-link:hover .icon {
  opacity: 1;
}

.nav-link.active .icon {
  opacity: 1;
  color: white;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

/* Mobile Sidebar Toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: var(--z-fixed);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-base);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-toggle {
    display: flex;
  }
}

/* -----------------------------------------------------------
    6. HEADER - Vantage-inspired Clean Header
    ----------------------------------------------------------- */
.header {
  height: var(--header-height);
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

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

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

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

/* Search Bar - Vantage style */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  min-width: 280px;
  transition: all var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-focus);
}

.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  font-size: var(--text-sm);
  color: var(--text-primary);
  width: 100%;
}

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

.search-bar .icon {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* User Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  color: white;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 2px solid var(--bg-primary);
  box-shadow: var(--shadow-sm);
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.user-welcome {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* -----------------------------------------------------------
    7. BUTTONS - Vantage-inspired Modern Buttons
    ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: var(--leading-none);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

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

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

/* Button Variants */
.btn-primary {
  background-color: var(--brand-500);
  color: white;
  border-color: var(--brand-500);
  box-shadow: 0 1px 2px var(--brand-alpha-20);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--brand-600);
  border-color: var(--brand-600);
  box-shadow: 0 2px 8px var(--brand-alpha-30);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

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

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

.btn-danger {
  background-color: var(--error-alpha-10);
  color: var(--error-500);
  border-color: var(--error-alpha-20);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--error-alpha-20);
  border-color: var(--error-alpha-30);
}

/* Button Sizes */
.btn-xs {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.btn-sm {
  padding: var(--space-1) var(--space-4);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
}

/* Icon Button */
.btn-icon {
  padding: var(--space-2);
  width: 40px;
  height: 40px;
}

.btn-icon .icon {
  width: 18px;
  height: 18px;
}

/* -----------------------------------------------------------
    8. CARDS - Vantage-inspired Soft Cards
    ----------------------------------------------------------- */
.card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  background-color: var(--bg-tertiary);
  border-top: 1px solid var(--border-subtle);
}

/* Card Variants */
.card-elevated {
  background-color: var(--bg-primary);
  box-shadow: var(--shadow-card);
}

.card-elevated:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--brand-alpha-10);
  transform: translateY(-2px);
}

/* Stat Card - Vantage style */
.stat-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: var(--leading-none);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-2);
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  margin-top: var(--space-3);
}

.stat-change.positive {
  color: var(--success-500);
}

.stat-change.negative {
  color: var(--error-500);
}

/* -----------------------------------------------------------
    9. FORMS - Vantage-inspired Clean Inputs
    ----------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-label-required::after {
  content: '*';
  color: var(--error-500);
  margin-left: var(--space-1);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-2);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--error-500);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* Inputs */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--shadow-focus);
}

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

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background-color: var(--bg-tertiary);
  color: var(--text-disabled);
  cursor: not-allowed;
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--error-500);
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
  box-shadow: 0 0 0 3px var(--error-alpha-20);
}

/* Textarea */
.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* Select */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.form-check-input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-500);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.form-check-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

/* Input Groups */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-input {
  border-radius: 0;
  flex: 1;
}

.input-group .form-input:first-child {
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
}

.input-group .form-input:last-child {
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.input-group .btn {
  border-radius: 0;
}

.input-group .btn:first-child {
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
}

.input-group .btn:last-child {
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* -----------------------------------------------------------
    10. TABLES - Vantage-inspired Clean Tables
    ----------------------------------------------------------- */
.table-container {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-4) var(--space-5);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  font-weight: var(--font-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  background: linear-gradient(180deg, var(--bg-tertiary), var(--bg-primary));
  border-bottom: 1px solid var(--border-default);
}

.table tbody tr {
  transition: all var(--transition-fast);
}

.table tbody tr:hover {
  background-color: var(--bg-hover);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Table Variants */
.table-compact th,
.table-compact td {
  padding: var(--space-2) var(--space-3);
}

/* -----------------------------------------------------------
    11. BADGES & STATUS - Vantage-inspired
    ----------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
}

.badge-neutral {
  background-color: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-brand {
  background-color: var(--brand-100);
  color: var(--brand-600);
}

.badge-success {
  background-color: rgba(4, 120, 87, 0.1);
  color: var(--success-500);
}

.badge-warning {
  background-color: rgba(180, 83, 9, 0.1);
  color: var(--warning-500);
}

.badge-error {
  background-color: rgba(220, 38, 38, 0.1);
  color: var(--error-500);
}

/* Notification Badge - Vantage style */
.badge-notification {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: var(--font-bold);
  background-color: var(--brand-500);
  color: white;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-primary);
}

/* -----------------------------------------------------------
   12. EMPTY STATES
   ----------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--border-default);
  margin-bottom: var(--space-4);
}

.empty-state-icon-container {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-4);
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 400px;
  margin-bottom: var(--space-6);
}

/* -----------------------------------------------------------
   13. DIVIDERS & SEPARATORS
   ----------------------------------------------------------- */
.divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin: var(--space-4) 0;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background-color: var(--border-subtle);
  margin: 0 var(--space-4);
}

/* -----------------------------------------------------------
   14. UTILITIES
   ----------------------------------------------------------- */
/* Spacing */
.m-0 { margin: 0; }
.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-6 { margin: var(--space-6); }
.m-8 { margin: var(--space-8); }

.mt-0 { margin-top: 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-0 { margin-bottom: 0; }
.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); }

.ml-0 { margin-left: 0; }
.ml-2 { margin-left: var(--space-2); }
.ml-3 { margin-left: var(--space-3); }
.ml-4 { margin-left: var(--space-4); }

.mr-0 { margin-right: 0; }
.mr-2 { margin-right: var(--space-2); }
.mr-3 { margin-right: var(--space-3); }
.mr-4 { margin-right: var(--space-4); }

.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); }

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

/* Flex */
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-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-grow-1 { flex-grow: 1; }
.flex-grow-2 { flex-grow: 2; }
.flex-grow-3 { flex-grow: 3; }
.flex-grow-4 { flex-grow: 4; }
.flex-grow-5 { flex-grow: 5; }
.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); }

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

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

/* Text */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* -----------------------------------------------------------
   15. ANIMATIONS & MICRO-INTERACTIONS
   ----------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

.animate-fade-in {
  animation: fadeIn var(--transition-base) ease-out;
}

.animate-slide-up {
  animation: slideInUp var(--transition-base) ease-out;
}

.animate-slide-right {
  animation: slideInRight var(--transition-base) ease-out;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Stagger animation for lists */
.stagger-children > * {
  animation: slideInUp var(--transition-base) ease-out backwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }

/* -----------------------------------------------------------
    16. LOADING STATES
    ----------------------------------------------------------- */
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--brand-500);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

.loading-skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-hover) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-lg);
}

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

/* -----------------------------------------------------------
   17. HTMX LOADING STATES
   ----------------------------------------------------------- */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

/* Hide button content while request is in flight (so spinner shows) */
.htmx-request .btn-content {
  display: none;
}

.htmx-request .btn-primary {
  opacity: 0.7;
  cursor: wait;
}

/* Loader overlay */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(240, 242, 245, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.loader-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loader-overlay .loading-spinner {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* -----------------------------------------------------------
    18. TOOLTIPS
    ----------------------------------------------------------- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: var(--space-2) var(--space-3);
  background-color: var(--text-primary);
  color: var(--bg-primary);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  white-space: nowrap;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: var(--z-tooltip);
  pointer-events: none;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-4px);
}

/* -----------------------------------------------------------
    19. DROPDOWN MENUS
    ----------------------------------------------------------- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition-fast);
  z-index: var(--z-dropdown);
  padding: var(--space-2);
}

.dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(4px);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-subtle);
  margin: var(--space-2) 0;
}

/* -----------------------------------------------------------
   20. RESPONSIVE UTILITIES
   ----------------------------------------------------------- */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 769px) {
  .show-mobile {
    display: none !important;
  }
}

/* -----------------------------------------------------------
   21. DARK MODE TRANSITION
   ----------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  *, *::before, *::after {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 0ms;
  }
}

/* ============================================================
   MODAL WEB COMPONENT
   ============================================================ */

x-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
}

x-modal.open {
  display: block;
}

x-modal .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  box-sizing: border-box;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

x-modal .modal-dialog {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalSlideIn 200ms ease-out;
  border: 1px solid var(--border-subtle);
}

x-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--space-3) var(--space-4) 0;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

x-modal .modal-close-btn {
  margin: 0;
  padding: var(--space-1);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

x-modal .modal-close-btn:hover {
  background-color: var(--bg-hover);
}

x-modal .modal-body {
  padding: var(--space-4) var(--space-6) var(--space-6);
}

x-modal .modal-body .card {
  box-shadow: none;
  border: none;
  margin: 0;
  padding: var(--space-4);
}

x-modal .modal-body .card-header {
  padding: 0 0 var(--space-4);
  border-bottom: none;
}

x-modal .modal-body .card-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

x-modal .modal-body .card-body {
  padding: 0;
}

x-modal .modal-body .form-group {
  margin-bottom: var(--space-4);
}

x-modal .modal-body .form-group:last-child {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  x-modal .modal-dialog {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg);
  }

  x-modal .modal-body {
    padding: var(--space-3) var(--space-4) var(--space-4);
  }
}

[data-theme="dark"] x-modal .modal-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

/* List view header standardization */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.list-header .page-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

/* Card grid for list views */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: var(--space-4);
}

@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* Table action buttons spacing */
.table .btn-sm {
  padding: var(--space-1) var(--space-2);
}

/* Empty state standardization */
.empty-state-compact {
  text-align: center;
  padding: var(--space-12) 0;
}

.empty-state-compact .empty-state-icon-wrapper {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-4);
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-2xl);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-compact .empty-state-icon {
  width: 40px;
  height: 40px;
  color: var(--text-tertiary);
}

.empty-state-compact .empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--space-2);
}

.empty-state-compact .empty-state-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0;
}
