/* COA-web 样式 */
/* 变量 */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-foreground: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* 基础重置 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 72px;
}

/* 占位导航 */
#bottomNav {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: center;
  height: 56px;
  z-index: 99;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 20px;
}
.nav-item.active { color: var(--primary); }

/* 头部 */
.header {
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 16px; padding-top: max(16px, env(safe-area-inset-top, 16px));
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 10;
}
.header h1 { font-size: 18px; font-weight: 600; margin: 0; flex:1; }
.subtitle { font-size: 12px; color: #93c5fd; margin-top: 4px; }
.btn-back {
  background: rgba(255,255,255,0.2); border: 0; color: #fff;
  border-radius: 9999px; padding: 8px 14px; font-size: 14px;
}
.header-actions { display:flex; gap:8px; }
.btn-icon {
  background: rgba(255,255,255,0.2); border: 0; color: #fff;
  border-radius: 10px; width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
}

/* 主页卡片 */
.card-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; padding: 12px;
}
.card {
  background: var(--surface); border-radius: 14px; padding: 16px;
  text-align: center; text-decoration: none; color: var(--text);
  box-shadow: var(--shadow);
}
.card-icon { font-size: 28px; }
.card-title { font-weight: 600; margin-top: 8px; font-size: 14px; }
.card-desc { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 设置栏 */
.settings-bar {
  display:flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 10px 12px; background: var(--surface);
}
.ocr-select, .field input, .field select {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 16px; background: #fff;
  width: 100%;
}
.ocr-select { min-width: 140px; }

/* 状态栏 */
.status-bar {
  padding: 10px 12px; font-size: 12px; color: var(--muted);
  background: var(--surface); border-top: 1px solid var(--border);
}

/* 表单 */
.container { padding: 12px; }
.section { background: var(--surface); border-radius: 14px; padding: 16px; margin: 12px; }
.section h2 { font-size: 14px; margin: 0 0 12px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
.required { color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); }
.actions-fixed {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  display:flex; gap: 8px; padding: 10px 12px;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
}
.action-row { display:flex; gap: 8px; }
.actions { display: flex; gap: 8px; padding: 12px; }

/* 按钮 */
.btn {
  appearance: none; border: 0; border-radius: 10px; padding: 10px 14px;
  font-size: 14px; font-weight: 500; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { padding: 14px; font-size: 16px; width: 100%; }
.btn-small { padding: 6px 10px; font-size: 12px; }

/* 相机 */
.camera-wrapper { position: relative; width: 100%; height: 340px; background:#000; border-radius: 14px; overflow:hidden; }
.camera-wrapper video { width:100%; height:100%; object-fit: cover; }
.overlay { position:absolute; left:0; top:0; width:100%; height:100%; pointer-events:none; }
.camera-hint {
  position: absolute; bottom: 8px; left:0; right:0; text-align:center;
  color: #fff; font-size: 12px; background: rgba(0,0,0,0.45); padding: 6px 10px;
}

/* OCR 结果 */
.ocr-result-box { white-space: pre-wrap; font-size: 12px; background:#f9fafb; padding:12px; border-radius:10px; border:1px solid var(--border); }
.ocr-lines { margin-top:8px; color: var(--muted); }

/* 映射列表 */
.search-bar { padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.search-bar input {
  width: 100%; border: 1px solid var(--border); border-radius: 9999px;
  padding: 8px 14px; font-size: 14px;
}
.list-header { display:flex; justify-content: space-between; align-items: center; padding: 10px 12px; }
.mapping-list {
  list-style: none; margin: 0; padding: 0 12px 12px;
  display:grid; gap: 8px;
}
.mapping-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px;
}
.mapping-primary { font-size: 14px; font-weight: 500; }
.mapping-en { color: var(--primary); font-weight: 600; margin-left: 6px; }
.mapping-secondary { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* 对话框 */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; padding: 12px;
  z-index: 50;
}
.dialog {
  background: var(--surface); border-radius: 16px; padding: 16px;
  width: 100%; max-width: 480px;
}
.dialog h3 { font-size: 16px; margin: 0 0 10px; }
.dialog label { display:block; font-size: 12px; color: var(--muted); margin-top: 8px; }
.dialog input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 16px;
}
.dialog-actions { display:flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.empty-hint { text-align: center; padding: 18px; color: var(--muted); font-size: 14px; }

/* Toast */
.toast {
  position: fixed; top: max(12px, env(safe-area-inset-top, 12px)); left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.72); color: #fff; padding: 10px 18px; border-radius: 9999px;
  font-size: 14px; opacity: 0; transition: opacity .25s ease; z-index: 99; white-space: nowrap;
}
.toast.show { opacity: 1; }

/* 公用页面块 */
.page.active { display: block; }
