/* ============================================
   wechat-chat.css
   微信聊天界面 1:1 还原样式
   适用于 Typecho Weui 移动端主题
   所有选择器以 .wechat-chat- 为前缀
   ============================================ */

/* ============================================
   1. 会话列表
   ============================================ */
.wechat-chat-list {
    background-color: #ededed;
    list-style: none;
    margin: 0;
    padding: 0;
}

.wechat-chat-list .chat-session-item {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 64px;
    padding: 8px 12px;
    background-color: #ffffff;
    box-sizing: border-box;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    color: #000;
}

/* 条目间细分隔线（左边距 60px 留出头像位置） */
.wechat-chat-list .chat-session-item:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 60px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background-color: #e0e0e0;
    transform: scaleY(0.5);
    transform-origin: 0 100%;
}

/* 条目点击高亮 */
.wechat-chat-list .chat-session-item:active {
    background-color: #d9d9d9;
}

/* 左侧头像：40x40，圆角 6px（微信头像为圆角矩形） */
.wechat-chat-list .chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    flex-shrink: 0;
    margin-right: 12px;
    background-color: #d9d9d9;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.wechat-chat-list .chat-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 6px;
    object-fit: cover;
}

/* 中间区域：名称 + 最后消息摘要 */
.wechat-chat-list .chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    overflow: hidden;
}

.wechat-chat-list .chat-name {
    font-size: 16px;
    color: #000;
    line-height: 1.4;
    margin: 0;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wechat-chat-list .chat-last-msg {
    font-size: 13px;
    color: #999;
    line-height: 1.4;
    margin: 2px 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 右侧：时间 + 未读角标 */
.wechat-chat-list .chat-side {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    height: 100%;
    margin-left: 8px;
}

.wechat-chat-list .chat-time {
    font-size: 11px;
    color: #999;
    line-height: 1.4;
    white-space: nowrap;
}

.wechat-chat-list .chat-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-top: 6px;
    background-color: #fa5151;
    color: #ffffff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    box-sizing: border-box;
    font-weight: 500;
    display: inline-block;
}

/* 未读角标无内容时（小圆点形式） */
.wechat-chat-list .chat-badge.chat-badge-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    padding: 0;
    border-radius: 50%;
    margin-top: 8px;
}

/* 勿扰模式（无角标占位） */
.wechat-chat-list .chat-badge.chat-badge-hidden {
    display: none;
}


/* ============================================
   2. 聊天详情页（沉浸式：隐藏顶部 header 和底部 tabbar）
   ============================================ */
.wechat-chat-detail {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background-color: #ededed;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.wechat-chat-detail.active {
    display: flex;
}

/* 聊天详情页打开时隐藏底层 header 和 tabbar（沉浸式体验） */
body.wechat-chat-open .weui-header,
body.wechat-chat-open .weui-tabbar,
body.wechat-chat-open .roll {
    display: none !important;
}

/* 适配 iPhone 刘海屏（顶部安全区） */
@supports (padding-top: env(safe-area-inset-top)) {
    .wechat-chat-detail .chat-nav-bar {
        padding-top: env(safe-area-inset-top);
        height: calc(44px + env(safe-area-inset-top));
    }
}

/* 适配 iPhone 底部安全区（Home Indicator） */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .wechat-chat-detail .chat-input-bar {
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
    }
}

/* 电脑端：在 588px 手机框架内居中显示，不全屏铺满 */
@media (min-width: 768px) {
    .wechat-chat-detail {
        /* 相对 #app-main 容器定位（#app-main 在 style_pc.css 中 position:relative） */
        /* 但 fixed 无法相对非视口父级，这里用绝对宽度限制 + margin auto 居中 */
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        max-width: 588px;
        /* 顶部和底部留白与 body padding 一致 */
        top: 0;
        bottom: 0;
    }
    /* 电脑端 body 有 padding: 110px 0，聊天页需要覆盖全屏，临时清除 */
    body.wechat-chat-open {
        padding: 0 !important;
        overflow: hidden;
    }
    /* 电脑端导航栏适配框架顶部 */
    @supports (padding-top: env(safe-area-inset-top)) {
        .wechat-chat-detail .chat-nav-bar {
            padding-top: 0;
            height: 44px;
        }
    }
}

/* ----- 2.1 顶部导航栏 ----- */
.wechat-chat-detail .chat-nav-bar {
    height: 44px;
    flex-shrink: 0;
    background-color: #ededed;
    border-bottom: 0.5px solid #d9d9d9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    box-sizing: border-box;
    position: relative;
}

.wechat-chat-detail .chat-back-btn,
.wechat-chat-detail .chat-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    color: #000;
    background: transparent;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    font-size: 18px;
    line-height: 1;
}

.wechat-chat-detail .chat-back-btn:active,
.wechat-chat-detail .chat-more-btn:active {
    opacity: 0.6;
}

/* 返回按钮：黑色箭头（用 CSS 三角实现） */
.wechat-chat-detail .chat-back-btn::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border-left: 2px solid #000;
    border-bottom: 2px solid #000;
    transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
}

/* 更多按钮：省略号图标 */
.wechat-chat-detail .chat-more-btn::before {
    content: "···";
    font-size: 22px;
    color: #000;
    letter-spacing: 1px;
    line-height: 1;
}

/* 更多按钮下拉菜单（仿首页右上角下拉风格） */
.wechat-chat-detail .chat-action-menu {
    position: absolute;
    top: 44px;
    right: 8px;
    min-width: 140px;
    background: #393a3f;
    border-radius: 4px;
    z-index: 10001;
    display: none;
    overflow: hidden;
    animation: chatMenuZoomIn 0.2s ease;
}

@keyframes chatMenuZoomIn {
    from { opacity: 0; transform: scale(0.85); transform-origin: top right; }
    to   { opacity: 1; transform: scale(1); transform-origin: top right; }
}

.wechat-chat-detail .chat-action-menu.show {
    display: block;
}

/* 下拉菜单小三角 */
.wechat-chat-detail .chat-action-menu::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 18px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #393a3f;
}

.wechat-chat-detail .chat-action-menu-item {
    padding: 12px 15px;
    color: #ffffff;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    position: relative;
    background: transparent;
    border: none;
    width: 100%;
    box-sizing: border-box;
    display: block;
    line-height: 1.4;
}

.wechat-chat-detail .chat-action-menu-item:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    right: 0;
    height: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transform: scaleY(0.5);
}

.wechat-chat-detail .chat-action-menu-item:active {
    background: #2b2c33;
}

.wechat-chat-detail .chat-action-menu-item.danger {
    color: #fa5151;
}

/* 下拉菜单遮罩（透明，用于点击外部关闭） */
.wechat-chat-detail .chat-action-menu-mask {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none;
}

.wechat-chat-detail .chat-action-menu-mask.show {
    display: block;
}

.wechat-chat-detail .chat-nav-title {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 500;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 8px;
}

/* ----- 2.2 消息区域 ----- */
.wechat-chat-detail .chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    box-sizing: border-box;
}

.wechat-chat-detail .chat-messages .chat-message,
.wechat-chat-detail .chat-messages .chat-time,
.wechat-chat-detail .chat-messages .chat-system-msg-wrap {
    margin-bottom: 15px;
}

.wechat-chat-detail .chat-messages .chat-message:last-child {
    margin-bottom: 5px;
}

/* ----- 2.3 消息气泡 ----- */
.wechat-chat-detail .chat-message {
    display: flex;
    align-items: flex-start;
    width: 100%;
    box-sizing: border-box;
}

/* 头像 */
.wechat-chat-detail .chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    flex-shrink: 0;
    background-color: #d9d9d9;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.wechat-chat-detail .chat-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 6px;
    object-fit: cover;
}

/* 气泡内容 */
.wechat-chat-detail .chat-bubble {
    position: relative;
    max-width: 70%;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1.5;
    color: #000;
    word-break: break-word;
    box-sizing: border-box;
}

/* 自己的消息：头像在右 */
.wechat-chat-detail .chat-message-self {
    flex-direction: row-reverse;
}

.wechat-chat-detail .chat-message-self .chat-avatar {
    margin-left: 12px;
}

.wechat-chat-detail .chat-message-self .chat-bubble {
    background-color: #95EC69;
    margin-right: 8px;
}

/* 自己的气泡小三角：指向右侧 */
.wechat-chat-detail .chat-message-self .chat-bubble::before {
    content: "";
    position: absolute;
    top: 12px;
    right: -6px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid #95EC69;
}

/* 对方的消息：头像在左 */
.wechat-chat-detail .chat-message-other .chat-avatar {
    margin-right: 12px;
}

.wechat-chat-detail .chat-message-other .chat-bubble {
    background-color: #ffffff;
    margin-left: 8px;
}

/* 对方的气泡小三角：指向左侧 */
.wechat-chat-detail .chat-message-other .chat-bubble::before {
    content: "";
    position: absolute;
    top: 12px;
    left: -6px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid #ffffff;
}

/* 时间标签（详情页消息列表内的居中时间，覆盖会话列表样式） */
.wechat-chat-detail .chat-messages .chat-time {
    text-align: center;
    font-size: 11px;
    color: #999;
    margin: 10px auto;
    display: block;
    max-width: 200px;
}

/* ----- 2.4 输入栏 ----- */
.wechat-chat-detail .chat-input-bar {
    flex-shrink: 0;
    background-color: #f7f7f7;
    border-top: 0.5px solid #d9d9d9;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.wechat-chat-detail .chat-input {
    flex: 1;
    min-width: 0;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    padding: 8px 10px;
    font-size: 16px;
    background-color: #ffffff;
    color: #000;
    box-sizing: border-box;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.4;
    font-family: inherit;
}

.wechat-chat-detail .chat-input:focus {
    border-color: #07c160;
}

.wechat-chat-detail .chat-send-btn {
    background-color: #07c160;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 15px;
    margin-left: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.5;
    flex-shrink: 0;
    font-family: inherit;
}

.wechat-chat-detail .chat-send-btn:active {
    opacity: 0.85;
}

.wechat-chat-detail .chat-send-btn:disabled,
.wechat-chat-detail .chat-send-btn.is-disabled {
    background-color: #d9d9d9;
    color: #ffffff;
    cursor: not-allowed;
}


/* ============================================
   3. 加载状态（对方正在输入）
   ============================================ */
.wechat-chat-detail .chat-typing .chat-bubble {
    background-color: #ffffff;
    color: #000;
    padding: 12px 14px;
    display: inline-flex;
    align-items: center;
}

.wechat-chat-detail .chat-typing .chat-typing-text {
    font-size: 14px;
    color: #999;
    margin-left: 6px;
}

.wechat-chat-detail .chat-typing-dots {
    display: inline-flex;
    align-items: center;
}

.wechat-chat-detail .chat-typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin: 0 2px;
    border-radius: 50%;
    background-color: #999;
    animation: typing-dot 1.2s infinite ease-in-out;
}

.wechat-chat-detail .chat-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.wechat-chat-detail .chat-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-dot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}


/* ============================================
   4. 系统消息
   ============================================ */
.wechat-chat-detail .chat-system-msg-wrap {
    text-align: center;
    margin: 10px 0;
}

.wechat-chat-detail .chat-system-msg {
    display: inline-block;
    text-align: center;
    font-size: 12px;
    color: #999;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    padding: 4px 8px;
    max-width: 80%;
    line-height: 1.4;
    word-break: break-word;
}


/* ============================================
   5. PJAX 兼容
   ============================================ */

/* 会话列表在详情页打开时保持隐藏（防止 PJAX 切换后样式错乱） */
body.wechat-chat-open .wechat-chat-list {
    visibility: hidden;
}

/* 详情页关闭时恢复会话列表 */
.wechat-chat-detail:not(.active) {
    display: none;
}

/* 确保在 Weui 的 .weui-tab__content 容器内正常显示 */
.weui-tab__content .wechat-chat-list,
.weui-tab__bd .wechat-chat-list {
    background-color: #ededed;
}

/* 防止 PJAX 切换时残留的滚动锁定 */
body.wechat-chat-open.pjax-loading {
    overflow: hidden;
}

/* 确保 PJAX 重新加载后样式仍生效 */
.wechat-chat-detail.active[style*="display:none"],
.wechat-chat-detail.active[style*="display: none"] {
    display: flex !important;
}


/* ============================================
   6. 移动端适配
   ============================================ */
@media (max-width: 320px) {
    .wechat-chat-list .chat-name {
        font-size: 15px;
    }

    .wechat-chat-detail .chat-nav-title {
        font-size: 16px;
    }

    .wechat-chat-detail .chat-bubble {
        font-size: 14px;
    }

    .wechat-chat-detail .chat-input {
        font-size: 15px;
    }
}

/* 适配 iPhone 底部安全区 — 已在第 2 节统一处理 */

/* 电脑端框架内居中（已在第 2 节统一处理） */
