/* ===== 名片识别系统 - 移动端优先样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #1a56db;
  --primary-dark: #1e429f;
  --primary-light: #e1effe;
  --secondary: #6b7280;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; }

/* ===== 顶部导航 ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 12px rgba(26,86,219,0.3);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.logo { flex-shrink: 0; }
.header-title h1 { font-size: 17px; font-weight: 600; line-height: 1.2; }
.header-title span { font-size: 11px; opacity: 0.85; }
.header-btn {
  position: relative;
  background: rgba(255,255,255,0.15); border: none; border-radius: 10px;
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer; transition: background 0.2s;
}
.header-btn:active { background: rgba(255,255,255,0.25); }
.badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--danger); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

/* ===== 页面切换 ===== */
.page { display: none; padding-bottom: 30px; }
.page.active { display: block; }

/* ===== 上传区域 ===== */
.upload-zone {
  margin: 20px 16px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px dashed var(--border);
}
.upload-icon { margin-bottom: 16px; opacity: 0.9; }
.upload-zone h2 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.upload-zone p { color: var(--text-light); font-size: 13px; margin-bottom: 24px; line-height: 1.6; }
.upload-buttons { display: flex; flex-direction: column; gap: 12px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: 10px; border: none;
  font-size: 15px; font-weight: 500; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-large { padding: 14px 24px; font-size: 16px; width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: var(--primary-light); color: var(--primary); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-text { background: transparent; color: var(--text-light); padding: 8px 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 加载遮罩 ===== */
.loading-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.95); z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { color: var(--text-light); font-size: 14px; }

/* ===== 识别结果 ===== */
.result-section { margin: 16px; }
.result-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.result-header h3 { font-size: 17px; }
.provider-tag {
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  background: var(--primary-light); color: var(--primary);
}

/* 查重提示 */
.dup-alert {
  background: #fef3c7; border: 1px solid #fcd34d; border-radius: 10px;
  padding: 12px; margin-bottom: 12px; display: flex; gap: 10px;
}
.dup-icon { font-size: 20px; flex-shrink: 0; }
.dup-content { flex: 1; }
.dup-content strong { font-size: 13px; color: #92400e; display: block; margin-bottom: 4px; }
.dup-item {
  font-size: 12px; color: #78350f; padding: 4px 0;
  border-bottom: 1px solid #fde68a;
}
.dup-item:last-child { border-bottom: none; }

/* 名片预览 */
.card-preview {
  margin-bottom: 12px; border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow); background: #fff;
}
.card-preview img { width: 100%; display: block; }

/* ===== 表单 ===== */
.card-form {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-group label {
  display: block; font-size: 13px; color: var(--text-light);
  margin-bottom: 6px; font-weight: 500;
}
.required { color: var(--danger); }
.form-group input, .form-group textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 15px; font-family: inherit; color: var(--text);
  background: #fafafa; transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); background: #fff;
}
.form-group textarea { resize: vertical; min-height: 44px; }

/* ===== 操作按钮 ===== */
.action-buttons { display: flex; flex-direction: column; gap: 10px; }
.action-buttons .btn { width: 100%; }

/* ===== 名片夹列表 ===== */
.list-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; background: var(--card);
  border-bottom: 1px solid var(--border);
}
.list-header h3 { font-size: 17px; }
.list-container { padding: 12px 16px; }
.card-item {
  background: var(--card); border-radius: 10px; padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow);
  position: relative;
}
.card-item-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.card-item-company { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; }
.card-item-status {
  font-size: 11px; padding: 2px 8px; border-radius: 4px; flex-shrink: 0; margin-left: 8px;
}
.status-pending { background: #fef3c7; color: #92400e; }
.status-synced { background: #d1fae5; color: #065f46; }
.card-item-info { font-size: 13px; color: var(--text-light); line-height: 1.8; }
.card-item-info span { display: inline-block; margin-right: 12px; }
.card-item-actions {
  display: flex; gap: 8px; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.card-item-actions .btn { padding: 6px 12px; font-size: 12px; flex: 1; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }

/* ===== 摄像头模态框 ===== */
.camera-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: #000; z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
.camera-container {
  width: 100%; height: 100%; position: relative;
  display: flex; flex-direction: column;
}
#cameraVideo {
  width: 100%; height: 100%; object-fit: cover;
}
.camera-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.camera-frame {
  width: 85%; max-width: 400px; aspect-ratio: 1.6/1;
  border: 2px solid rgba(255,255,255,0.8); border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}
.camera-overlay p { color: #fff; font-size: 14px; margin-top: 16px; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.camera-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-around;
  padding: 20px; background: linear-gradient(transparent, rgba(0,0,0,0.7));
}
.btn-capture {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255,255,255,0.3); border: 4px solid #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.capture-inner {
  width: 56px; height: 56px; border-radius: 50%; background: #fff;
  transition: transform 0.1s;
}
.btn-capture:active .capture-inner { transform: scale(0.9); }
.camera-controls .btn-text { color: #fff; font-size: 15px; padding: 10px 16px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: rgba(0,0,0,0.8); color: #fff;
  padding: 12px 24px; border-radius: 8px; font-size: 14px;
  z-index: 500; opacity: 0; transition: all 0.3s;
  max-width: 80%; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== 响应式 ===== */
@media (min-width: 640px) {
  body { padding: 20px 0; }
  #app { border-radius: 16px; overflow: hidden; box-shadow: 0 4px 24px rgba(0,0,0,0.1); }
}
