/**
 * CFM邮件数据看板 - 统一设计系统
 * CFM Unified Design System v1.0
 * 
 * 包含全站统一的组件样式：
 * 1. 按钮组件 (Buttons)
 * 2. 卡片组件 (Cards)  
 * 3. 表格组件 (Tables)
 * 4. 表单组件 (Forms)
 * 5. 标签页组件 (Tabs)
 * 6. 侧边栏组件 (Sidebar)
 * 7. 消息气泡组件 (Chat Bubbles)
 * 8. 步骤指示器 (Steps)
 * 9. 树形组件 (Tree)
 * 10. 筛选器组件 (Filters)
 * 
 * 所有页面必须使用此设计系统以确保风格一致性
 */

/* ==================== CSS变量扩展 ==================== */
:root {
  /* 扩展颜色系统 */
  --primary-gradient: linear-gradient(135deg, #447793 0%, #5a8aa6 100%);
  --primary-gradient-light: linear-gradient(135deg, rgba(68, 119, 147, 0.1) 0%, rgba(90, 138, 166, 0.1) 100%);
  
  /* 玻璃拟态背景 */
  --glass-white: rgba(255, 255, 255, 0.85);
  --glass-white-hover: rgba(255, 255, 255, 0.95);
  --glass-blue: rgba(68, 119, 147, 0.08);
  --glass-purple: rgba(156, 123, 152, 0.08);
  
  /* 间距系统 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* 字体大小 */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  
  /* 行高 */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.75;
}

/* ==================== 1. 按钮组件 ==================== */

/* 基础按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 主要按钮 */
.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(68, 119, 147, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(68, 119, 147, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

/* 次要按钮 */
.btn-secondary {
  background: var(--glass-white);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(68, 119, 147, 0.08);
  border-color: var(--primary-dark);
}

/* 幽灵按钮 */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--glass-blue);
  color: var(--primary-color);
}

/* 危险按钮 */
.btn-danger {
  background: linear-gradient(135deg, #d19a9a 0%, #c47a7a 100%);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #c47a7a 0%, #b06060 100%);
}

/* 按钮尺寸 */
.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-xs);
}

.btn-lg {
  padding: 12px 24px;
  font-size: var(--text-base);
}

/* 图标按钮 */
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-md);
}

/* ==================== 2. 卡片组件 ==================== */

/* 基础卡片 */
.card {
  background: var(--glass-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: var(--transition-base);
}

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

/* 卡片头部 */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--card-border);
}

.card-header h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

/* 卡片内容 */
.card-body {
  padding: var(--space-lg);
}

/* 卡片底部 */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--card-border);
  background: rgba(248, 249, 250, 0.5);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* 强调卡片 - 带顶部边框 */
.card-accent {
  border-top: 3px solid var(--primary-color);
}

.card-accent-purple {
  border-top: 3px solid var(--secondary-color);
}

.card-accent-gold {
  border-top: 3px solid var(--accent-color);
}

/* 信息卡片 */
.card-info {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--glass-blue);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary-color);
}

.card-info-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-gradient);
  color: white;
  border-radius: var(--radius-md);
  font-size: var(--text-lg);
}

.card-info-content h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.card-info-content p {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* ==================== 3. 表格组件 ==================== */

/* 基础表格容器 */
.table-container {
  background: var(--glass-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* 表格 */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

/* 表头 */
.table thead {
  background: linear-gradient(135deg, rgba(68, 119, 147, 0.08) 0%, rgba(68, 119, 147, 0.05) 100%);
}

.table th {
  padding: var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

/* 表体 */
.table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--card-border);
  color: var(--text-secondary);
}

/* 行悬停 */
.table tbody tr {
  transition: var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--glass-blue);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* 选中行 */
.table tbody tr.selected {
  background: rgba(68, 119, 147, 0.12);
}

/* 可点击行 */
.table tbody tr.clickable {
  cursor: pointer;
}

.table tbody tr.clickable:hover {
  background: rgba(68, 119, 147, 0.08);
}

/* 状态标签 */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: 20px;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-success {
  background: rgba(112, 179, 164, 0.15);
  color: #4a9b88;
}

.status-success::before {
  background: #70b3a4;
}

.status-warning {
  background: rgba(250, 173, 20, 0.15);
  color: #d48806;
}

.status-warning::before {
  background: #faad14;
}

.status-error {
  background: rgba(209, 154, 154, 0.15);
  color: #c47a7a;
}

.status-error::before {
  background: #d19a9a;
}

.status-info {
  background: rgba(68, 119, 147, 0.1);
  color: var(--primary-color);
}

.status-info::before {
  background: var(--primary-color);
}

/* ==================== 4. 表单组件 ==================== */

/* 表单组 */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  margin-bottom: var(--space-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.form-label-required::after {
  content: '*';
  color: #d19a9a;
  margin-left: 4px;
}

/* 输入框 */
.form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--glass-white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(68, 119, 147, 0.1);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

/* 选择框 */
.form-select {
  width: 100%;
  padding: 10px 14px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--glass-white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* 文本域 */
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--glass-white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  resize: vertical;
  min-height: 100px;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* 复选框 */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border: 2px solid var(--card-border);
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

/* 开关 */
.form-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.form-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card-border);
  border-radius: 24px;
  transition: var(--transition-base);
}

.switch-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition-base);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.form-switch input:checked + .switch-slider {
  background: var(--primary-color);
}

.form-switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* ==================== 5. 标签页组件 ==================== */

/* 基础标签页 */
.tabs {
  display: flex;
  gap: var(--space-xs);
  border-bottom: 1px solid var(--card-border);
  margin-bottom: var(--space-lg);
}

.tab {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--primary-color);
}

.tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* 卡片式标签页 */
.tabs-card {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-xs);
  background: rgba(248, 249, 250, 0.8);
  border-radius: var(--radius-md);
}

.tab-card {
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.tab-card:hover {
  color: var(--primary-color);
}

.tab-card.active {
  color: var(--primary-color);
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ==================== 6. 侧边栏组件 ==================== */

/* 基础侧边栏 */
.sidebar {
  background: var(--glass-white);
  border-right: 1px solid var(--border-light);
  height: 100%;
  overflow-y: auto;
}

/* 侧边栏菜单项 */
.sidebar-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  margin: 2px var(--space-sm);
  transition: var(--transition-fast);
}

.sidebar-menu-item:hover {
  background: var(--glass-blue);
  color: var(--primary-color);
}

.sidebar-menu-item.active {
  background: var(--primary-gradient);
  color: white;
}

.sidebar-menu-item i {
  width: 20px;
  text-align: center;
}

/* 树形菜单 */
.tree-node {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.tree-node:hover {
  background: var(--glass-blue);
}

.tree-node.active {
  background: var(--glass-blue);
  color: var(--primary-color);
  font-weight: 500;
}

.tree-toggle {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-tertiary);
  transition: transform 0.2s;
}

.tree-toggle.expanded {
  transform: rotate(90deg);
}

.tree-children {
  padding-left: var(--space-lg);
}

/* ==================== 7. 消息气泡组件 ==================== */

/* 消息容器 */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
}

/* 消息气泡 */
.message-bubble {
  max-width: 80%;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

/* AI消息 */
.message-ai {
  align-self: flex-start;
  background: var(--glass-white);
  border: 1px solid var(--border-light);
  border-bottom-left-radius: var(--space-xs);
}

/* 用户消息 */
.message-user {
  align-self: flex-end;
  background: var(--primary-gradient);
  color: white;
  border-bottom-right-radius: var(--space-xs);
}

/* 消息头部 */
.message-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
  font-size: var(--text-xs);
}

.message-ai .message-header {
  color: var(--text-tertiary);
}

.message-user .message-header {
  color: rgba(255, 255, 255, 0.8);
}

/* 快捷操作按钮 */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.quick-action-btn {
  padding: 6px 12px;
  font-size: var(--text-xs);
  color: var(--primary-color);
  background: rgba(68, 119, 147, 0.08);
  border: 1px solid rgba(68, 119, 147, 0.2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.quick-action-btn:hover {
  background: rgba(68, 119, 147, 0.15);
  border-color: var(--primary-color);
}

/* ==================== 8. 步骤指示器 ==================== */

/* 步骤容器 */
.steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
}

/* 单个步骤 */
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  position: relative;
}

.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--card-border);
  z-index: 0;
}

.step.completed:not(:last-child)::after {
  background: var(--primary-color);
}

/* 步骤数字 */
.step-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-white);
  border: 2px solid var(--card-border);
  border-radius: 50%;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  z-index: 1;
}

.step.active .step-number {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.step.completed .step-number {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

/* 步骤标题 */
.step-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.step.active .step-title {
  color: var(--primary-color);
  font-weight: 600;
}

.step.completed .step-title {
  color: var(--text-primary);
}

/* ==================== 9. 筛选器组件 ==================== */

/* 筛选器容器 */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--glass-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
}

/* 筛选组 */
.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.filter-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* 日期选择器 */
.date-picker {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.date-picker input {
  width: 130px;
  padding: 8px 12px;
  font-size: var(--text-sm);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
}

/* 标签筛选 */
.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: var(--text-xs);
  background: var(--glass-blue);
  border: 1px solid rgba(68, 119, 147, 0.2);
  border-radius: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.filter-tag:hover {
  background: rgba(68, 119, 147, 0.15);
}

.filter-tag.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

/* ==================== 10. 分页组件 ==================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-md);
}

.page-btn {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: var(--glass-white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  background: var(--glass-blue);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.page-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ==================== 11. 加载状态 ==================== */

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, 
    rgba(200, 200, 200, 0.2) 25%, 
    rgba(200, 200, 200, 0.3) 50%, 
    rgba(200, 200, 200, 0.2) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 加载动画 */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(68, 119, 147, 0.1);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== 12. 空状态 ==================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  background: var(--glass-blue);
  border-radius: 50%;
  font-size: 32px;
  color: var(--primary-color);
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 300px;
}

/* ==================== 13. 工具类 ==================== */

/* 文本对齐 */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* 字体粗细 */
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* 颜色 */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-primary-color { color: var(--primary-color); }

/* 弹性布局 */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* 间距 */
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.m-md { margin: var(--space-md); }
.m-lg { margin: var(--space-lg); }

/* 隐藏 */
.hidden { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==================== 14. 响应式工具类 ==================== */

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
  
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-group {
    flex-wrap: wrap;
  }
  
  .table-container {
    overflow-x: auto;
  }
  
  .table {
    min-width: 600px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .hide-tablet {
    display: none !important;
  }
}

@media (min-width: 1025px) {
  .hide-desktop {
    display: none !important;
  }
}
