/* ========== 基础重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #4A90D9;
  --primary-dark: #357ABD;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #333333;
  --text-light: #888888;
  --border: #e8e8e8;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --radius: 12px;
}

html, body {
  height: 100%;
}

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;
  max-width: 480px;
  margin: 0 auto;
  font-size: 15px;
}

/* 聊天页需要锁定滚动 */
body.chat-active {
  overflow: hidden;
}

a { text-decoration: none; color: var(--primary); }

/* ========== 首页 ========== */
.page-home {
  padding: 20px 16px;
  text-align: center;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.official-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.official-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.contact-guide {
  background: linear-gradient(135deg, #e8f4fd, #f0f7ff);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--primary-dark);
  line-height: 1.6;
  text-align: left;
}

.contact-guide strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

/* 对接人网格布局 */
.contact-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  max-width: 360px;
  margin: 0 auto;
}

.contact-card {
  width: 100px;
  height: 100px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
}

.contact-card:active {
  transform: scale(0.95);
}

.contact-card.recommended {
  border-color: var(--warning);
  background: linear-gradient(135deg, #fffbe6, #fff);
  position: relative;
}

.contact-card.recommended::after {
  content: '⭐';
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 16px;
}

.contact-card-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.contact-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
  line-height: 1.3;
}

.contact-card-status {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--text-light);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-online { background: var(--success); }
.status-away { background: var(--warning); }

.contact-card-arrow {
  display: none;
}

/* ========== 表单页 ========== */
.page-form {
  padding: 20px 16px;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.form-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.form-label .required {
  color: var(--danger);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
}

.form-input::placeholder {
  color: #bbb;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-back {
  display: block;
  text-align: center;
  margin-top: 16px;
  color: var(--text-light);
  font-size: 14px;
}

/* ========== 聊天页 ========== */
.page-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

.chat-header {
  background: var(--card);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}

.chat-contact-btn {
  font-size: 11px;
  color: var(--primary);
  background: #e8f4fd;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 联系方式弹窗 */
.platform-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

.platform-modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px;
  max-width: 360px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.platform-modal-title {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 20px;
}

.platform-item {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.platform-item-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.platform-item-account {
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 8px;
  word-break: break-all;
}

.platform-item-account .copy-btn {
  font-size: 12px;
  color: var(--primary);
  background: #e8f4fd;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 6px;
}

.platform-item-link {
  display: inline-block;
  font-size: 13px;
  color: #fff;
  background: var(--primary);
  padding: 6px 16px;
  border-radius: 6px;
  text-decoration: none;
}

.platform-empty {
  text-align: center;
  color: var(--text-light);
  padding: 30px 0;
  font-size: 14px;
}

.platform-close-btn {
  width: 100%;
  padding: 12px;
  background: #f5f5f5;
  color: var(--text);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 8px;
}

.chat-back {
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
  line-height: 1;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 11px;
  color: var(--text-light);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-time {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 3px;
}

.msg-from-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-from-user .msg-time {
  color: rgba(255, 255, 255, 0.7);
}

.msg-from-contact {
  align-self: flex-start;
  background: var(--card);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.msg-system {
  align-self: center;
  background: #fff7e6;
  color: #d48806;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 8px;
  max-width: 90%;
  text-align: center;
}

.msg-image {
  max-width: 200px;
  border-radius: 12px;
  display: block;
}

.msg-from-user .msg-image {
  align-self: flex-end;
}

.chat-hint {
  background: #fffbe6;
  border-top: 1px solid #ffe58f;
  padding: 4px 12px;
  font-size: 11px;
  color: #ad6800;
  text-align: center;
  flex-shrink: 0;
}

.chat-input-area {
  background: var(--card);
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}

.chat-camera-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--card);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 80px;
  min-height: 36px;
  line-height: 1.4;
}

.chat-input:focus {
  border-color: var(--primary);
}

.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-send:disabled {
  background: #ccc;
}

/* ========== 拍照模态框 ========== */
.camera-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.camera-container {
  width: 100%;
  max-width: 480px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
}

.camera-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  color: #fff;
  font-size: 15px;
  background: rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

.camera-close {
  cursor: pointer;
  font-size: 18px;
}

.camera-title {
  font-weight: 600;
}

.camera-switch {
  cursor: pointer;
  font-size: 18px;
}

#cameraVideo {
  flex: 1;
  width: 100%;
  object-fit: cover;
  background: #000;
  min-height: 0;
}

.camera-actions {
  padding: 16px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.7);
  flex-shrink: 0;
}

.camera-capture-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.camera-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#previewImg {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.preview-actions {
  display: flex;
  gap: 20px;
  margin-top: 20px;
}

.preview-retry, .preview-send {
  padding: 12px 32px;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  cursor: pointer;
}

.preview-retry {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.preview-send {
  background: var(--primary);
  color: #fff;
}

/* ========== 通用 ========== */
.hidden { display: none !important; }

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========== 后台管理 ========== */
.admin-body {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

.admin-header {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.admin-title {
  font-size: 20px;
  font-weight: 700;
}

.admin-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.admin-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.admin-form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.admin-form-row input {
  flex: 1;
  min-width: 120px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.admin-table th {
  font-weight: 600;
  color: var(--text-light);
  font-size: 13px;
}

.admin-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.admin-btn-edit { background: var(--primary); color: #fff; }
.admin-btn-delete { background: var(--danger); color: #fff; }
.admin-btn-save { background: var(--success); color: #fff; }

.admin-login {
  max-width: 400px;
  margin: 80px auto;
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 30px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
