/* ============================================
   通用组件 — 产品卡片/客户管理/CRM/反馈/文案/AI控制台
   从 style.css 拆分
   ============================================ */

/* ----- Product Card ----- */
.product-list { display: flex; flex-direction: column; gap: var(--space-3); }

.product-card {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-light);
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  cursor: pointer;
}
.product-card:active {
  background: var(--color-surface-hover);
  transform: scale(.985);
}

.product-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: var(--color-primary-soft);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.625rem;
}

.product-body { flex: 1; min-width: 0; }

.product-name {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-category {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.product-pricing {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.price-now {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
}

.price-cost {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-decoration: line-through;
}

.price-margin {
  font-size: var(--text-xs);
  color: var(--color-success);
  font-weight: 600;
  margin-left: auto;
  background: var(--color-success-bg);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
}

.product-reason {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-tags {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: .01em;
}

.tag-warm  { background: var(--color-primary-soft); color: var(--color-primary); }
.tag-cool  { background: #EEF2FF; color: #4F6EF7; }
.tag-green { background: var(--color-success-bg); color: var(--color-success); }

/* ----- Customer Management ----- */
#page-customers.active {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-2) var(--space-5) 0;
}

#page-customers .product-list {
  flex: 1;
  overflow-y: auto;
  gap: 4px;
  padding-bottom: calc(var(--nav-height) + var(--space-4) + env(safe-area-inset-bottom, 0px));
}

.customer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.customer-topbar-left {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.customer-topbar-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

.customer-topbar-count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.customer-topbar-actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

#page-customers .search-bar {
  margin-top: var(--space-1);
  margin-bottom: var(--space-2);
  flex-shrink: 0;
}

.customer-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
  margin-bottom: var(--space-1);
}

#page-customers .product-card {
  padding: var(--space-4);
  align-items: flex-start;
  cursor: default;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.customer-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #F97316, #FB923C);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(249,115,22,.18);
}

.customer-name-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 2px;
}

.customer-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.customer-phone {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-left: auto;
}

.customer-status {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  line-height: 1.5;
}

.customer-status.active  { background: var(--color-success-bg); color: var(--color-success); }
.customer-status.sleeping { background: var(--color-warning-bg); color: var(--color-warning); }
.customer-status.lost     { background: var(--color-danger-bg); color: var(--color-danger); }

.customer-stats {
  display: flex;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  flex-wrap: wrap;
  line-height: 1.5;
  margin-top: 2px;
}

.customer-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.customer-delete:active {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* ----- CRM Overview ----- */
.crm-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.crm-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  text-align: center;
}

.crm-stat-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
}

.crm-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ----- CRM Filter Tabs ----- */
.crm-filter-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  overflow-x: auto;
}

.crm-filter-tab {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast);
  text-align: center;
}

.crm-filter-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ----- CRM Insights ----- */
.crm-insights-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.crm-insights-toggle:active {
  opacity: 0.7;
}

.crm-insight-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.crm-insight-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.crm-insight-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.crm-insight-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.crm-insight-item .cust-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.crm-insight-item .cust-info {
  flex: 1;
  min-width: 0;
}

.crm-insight-item .cust-name {
  font-weight: 600;
  color: var(--color-text);
}

.crm-insight-item .cust-detail {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-insight-item .risk-badge {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.risk-critical { background: #FEE2E2; color: #DC2626; }
.risk-high     { background: #FEF3C7; color: #D97706; }
.risk-medium   { background: #FEF9C3; color: #CA8A04; }
.risk-low      { background: #DBEAFE; color: #2563EB; }

.crm-empty {
  text-align: center;
  padding: var(--space-4);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

/* ----- Feedback Buttons ----- */
.product-actions {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-2);
  justify-content: flex-end;
}

.feedback-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--color-surface);
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--duration-fast) var(--ease-out);
}

.feedback-btn:active {
  transform: scale(1.2);
  background: var(--color-primary-soft);
}

/* ----- Feedback Reason Picker ----- */
.feedback-reason-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-4);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  z-index: 1200;
  transform: translateY(100%);
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
}
.feedback-reason-panel.show {
  transform: translateY(0);
}
.feedback-reason-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  text-align: center;
}
.feedback-reason-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.feedback-reason-chip {
  padding: var(--space-3) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--duration-fast);
  text-align: center;
}
.feedback-reason-chip:active {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.feedback-reason-close {
  display: block;
  width: 100%;
  padding: var(--space-3);
  border: none;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}
.feedback-reason-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 1199;
}

/* ----- Copy Generator ----- */
.form-group { margin-bottom: var(--space-4); }

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-select, .form-textarea {
  width: 100%;
  padding: var(--space-3) 0;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color var(--duration-fast) var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A8A29E' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.form-textarea {
  min-height: 76px;
  resize: vertical;
}

/* Style pills */
.style-pills {
  display: flex;
  gap: var(--space-2);
}

.style-pill {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  text-align: center;
  transition: all var(--duration-fast) var(--ease-out);
}

.style-pill.active {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

/* ----- AI 智能体生成控制台 ----- */
.generate-console {
  height: auto !important;
  min-height: 104px !important;
  padding: var(--space-3) var(--space-4) !important;
  border: 1.5px solid #6366F1 !important;
  border-radius: 14px !important;
  background: linear-gradient(160deg, #1E1B2E 0%, #1A1728 50%, #1E1B2E 100%) !important;
  color: #A5B4FC !important;
  font-size: var(--text-xs) !important;
  font-weight: 400 !important;
  line-height: 1.6 !important;
  text-align: left !important;
  letter-spacing: .01em !important;
  box-shadow: 0 0 12px rgba(99,102,241,.2), 0 4px 24px rgba(99,102,241,.08), inset 0 1px 0 rgba(255,255,255,.04) !important;
  cursor: default !important;
  overflow: hidden !important;
  transition: all .3s ease !important;
}

.console-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.console-line {
  animation: consoleSlideIn .35s cubic-bezier(.16,1,.3,1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.console-prompt {
  color: #818CF8;
  font-weight: 700;
  margin-right: 2px;
}

.console-line.log-info  { color: #94A3B8; }
.console-line.log-think { color: #A5B4FC; }
.console-line.log-action { color: #F9A8D4; }
.console-line.log-highlight { color: #FBBF24; font-weight: 500; }

@keyframes consoleSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Copy result card */
.copy-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.copy-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-surface);
}

.badge {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 3px var(--space-3);
  border-radius: var(--radius-full);
  letter-spacing: .03em;
  text-transform: uppercase;
}

.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-warm    { background: #FFF7ED; color: var(--color-primary); }
.badge-muted   { background: var(--color-surface-hover); color: var(--color-text-muted); }

.copy-card-body {
  padding: var(--space-5);
  font-size: var(--text-base);
  line-height: 1.8;
  white-space: pre-line;
  color: var(--color-text);
}

.copy-card-actions {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border-light);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:active { background: var(--color-surface-hover); transform: scale(.97); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  font-weight: 700;
}
.btn-primary:active { background: var(--color-primary-hover); }

.btn-secondary {
  background: var(--color-surface-hover);
  color: var(--color-text);
  border-color: transparent;
}
.btn-secondary:active { background: var(--color-border); }

.btn-outline {
  background: transparent;
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.btn-outline:active { background: var(--color-primary-soft); }

.btn-block { width: 100%; }

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

