/* ============ 全局重置 ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4A90D9;
  --primary-dark: #3A7BC8;
  --primary-light: #E8F2FE;
  --success: #52C41A;
  --warning: #FAAD14;
  --danger: #FF4D4F;
  --text: #333;
  --text-secondary: #666;
  --text-light: #999;
  --border: #e8e8e8;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============ 用户端预约页面 ============ */
.booking-page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 40px;
}

.booking-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 28px 20px 24px;
  text-align: center;
}
.booking-header h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.booking-header p { font-size: 13px; opacity: 0.85; }

.booking-body { padding: 20px 16px; }

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 8px;
}
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-group input,
.form-group select {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 16px; color: var(--text); background: var(--card-bg);
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.section-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  margin: 24px 0 12px; padding-left: 10px;
  border-left: 3px solid var(--primary);
}

/* 时间段卡片 */
.slot-list { display: flex; flex-direction: column; gap: 10px; }
.slot-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--card-bg);
  border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.2s;
}
.slot-card:hover { border-color: var(--primary); }
.slot-card.selected {
  border-color: var(--primary); background: var(--primary-light);
}
.slot-card.full {
  opacity: 0.55; cursor: not-allowed; border-style: dashed;
}
.slot-card .slot-time { font-size: 16px; font-weight: 600; }
.slot-card .slot-info { display: flex; align-items: center; gap: 10px; }
.slot-card .slot-count { font-size: 13px; color: var(--text-secondary); }
.slot-card .slot-badge {
  padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.slot-badge.available { background: #e6f7ed; color: var(--success); }
.slot-badge.warning { background: #fff7e6; color: var(--warning); }
.slot-badge.full { background: #fff1f0; color: var(--danger); }

/* 提交按钮 */
.btn-submit {
  width: 100%; height: 50px; border: none; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 18px; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s; margin-top: 20px;
}
.btn-submit:hover { opacity: 0.9; }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ 预约成功弹窗 ============ */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: #fff; border-radius: 16px; width: 100%; max-width: 380px;
  max-height: 90vh; overflow-y: auto; padding: 28px 24px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.success-icon {
  width: 64px; height: 64px; margin: 0 auto 16px;
  background: var(--success); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #fff;
}
.modal-content h2 { text-align: center; font-size: 20px; margin-bottom: 20px; }

.appointment-card { background: var(--primary-light); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.appointment-card .info-row {
  display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px;
}
.appointment-card .info-row .label { color: var(--text-secondary); }
.appointment-card .info-row .value { font-weight: 600; }
.appointment-card .verify-code { color: var(--primary); font-size: 16px; letter-spacing: 1px; }

.qr-container { text-align: center; margin: 16px 0; }
.qr-container img { width: 200px; height: 200px; border-radius: 8px; border: 1px solid var(--border); }
.qr-container p { font-size: 12px; color: var(--text-light); margin-top: 8px; }

.btn-close {
  width: 100%; height: 44px; border: none; border-radius: var(--radius);
  background: var(--primary); color: #fff; font-size: 16px;
  font-weight: 600; cursor: pointer;
}

/* ============ Toast ============ */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.8); color: #fff; padding: 12px 24px;
  border-radius: 8px; font-size: 14px; z-index: 2000;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ============ 后台管理页面 ============ */
.admin-page { max-width: 1200px; margin: 0 auto; padding: 20px; }

.admin-header {
  background: #fff; border-radius: var(--radius); padding: 20px 24px;
  box-shadow: var(--shadow); margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.admin-header h1 { font-size: 20px; color: var(--text); }
.admin-header .back-link { font-size: 14px; color: var(--primary); text-decoration: none; }

/* 统计卡片 */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); text-align: center;
}
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* 筛选栏 */
.filter-bar {
  background: #fff; border-radius: var(--radius); padding: 16px 20px;
  box-shadow: var(--shadow); margin-bottom: 20px;
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
}
.filter-item { display: flex; flex-direction: column; gap: 4px; }
.filter-item label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.filter-item select, .filter-item input {
  height: 38px; padding: 0 10px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; background: #fff;
}
.btn {
  height: 38px; padding: 0 18px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }

/* 表格 */
.table-container {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: #f0f5ff; color: var(--text); font-weight: 600;
  padding: 12px 14px; text-align: left; white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #fafbff; }

.status-tag {
  display: inline-block; padding: 2px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.status-tag.pending { background: #fff7e6; color: var(--warning); }
.status-tag.used { background: #f6ffed; color: var(--success); }

/* 核销弹窗 */
.verify-modal { display: none; }
.verify-modal.active { display: block; }
.verify-input-group { display: flex; gap: 10px; margin-bottom: 16px; }
.verify-input-group input {
  flex: 1; height: 44px; padding: 0 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 16px;
}
.verify-result { padding: 16px; border-radius: 8px; margin-top: 16px; display: none; }
.verify-result.success { background: #f6ffed; border: 1px solid var(--success); }
.verify-result.error { background: #fff1f0; border: 1px solid var(--danger); }

/* 时间段统计表 */
.slot-table { margin-bottom: 20px; }
.slot-table .progress-bar {
  display: inline-block; width: 100px; height: 8px; background: #f0f0f0;
  border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 8px;
}
.slot-table .progress-fill {
  height: 100%; border-radius: 4px; transition: width 0.3s;
}
.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--warning); }
.progress-fill.red { background: var(--danger); }

/* 响应式 */
@media (max-width: 768px) {
  .admin-header { flex-direction: column; gap: 10px; align-items: flex-start; }
  .filter-bar { flex-direction: column; }
  .filter-item { width: 100%; }
  .filter-item select, .filter-item input { width: 100%; }
  table { font-size: 13px; }
  thead th, tbody td { padding: 8px 10px; }
}

@media (max-width: 480px) {
  .booking-body { padding: 16px 12px; }
  .modal-content { padding: 20px 16px; }
}

/* ============ 扫码核销页面（手机端） ============ */
.scan-page {
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  background: var(--bg); padding-bottom: 40px;
}

.scan-header {
  background: linear-gradient(135deg, #52C41A, #389E0D);
  color: #fff; padding: 24px 20px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.scan-header h1 { font-size: 20px; font-weight: 700; }
.scan-header .scan-back-link { font-size: 13px; color: #fff; opacity: 0.85; text-decoration: none; }

.scan-area { padding: 16px; }

/* 扫码结果区 */
.scan-result-area {
  min-height: 50px; margin-bottom: 16px;
}

.result-card {
  border-radius: var(--radius); padding: 20px; text-align: center;
  animation: slideUp 0.3s ease;
}
.result-card.success { background: #f6ffed; border: 2px solid var(--success); }
.result-card.error { background: #fff1f0; border: 2px solid var(--danger); }

.result-icon {
  width: 56px; height: 56px; margin: 0 auto 12px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff; font-weight: 700;
}
.result-card.success .result-icon { background: var(--success); }
.result-card.error .result-icon { background: var(--danger); }

.result-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.result-card.success .result-title { color: var(--success); }
.result-card.error .result-title { color: var(--danger); }

.result-detail {
  background: rgba(255,255,255,0.6); border-radius: 8px; padding: 12px 16px;
  text-align: left;
}
.detail-row {
  display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .dl { color: var(--text-secondary); }
.detail-row .dv { font-weight: 600; color: var(--text); }
.detail-row.error-msg { color: var(--danger); justify-content: center; font-weight: 600; }

.result-hint {
  text-align: center; color: var(--text-light); font-size: 14px; padding: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.hint-icon { font-size: 20px; }

/* 摄像头容器 */
.reader-container {
  display: none; width: 100%; max-width: 400px; margin: 0 auto 16px;
  border-radius: var(--radius); overflow: hidden; border: 3px solid var(--success);
  box-shadow: 0 4px 20px rgba(82,196,26,0.2);
}
.reader-container video { width: 100% !important; border-radius: 0; }

/* 扫码按钮 */
.scan-controls { text-align: center; margin-bottom: 24px; display: flex; flex-direction: column; gap: 10px; }
.btn-scan-start, .btn-scan-stop, .btn-scan-upload {
  width: 100%; height: 54px; border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 700; cursor: pointer; transition: opacity 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-scan-start {
  background: linear-gradient(135deg, #52C41A, #389E0D); color: #fff;
}
.btn-scan-upload {
  background: #fff; color: var(--primary); border: 2px solid var(--primary);
  display: flex;
}
.btn-scan-stop {
  background: #fff; color: var(--danger); border: 2px solid var(--danger);
}
.btn-scan-start:hover, .btn-scan-stop:hover, .btn-scan-upload:active { opacity: 0.88; }
.scan-icon { font-size: 22px; }

/* 使用提示 */
.scan-tip {
  background: #E8F2FE; border: 1px solid #B3D8FF; border-radius: 8px;
  padding: 12px 14px; font-size: 13px; line-height: 1.9; color: #1F4E96;
  margin-bottom: 16px;
}
.scan-tip code { background: #fff; padding: 1px 6px; border-radius: 3px; color: var(--primary); font-size: 12px; }

/* 手动输入 */
.manual-verify {
  background: #fff; border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 20px;
}
.manual-title {
  font-size: 14px; font-weight: 700; color: var(--text-secondary);
  margin-bottom: 10px; padding-left: 8px; border-left: 3px solid var(--primary);
}
.manual-input-group { display: flex; gap: 10px; }
.manual-input-group input {
  flex: 1; height: 46px; padding: 0 14px;
  border: 1.5px solid var(--border); border-radius: 8px; font-size: 15px;
}
.manual-input-group input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.manual-input-group button {
  height: 46px; padding: 0 24px; border: none; border-radius: 8px;
  background: var(--success); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.manual-input-group button:active { opacity: 0.85; }

/* 今日统计 */
.scan-stats {
  display: flex; gap: 10px;
}
.scan-stat-item {
  flex: 1; background: #fff; border-radius: var(--radius); padding: 14px 8px;
  text-align: center; box-shadow: var(--shadow);
}
.scan-stat-num { display: block; font-size: 24px; font-weight: 700; color: var(--primary); }
.scan-stat-label { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* 扫码结果状态（v2 简化版） */
.scan-result-area.scan-result-success,
.scan-result-area.scan-result-error,
.scan-result-area.scan-result-loading {
  border-radius: var(--radius); padding: 20px; text-align: center; margin-bottom: 16px;
  animation: slideUp 0.3s ease;
}
.scan-result-area.scan-result-success { background: #f6ffed; border: 2px solid var(--success); }
.scan-result-area.scan-result-error { background: #fff1f0; border: 2px solid var(--danger); }
.scan-result-area.scan-result-loading { background: #E8F2FE; border: 2px solid var(--primary); }
.result-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--primary); font-size: 15px; }
.loading-spinner {
  width: 32px; height: 32px; border: 3px solid #B3D8FF; border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-info { text-align: left; margin: 12px 0; }
.result-info .info-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.05); font-size: 14px;
}
.result-info .info-row .info-label { color: var(--text-secondary); }
.result-info .info-row .info-value { font-weight: 600; }
.result-message { font-size: 15px; color: var(--danger); margin: 8px 0 16px; }
.result-close-btn {
  margin-top: 12px; padding: 8px 28px; border: none; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.result-close-btn:active { opacity: 0.85; }

/* ============ 预约页面头部链接 ============ */
.header-profile-link {
  display: inline-block; margin-top: 8px; color: #fff; opacity: 0.9;
  font-size: 13px; text-decoration: none; padding: 4px 14px;
  background: rgba(255,255,255,0.2); border-radius: 20px;
}
.header-profile-link:active { opacity: 1; }

/* ============ 个人中心页面 ============ */
.profile-page {
  max-width: 480px; margin: 0 auto; min-height: 100vh;
  background: var(--bg); padding-bottom: 40px;
}
.profile-header {
  background: linear-gradient(135deg, #4A90D9, #3A7BC8);
  color: #fff; padding: 24px 20px 20px;
  display: flex; align-items: center; gap: 12px;
}
.profile-header h1 { font-size: 20px; font-weight: 700; flex: 1; }
.profile-header .back-link { font-size: 13px; color: #fff; opacity: 0.85; text-decoration: none; }

.profile-search-area { padding: 16px; }
.search-tip {
  background: #E8F2FE; border: 1px solid #B3D8FF; border-radius: 8px;
  padding: 12px 14px; font-size: 13px; line-height: 1.6; color: #1F4E96;
  margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
.search-icon { font-size: 18px; }
.search-input-group { display: flex; gap: 10px; }
.search-input-group input {
  flex: 1; height: 48px; padding: 0 14px;
  border: 1.5px solid var(--border); border-radius: 8px; font-size: 16px;
}
.search-input-group input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.search-input-group button {
  height: 48px; padding: 0 28px; border: none; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.search-input-group button:active { opacity: 0.85; }
.search-input-group button:disabled { opacity: 0.5; }

.profile-list { padding: 0 16px; }
.loading-tip, .error-tip {
  text-align: center; padding: 30px 0; color: var(--text-light); font-size: 15px;
}
.error-tip { color: var(--danger); }

.empty-tip {
  text-align: center; padding: 40px 0;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-tip p { color: var(--text-secondary); font-size: 15px; margin-bottom: 20px; }
.btn-go-book {
  display: inline-block; padding: 10px 28px; border-radius: 8px;
  background: var(--primary); color: #fff; text-decoration: none; font-size: 15px; font-weight: 600;
}

/* 统计 */
.profile-stats {
  display: flex; gap: 10px; margin-bottom: 16px;
}
.profile-stat-item {
  flex: 1; background: #fff; border-radius: var(--radius); padding: 14px 8px;
  text-align: center; box-shadow: var(--shadow);
}
.profile-stat-item .stat-num { display: block; font-size: 24px; font-weight: 700; color: var(--primary); }
.profile-stat-item .stat-label { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* 预约卡片 */
.profile-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px; overflow: hidden;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: #f0f5ff;
}
.card-index { font-size: 14px; font-weight: 700; color: var(--primary); }
.card-status {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px;
}
.card-status.pending { background: #fff7e6; color: var(--warning); }
.card-status.used { background: #f6ffed; color: var(--success); }
.card-body { padding: 16px; }

.info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-item.full-width { grid-column: 1 / -1; }
.info-label { font-size: 12px; color: var(--text-light); }
.info-value { font-size: 15px; font-weight: 600; color: var(--text); }
.info-value.verify-code {
  font-family: monospace; font-size: 16px; color: var(--primary);
  letter-spacing: 1px;
}

/* 二维码区域 */
.qr-section { margin-top: 16px; text-align: center; }
.btn-show-qr, .btn-hide-qr {
  padding: 8px 24px; border: 1.5px solid var(--primary); border-radius: 8px;
  background: #fff; color: var(--primary); font-size: 14px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn-show-qr:active, .btn-hide-qr:active { opacity: 0.8; }
.qr-loading { color: var(--text-light); font-size: 14px; padding: 20px 0; }
.qr-error { color: var(--danger); font-size: 14px; padding: 20px 0; }
.qr-display {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 16px; background: #f9fbff; border-radius: 8px;
}
.qr-img { width: 220px; height: 220px; border: 1px solid var(--border); border-radius: 8px; }
.qr-tip { font-size: 13px; color: var(--text-secondary); }

.card-tip {
  margin-top: 12px; padding: 8px 12px; border-radius: 6px;
  font-size: 13px; background: #fffbe6; color: #ad6800; line-height: 1.5;
}
