/* ==========================================
   回执超多 - 无登录版 · 清爽淡蓝
   ========================================== */

:root {
  --bg: #e8f4ff;
  --surface: #ffffff;
  --surface2: #f0f8fe;
  --primary: #4a9eff;
  --primary2: #2b7fd4;
  --primary-light: #7bb9ff;
  --primary-bg: rgba(74, 158, 255, 0.08);
  --success: #2ecc71;
  --danger: #e74c3c;
  --warning: #f39c12;
  --text: #1a2a3a;
  --text2: #7f8c8d;
  --border: #d0e8f5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(74, 158, 255, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ====== 容器居中 ====== */
@media (min-width: 768px) {
  body { display: flex; justify-content: center; background: #d4e8f4; }
  #app { width: 100%; max-width: 520px; min-height: 100vh; background: var(--bg); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ====== 头部 ====== */
.app-header {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 100;
  background: var(--bg); padding: 10px 16px 6px;
  display: flex; justify-content: space-between; align-items: center;
  backdrop-filter: blur(10px);
}
.header-left { display: flex; align-items: center; gap: 6px; }
.header-left .logo { font-size: 22px; }
.header-left h1 { font-size: 18px; font-weight: 700; color: var(--primary2); }
.header-right { display: flex; gap: 2px; }
.icon-btn {
  background: none; border: none; font-size: 20px;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.1s;
}
.icon-btn:active { background: var(--primary-bg); }

/* ====== Tab ====== */
.tab-bar {
  position: fixed; top: 50px; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 99;
  background: var(--bg); display: flex;
}
.tab-item {
  flex: 1; text-align: center; padding: 8px 0;
  font-size: 14px; color: var(--text2); cursor: pointer;
  position: relative; transition: all 0.15s;
}
.tab-item.active { color: var(--primary); font-weight: 600; }
.tab-item.active::after {
  content: ''; position: absolute; bottom: 0; left: 25%; right: 25%;
  height: 3px; background: var(--primary); border-radius: 3px 3px 0 0;
}

/* ====== 主内容 ====== */
main { padding-top: 90px; padding-bottom: 10px; min-height: 100vh; }
.view { display: none; }
.view.active { display: block; }

/* ====== 搜索 ====== */
.search-bar { padding: 6px 12px; }
.search-bar input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 14px; outline: none; background: var(--surface);
  color: var(--text); transition: border 0.15s;
}
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-bg); }

/* ====== 联系人列表 ====== */
.contact-list { padding: 4px 12px; }
.contact-item {
  background: var(--surface); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 6px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.contact-item:active { transform: scale(0.98); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-bg), rgba(74,158,255,0.15));
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.avatar.saved { background: linear-gradient(135deg, rgba(46,204,113,0.1), rgba(46,204,113,0.15)); }
.info { flex: 1; min-width: 0; }
.name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone { font-size: 12px; color: var(--primary); font-family: monospace; margin-top: 1px; letter-spacing: 0.5px; }
.status { font-size: 11px; margin-top: 2px; }
.status.answered { color: var(--success); }
.status.missed { color: var(--danger); }
.actions { display: flex; gap: 4px; flex-shrink: 0; }
.call-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #4a9eff, #2b7fd4);
  color: white; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s;
  touch-action: manipulation;
}
.call-btn:active { transform: scale(0.88); }

/* ====== 空状态 ====== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 20px; text-align: center;
}
.empty-icon { font-size: 56px; margin-bottom: 12px; opacity: 0.3; color: var(--primary-light); }
.empty-state p { font-size: 15px; color: var(--text2); }
.empty-state .sub { font-size: 13px; margin-top: 4px; opacity: 0.6; }
.empty-state button { margin-top: 18px; }

/* ====== 统计 ====== */
.stats-page { padding: 8px 12px; }
.datebar {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-bottom: 10px; font-size: 15px; font-weight: 600;
}
.datebar button {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 50%; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; color: var(--text2);
}
.datebar button:active { background: var(--bg); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stats-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 14px; text-align: center; border: 1px solid var(--border);
}
.stats-card .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stats-card .label { font-size: 11px; color: var(--text2); margin-top: 2px; }
.stats-card .num.success { color: var(--success); }
.stats-card .num.danger { color: var(--danger); }
.stats-card .num.warning { color: var(--warning); }
.totaltime { text-align: center; font-size: 13px; color: var(--text2); margin-bottom: 8px; }

.timeline { }
.tl-item {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); font-size: 13px;
}
.tl-time { color: var(--text2); min-width: 48px; font-size: 11px; }
.tl-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-status { font-size: 11px; white-space: nowrap; }
.tl-status.answered { color: var(--success); }
.tl-status.missed { color: var(--danger); }
.tl-detail { color: var(--text2); font-size: 10px; white-space: nowrap; }

/* ====== 自动拨打栏 ====== */
.auto-bar {
  position: fixed; top: 90px; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 99;
  background: var(--surface); border-bottom: 2px solid var(--primary);
  padding: 6px 12px; display: flex; align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(74,158,255,0.1);
}
.auto-status { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.pulse { width: 8px; height: 8px; background: var(--success); border-radius: 50%; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.auto-actions { display: flex; gap: 4px; }
.btn-sm {
  padding: 5px 12px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 11px;
  cursor: pointer; touch-action: manipulation;
}
.btn-sm:active { background: var(--surface2); }
.btn-green { border-color: var(--success); color: var(--success); }

/* ====== 按钮 ====== */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: white; border: none; padding: 12px 20px;
  border-radius: var(--radius); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: opacity 0.1s; touch-action: manipulation;
}
.btn-primary:active { opacity: 0.85; }
.btn-full { width: 100%; }
.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); padding: 12px 20px;
  border-radius: var(--radius); font-size: 14px; cursor: pointer;
  touch-action: manipulation;
}
.btn-secondary:active { background: var(--surface2); }

/* ====== 相机页 ====== */
.camera-page { }
.preview-box {
  width: 100%; height: min(45vh, 380px); min-height: 200px;
  background: var(--surface2); display: flex;
  align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.preview-box .placeholder { text-align: center; color: var(--text2); }
.preview-box video, .preview-box img { width: 100%; height: 100%; object-fit: contain; }
.camera-btns { display: flex; gap: 8px; padding: 8px 12px; justify-content: center; flex-wrap: wrap; }
.ocr-progress {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--surface); margin: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 13px;
}
.spinner {
  width: 18px; height: 18px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ocr-results {
  margin: 8px 12px; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border); padding: 12px;
}
.ocr-badge { display: inline-block; background: rgba(46,204,113,0.1); color: var(--success); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; margin-bottom: 8px; }
.ocr-item { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ocr-item:last-child { border-bottom: none; }
.ocr-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ocr-phone { font-size: 11px; color: var(--primary); }

/* ====== 弹窗 ====== */
.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.35); display: flex;
  align-items: flex-end; justify-content: center;
}
.modal-inner {
  background: var(--surface); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 520px; max-height: 70vh; overflow-y: auto;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-hd { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-hd h2 { font-size: 16px; font-weight: 600; }
.modal-bd { padding: 16px; }
.row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.row .lbl { font-size: 12px; color: var(--text2); width: 70px; flex-shrink: 0; }
.row .val { font-size: 14px; }
.big-phone { color: var(--primary) !important; font-family: monospace; font-size: 18px !important; font-weight: 600; letter-spacing: 1px; }

/* ====== Toast ====== */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--text);
  padding: 8px 16px; border-radius: 20px;
  border: 1px solid var(--border); font-size: 13px;
  z-index: 300; animation: toastIn 0.2s ease;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  white-space: nowrap; pointer-events: none;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%); } }

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

.timeline-nodata { text-align: center; color: var(--text2); padding: 30px; font-size: 13px; }

@media (min-width: 768px) {
  .modal { align-items: center; }
  .modal-inner { border-radius: 16px; max-width: 420px; }
}
