/* Core Design System */
@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-bg: #ffffff;
  --color-bg-secondary: #f8f9fa;
  --color-bg-tertiary: #f1f3f5;
  --color-surface: #ffffff;
  --color-border: #e2e5e9;
  --color-text: #1a1a2e;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  --color-primary: #7c5cfc;
  --color-primary-hover: #6a4ae8;
  --color-primary-light: rgba(124,92,252,0.08);
  --color-primary-text: #ffffff;
  --color-success: #22c55e;
  --color-success-light: rgba(34,197,94,0.1);
  --color-warning: #f59e0b;
  --color-warning-light: rgba(245,158,11,0.1);
  --color-danger: #ef4444;
  --color-danger-light: rgba(239,68,68,0.1);
  --color-info: #3b82f6;
  --color-info-light: rgba(59,130,246,0.1);
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 56px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: 0.15s ease;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
}

[data-theme="dark"] {
  --color-bg: #0f1117;
  --color-bg-secondary: #161922;
  --color-bg-tertiary: #1e212b;
  --color-surface: #1a1d27;
  --color-border: #2a2d38;
  --color-text: #e2e4e9;
  --color-text-secondary: #9ca3af;
  --color-text-muted: #5c6370;
  --color-primary-light: rgba(124,92,252,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.2;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-primary-hover);
}

ul, ol {
  list-style: none;
}

code {
  font-family: var(--font-mono);
  background: var(--color-bg-tertiary);
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

::selection {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-info { color: var(--color-info); }
.text-white { color: #fff; }
.text-dark { color: var(--color-text); }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }
.text-3xl { font-size: 30px; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.uppercase { text-transform: uppercase; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; }

.mr-2 { margin-right: 8px; }
.ml-auto { margin-left: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 24px; }
.px-5 { padding-left: 24px; padding-right: 24px; }
.pb-4 { padding-bottom: 16px; }
.pt-4 { padding-top: 16px; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 24px; }

.w-full { width: 100%; }
.w-32 { width: 128px; }
.max-w-3xl { max-width: 768px; }
.max-w-5xl { max-width: 1024px; }
.border { border: 1px solid var(--color-border); }
.border-t { border-top: 1px solid var(--color-border); }
.border-b { border-bottom: 1px solid var(--color-border); }
.rounded { border-radius: var(--radius); }
.cursor-pointer { cursor: pointer; }
.relative { position: relative; }

.hidden { display: none !important; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Chip (inline label badge) */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }

/* Responsive visibility */
@media (min-width: 769px) {
  .hidden-desktop { display: none !important; }
}
@media (max-width: 768px) {
  .hidden-mobile { display: none !important; }
}

/* Layout */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-overlay);
  transition: transform 0.2s ease, width 0.2s ease;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-weight: 700;
  font-size: 18px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  transition: var(--transition);
  gap: 12px;
}

.sidebar-nav-item:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.sidebar-nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 500;
}

.sidebar-divider {
  height: 1px;
  background: var(--color-border);
  margin: 12px 0;
}

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
}

.sidebar-user-name {
  font-weight: 500;
  color: var(--color-text);
  font-size: 14px;
}

.sidebar-user-email {
  font-size: 12px;
  color: var(--color-text-muted);
}

.sidebar-user-logout {
  color: var(--color-text-muted);
  cursor: pointer;
}
.sidebar-user-logout:hover {
  color: var(--color-danger);
}

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}

.topbar {
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-sticky);
  display: none;
}

.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  z-index: 100;
  padding: 0 16px;
}

.mobile-nav-items {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 10px;
  gap: 4px;
  width: 20%;
}

.mobile-nav-item.active {
  color: var(--color-primary);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.active {
    display: block;
  }
  .main {
    margin-left: 0;
  }
  .mobile-nav {
    display: block;
  }
  .content {
    padding-bottom: 88px; /* space for mobile nav */
  }
  .grid-2, .grid-3, .grid-4, .grid-5 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .grid-4, .grid-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media print {
  .sidebar, .topbar, .mobile-nav { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
}
