/* FamilyBot — 移动端优先聊天界面样式 */
/* 深色主题，护眼 */

:root {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-tertiary: #252533;
  --bg-user-bubble: #3b5998;
  --bg-bot-bubble: #252533;
  --text-primary: #e4e4ec;
  --text-secondary: #8e8ea0;
  --text-hint: #6b6b7b;
  --accent: #7c5cfc;
  --accent-hover: #9478ff;
  --success: #4ade80;
  --danger: #f87171;
  --border: #2d2d3d;
  --radius: 14px;
  --radius-sm: 8px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

/* === 密码验证页 === */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1030 100%);
}

.auth-card {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.auth-logo { font-size: 48px; margin-bottom: 12px; }
.auth-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-input {
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.auth-input:focus { border-color: var(--accent); }
.auth-input.shake {
  animation: shake 0.5s ease-in-out;
  border-color: var(--danger);
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}

.auth-btn {
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: linear-gradient(135deg, var(--accent), #9478ff);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.auth-btn:hover { opacity: 0.9; }
.auth-btn:active { transform: scale(0.98); }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}

/* === 主聊天页 === */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* 动态视口高度，处理 iOS Safari */
}

/* 顶部栏 */
.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-header-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  margin-right: 8px;
}
.chat-header-name {
  font-size: 16px;
  font-weight: 600;
}

/* 消息列表 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.date-divider {
  text-align: center;
  color: var(--text-hint);
  font-size: 12px;
  margin: 16px 0 8px;
}

.message {
  display: flex;
  margin-bottom: 12px;
  max-width: 85%;
  animation: fadeIn 0.2s ease;
}
.message.user { margin-left: auto; flex-direction: row-reverse; }

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  position: relative;
}
.message.user .bubble {
  background: var(--bg-user-bubble);
  border-bottom-right-radius: 4px;
}
.message.bot .bubble {
  background: var(--bg-bot-bubble);
  border-bottom-left-radius: 4px;
  padding-bottom: 24px;
}

.bubble img {
  max-width: 200px;
  border-radius: var(--radius-sm);
  margin: 4px 0;
  cursor: pointer;
}

/* Markdown 表格 */
.bubble table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
  width: 100%;
}
.bubble th, .bubble td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
}
.bubble th { background: var(--bg-tertiary); }

/* 反馈按钮 */
.feedback-btn {
  position: absolute;
  bottom: 2px;
  right: 6px;
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 2px 4px;
  line-height: 1;
}
.message.bot:hover .feedback-btn { opacity: 0.5; }
.feedback-btn:hover { opacity: 0.9 !important; }
.feedback-btn.done { opacity: 0.4 !important; cursor: default; }

/* 打字指示器 */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 8px 12px;
}
.typing-indicator span {
  width: 6px; height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* 欢迎消息 */
.welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.welcome-emoji { font-size: 48px; margin-bottom: 12px; }
.welcome-title { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.welcome-text { font-size: 14px; line-height: 1.6; }

/* === 底部输入区 === */
.input-area {
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

/* Skill 快捷按钮条 */
.skill-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.skill-bar::-webkit-scrollbar { display: none; }

.skill-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}
.skill-btn:hover {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.15);
}
.skill-btn:active { transform: scale(0.95); }

/* 输入框行 */
.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  transition: border-color 0.2s;
}
.input-wrapper:focus-within { border-color: var(--accent); }

#message-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  padding: 8px 10px;
  outline: none;
  resize: none;
  max-height: 120px;
  min-height: 20px;
  line-height: 1.4;
  font-family: var(--font-family);
}
#message-input::placeholder { color: var(--text-hint); }

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent); background: rgba(124,92,252,0.1); }

.send-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* 图片预览 */
.image-preview {
  position: relative;
  display: inline-block;
  margin: 4px 0;
}
.image-preview img {
  max-width: 80px;
  max-height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.image-preview .remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px; height: 20px;
  background: var(--danger);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 反馈弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s;
}
.modal-card {
  background: var(--bg-secondary);
  border-radius: 20px 20px 0 0;
  padding: 24px;
  width: 100%;
  max-width: 500px;
  animation: slideUp 0.3s ease;
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}
.modal-input {
  width: 100%;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  resize: none;
  min-height: 60px;
  font-family: var(--font-family);
}
.modal-input:focus { border-color: var(--accent); }
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.modal-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.modal-btn.cancel {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.modal-btn.submit {
  background: var(--accent);
  color: white;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* 隐藏元素 */
.hidden { display: none !important; }

/* 确认操作按钮 */
.confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.confirm-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.confirm-btn.yes {
  background: rgba(76, 175, 80, 0.2);
  color: #81c784;
  border: 1px solid rgba(76, 175, 80, 0.3);
}
.confirm-btn.yes:hover:not(:disabled) {
  background: rgba(76, 175, 80, 0.35);
}
.confirm-btn.no {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.confirm-btn.no:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

/* 确认结果 */
.confirm-result {
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}
.confirm-result.success {
  background: rgba(76, 175, 80, 0.15);
  color: #a5d6a7;
  border: 1px solid rgba(76, 175, 80, 0.2);
}
.confirm-result.cancel {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.4);
}
