/* ============================================================
 * mobile.css —— 手机/小屏适配（≤820px）
 * 叠加在 app.css / social.css 之后的最终覆盖层
 * ============================================================ */

/* 移动端导航：默认隐藏（桌面端）。「更多」抽屉样式在 app.css（全端可用） */
.mtab { display: none; }

@media (max-width: 820px), (max-width: 1024px) and (orientation: portrait) {

  /* ---------- 桌面侧栏整体隐藏，改用微信式 4 图标底部导航 ---------- */
  .rail { display: none !important; }
  .rail-btn-mob-avatar { display: none !important; }

  /* ---------- 微信/QQ 风格底部导航（4 图标） ---------- */
  .mtab {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; height: 54px;
    background: #f7f7f7; border-top: 1px solid #dcdcdc;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mtab-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; background: none; border: none; padding: 0; cursor: pointer;
    color: #7a7a7a;
  }
  .mtab-btn svg { width: 25px; height: 25px; display: block; }
  .mtab-btn span { font-size: 10.5px; line-height: 1; }
  .mtab-btn.is-on { color: #07c160; }

  /* 「更多」抽屉：底部弹出（覆盖桌面居中样式） */
  .mtab-drawer {
    display: flex; align-items: flex-end; justify-content: stretch;
  }
  .mtab-drawer-panel {
    width: 100%;
    position: absolute; left: 0; right: 0; bottom: 0;
    border-radius: 16px 16px 0 0;
    padding: 18px 14px calc(24px + env(safe-area-inset-bottom));
    max-height: 62vh;
  }

  /* 聊天列表顶部公告横幅 */
  .chat-ann {
    display: flex; align-items: center; gap: 8px;
    margin: 6px 8px; padding: 8px 10px;
    background: #eef7ee; border: 1px solid #d5ecd5; border-radius: 8px;
    font-size: 12.5px; color: #2c6e3f; cursor: pointer;
  }
  .chat-ann .ca-badge {
    flex: none; background: #e74c3c; color: #fff; font-size: 10px;
    border-radius: 8px; padding: 1px 6px;
  }
  .chat-ann .ca-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

  /* 内容底部为 4 图标导航留空间 */
  .list-stack { padding-bottom: 62px; }
  .msg-scroll { padding-bottom: 16px; }

  /* ---------- 大区域视图 ---------- */
  .pane-full { border-left: none; }
  .full-body { padding: 12px; }
  .full-head { padding: 10px 12px; }
  .full-title { font-size: 14px; }
  .full-tabs { padding: 8px 12px; }
  .full-foot { padding: 10px 12px; flex-wrap: wrap; }
  .full-foot .btn-primary { width: auto; padding: 0 28px; }

  /* ---------- 各视图微调 ---------- */
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
  .music-frame-wrap { height: min(560px, 62vh); }
  .hobby-groups { max-width: none; }
  .hobby-bar { flex-wrap: wrap; }
  .bubble-form-scroll { max-height: 44vh; }
  .lk-stage { max-width: 100%; }
  .games-tip { font-size: 11.5px; padding: 4px 8px; }

  /* ---------- 消息与输入 ---------- */
  .msg { max-width: 88%; }
  .msg-scroll { padding: 12px 10px 8px; }
  .composer, .chat-input { flex-wrap: nowrap; }
  .pane-list { width: 100%; }

  /* ---------- 弹窗 ---------- */
  .modal { width: min(420px, 94vw); max-height: 88vh; overflow-y: auto; }
  .modal-wide { width: 96vw; }
  .emoji-pop { width: min(320px, 94vw); max-width: 94vw; }

  /* ---------- 管理面板 ---------- */
  .admin-tabs { flex-wrap: wrap; }
  .admin-item { flex-direction: column; align-items: stretch; }
  .admin-ops { margin-top: 8px; flex-wrap: wrap; }

  /* ---------- 找朋友泡泡海 ---------- */
  .bubble-float { width: 84px; }
}


/* ===== 移动端视觉更新：底部导航触感 + 抽屉多彩图标 + 引导 ===== */
.mtab-btn svg { transition: transform .12s ease; }
.mtab-btn:active svg { transform: scale(.82); }
.mtab-btn.is-on svg { transform: translateY(-1px); }
.mtab-btn::after {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: 0; transition: opacity .15s;
}
.mtab-btn.is-on::after { opacity: 1; }
.drawer-item[data-act="profile"] .di-ico { background: #fa9d3b; }
.drawer-item[data-act="contacts"] .di-ico { background: #07c160; }
.drawer-item[data-act="ann"] .di-ico { background: #e74c3c; }
.drawer-item[data-act="favorites"] .di-ico { background: #f5a623; }
.drawer-item[data-act="files"] .di-ico { background: #1989fa; }
.drawer-item[data-act="find"] .di-ico { background: #00b8a9; }
.drawer-item[data-act="lucky"] .di-ico { background: #7c4dff; }
.drawer-item[data-act="guide"] .di-ico { background: #07c160; }
.drawer-item[data-act="feedback"] .di-ico { background: #5b7a9d; }
.drawer-item[data-act="settings"] .di-ico { background: #6b6b6b; }
.drawer-item[data-act="admin"] .di-ico { background: #c0392b; }
/* 点击式引导：高亮目标呼吸光圈 */
.guide-hole { animation: guidePulse 1.6s ease-in-out infinite; }
@keyframes guidePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(7,193,96,.55); }
  50% { box-shadow: 0 0 0 7px rgba(7,193,96,.25); }
}

/* 游戏中心头部「⋯ 更多」按钮（仅移动端显示） */
#btnMoreFloat2 { display: flex; }

/* ============================================================
 * 通讯录微信化（基础样式：桌面/移动通用，renderContacts 新结构）
 * ============================================================ */
.ct-fn-ico {
  width: 42px; height: 42px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px;
}
.ct-gap { height: 8px; background: #ededed; }
.ct-sec-head {
  padding: 3px 16px; background: #ededed; color: #808080;
  font-size: 12.5px; font-weight: 400;
  position: sticky; top: 0; z-index: 2;
}
.ct-empty { color: #b2b2b2; font-size: 13px; padding: 14px 16px; }
.ct-sq { border-radius: 6px; }
.ct-index {
  position: sticky; top: 46%; align-self: flex-end;
  height: 0; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  z-index: 5; padding: 4px 2px; overflow: visible;
}
.ct-index span {
  font-size: 10px; line-height: 13px; color: #7a7a7a;
  padding: 0 4px; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.ct-index span:active { color: #07c160; font-weight: 700; }
/* 底部导航未读红泡（元素只在移动端可见） */
.mtab-btn { position: relative; }
.mtab-badge {
  position: absolute; top: 4px; left: calc(50% + 6px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: #fa5151; color: #fff; font-style: normal;
  font-size: 10px; line-height: 16px; text-align: center;
  border-radius: 9px; white-space: nowrap;
  box-shadow: 0 0 0 2px #f7f7f7;
}

/* ============================================================
 * 移动端微信化布局（仅小屏：模仿微信，桌面端不受影响）
 * ============================================================ */
@media (max-width: 820px), (max-width: 1024px) and (orientation: portrait) {

  /* ---------- 底部导航 ---------- */
  .mtab { background: #f7f7f7; border-top: 1px solid #e3e3e3; }

  /* ---------- 聊天会话：微信式头部（居中标题，隐藏在线状态） ---------- */
  .chat-head { background: #f7f7f7; border-bottom: 1px solid #e3e3e3; }
  .chat-head .chat-title {
    position: absolute; left: 50%; transform: translateX(-50%);
    max-width: 46%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    font-weight: 500;
  }
  .chat-head .chat-status { display: none; }
  .chat-head .back-btn { color: #181818; }
  .chat-head .more-btn { margin-left: auto; }

  /* ---------- 通讯录：微信风格行高与分隔 ---------- */
  #contactList { background: #fff; }
  .contact { background: #fff; align-items: center; padding: 9px 14px; }
  .contact .contact-av { width: 40px; height: 40px; }
  .contact + .contact { border-top: 0.5px solid #f0f0f0; }
  .contact + .ct-sec-head, .ct-gap + .contact { border-top: none; }
  .ct-fn .contact-name { font-size: 15.5px; color: #181818; }
  .contact-name { font-size: 15.5px; }

  /* ---------- 列表头部：微信式白底灰线、标题居中 ---------- */
  .list-head { background: #f7f7f7; border-bottom: 1px solid #e3e3e3; }
  .list-head .social-view-title { flex: 1; text-align: center; font-weight: 500; color: #181818; }
}

/* ---------- 移动端登录卡片：不超出屏幕 ---------- */
@media (max-width: 820px), (max-width: 1024px) and (orientation: portrait) {
  .login-wrap { padding: 12px; align-items: flex-start; }
  .login-box { width: 100%; max-width: 380px; }
  .login-card { width: 100%; padding: 26px 20px 20px; }
  .login-title { font-size: 19px; }
  .login-sub { font-size: 12px; }
}

/* ---------- 移动端 AI：顶部 chips 收起，功能进「＋」网格（微信式） ---------- */
@media (max-width: 820px), (max-width: 1024px) and (orientation: portrait) {
  /* 登录卡片自适应：360~390px 窄屏不再横向溢出 */
  .login-wrap { padding: 12px; }
  .login-box { width: 100%; max-width: 380px; }
  .login-card { width: 100%; box-sizing: border-box; }
  .composer.ai-mode .ai-chip-wrap { display: none; }
  .composer.ai-mode { margin: 0 8px 8px; padding: 8px 10px; }
  .composer.ai-mode #msgInput { height: 52px; }
  #aiPlus { display: none; }
  .composer.ai-mode #aiPlus { display: flex; font-size: 20px; color: #444; }
  .composer.ai-mode .composer-foot { display: flex; align-items: center; gap: 8px; }
  .composer.ai-mode .composer-foot .btn-send { margin-left: auto; }
  .ai-plus-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 8px;
    background: #f7f8fa; padding: 18px 14px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid #ececec;
  }
  .ai-plus-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: none; border: none; padding: 0; cursor: pointer; color: #333; font-size: 11.5px;
  }
  .ai-plus-item .api-ico {
    width: 52px; height: 52px; border-radius: 16px; background: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 25px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
  }
  .ai-plus-item.is-on .api-ico { background: #e8f8ef; box-shadow: 0 0 0 2px #07c160 inset; }
  .ai-plus-item.is-on { color: #07c160; }
}

/* ---------- 聊天头部返回箭头：清晰的 SVG 图标 + 更大点击区 ---------- */
@media (max-width: 820px), (max-width: 1024px) and (orientation: portrait) {
  .chat-head .back-btn {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; margin-right: 4px; padding: 0;
    color: #181818; background: none; border: none; cursor: pointer;
  }
  .chat-head .back-btn svg { display: block; }
}

/* 发现网格在手机上铺满宽度 */
@media (max-width: 820px), (max-width: 1024px) and (orientation: portrait) {
  .discover-grid { grid-template-columns: repeat(4, 1fr); gap: 18px 8px; }
}

/* ---------- 微信式输入区（移动端）：语音切换 / 按住说话 / ＋更多面板 ---------- */
@media (max-width: 820px), (max-width: 1024px) and (orientation: portrait) {
  .composer { padding: 8px 10px 10px; }
  .composer-main { align-items: center; gap: 8px; }
  .composer-main .tool { width: 34px; height: 34px; font-size: 19px; opacity: .85; }
  .composer-main #msgInput { height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; background: #f6f7f9; }
  .hold-talk { height: 42px; font-size: 14px; border-radius: 8px; }
  .more-grid { gap: 14px 6px; padding: 16px 8px 18px; }
  .more-item .mi-ico { width: 50px; height: 50px; font-size: 25px; }
  /* 深色背景（用户自定义深色壁纸）下输入框和面板不再刺眼 */
  body.has-user-bg.bg-dark-bg .composer-main #msgInput { background: rgba(28, 28, 30, .82); color: #ececec; }
  body.has-user-bg.bg-dark-bg .hold-talk { background: rgba(52, 52, 56, .9); color: #ececec; }
  body.has-user-bg.bg-dark-bg .hold-talk.is-rec { background: rgba(70, 70, 76, .95); }
  body.has-user-bg.bg-dark-bg .more-item .mi-ico { background: rgba(255, 255, 255, .1); }
  body.has-user-bg.bg-dark-bg .more-item { color: #cfcfcf; }
}

/* ---------- ＋更多面板：微信/QQ 式底部弹层 ---------- */
@media (max-width: 820px), (max-width: 1024px) and (orientation: portrait) {
  .sheet-mask { position: fixed; inset: 0; z-index: 58; background: rgba(0, 0, 0, .45); -webkit-tap-highlight-color: transparent; }
  .composer .more-grid {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 59;
    background: #f7f8fa; border-top: none; border-radius: 16px 16px 0 0;
    padding: 20px 10px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .16);
    transform: translateY(102%); transition: transform .24s cubic-bezier(.2, .8, .3, 1);
    will-change: transform;
  }
  .composer .more-grid.is-open { transform: translateY(0); }
  .composer .more-item .mi-ico { width: 52px; height: 52px; font-size: 24px; }
  body.has-user-bg.bg-dark-bg .composer .more-grid { background: rgba(32, 32, 36, .96); }
  body.has-user-bg.bg-dark-bg .composer .more-item { color: #cfcfcf; }
}
