/* ========================================
   AgentFlow Design System v2.0
   统一设计语言 - 所有页面共享
   ======================================== */

:root {
  /* Colors - Dark tech aesthetic */
  --bg-primary: #07090d;
  --bg-secondary: #0d1117;
  --bg-tertiary: #121821;
  --bg-elevated: #161d27;
  --bg-hover: #1c2532;
  
  /* Brand - Cyan electric */
  --brand: #00d4ff;
  --brand-dim: #00a3cc;
  --brand-glow: rgba(0, 212, 255, 0.15);
  --brand-strong: rgba(0, 212, 255, 0.25);
  
  /* Accents */
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  /* Text */
  --text-primary: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-muted: #475569;
  
  /* Borders */
  --border-subtle: rgba(148, 163, 184, 0.08);
  --border-light: rgba(148, 163, 184, 0.12);
  --border-medium: rgba(148, 163, 184, 0.2);
  
  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px var(--brand-glow);
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  
  /* Spacing */
  --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;
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  
  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

/* ===== Reset ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Background ambient glow */
body::before {
  content: '';
  position: fixed;
  top: -20%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--brand-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

body::after {
  content: '';
  position: fixed;
  bottom: -30%;
  left: -15%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ===== App Layout ===== */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-5) 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
}

.logo-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--brand), var(--accent-purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  position: relative;
}

.logo-mark::after {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, var(--brand), var(--accent-purple));
  border-radius: var(--radius-md);
  filter: blur(8px);
  opacity: 0.4;
  z-index: -1;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-top: 1px;
}

.sidebar-section {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-5);
}

.sidebar-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
  position: relative;
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: var(--brand-glow);
  color: var(--brand);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 18px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  background: var(--accent-rose);
  color: white;
  border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

.user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: background var(--duration-fast);
  cursor: pointer;
}

.user-card:hover { background: var(--bg-hover); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--brand));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-plan {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ===== Main Content ===== */
.main {
  padding: var(--space-6) var(--space-8);
  min-width: 0;
}

/* ===== Top Bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
}

.page-title-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.page-eyebrow {
  font-size: 12px;
  color: var(--brand);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page-eyebrow .dot {
  width: 6px;
  height: 6px;
  background: var(--brand);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--brand);
  color: #001820;
  font-weight: 600;
}

.btn-primary:hover {
  background: #33ddff;
  box-shadow: 0 0 20px var(--brand-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  color: var(--text-primary);
}

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

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

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  transition: all var(--duration-fast);
  cursor: pointer;
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-medium);
  background: var(--bg-hover);
}

/* ===== Panels / Cards ===== */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.panel-title {
  font-size: 14px;
  font-weight: 600;
}

.panel-body {
  padding: var(--space-5);
}

/* ===== Section Headers ===== */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-link {
  font-size: 12.5px;
  color: var(--brand);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap var(--duration-fast);
}

.section-link:hover { gap: 6px; }

/* ===== Status Dots ===== */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.running {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: pulse 2s infinite;
}

.status-dot.idle {
  background: var(--text-muted);
}

.status-dot.error {
  background: var(--accent-rose);
}

.status-text.running { color: var(--accent-green); }
.status-text.idle { color: var(--text-tertiary); }
.status-text.error { color: var(--accent-rose); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ===== Entrance Animations ===== */
.fade-in {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.6s var(--ease-out) forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }
.stagger-9 { animation-delay: 0.45s; }
.stagger-10 { animation-delay: 0.5s; }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .module-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .content-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: var(--space-4) !important; }
  .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .module-grid { grid-template-columns: 1fr !important; }
}
