/* ============================================
   CONTACTS PAGE - 通讯录（表格布局）
   ============================================ */
.contacts-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

/* Toolbar */
.contacts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.contacts-toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.contacts-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.contacts-count {
  font-size: 12.5px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.contacts-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search box */
.contacts-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.contacts-search-box svg {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.contacts-search-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px 7px 34px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-white);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 220px;
}

.contacts-search-input::placeholder {
  color: var(--gray-400);
}

.contacts-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

/* Groups bar */
.contacts-groups-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px 14px;
  border-bottom: 1px solid var(--border-light);
}

.contacts-groups-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.contacts-group-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px dashed var(--border);
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.contacts-group-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-subtle);
}

.contacts-group-add-btn svg {
  width: 14px;
  height: 14px;
}

/* Group tags */
.contact-group-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  white-space: nowrap;
}

.contact-group-tag svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.contact-group-tag:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.contact-group-tag.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.contact-group-count {
  font-size: 10.5px;
  background: var(--gray-100);
  color: var(--text-tertiary);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
  line-height: 1.4;
}

.contact-group-tag.active .contact-group-count {
  background: rgba(67, 97, 238, 0.15);
  color: var(--primary);
}

.contact-group-actions {
  display: none;
  align-items: center;
  gap: 1px;
  margin-left: 2px;
}

.contact-group-tag:hover .contact-group-actions {
  display: inline-flex;
}

.contact-group-edit,
.contact-group-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.contact-group-edit svg,
.contact-group-delete svg {
  width: 11px;
  height: 11px;
}

.contact-group-edit:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.contact-group-delete:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Contacts table */
.contacts-list-wrapper {
  position: relative;
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
}

.contacts-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.contacts-table th {
  padding: 10px 24px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.contacts-th-actions {
  width: 100px;
}

.contacts-table td {
  padding: 12px 24px;
  font-size: 13.5px;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.contacts-table tbody tr {
  transition: background var(--transition-fast);
}

.contacts-table tbody tr:hover {
  background: var(--primary-subtle);
}

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

/* Contact name cell */
.contacts-cell-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contacts-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.contacts-name-text {
  font-weight: 600;
  color: var(--text);
}

/* Contact email cell */
.contacts-cell-email {
  color: var(--text-secondary);
  font-size: 13px;
}

/* Contact group badge */
.contacts-group-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--text-secondary);
}

.contacts-group-badge svg {
  width: 11px;
  height: 11px;
}

/* Contact actions cell */
.contacts-cell-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.contacts-table tbody tr:hover .contacts-cell-actions {
  opacity: 1;
}

.contacts-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.contacts-action-btn:hover {
  background: var(--gray-100);
  color: var(--primary);
}

.contacts-action-btn.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.contacts-action-btn svg {
  width: 15px;
  height: 15px;
}

/* Empty states */
.contacts-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.contacts-empty svg {
  width: 48px;
  height: 48px;
  color: var(--gray-300);
  margin-bottom: 16px;
}

.contacts-empty h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.contacts-empty p {
  font-size: 13px;
  color: var(--text-tertiary);
}

.contacts-empty-sm {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 768px) {
  .contacts-toolbar {
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .contacts-toolbar-right {
    flex-wrap: wrap;
  }

  .contacts-search-input {
    width: 100%;
  }

  .contacts-groups-bar {
    padding: 0 16px 12px;
  }

  .contacts-table th,
  .contacts-table td {
    padding: 10px 16px;
  }

  .contacts-th-group {
    display: none;
  }

  .contacts-table td:nth-child(3) {
    display: none;
  }

  .contacts-cell-actions {
    opacity: 1;
  }
}

/* ============================================
   CONTACT PROFILE MODAL - 联系人画像弹窗
   Linear-style minimalist: 画廊级留白、电光蓝强调、发丝线分隔
   ============================================ */
.profile-modal {
  max-width: 560px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.18), 0 8px 24px -8px rgba(0, 0, 0, 0.08);
}

.profile-modal .modal-header {
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.profile-modal .modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.profile-content {
  overflow-y: auto;
  padding: 0 28px 32px;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.profile-content::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Opera */
}

/* ---------- 加载状态 ---------- */
.profile-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
}

.profile-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--gray-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: profile-spin 0.7s linear infinite;
  margin-bottom: 20px;
}

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

.profile-loading p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.profile-loading .profile-loading-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ---------- 错误状态 ---------- */
.profile-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
}

.profile-error svg {
  width: 28px;
  height: 28px;
  color: var(--gray-300);
  margin-bottom: 16px;
}

.profile-error p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* ---------- 区块通用 ---------- */
.profile-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--border-light);
}

.profile-section:last-child {
  border-bottom: none;
  padding-bottom: 4px;
}

.profile-section:first-child {
  padding-top: 24px;
}

.profile-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  margin: 0 0 16px;
}

/* ---------- 头部信息 ---------- */
.profile-header-info {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 4px 0 0;
}

.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.profile-header-text {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}

.profile-header-text h4 {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.3;
}

.profile-header-text .profile-email {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
}

.profile-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.profile-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.profile-meta-item svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* ---------- 大数字展示（画廊感） ---------- */
.profile-metrics {
  display: flex;
  gap: 32px;
  align-items: baseline;
}

.profile-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-metric-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.profile-metric-value-accent {
  color: var(--primary);
}

.profile-metric-label {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

/* ---------- 次要信息行 ---------- */
.profile-sub-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: 16px;
  font-size: 12px;
}

.profile-sub-item {
  color: var(--text-secondary);
}

.profile-sub-item strong {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ---------- 联系频率图表（精炼版） ---------- */
.profile-chart {
  margin-top: 20px;
}

.profile-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 48px;
}

.profile-chart-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.profile-chart-bar-fill {
  width: 100%;
  background: var(--gray-200);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: background 0.2s ease;
}

.profile-chart-bar.active .profile-chart-bar-fill {
  background: var(--primary);
}

.profile-chart-bar:hover .profile-chart-bar-fill {
  background: var(--primary-hover);
}

.profile-chart-labels {
  display: flex;
  gap: 3px;
  margin-top: 8px;
}

.profile-chart-label {
  flex: 1;
  text-align: center;
  font-size: 9px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ---------- 话题标签（轮廓线版） ---------- */
.profile-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-topic-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xs);
  font-size: 12px;
  color: var(--text-secondary);
  background: transparent;
  transition: all 0.15s ease;
  letter-spacing: -0.01em;
}

.profile-topic-tag:hover {
  border-color: var(--gray-300);
  color: var(--text);
}

/* ---------- AI 画像总结（左强调边） ---------- */
.profile-summary {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: pre-wrap;
  padding-left: 14px;
  border-left: 2px solid var(--primary);
}

/* ---------- AI 未配置 / 无数据 ---------- */
.profile-ai-placeholder {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.profile-ai-placeholder p {
  margin: 0 0 4px;
}

.profile-ai-placeholder .profile-ai-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0;
}

.profile-ai-error {
  font-size: 13px;
  color: var(--danger);
  line-height: 1.6;
}

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
  .profile-modal {
    max-width: 95vw;
  }

  .profile-modal .modal-header,
  .profile-content {
    padding-left: 20px;
    padding-right: 20px;
  }

  .profile-metrics {
    gap: 20px;
    flex-wrap: wrap;
  }

  .profile-metric-value {
    font-size: 24px;
  }

  .profile-header-info {
    flex-direction: column;
    gap: 12px;
  }
}
