/* ============================================================
   仕必达业务中台 v2 — Business Console Design System
   配色: primary(#3b82f6, #1e293b, #334155)
   ============================================================ */

:root {
  /* ---- 品牌色 ---- */
  --brand: #3b82f6;
  --brand-hover: #2563eb;
  --brand-light: #eff6ff;
  --brand-bg: rgba(59, 130, 246, 0.08);

  /* ---- 侧边栏 ---- */
  --sidebar-bg: #0f172a;
  --sidebar-bg-hover: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-group-title: #64748b;
  --sidebar-divider: rgba(148, 163, 184, 0.12);

  /* ---- 中性色 ---- */
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* ---- 功能色 ---- */
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #6366f1;
  --info-light: #eef2ff;

  /* ---- 圆角/阴影/间距 ---- */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.06), 0 4px 6px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.08), 0 10px 10px rgba(0,0,0,0.04);

  /* ---- 动效 ---- */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- 字体 ---- */
  --font-sans: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;

  /* ---- 侧边栏宽度 ---- */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
}

/* ============================================================
   全局重置
   ============================================================ */
* { box-sizing: border-box; }

html { font-size: 14px; }

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

/* ============================================================
   侧边栏 — Business Console 风格
   ============================================================ */
.sidebar {
  min-height: 100vh;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #1a2332 100%);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1030;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition);
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--sidebar-divider);
}

.sidebar .brand .brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar .brand .brand-icon svg {
  color: #fff;
  width: 18px;
  height: 18px;
}

/* 侧边栏导航容器 */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

/* 业务域分组标题 */
.sidebar-group {
  margin-bottom: 2px;
}

.sidebar-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 6px;
  color: var(--sidebar-group-title);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-group-header:hover {
  color: var(--sidebar-text);
}

.sidebar-group-header .chevron {
  margin-left: auto;
  transition: transform var(--transition);
  opacity: 0.5;
}

.sidebar-group-header .chevron.open {
  transform: rotate(90deg);
}

/* 导航链接 */
.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 20px;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  margin: 1px 8px;
  font-size: 13.5px;
  font-weight: 450;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav-link:hover {
  background: var(--sidebar-bg-hover);
  color: #e2e8f0;
}

.sidebar-nav-link.active {
  background: var(--brand);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.sidebar-nav-link .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-nav-link .nav-icon svg {
  width: 18px;
  height: 18px;
}

/* 侧边栏子链接 */
.sidebar-sub {
  display: none;
}

.sidebar-sub.open {
  display: block;
}

.sidebar-sub .sidebar-nav-link {
  padding-left: 48px;
  font-size: 13px;
}

/* 侧边栏底部用户区 */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-divider);
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-footer .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--sidebar-bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-footer .user-meta {
  flex: 1;
  min-width: 0;
}

.sidebar-footer .user-meta .user-name {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer .user-meta .user-role {
  color: var(--sidebar-group-title);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer .logout-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-footer .logout-btn:hover {
  background: var(--sidebar-bg-hover);
  color: var(--danger);
}

/* ============================================================
   主内容区
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 24px 28px;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* 页面标题 */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title .icon {
  width: 28px;
  height: 28px;
  color: var(--brand);
}

/* ============================================================
   卡片系统
   ============================================================ */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: 14px 18px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-body { padding: 18px; }

.card-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  padding: 12px 18px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* 统计卡片 */
.stat-card {
  border: none;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  transition: all var(--transition);
  cursor: default;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg) !important;
}

.stat-card .card-body {
  padding: 20px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

/* ============================================================
   Section 标题
   ============================================================ */
.section-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--brand);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ============================================================
   看板/Kanban 列
   ============================================================ */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.kanban-col {
  min-width: 260px;
  max-width: 300px;
  flex: 1;
  background: var(--border-light);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 400px;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-secondary);
}

.kanban-col-header .count-badge {
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.kanban-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.kanban-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--brand);
}

/* ============================================================
   表格增强
   ============================================================ */
.table-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table thead th {
  background: #f8fafc;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--border);
  padding: 12px 14px;
}

.table tbody td {
  padding: 12px 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
}

.table tbody tr:hover {
  background: var(--brand-light);
}

/* ============================================================
   按钮系统
   ============================================================ */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  padding: 7px 16px;
  transition: all var(--transition-fast);
}

.btn-sm {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

/* ============================================================
   Badge / 状态标签
   ============================================================ */
.badge {
  font-weight: 500;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 20px;
}

/* ============================================================
   预警行
   ============================================================ */
.alert-critical {
  border-left: 3px solid var(--danger);
}

.alert-warning {
  border-left: 3px solid var(--warning);
}

.alert-row:hover {
  background-color: #f8fafc;
}

/* ============================================================
   表单增强
   ============================================================ */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border);
  font-size: 13.5px;
  padding: 8px 12px;
  transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-label {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ============================================================
   分页
   ============================================================ */
.pagination .page-link {
  border-radius: var(--radius-sm);
  margin: 0 2px;
  color: var(--text-secondary);
  font-size: 13px;
  border: 1px solid var(--border);
}

.pagination .page-link:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.pagination .active .page-link {
  background: var(--brand);
  border-color: var(--brand);
}

/* ============================================================
   进度条
   ============================================================ */
.progress {
  background: var(--border-light);
  border-radius: 10px;
  height: 8px;
}

.progress-bar {
  border-radius: 10px;
}

/* ============================================================
   Alert 消息
   ============================================================ */
.alert {
  border-radius: var(--radius);
  border: none;
  font-size: 13.5px;
}

/* ============================================================
   工具类
   ============================================================ */
.bg-brand-soft { background: var(--brand-bg); }
.text-brand { color: var(--brand); }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }
  .sidebar .brand span,
  .sidebar-group-header span,
  .sidebar-nav-link span,
  .sidebar-footer .user-meta { display: none; }
  .sidebar-nav-link { padding: 10px; justify-content: center; }
  .main-content { margin-left: var(--sidebar-collapsed); }
}

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ============================================================
   内容管线看板额外样式
   ============================================================ */
.pipeline-stage {
  transition: all var(--transition);
}

.pipeline-card {
  border-left: 3px solid transparent;
}

.pipeline-card.stage-draft { border-left-color: var(--text-muted); }
.pipeline-card.stage-review { border-left-color: var(--warning); }
.pipeline-card.stage-doc-linked { border-left-color: var(--info); }
.pipeline-card.stage-designing { border-left-color: #8b5cf6; }
.pipeline-card.stage-published { border-left-color: var(--success); }
.pipeline-card.stage-review-data { border-left-color: var(--brand); }
.pipeline-card.stage-optimizing { border-left-color: var(--danger); }

/* ============================================================
   客户360视图
   ============================================================ */
.customer-360-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ============================================================
   下拉菜单与筛选栏
   ============================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.filter-bar .form-control,
.filter-bar .form-select {
  width: auto;
  min-width: 140px;
}

/* ============================================================
   动画 — 淡入
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in-up {
  animation: fadeInUp var(--transition-slow) ease-out;
}

/* 卡片交错动画 */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }
