/* 名片系统全局样式 - 移动优先 */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #0d9e6c;
  --danger: #e54545;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 容器 */
.container { max-width: 480px; margin: 0 auto; padding: 16px; }
.container-wide { max-width: 900px; margin: 0 auto; padding: 16px; }

/* 卡片 */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 24px; border: none; border-radius: 8px;
  font-size: 15px; font-weight: 500; cursor: pointer;
  transition: all 0.2s; text-decoration: none;
  gap: 6px; min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; min-height: 34px; }
.btn-lg { padding: 14px 32px; font-size: 16px; min-height: 52px; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 15px; font-family: inherit;
  transition: border-color 0.2s; background: #fff;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* Toast */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #1a1a2e; color: #fff; padding: 12px 24px;
  border-radius: 8px; font-size: 14px; z-index: 9999;
  animation: toastIn 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* 头部导航 */
.navbar {
  background: #fff; padding: 12px 16px; display: flex;
  align-items: center; justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 100;
}
.navbar-title { font-size: 17px; font-weight: 700; }
.navbar-back { font-size: 14px; color: var(--primary); cursor: pointer; background: none; border: none; }

/* 文件上传 */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; cursor: pointer;
  transition: border-color 0.2s; background: #fafbfc;
}
.upload-area:hover { border-color: var(--primary); }
.upload-area.has-image { border-style: solid; padding: 8px; }
.upload-area img { max-width: 100%; max-height: 200px; border-radius: 8px; }
.upload-icon { font-size: 32px; margin-bottom: 8px; }
.upload-text { font-size: 13px; color: var(--text-secondary); }

/* 头像圆形裁剪 */
.avatar-preview {
  width: 80px; height: 80px; border-radius: 50%;
  object-fit: cover; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* 加载动画 */
.loading { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 空状态 */
.empty { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* 模态框 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--radius); padding: 24px;
  max-width: 400px; width: 100%; max-height: 80vh; overflow-y: auto;
}

/* 产品相册网格 */
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.gallery-item {
  background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: none; padding: 0; text-align: left;
  font: inherit; color: inherit; cursor: pointer; width: 100%;
}
.gallery-item:active { transform: scale(0.99); }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.gallery-fallback {
  width: 100%; aspect-ratio: 1; background: #f3f4f6; color: var(--text-secondary);
  display: none; align-items: center; justify-content: center; font-size: 13px;
}
.gallery-item-body { padding: 10px 12px; }
.gallery-item-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.gallery-item-desc { font-size: 12px; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.image-lightbox {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.82);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.image-lightbox-panel {
  position: relative; width: 100%; max-width: 720px; max-height: 92vh;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.image-lightbox-panel img {
  max-width: 100%; max-height: min(78vh, 720px); object-fit: contain;
  border-radius: 8px; background: #fff;
}
.image-lightbox-close {
  position: absolute; right: 0; top: -44px; width: 36px; height: 36px;
  border: none; border-radius: 50%; background: rgba(255,255,255,0.18);
  color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
}
.image-lightbox-caption {
  color: #fff; text-align: center; font-size: 14px; line-height: 1.5;
  max-width: min(100%, 560px);
}
.image-lightbox-caption strong,
.image-lightbox-caption span { display: block; }
.image-lightbox-caption span { color: rgba(255,255,255,0.78); margin-top: 2px; }

/* 微信按钮 */
.wechat-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; background: #07c160; color: #fff; padding: 14px 32px;
  border-radius: 25px; font-size: 16px; font-weight: 600;
  border: none; cursor: pointer; width: 100%; margin: 16px 0;
  transition: all 0.2s;
}
.wechat-btn:active { transform: scale(0.97); background: #06ad56; }
.wechat-icon { width: 24px; height: 24px; }

/* PC端编辑器布局 */
.editor-layout { display: flex; gap: 24px; }
.editor-preview { flex: 0 0 375px; position: sticky; top: 80px; align-self: flex-start; }
.editor-form { flex: 1; min-width: 0; }

/* 手机模拟框 */
.phone-frame {
  width: 375px; min-height: 600px; background: #fff;
  border-radius: 24px; overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  border: 8px solid #1a1a2e; position: relative;
}
.phone-frame .phone-notch {
  width: 120px; height: 24px; background: #1a1a2e;
  border-radius: 0 0 16px 16px; margin: 0 auto;
}
.phone-frame-content { overflow-y: auto; max-height: 650px; }

/* 响应式 */
@media (max-width: 768px) {
  .editor-layout { flex-direction: column; }
  .editor-preview { position: static; flex: none; display: flex; justify-content: center; }
  .phone-frame { width: 100%; max-width: 375px; }
  .container-wide { padding: 12px; }
  .gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 375px) {
  .gallery { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card { padding: 16px; }
}

/* 隐藏 */
.hidden { display: none !important; }

/* 颜色选择器 */
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: border-color 0.2s;
}
.color-swatch.active { border-color: var(--text); }
.color-swatch:hover { transform: scale(1.1); }

/* 产品管理列表 */
.product-list-item {
  display: flex; gap: 12px; align-items: center; padding: 12px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
  background: #fff;
}
.product-list-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.product-list-info { flex: 1; min-width: 0; }
.product-list-info .title { font-weight: 600; font-size: 14px; }
.product-list-info .desc { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-list-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* 统计卡片 */
.stat-card { text-align: center; padding: 16px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

/* Profile header area */
.profile-header {
  position: relative; text-align: center; padding-bottom: 20px;
}
.profile-bg {
  width: 100%; height: 160px; object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
}
.profile-bg-color { width: 100%; height: 160px; border-radius: var(--radius) var(--radius) 0 0; }
.profile-avatar-wrap {
  margin-top: -40px; display: inline-block;
}
.profile-name { font-size: 20px; font-weight: 700; margin-top: 8px; }
.profile-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* Info row */
.info-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
}
.info-row:last-child { border-bottom: none; }
.info-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.info-label { font-size: 12px; color: var(--text-secondary); }
.info-value { font-size: 15px; }

/* Tab */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 20px; font-size: 14px; font-weight: 500; cursor: pointer;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all 0.2s;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
