/* ===================================
   chat.css — 双人实时对话窗口
   =================================== */

/* ============ 聊天按钮 ============ */
.chat-btn {
    position: absolute;
    top: 24px;
    right: 136px;
    z-index: 10;
    width: 44px; height: 44px;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s ease;
}
.chat-btn:hover { background: rgba(255,255,255,0.45); }

.chat-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    background: #ff4757;
    color: #fff;
    font-size: 0.65rem; font-weight: 700;
    display: none; align-items: center; justify-content: center;
    padding: 0 5px;
}

/* ============ 聊天窗口 ============ */
.chat-window {
    position: fixed; bottom: 20px; right: 20px;
    z-index: 180;
    width: 340px; height: 440px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.05);
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: chat-pop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes chat-pop {
    from { transform: translateY(20px) scale(0.9); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.chat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #FFB7C5, #C7CEEA);
    color: #fff;
    flex-shrink: 0;
}
.chat-title {
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem; font-weight: 700;
}
.chat-close {
    width: 28px; height: 28px;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,0.3);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.chat-close:hover { background: rgba(255,255,255,0.5); }

/* 消息列表 */
.chat-msgs {
    flex: 1; overflow-y: auto;
    padding: 12px;
    display: flex; flex-direction: column;
    gap: 8px;
    background: #faf8fc;
}
.chat-msgs::-webkit-scrollbar { width: 4px; }
.chat-msgs::-webkit-scrollbar-track { background: transparent; }
.chat-msgs::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 2px; }

.chat-empty {
    text-align: center; padding: 40px 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.85rem;
    color: #ccc;
}

/* 消息容器（自己的消息加操作按钮） */
.chat-msg-wrap {
    display: flex; align-items: center; gap: 4px;
}
.chat-msg-wrap.mine-wrap { flex-direction: row-reverse; }

/* 操作按钮（hover 显示） */
.chat-msg-actions {
    display: flex; flex-direction: column; gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}
.chat-msg-wrap:hover .chat-msg-actions { opacity: 1; }
.chat-act-btn {
    width: 22px; height: 22px;
    border: none; border-radius: 50%;
    font-size: 0.6rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s ease;
}
.chat-act-btn:hover { transform: scale(1.2); }
.chat-act-btn[data-act="edit"] { background: #e8e4f0; color: #888; }
.chat-act-btn[data-act="del"]  { background: #ffe0e5; color: #e0606a; }

/* 单条消息 */
.chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex; flex-direction: column;
}
.chat-msg.mine {
    background: linear-gradient(135deg, #C7CEEA, #FFD1DC);
}
.chat-msg-sender {
    font-family: 'Nunito', sans-serif;
    font-size: 0.68rem; font-weight: 700;
    color: #b8a8c8;
    margin-bottom: 2px;
}
.chat-msg.mine .chat-msg-sender { color: #7a6a8a; }
.chat-msg-text {
    font-family: 'Quicksand', sans-serif;
    font-size: 0.88rem; font-weight: 500;
    color: #4A3F50;
    word-break: break-word;
    line-height: 1.5;
}
.chat-msg-time {
    align-self: flex-end;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.62rem;
    color: #c0b8c8;
    margin-top: 2px;
}

/* 输入区 */
.chat-input-row {
    display: flex; gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #eee;
    border-radius: 20px;
    font-size: 0.88rem; font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input:focus { border-color: #C7CEEA; }
.chat-send {
    padding: 8px 16px;
    border: none; border-radius: 20px;
    background: linear-gradient(135deg, #C7CEEA, #FFB7C5);
    color: #fff;
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem; font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.chat-send:hover { transform: scale(1.03); }

/* 编辑行 */
.chat-edit-row {
    display: flex; gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: #fffef8;
    flex-shrink: 0;
}
.chat-edit-cancel {
    padding: 8px 14px;
    border: 1px solid #ddd; border-radius: 20px;
    background: #fff;
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem; font-weight: 600;
    color: #999; cursor: pointer;
    transition: all 0.2s ease;
}
.chat-edit-cancel:hover { background: #f5f5f5; color: #666; }

/* ============ 响应式 ============ */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 20px); height: 380px;
        bottom: 10px; right: 10px;
    }
}
