/**
 * 扫码挪车 - 移动端优化样式
 */

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

/* ── Base ── */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* ── Card 容器 ── */
.card {
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.18);
  width: 100%;
  max-width: 480px;
  padding: 24px 20px;
  margin: auto;
}

/* ── 标题 ── */
.card-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
  text-align: center;
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 13px;
  color: #888;
  text-align: center;
  margin-bottom: 20px;
}

/* ── 表单通用 ── */
.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 14px;
  color: #444;
  margin-bottom: 8px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
  font-family: inherit;
  background: #fff;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

input::placeholder {
  color: #bbb;
}

.hint {
  font-size: 12px;
  color: #999;
  margin-top: 6px;
  line-height: 1.5;
}

/* ── 按钮 ── */
.submit-btn,
.gen-btn,
.action-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  letter-spacing: 0.5px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.submit-btn:hover,
.gen-btn:hover,
.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.submit-btn:active,
.gen-btn:active,
.action-btn:active {
  transform: translateY(0);
}

.submit-btn:disabled,
.gen-btn:disabled {
  background: #ccc;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

/* ── 次要按钮 ── */
.btn-secondary {
  background: #f5f5f5;
  color: #666;
  box-shadow: none;
}

.btn-secondary:hover {
  background: #eee;
  box-shadow: none;
}

/* ── 位置按钮 ── */
.location-btn {
  width: 100%;
  padding: 14px;
  border: 2px solid #667eea;
  border-radius: 12px;
  background: #fff;
  color: #667eea;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 50px;
}

.location-btn:hover {
  background: #667eea;
  color: #fff;
}

.location-btn.success {
  background: #28a745;
  border-color: #28a745;
  color: #fff;
}

.location-btn.success::before {
  content: '✅ ';
}

/* ── 快捷留言按钮 ── */
.msg-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.msg-btn {
  padding: 12px 8px;
  border: 2px solid #e8e8e8;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 46px;
}

.msg-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.msg-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-color: transparent;
}

/* ── 场景选择 ── */
.scenario-btns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.scenario-btn {
  padding: 12px 4px;
  border: 2px solid #e8e8e8;
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.scenario-btn:hover {
  border-color: #667eea;
}

.scenario-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-color: transparent;
}

.scenario-btn .emoji {
  font-size: 20px;
}

/* ── 车牌输入 ── */
.plate-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.plate-row select {
  flex: 1;
  min-width: 0;
  padding: 12px 8px;
  border: 2px solid #e8e8e8;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  background: #fff;
  color: #333;
  cursor: pointer;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
}

.plate-row select:focus {
  border-color: #667eea;
}

.plate-row .plate-dots {
  color: #667eea;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── 隐私提示 ── */
.privacy-note {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 12px;
  margin-top: 16px;
  font-size: 12px;
  color: #888;
  text-align: center;
  line-height: 1.5;
}

/* ── Loading ── */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.loading-overlay.show {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e8e8e8;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 16px;
  font-size: 15px;
  color: #666;
}

.retry-btn {
  margin-top: 16px;
  padding: 12px 24px;
  background: #667eea;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ── 成功/等待视图 ── */
.success-view,
.waiting-view,
.result-view,
#waitingView,
#successView,
#confirmedView {
  display: none;
}

.show-view .form-view {
  display: none;
}

.show-view .success-view,
.show-view .waiting-view,
.show-view .result-view {
  display: block;
}

/* ── 结果卡片 ── */
.result-card {
  text-align: center;
  padding: 20px 0;
}

.result-emoji {
  font-size: 64px;
  margin-bottom: 16px;
}

.result-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 8px;
}

.result-message {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* ── 等待视图 ── */
.waiting-content {
  text-align: center;
}

.waiting-emoji {
  font-size: 48px;
  margin-bottom: 12px;
}

.waiting-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.waiting-countdown {
  font-size: 36px;
  font-weight: 700;
  color: #667eea;
  margin: 16px 0;
}

.waiting-hint {
  font-size: 13px;
  color: #888;
}

/* ── 确认页 ── */
.info {
  background: #f8f9fa;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.info-item:last-child {
  border-bottom: none;
}

.info-label {
  color: #888;
  font-size: 14px;
}

.info-value {
  color: #333;
  font-size: 15px;
  font-weight: 500;
}

/* ── 操作按钮组 ── */
.btn-group {
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 52px;
}

.btn-confirm {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: #fff;
}

.btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.btn-confirm:disabled {
  background: #ccc;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-reject {
  background: #f5f5f5;
  color: #666;
}

.btn-reject:hover {
  background: #eee;
}

/* ── 状态框 ── */
.status-box {
  padding: 14px;
  border-radius: 12px;
  margin-top: 16px;
  font-size: 14px;
  text-align: center;
}

.status-success {
  background: #d4edda;
  color: #155724;
}

.status-error {
  background: #f8d7da;
  color: #721c24;
}

/* ── 车主位置信息 ── */
.owner-location {
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: 12px;
  padding: 14px;
  margin-top: 16px;
  text-align: left;
  font-size: 14px;
  color: #2e7d32;
}

.owner-location a {
  color: #2e7d32;
  text-decoration: underline;
}

/* ── 二维码 ── */
.qr-container {
  text-align: center;
  padding: 20px 0;
}

.qr-container img {
  max-width: 200px;
  border-radius: 12px;
}

.token-display {
  background: #f5f5f5;
  border-radius: 10px;
  padding: 14px;
  margin: 16px 0;
  font-family: monospace;
  font-size: 14px;
  word-break: break-all;
}

/* ── 响应式 ── */
@media (max-width: 480px) {
  body {
    padding: 12px;
  }
  
  .card {
    padding: 20px 16px;
    border-radius: 20px;
  }
  
  .card-title {
    font-size: 20px;
  }
  
  .scenario-btns {
    grid-template-columns: 1fr 1fr;
  }
  
  .msg-btns {
    grid-template-columns: 1fr;
  }
  
  .btn-group {
    flex-direction: column;
  }
}

/* ── 安全区域适配 ── */
@supports (padding: env(safe-area-inset-top)) {
  .card {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }
}

/* ── 隐藏默认视图 ── */
#formView,
#resultView,
#qrView {
  display: block;
}

#waitingView,
#confirmedView,
#successView {
  display: none;
}
