/* ==========================================================================
   WeCom Mobile CRM - Design System & Modern Responsive UI
   ========================================================================== */

:root {
  --primary: #2b7afb;
  --primary-hover: #1e62db;
  --primary-light: #eaf2ff;
  --primary-gradient: linear-gradient(135deg, #2b7afb 0%, #1e52db 100%);
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #06b6d4;
  --info-light: #ecfeff;

  --bg-main: #f4f6fb;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 响应式容器：移动端全屏，桌面端居中保持手机模拟器优雅宽度 */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background-color: var(--bg-main);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.06);
}

@media (min-width: 768px) {
  body {
    padding: 24px 0;
    background: linear-gradient(135deg, #e6ecf8 0%, #f4f6fb 100%);
  }
  .app-container {
    min-height: 880px;
    height: auto;
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 20px 40px rgba(30, 41, 59, 0.12);
  }
}

/* 顶部导航栏 (Header) */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.header-btn {
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.header-btn:active {
  background-color: var(--border-light);
  transform: scale(0.95);
}

/* 主内容区域 */
.app-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(76px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 底部 Tabbar */
.app-tabbar {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 calc(6px + var(--safe-bottom)) 0;
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  gap: 3px;
  flex: 1;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.tab-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  transition: transform 0.2s;
}

.tab-item.active {
  color: var(--primary);
  font-weight: 600;
}

.tab-item.active svg {
  transform: translateY(-2px);
}

.tab-badge {
  position: absolute;
  top: -2px;
  right: 25%;
  background-color: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  padding: 1px 5px;
  border-radius: 10px;
  line-height: 1.2;
}

/* 卡片系统 */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* 顶部用户微名片 */
.user-hero-card {
  background: linear-gradient(135deg, #1e52db 0%, #2b7afb 50%, #4c8fff 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 20px rgba(43, 122, 251, 0.25);
}

.user-hero-card::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -30px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.user-profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-sm);
  background: #fff;
}

.user-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.user-sub {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}

/* 统计卡片网格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-box {
  background: #ffffff;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.stat-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-box.blue::before { background: var(--primary); }
.stat-box.green::before { background: var(--success); }
.stat-box.amber::before { background: var(--warning); }
.stat-box.rose::before { background: var(--danger); }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 6px;
  letter-spacing: -0.5px;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

/* 快捷操作栏 */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.quick-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  background: #ffffff;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all 0.2s;
}

.quick-action-item:active {
  transform: scale(0.96);
  background-color: var(--primary-light);
}

.action-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.quick-action-item span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

/* 徽章 Badge & 标签 Tag */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-muted   { background: #f1f5f9; color: #475569; }

/* 客户列表项卡片 */
.customer-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: block;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}

.customer-card:active {
  transform: scale(0.985);
  background-color: #fafbfc;
}

.customer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.customer-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.customer-company {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.customer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-light);
  border-top: 1px dashed var(--border-light);
  padding-top: 8px;
  margin-top: 8px;
}

/* 跟进时间线 Timeline */
.timeline {
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 6px;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 1px var(--primary);
}

.timeline-dot.system { background: #64748b; box-shadow: 0 0 0 1px #64748b; }
.timeline-dot.visit { background: var(--success); box-shadow: 0 0 0 1px var(--success); }
.timeline-dot.phone { background: var(--warning); box-shadow: 0 0 0 1px var(--warning); }

.timeline-content {
  background: var(--bg-card);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.timeline-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.timeline-time {
  font-size: 11px;
  color: var(--text-light);
}

.timeline-body {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.5;
  word-break: break-word;
}

.timeline-plan {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-color);
  font-size: 12px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 按钮规范 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  line-height: 1.2;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(43, 122, 251, 0.3);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-fab {
  position: fixed;
  right: calc(50% - 210px);
  bottom: calc(85px + var(--safe-bottom));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(43, 122, 251, 0.4);
  z-index: 90;
  text-decoration: none;
}

@media (max-width: 480px) {
  .btn-fab {
    right: 20px;
  }
}

/* 表单输入与控件 */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 122, 251, 0.15);
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

/* 筛选横条 Horizontal Tabs */
.filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.filter-scroll::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: #ffffff;
  border-radius: var(--radius-full);
  text-decoration: none;
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.filter-chip.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(43, 122, 251, 0.25);
}

/* 模态框 / 底部抽屉 (Modal Bottom Sheet) */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.empty-state svg {
  width: 56px;
  height: 56px;
  stroke: var(--text-light);
  margin-bottom: 12px;
  opacity: 0.6;
}
.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
}
