/* 办公室访客接待系统 - 访客端样式（干练商务风） */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #1a365d;
  --primary-light: #2c5282;
  --success: #276749;
  --warning: #c05621;
  --danger: #c53030;
  --gray-50: #f7fafc;
  --gray-100: #edf2f7;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e0;
  --gray-400: #a0aec0;
  --gray-500: #718096;
  --gray-600: #4a5568;
  --gray-700: #2d3748;
  --gray-800: #1a202c;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  background: var(--gray-100);
  color: var(--gray-700);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gray-100);
  position: relative;
  max-width: 960px;
  margin: 0 auto;
}

/* 头部 */
.header {
  background: var(--primary);
  color: #fff;
  padding: 18px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.header-title { font-size: 18px; font-weight: 600; letter-spacing: 0.5px; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.connection-status {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.85;
  font-weight: 500;
}

.settings-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s;
  line-height: 1;
  color: #fff;
  opacity: 0.8;
}

.settings-btn:hover {
  background: rgba(255,255,255,0.15);
  opacity: 1;
}

/* 主题选择面板 - 简化为仅保留暗色切换 */
.theme-panel {
  position: absolute;
  top: 58px;
  right: 16px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  border: 1px solid var(--gray-200);
  padding: 12px 16px;
  z-index: 100;
  min-width: 160px;
}

.theme-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 10px;
}

.theme-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s;
  min-width: 44px;
}

.theme-option:hover {
  background: var(--gray-100);
}

.theme-option span {
  font-size: 11px;
  color: var(--gray-500);
}

.theme-color {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.2s;
}

.theme-option:hover .theme-color {
  transform: scale(1.1);
}

.theme-blue .theme-color { background: #1a365d; }
.theme-dark .theme-color { background: #1a202c; border-color: var(--gray-400); }

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.dot.online { background: #68d391; box-shadow: 0 0 4px rgba(104,211,145,0.4); }
.dot.offline { background: var(--gray-400); }
.dot.busy { background: var(--danger); }

/* ========== 登录界面 ========== */
.login-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  padding: 36px 28px;
  box-shadow: var(--shadow-md);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  text-align: center;
  margin-bottom: 28px;
}

/* ========== 三模块主界面 ========== */

.main-content {
  flex: 1;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 18px;
  flex: 1;
}

.module-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 28px 24px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s;
  border-left: 3px solid var(--gray-300);
}

.module-card:active { transform: scale(0.98); }
.module-card:hover { box-shadow: var(--shadow-md); border-color: var(--gray-300); }

.module-icon {
  font-size: 32px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid var(--gray-200);
}

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

.module-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray-800);
}

.module-desc {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 5px;
}

/* 接待时间：时间文字做明显一点 */
#homeTimeLabel {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-700);
}

.module-arrow {
  font-size: 22px;
  color: var(--gray-400);
  font-weight: 300;
  padding-right: 2px;
}

/* 访客留言模块高亮 */
.module-primary {
  border-left-color: var(--primary);
  background: linear-gradient(135deg, #ebf8ff 0%, #fff 100%);
}
.module-primary .module-icon { background: #ebf8ff; border-color: #bee3f8; }

/* 状态模块边框色 */
#cardStatus { border-left-color: var(--success); }
#cardStatus .module-icon { background: #f0fff4; border-color: #c6f6d5; }

#cardTime { border-left-color: var(--warning); }
#cardTime .module-icon { background: #fffaf0; border-color: #feebc8; }

/* ========== 表单视图 ========== */

.form-view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
}

.form-back {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 0;
}

.form-header .form-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  color: var(--gray-800);
}

.form-container {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
  background: #fff;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.form-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--gray-800);
}

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

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

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

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 15px;
  background: var(--gray-50);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  color: var(--gray-700);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(26,54,93,0.08);
  background: #fff;
}

.form-group textarea { resize: none; }

.submit-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-top: 6px;
  letter-spacing: 0.5px;
}

.submit-btn:hover { background: var(--primary-light); }
.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== 等待界面 ========== */

.wait-view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.wait-container {
  flex: 1;
  text-align: center;
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.wait-animation { margin-bottom: 18px; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

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

.wait-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; color: var(--gray-800); }
.wait-desc { color: var(--gray-500); font-size: 14px; margin-bottom: 20px; }

.wait-info {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 18px;
  text-align: left;
  font-size: 13px;
  line-height: 1.6;
  width: 100%;
  max-width: 440px;
  border: 1px solid var(--gray-200);
  color: var(--gray-600);
}

/* 反馈卡片 */
.response-area { margin-bottom: 18px; width: 100%; max-width: 440px; }

.response-card {
  padding: 18px;
  border-radius: 8px;
  background: #f0fff4;
  border: 1px solid #c6f6d5;
  animation: fadeInUp 0.4s ease;
}

.response-card.response-rejected {
  background: #fff5f5;
  border-color: #fed7d7;
}

.response-card.response-delayed {
  background: #fffaf0;
  border-color: #feebc8;
}

.response-icon { font-size: 32px; margin-bottom: 6px; }
.response-text { font-size: 15px; font-weight: 600; color: var(--gray-800); }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.back-btn {
  padding: 11px 24px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: #fff;
  color: var(--gray-600);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 500;
}

.back-btn:hover { background: var(--gray-50); }

/* 底部 */
.footer {
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
  background: #fff;
}

/* 提示条 */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--gray-800);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error { background: var(--danger); }

/* ========== 主人回复模块样式 ========== */

.module-secondary {
  border-left-color: #553c9a;
  background: linear-gradient(135deg, #faf5ff 0%, #fff 100%);
}

.module-secondary .module-icon {
  background: #faf5ff;
  border-color: #e9d8fd;
}

.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

/* 按访客分组的回复列表 */
.chat-groups {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--gray-50);
}

.chat-empty {
  text-align: center;
  color: var(--gray-400);
  padding: 50px 0;
  font-size: 14px;
}

.chat-group {
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.chat-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

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

.chat-group-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}

.chat-group-reason {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.chat-group-delete {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  transition: background 0.2s;
  opacity: 0.4;
}

.chat-group-delete:hover {
  background: #fff5f5;
  opacity: 0.8;
}

.chat-group-messages {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-group-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 85%;
}

.chat-group-msg.msg-master {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-group-msg.msg-visitor {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-group-msg-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  padding: 0 3px;
}

.msg-master .chat-group-msg-label {
  color: var(--primary);
}

.msg-visitor .chat-group-msg-label {
  color: var(--gray-400);
}

.chat-group-msg-bubble {
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  color: var(--gray-700);
}

.msg-master .chat-group-msg-bubble {
  color: var(--gray-700);
}

.msg-visitor .chat-group-msg-bubble {
  color: var(--primary);
  font-weight: 500;
}

.chat-group-msg-time {
  font-size: 11px;
  color: var(--gray-400);
  padding: 0 3px;
  margin-top: 2px;
}

/* ========== 暗色主题 ========== */
[data-theme="dark"] {
  --primary: #63b3ed;
  --primary-light: #4299e1;
  --success: #68d391;
  --warning: #f6ad55;
  --danger: #fc8181;
  --gray-50: #171923;
  --gray-100: #1a202c;
  --gray-200: #2d3748;
  --gray-300: #4a5568;
  --gray-400: #718096;
  --gray-500: #a0aec0;
  --gray-600: #cbd5e0;
  --gray-700: #e2e8f0;
  --gray-800: #f7fafc;
}

[data-theme="dark"] body {
  background: #0d1117;
  color: var(--gray-700);
}

[data-theme="dark"] .app {
  background: #0d1117;
}

[data-theme="dark"] .main-content {
  background: #0d1117;
}

[data-theme="dark"] .module-card,
[data-theme="dark"] .chat-group,
[data-theme="dark"] .login-box {
  background: #161b22;
  border-color: #30363d;
}

[data-theme="dark"] .module-icon {
  background: #21262d;
  border-color: #30363d;
}

[data-theme="dark"] .module-primary {
  background: linear-gradient(135deg, rgba(99,179,237,0.08) 0%, #161b22 100%);
}

[data-theme="dark"] .module-primary .module-icon {
  background: rgba(99,179,237,0.1);
  border-color: rgba(99,179,237,0.15);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .form-group select {
  background: #21262d;
  border-color: #30363d;
  color: var(--gray-700);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group textarea:focus,
[data-theme="dark"] .form-group select:focus {
  background: #21262d;
  box-shadow: 0 0 0 2px rgba(99,179,237,0.1);
}

[data-theme="dark"] .chat-groups {
  background: #0d1117;
}

[data-theme="dark"] .chat-group-header {
  background: #21262d;
  border-color: #30363d;
}

[data-theme="dark"] .chat-empty {
  color: var(--gray-500);
}

[data-theme="dark"] .footer {
  border-color: #21262d;
  color: var(--gray-500);
  background: #161b22;
}

[data-theme="dark"] .form-header {
  background: #161b22;
  border-color: #30363d;
}

[data-theme="dark"] .wait-info {
  background: #21262d;
  border-color: #30363d;
}

[data-theme="dark"] .back-btn {
  background: #21262d;
  border-color: #30363d;
  color: var(--gray-600);
}

[data-theme="dark"] .back-btn:hover {
  background: #30363d;
}

[data-theme="dark"] .theme-panel {
  background: #161b22;
  border-color: #30363d;
}

[data-theme="dark"] .theme-option:hover {
  background: #21262d;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .app {
    max-width: 100%;
    box-shadow: none;
  }

  .header {
    padding: 14px 18px;
  }
  .header-title {
    font-size: 17px;
  }

  .main-content {
    padding: 16px;
  }

  .module-grid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
    gap: 12px;
  }

  .module-card {
    padding: 18px 16px;
    gap: 14px;
  }

  .module-icon {
    font-size: 24px;
    width: 44px;
    height: 44px;
  }

  .module-title {
    font-size: 15px;
  }

  .module-desc {
    font-size: 13px;
  }

  .form-container {
    padding: 16px;
    max-width: 100%;
  }

  .wait-container {
    padding: 40px 20px;
    max-width: 100%;
  }

  .chat-groups {
    padding: 14px;
  }

  .chat-group-msg-bubble {
    font-size: 14px;
  }

  .login-box {
    padding: 28px 20px;
  }
}

/* ========== 红点提醒 ========== */
.module-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

#cardChat {
  position: relative;
}

/* ========== 登录界面气泡提醒 ========== */
.reply-bubbles {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeSlideDown 0.3s ease;
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.reply-bubble {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--gray-700);
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
  position: relative;
}

.reply-bubble::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 20px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-left: 1px solid var(--gray-200);
  border-top: 1px solid var(--gray-200);
  transform: rotate(45deg);
}

.reply-bubble-name {
  font-weight: 600;
  color: var(--primary);
  font-size: 13px;
}

.reply-bubble-text {
  color: var(--gray-600);
  font-size: 12px;
  line-height: 1.5;
}

.reply-bubble-more {
  text-align: center;
  font-size: 12px;
  color: var(--gray-500);
  padding: 4px 0;
}

/* 被拉黑访客限制信息页面 */
.blocked-view {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 40px 20px;
}

.blocked-container {
  background: #fff;
  border-radius: 12px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: var(--shadow-md);
  max-width: 480px;
  width: 100%;
}

.blocked-icon {
  font-size: 48px;
  color: var(--warning);
  margin-bottom: 16px;
}

.blocked-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.blocked-subtitle {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 24px;
}

.blocked-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: 8px;
  margin-bottom: 10px;
}

.blocked-info-label {
  font-size: 14px;
  color: var(--gray-500);
}

.blocked-info-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}


/* CSG-MTL 结构化输入 */
.form-row-2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.form-group select { cursor:pointer; }
.ai-form-tip { margin:-5px 0 18px; padding:9px 11px; border-radius:8px; background:#ebf8ff; color:#2b6cb0; font-size:12px; line-height:1.5; }
@media (max-width:520px) { .form-row-2 { grid-template-columns:1fr; gap:0; } }

/* V9：结构化场景预览 + 融合决策反馈 */
.visit-context-preview {
  margin:-4px 0 10px;
  padding:11px 12px;
  border:1px solid #d7e3f1;
  border-radius:9px;
  background:#f8fbff;
  color:#334155;
  font-size:12px;
  line-height:1.65;
}
.visit-context-preview strong { color:#1f497d; }
.visit-context-preview .preview-tags { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:5px; }
.visit-context-preview .preview-tags span { padding:2px 8px; border-radius:999px; background:#eaf2fb; color:#1f497d; font-weight:700; }
.scene-decision-box {
  width:100%;
  box-sizing:border-box;
  margin:12px 0 4px;
  padding:13px 14px;
  border:1px solid #cfe0f2;
  border-radius:10px;
  background:linear-gradient(135deg,#f7fbff 0%,#ffffff 100%);
  text-align:left;
}
.scene-decision-title { display:flex; justify-content:space-between; align-items:center; gap:8px; font-size:13px; font-weight:800; color:#1f497d; margin-bottom:7px; }
.scene-decision-title b { font-size:11px; color:#276749; background:#e6fffa; padding:2px 7px; border-radius:999px; }
.scene-decision-text { font-size:13px; color:#475569; line-height:1.65; }
.scene-decision-tags { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.scene-decision-tags span { font-size:11px; color:#475569; background:#f1f5f9; border-radius:999px; padding:3px 8px; }
