/* ============================================================
   Chat 专有样式 — 气泡 / Header / 输入框 / 打字指示器
   共享外壳 (颜色变量/按钮/Toast/底部导航/模态框) 由 dark-theme.css 提供

   布局结构（flex column，100dvh）：
     header (56px) → chat (flex:1, scroll) → typing (auto) → input (auto)
     底部导航 (position:fixed) 叠在最下层
   ============================================================ */

/* ── 聊天专有变量 ── */
:root {
  --header-h: 56px;
  --bubble-her: #1a1a28;
  --bubble-him-start: #e84393;
  --bubble-him-end: #fd79a8;
}

/* ── Body 覆写：全高 flex 布局，其余属性由 dark-theme.css 提供 ── */
html, body { height: 100dvh; overflow: hidden; }
body {
  background: #0a0a12;
  display: flex;
  flex-direction: column;
}

/* ── 年龄验证门 (聊天专有结构，chat.js 管理 #ageGate / #ageGateBtn) ── */
.age-gate {
  position: fixed; inset: 0; z-index: 1000;
  background: #0a0a12;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.age-gate.hidden { display: none; }
.age-gate-card { text-align: center; max-width: 320px; width: 100%; }
.age-gate-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--bubble-him-start), var(--bubble-him-end));
  overflow: hidden;
  margin: 0 auto 20px;
}
.age-gate-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.age-gate-card h1 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.age-gate-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.age-gate-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 6px; }
.age-gate-desc-zh { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 24px; }
.age-gate-btn {
  display: block; width: 100%;
  padding: 14px 24px; border: none; border-radius: 25px;
  background: linear-gradient(135deg, var(--bubble-him-start), var(--bubble-him-end));
  color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: opacity .15s;
}
.age-gate-btn:active { opacity: .85; }
.age-gate-btn-zh { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }

/* ── Header ── */
.header {
  height: var(--header-h); display: flex; align-items: center;
  padding: 8px 14px; gap: 10px; flex-shrink: 0;
  background: rgba(10,10,18,.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 10;
}
.header-back {
  width: 32px; height: 32px; border: none; background: none;
  cursor: pointer; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.header-back.hidden { visibility: hidden; }
.header-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--bubble-him-start), var(--bubble-him-end));
  overflow: hidden;
}
.header-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.header-info { flex: 1; min-width: 0; }
.header-name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.header-status { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online { background: #4caf50; }
.status-dot.typing { background: #ff9800; }
.status-dot.offline { background: #555; }
.header-menu-btn {
  width: 36px; height: 36px; border: none; background: none;
  cursor: pointer; border-radius: 50%; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ── 菜单下拉 ── */
.menu-dropdown {
  position: fixed; top: var(--header-h); right: 8px; z-index: 200;
  background: var(--bg-card); border-radius: 14px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
  min-width: 180px; padding: 6px;
  animation: menuIn .15s ease-out;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.menu-dropdown.hidden { display: none; }
.menu-dropdown button {
  display: block; width: 100%;
  padding: 11px 16px; border: none; background: none;
  font-size: 14px; text-align: left; color: var(--text-primary);
  cursor: pointer; border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}
.menu-dropdown button:active { background: rgba(255,255,255,.04); }
.menu-divider { height: 1px; background: var(--border-subtle); margin: 4px 8px; }
.menu-footer {
  padding: 10px 16px 6px; font-size: 11px;
  color: var(--text-secondary); text-align: center;
}

/* ── 网络状态条 ── */
.network-bar {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 150;
  padding: 6px 16px; text-align: center; font-size: 12px; font-weight: 500;
  transition: transform .3s, opacity .3s;
}
.network-bar.reconnecting { background: rgba(255,152,0,.15); color: #ff9800; }
.network-bar.online { background: rgba(76,175,80,.15); color: #4caf50; }
.network-bar.lost { background: rgba(244,67,54,.15); color: #ef5350; }
.network-bar.hidden { display: none; }
.network-bar.fade-out { opacity: 0; transform: translateY(-100%); }

/* ── 聊天区域（flex:1 填充中间空间，独立滚动） ── */
.chat {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px;
  -webkit-overflow-scrolling: touch; scroll-behavior: smooth;
}
.chat::-webkit-scrollbar { width: 0; }

/* ── 消息气泡 ── */
.msg-group { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; }
.msg-row { display: flex; align-items: flex-end; gap: 6px; max-width: 85%; }
.msg-row.her { align-self: flex-start; margin-right: auto; }
.msg-row.him { align-self: flex-end; margin-left: auto; flex-direction: row-reverse; }
.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--bubble-him-start), var(--bubble-him-end));
  background-size: cover; background-position: center;
  color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  align-self: flex-end; margin-bottom: 2px;
}
.msg-avatar.hidden { visibility: hidden; }
.msg-bubble {
  padding: 10px 14px; border-radius: 18px;
  font-size: 15px; line-height: 1.45; word-break: break-word;
  position: relative; max-width: 100%;
}
.msg-row.her .msg-bubble {
  background: var(--bubble-her); color: var(--text-primary);
  border-bottom-left-radius: 6px; border: 1px solid var(--border-subtle);
}
.msg-row.him .msg-bubble {
  background: linear-gradient(135deg, var(--bubble-him-start), var(--bubble-him-end));
  color: #fff; border-bottom-right-radius: 6px;
  box-shadow: 0 2px 8px rgba(232,67,147,.2);
}
.msg-status { font-size: 10px; opacity: .35; margin-top: 2px; padding: 0 4px; align-self: flex-end; letter-spacing: .3px; }
.msg-row.him .msg-status { color: var(--text-secondary); text-align: right; }
.msg-status.failed { color: #ef5350; opacity: 1; }
.msg-time { font-size: 10px; color: var(--text-secondary); text-align: center; margin: 10px 0 4px; opacity: .5; }
.retry-btn {
  font-size: 11px; color: var(--bubble-him-start);
  background: none; border: 1px solid var(--bubble-him-start);
  border-radius: 12px; padding: 4px 12px; cursor: pointer;
  margin-top: 4px; align-self: flex-end;
  -webkit-tap-highlight-color: transparent;
}

/* ── 打字指示器 ── */
.typing-indicator { display: flex; align-items: flex-end; gap: 6px; padding: 0 14px; margin: 6px 0; flex-shrink: 0; }
.typing-indicator.hidden { display: none; }
.typing-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--bubble-him-start), var(--bubble-him-end));
  background-size: cover; background-position: center;
  color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.typing-bubble {
  background: var(--bubble-her); border-radius: 18px;
  border-bottom-left-radius: 6px; border: 1px solid var(--border-subtle);
  padding: 12px 16px; display: flex; gap: 4px; align-items: center;
}
.typing-dot { width: 7px; height: 7px; border-radius: 50%; background: #555; animation: dotBounce 1.4s infinite ease-in-out both; }
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: .16s; }
.typing-dot:nth-child(3) { animation-delay: .32s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── 事件卡片 / 预览卡片 ── */
.event-card {
  align-self: center; background: var(--bg-card);
  border-radius: 16px; border: 1px solid var(--border-subtle);
  padding: 14px 16px; margin: 6px 0; max-width: 260px; text-align: center;
}
.event-card-icon { font-size: 28px; margin-bottom: 6px; }
.event-card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.event-card-price { font-size: 18px; font-weight: 700; color: var(--bubble-him-start); margin-bottom: 8px; }
.event-card-btn {
  display: block; width: 100%; padding: 10px 20px; border: none; border-radius: 20px;
  background: linear-gradient(135deg, var(--bubble-him-start), var(--bubble-him-end));
  color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: opacity .15s;
}
.event-card-btn:active { opacity: .85; }
.event-card-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.4; margin-top: 6px; }
.preview-card {
  cursor: pointer; border: 1px solid var(--border-subtle); border-radius: 16px;
  overflow: hidden; max-width: 240px; background: var(--bg-card);
}
.preview-card img, .preview-card video { width: 100%; display: block; max-height: 200px; object-fit: cover; }
.preview-card-label { padding: 8px 12px; font-size: 12px; color: var(--text-secondary); text-align: center; }
.preview-card.clickable { cursor: pointer; }

/* ── 滚动到底部按钮（位于底部导航上方） ── */
.scroll-btn {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 60px);
  right: 10px; z-index: 50;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border-subtle); background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .2s, transform .2s;
  -webkit-tap-highlight-color: transparent; color: var(--text-muted);
}
@media (min-width: 481px) {
  .scroll-btn { right: calc(50% - 240px + 10px); }
}
.scroll-btn.hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }

/* ── 输入区域（flex-shrink:0 留在 flex 流底部，padding-bottom 清除底部导航） ── */
.input-area {
  flex-shrink: 0;
  padding: 8px 10px;
  padding-bottom: calc(8px + var(--nav-height) + var(--safe-bottom));
  background: rgba(10,10,18,.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  z-index: 20;
}
.input-wrapper {
  display: flex; align-items: flex-end; gap: 8px;
  background: #1a1a28; border-radius: 24px;
  padding: 4px 4px 4px 16px;
  border: 1px solid var(--border-subtle);
  transition: border-color .2s;
}
.input-wrapper:focus-within { border-color: rgba(232,67,147,.3); }
.input-field {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; line-height: 1.4; color: var(--text-primary);
  resize: none; padding: 8px 0; max-height: 120px; font-family: inherit;
  -webkit-user-select: text; user-select: text;
}
.input-field::placeholder { color: #4a4450; }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0;
  background: linear-gradient(135deg, var(--bubble-him-start), var(--bubble-him-end));
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: opacity .15s, transform .15s;
}
.send-btn:active { opacity: .85; transform: scale(.95); }
.send-btn:disabled { opacity: .4; cursor: default; }

/* ── 媒体预览浮层 ── */
.preview-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.preview-overlay img, .preview-overlay video { max-width: 95vw; max-height: 90vh; border-radius: 8px; }
.preview-overlay-close {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.15);
  color: #fff; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── 桌面：边框由 dark-theme.css 提供（@media min-width:481px）；聊天区加宽内边距 ── */
@media (min-width: 481px) {
  .chat { padding: 12px 20px; }
}
