/* =============================================
   CRM销售管理系统 - 全局样式
   ============================================= */

:root {
  --primary:    #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #3b82f6;
  --success:    #10b981;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --info:       #06b6d4;
  --sidebar-bg: #1e293b;
  --sidebar-w:  240px;
  --topbar-h:   60px;
  --text-muted: #64748b;
  --border:     #e2e8f0;
  --bg-light:   #f8fafc;
  --card-shadow: 0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  background: var(--bg-light);
  color: #1e293b;
  margin: 0;
  padding: 0;
}

/* =====================
   布局框架
   ===================== */
.wrapper {
  display: flex;
  min-height: 100vh;
}

/* =====================
   侧边栏
   ===================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px 16px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.08);
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.sidebar-brand i { color: var(--primary-light); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { color: #f1f5f9; font-size: 13px; font-weight: 600; }
.user-role { color: #94a3b8; font-size: 11px; }

.sidebar-menu {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
}

.menu-sep {
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 16px 16px 4px;
}

.menu-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #94a3b8;
  text-decoration: none;
  transition: all .15s;
  border-radius: 0;
  white-space: nowrap;
}

.menu-item a i {
  width: 16px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.menu-item a:hover {
  color: #f1f5f9;
  background: rgba(255,255,255,.06);
}

.menu-item.active a {
  color: #fff;
  background: var(--primary);
}

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

/* =====================
   顶部导航栏
   ===================== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all .15s;
  display: none;
}
.sidebar-toggle:hover { background: var(--bg-light); color: var(--primary); }

.topbar-icon {
  position: relative;
  color: #64748b;
  text-decoration: none;
  padding: 6px;
  border-radius: 6px;
}
.topbar-icon:hover { background: var(--bg-light); }
.topbar-icon .badge {
  position: absolute;
  top: 0; right: 0;
  font-size: 10px;
  padding: 2px 4px;
}

.topbar-user {
  color: #1e293b !important;
  text-decoration: none !important;
  padding: 4px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
  overflow: hidden;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* =====================
   内容区域
   ===================== */
.content-area {
  flex: 1;
  padding: 24px;
}

/* =====================
   卡片
   ===================== */
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  background: #fff;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: 10px 10px 0 0 !important;
  font-weight: 600;
}

.card-body { padding: 20px; }

/* 统计卡片 */
.stat-card {
  border-radius: 12px;
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}
.stat-card .stat-icon {
  font-size: 36px;
  opacity: .3;
  position: absolute;
  right: 20px; top: 50%;
  transform: translateY(-50%);
}
.stat-card .stat-number {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card .stat-label {
  font-size: 13px;
  opacity: .85;
}
.stat-card .stat-change {
  font-size: 12px;
  margin-top: 8px;
  opacity: .9;
}
.stat-card.primary { background: linear-gradient(135deg, #1e40af, #3b82f6); }
.stat-card.success { background: linear-gradient(135deg, #047857, #10b981); }
.stat-card.warning { background: linear-gradient(135deg, #b45309, #f59e0b); }
.stat-card.danger  { background: linear-gradient(135deg, #b91c1c, #ef4444); }
.stat-card.info    { background: linear-gradient(135deg, #0e7490, #06b6d4); }
.stat-card.purple  { background: linear-gradient(135deg, #6d28d9, #8b5cf6); }

/* =====================
   表格
   ===================== */
.table {
  margin-bottom: 0;
}
.table thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  padding: 12px 16px;
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  border-color: #f1f5f9;
}
.table-striped tbody tr:nth-of-type(odd) td { background: #fafbfc; }
.table-hover tbody tr:hover td { background: #eff6ff; }
.table-responsive { border-radius: 8px; }

/* =====================
   按钮
   ===================== */
.btn {
  border-radius: 7px;
  font-size: 13px;
  padding: 7px 14px;
  font-weight: 500;
  transition: all .15s;
}
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon {
  width: 30px; height: 30px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
}

/* =====================
   表单
   ===================== */
.form-control, .form-select {
  border-radius: 7px;
  border-color: var(--border);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-label { font-weight: 500; font-size: 13px; margin-bottom: 5px; }

/* =====================
   徽章
   ===================== */
.badge { font-size: 11px; font-weight: 500; border-radius: 5px; padding: 3px 8px; }

/* =====================
   页面标题区
   ===================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; color: #1e293b; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin: 2px 0 0; }

/* =====================
   搜索/筛选栏
   ===================== */
.filter-bar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--card-shadow);
}

/* =====================
   时间轴
   ===================== */
.timeline {
  position: relative;
  padding-left: 28px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 10px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  margin-bottom: 20px;
}
.timeline-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  position: absolute;
  left: -28px; top: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--border);
}
.timeline-content {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.timeline-time { color: var(--text-muted); font-size: 12px; }

/* =====================
   仪表盘
   ===================== */
.dash-chart-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--card-shadow);
}
.dash-chart-card .card-header {
  border-radius: 12px 12px 0 0;
}

/* =====================
   进度条
   ===================== */
.progress { border-radius: 10px; }
.progress-bar { transition: width .6s ease; }

/* =====================
   登录页
   ===================== */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #1e40af 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo i {
  font-size: 40px;
  color: var(--primary);
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: #1e293b;
  margin-bottom: 4px;
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 28px;
}

/* =====================
   安装向导
   ===================== */
.install-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #1e40af 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.install-card {
  width: 100%;
  max-width: 680px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  overflow: hidden;
}
.install-header {
  background: var(--primary);
  color: #fff;
  padding: 28px 36px;
}
.install-body { padding: 36px; }
.install-steps {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
}
.install-step {
  flex: 1;
  text-align: center;
  position: relative;
}
.install-step::after {
  content: '';
  position: absolute;
  top: 16px; left: 50%; right: -50%;
  height: 2px;
  background: var(--border);
}
.install-step:last-child::after { display: none; }
.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  margin: 0 auto 6px;
  position: relative;
  z-index: 1;
}
.install-step.active .step-num,
.install-step.done .step-num { background: var(--primary); color: #fff; }
.step-label { font-size: 11px; color: var(--text-muted); }
.install-step.active .step-label { color: var(--primary); font-weight: 600; }

/* =====================
   快捷操作
   ===================== */
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: #1e293b;
  transition: all .2s;
  text-align: center;
  cursor: pointer;
}
.quick-action:hover {
  background: #eff6ff;
  border-color: var(--primary-light);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(30,64,175,.15);
}
.quick-action i { font-size: 24px; }
.quick-action span { font-size: 13px; font-weight: 500; }

/* =====================
   客户等级颜色
   ===================== */
.level-A { color: #ef4444; font-weight: 700; }
.level-B { color: #f59e0b; font-weight: 700; }
.level-C { color: #06b6d4; font-weight: 700; }
.level-D { color: #94a3b8; }

/* =====================
   库存预警行
   ===================== */
tr.stock-warning td { background: #fef9c3 !important; }
tr.stock-danger td  { background: #fee2e2 !important; }

/* =====================
   商机漏斗
   ===================== */
.funnel-bar {
  border-radius: 4px;
  height: 32px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  transition: width .6s ease;
}

/* =====================
   分页
   ===================== */
.pagination { gap: 2px; }
.page-link {
  border-radius: 6px !important;
  border-color: var(--border);
  color: #1e293b;
  font-size: 13px;
  padding: 5px 10px;
}
.page-link:hover { background: #eff6ff; color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* =====================
   图表容器
   ===================== */
.chart-container { position: relative; }

/* =====================
   空数据提示
   ===================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; opacity: .3; margin-bottom: 16px; }
.empty-state p { margin: 0; font-size: 14px; }

/* =====================
   响应式 - 移动端
   ===================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex !important; }
  .main-content { margin-left: 0; }
  .content-area { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stat-card .stat-number { font-size: 22px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .filter-bar .row > div { margin-bottom: 8px; }
  .table-responsive { font-size: 13px; }
  /* 底部固定导航（移动端） */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    z-index: 1100;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  }
}

.mobile-bottom-nav {
  display: none;
  justify-content: space-around;
  padding: 8px 0;
}
.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s;
}
.mobile-nav-item i { font-size: 18px; }
.mobile-nav-item.active, .mobile-nav-item:hover { color: var(--primary); }

@media (max-width: 768px) {
  .content-area { padding-bottom: 72px; }
}

/* =====================
   工具类
   ===================== */
.text-primary { color: var(--primary) !important; }
.bg-primary-soft { background: #eff6ff; }
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.cursor-pointer { cursor: pointer; }

/* 预测卡片 */
.predict-card {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 16px;
}
.predict-card h6 { color: var(--primary); font-weight: 700; }

/* 滚动条美化 */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }
