/* ============================================================
   公共样式 - 旷世居家 车辆通行及访客管理系统
   移动端优先，适配手机浏览器
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #1677ff;
  --primary-light: #e6f4ff;
  --success: #52c41a;
  --success-light: #f6ffed;
  --warning: #ff9900;
  --warning-light: #fff7e6;
  --danger: #f5222d;
  --danger-light: #fff1f0;
  --purple: #722ed1;
  --purple-light: #f9f0ff;
  --gray: #8c8c8c;
  --gray-light: #f5f5f5;
  --border: #d9d9d9;
  --text: #262626;
  --text-secondary: #595959;
  --text-light: #8c8c8c;
  --bg: #f0f2f5;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --header-height: 56px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
}

/* ============================================================
   布局
   ============================================================ */
.page-container {
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 20px;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.page-header-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.page-header-action {
  font-size: 14px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
}

.page-body {
  padding: 12px;
}

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-light);
}

/* ============================================================
   表单
   ============================================================ */
.form-item {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-label.required::before {
  content: '* ';
  color: var(--danger);
}

.form-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  font-size: 15px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.form-input.error {
  border-color: var(--danger);
}

.form-input.with-btn {
  border-radius: 6px 0 0 6px;
}

.form-error {
  font-size: 13px;
  color: var(--danger);
  margin-top: 4px;
  display: block;
}

.form-input-group {
  display: flex;
  align-items: center;
}

.form-input-group .form-input {
  flex: 1;
  border-radius: 6px 0 0 6px;
}

.form-input-group .lookup-btn {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--primary);
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: var(--primary);
  color: var(--white);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.form-input-group .lookup-btn:disabled {
  background: var(--gray-light);
  border-color: var(--border);
  color: var(--gray);
  cursor: not-allowed;
}

/* 回填提示 */
.autofill-tip {
  background: var(--success-light);
  border: 1px solid #b7eb8f;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  color: #389e0d;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 15px;
  color: var(--text);
  background: var(--white);
  outline: none;
  resize: none;
  font-family: inherit;
  line-height: 1.6;
}

.form-textarea:focus {
  border-color: var(--primary);
}

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 16px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
  transition: opacity 0.2s, background 0.2s;
  text-decoration: none;
  gap: 4px;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.text-muted { color: #8c8c8c !important; }
.btn:active:not(:disabled) { opacity: 0.8; }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger  { background: var(--danger);  color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-purple  { background: var(--purple);  color: var(--white); }
.btn-ghost   { background: var(--white); color: var(--primary); border: 1px solid var(--primary); }
.btn-default { background: var(--white); color: var(--text-secondary); border: 1px solid var(--border); }

.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 4px; }
.btn-block { width: 100%; }
.btn-lg { height: 50px; font-size: 17px; border-radius: 8px; }

/* ============================================================
   状态标签
   ============================================================ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-pending   { background: var(--warning-light); color: var(--warning); }
.badge-approved  { background: var(--primary-light); color: var(--primary); }
.badge-in        { background: var(--success-light); color: var(--success); }
.badge-warehouse_done { background: var(--purple-light); color: var(--purple); }
.badge-interviewee-confirmed { background: #e6fffb; color: #13c2c2; }
.badge-pending_approval { background: #e6f4ff; color: #1677ff; }
.badge-done      { background: var(--gray-light); color: var(--gray); }
.badge-rejected  { background: var(--danger-light); color: var(--danger); }

/* ============================================================
   通行证卡片
   ============================================================ */
.pass-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--border);
}

.pass-card.status-pending      { border-left-color: var(--warning); }
.pass-card.status-approved     { border-left-color: var(--primary); }
.pass-card.status-in           { border-left-color: var(--success); }
.pass-card.status-warehouse_done { border-left-color: var(--purple); }
.pass-card.status-pending_approval { border-left-color: #1677ff; }
.pass-card.status-done         { border-left-color: var(--gray); }
.pass-card.status-rejected     { border-left-color: var(--danger); }

.pass-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pass-plate {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}

.pass-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  margin-bottom: 8px;
}

.pass-info-item {
  font-size: 13px;
  color: var(--text-secondary);
}

.pass-info-item span {
  color: var(--text-light);
  margin-right: 4px;
}

.pass-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-light);
}

/* ============================================================
   Tab 导航
   ============================================================ */
.tab-bar {
  display: flex;
  background: var(--white);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 12px;
  gap: 4px;
  box-shadow: var(--shadow);
}

.tab-item {
  flex: 1;
  height: 36px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  padding: 0 4px;
}

.tab-item.active {
  background: var(--primary);
  color: var(--white);
  font-weight: 500;
}

/* ============================================================
   搜索框
   ============================================================ */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--white);
  border-radius: 20px;
  padding: 0 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  height: 38px;
  gap: 8px;
}

.search-icon { color: var(--text-light); font-size: 17px; flex-shrink: 0; }

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
  background: transparent;
}

.search-clear {
  color: var(--text-light);
  cursor: pointer;
  font-size: 17px;
  flex-shrink: 0;
  display: none;
}

/* ============================================================
   模态框
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: flex-end;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--white);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-box.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 12px;
  width: calc(100% - 48px);
  max-width: 360px;
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .btn { flex: 1; }

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-light);
}

.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 15px; }

/* ============================================================
   加载中
   ============================================================ */
.loading-spin {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

.loading-overlay.show { display: flex; }

/* ============================================================
   Toast 消息
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--white);
  background: rgba(0,0,0,0.75);
  max-width: 100%;
  text-align: center;
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}

.toast.success { background: rgba(82, 196, 26, 0.9); }
.toast.error   { background: rgba(245, 34, 45, 0.9); }
.toast.warning { background: rgba(255, 153, 0, 0.9); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   通用工具类
   ============================================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-light { color: var(--text-light); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-bold { font-weight: 600; }
.hidden { display: none !important; }

/* 分割线 */
.divider {
  border: none;
  border-top: 1px solid var(--gray-light);
  margin: 12px 0;
}

/* 通知提示条 */
.notice-bar {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 12px;
}

.notice-bar.warning { background: var(--warning-light); color: #d46b08; }
.notice-bar.success { background: var(--success-light); color: #389e0d; }

/* 信息行 */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-light);
  font-size: 14px;
}

.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-light); }
.info-row-value { color: var(--text); font-weight: 500; }

/* 图片上传区 */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  color: var(--text-light);
  font-size: 14px;
  transition: border-color 0.2s;
}

.upload-area:hover { border-color: var(--primary); color: var(--primary); }
.upload-area input[type=file] { display: none; }

.photo-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-item .photo-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  cursor: pointer;
}

/* 操作日志 */
.log-list { padding: 0; list-style: none; }
.log-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  position: relative;
}

.log-item::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 24px;
  bottom: -8px;
  width: 1px;
  background: var(--border);
}

.log-item:last-child::before { display: none; }

.log-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
}

.log-content { flex: 1; }
.log-action { color: var(--text); font-weight: 500; margin-bottom: 2px; }
.log-meta { color: var(--text-light); }

/* QR码展示 */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.qr-img {
  width: 200px;
  height: 200px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.qr-label {
  font-size: 14px;
  color: var(--text-light);
  text-align: center;
  line-height: 1.6;
}
