/* ==================== 聊天悬浮按钮 ==================== */
.chat-float-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(120,70,180,0.85), rgba(80,45,160,0.9));
    border: 1.5px solid rgba(255,255,255,0.25);
    color: white;
    font-size: 1.4em;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(40,10,80,0.4);
    backdrop-filter: blur(8px);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.chat-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(60,20,120,0.5);
}

.chat-float-btn.has-new-msg {
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 4px 20px rgba(40,10,80,0.4); }
    50% { box-shadow: 0 4px 30px rgba(180,100,255,0.6), 0 0 0 10px rgba(180,100,255,0.1); }
}

/* ==================== 聊天弹窗 ==================== */
.chat-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1100;
    justify-content: center;
    align-items: center;
}

.chat-overlay.active {
    display: flex;
}

.chat-window {
    width: 380px;
    max-width: 92vw;
    max-height: 520px;
    height: 480px;
    background: linear-gradient(180deg, rgba(30,10,55,0.97), rgba(15,5,35,0.98));
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: chatSlideUp 0.3s ease;
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==================== 聊天头部 ==================== */
.chat-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.chat-header-title {
    color: rgba(255,255,255,0.9);
    font-size: 0.95em;
    font-weight: 400;
    letter-spacing: 1px;
}

.chat-header-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ==================== 头像 + 在线状态 ==================== */
.chat-status-row {
    display: flex;
    gap: 16px;
}

.chat-status-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: rgba(255,255,255,0.5);
    font-size: 0.75em;
}

.chat-avatar-tiny {
    font-size: 1.1em;
    line-height: 1;
}

.chat-dot {
    font-size: 0.55em;
    line-height: 1;
    transition: color 0.4s ease, text-shadow 0.4s ease;
}

.chat-dot.offline {
    color: rgba(255,255,255,0.18);
}

.chat-dot.online {
    color: #4ade80;
    text-shadow: 0 0 6px rgba(74,222,128,0.5);
}

.chat-dot.online.self {
    color: #60d0ff;
    text-shadow: 0 0 8px rgba(96,208,255,0.6);
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ==================== 消息发送者标签（已弃用，改用 chat-msg-avatar） ==================== */

/* ==================== 密码弹窗头像行 ==================== */
.chat-avatar-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 16px;
}

.chat-avatar-small {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1.5px solid rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
}

/* ==================== Hello Kitty 头像 ==================== */
.chat-kitty-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: 1.5px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    transition: transform 0.2s, border-color 0.2s;
}

.chat-kitty-avatar svg {
    display: block;
}

.chat-kitty-tiny {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-kitty-tiny svg {
    width: 22px;
    height: 22px;
    display: block;
}

.chat-status-name {
    color: rgba(255,255,255,0.6);
    font-size: 0.8em;
}

.chat-msg-sender {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7em;
    color: rgba(255,255,255,0.45);
    margin-bottom: 2px;
    padding: 0 2px;
}

.chat-msg-sender svg {
    width: 16px;
    height: 16px;
}

.chat-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-close:hover {
    background: rgba(220,60,60,0.6);
    color: white;
}

/* ==================== 消息列表 ==================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

/* ==================== 单条消息 ==================== */
.chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 92%;
    animation: msgIn 0.3s ease;
    margin-bottom: 14px;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 自己发的：右对齐 */
.chat-msg.me {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* 对方发的：左对齐 */
.chat-msg.other {
    align-self: flex-start;
    flex-direction: row;
}

/* WeChat 头像 */
.chat-msg-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-msg-avatar svg {
    display: block;
}

/* 消息列（对方名字 + 气泡）*/
.chat-msg-col {
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.chat-msg-name {
    font-size: 0.7em;
    color: rgba(255,255,255,0.35);
    padding: 0 4px;
    margin-bottom: 2px;
}

/* 气泡 */
.chat-msg-bubble {
    padding: 10px 15px;
    border-radius: 16px;
    font-size: 0.92em;
    line-height: 1.55;
    word-break: break-word;
    color: rgba(255,255,255,0.92);
    max-width: 100%;
}

.chat-msg.me .chat-msg-bubble {
    background: linear-gradient(135deg, rgba(130,80,200,0.7), rgba(100,55,180,0.65));
    border-radius: 16px 4px 16px 16px;
}

.chat-msg.other .chat-msg-bubble {
    background: rgba(255,255,255,0.1);
    border-radius: 4px 16px 16px 16px;
}

/* 时间 */
.chat-msg-time {
    font-size: 0.65em;
    color: rgba(255,255,255,0.25);
    padding: 0 3px;
    white-space: nowrap;
    align-self: flex-end;
    margin-bottom: 2px;
}

/* ==================== 空状态 ==================== */
.chat-empty {
    text-align: center;
    color: rgba(255,255,255,0.25);
    font-size: 0.85em;
    margin-top: 60px;
    letter-spacing: 1px;
}

/* ==================== 输入区域 ==================== */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    padding: 10px 16px;
    color: white;
    font-size: 0.9em;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.chat-input::placeholder {
    color: rgba(255,255,255,0.3);
}

.chat-input:focus {
    background: rgba(255,255,255,0.12);
    border-color: rgba(180,120,255,0.4);
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, rgba(130,80,200,0.7), rgba(80,45,160,0.8));
    color: white;
    font-size: 1em;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s, background 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.08);
    background: linear-gradient(135deg, rgba(150,95,220,0.8), rgba(95,55,180,0.85));
}

.chat-send-btn:active {
    transform: scale(0.95);
}

/* ==================== 图片发送按钮 ==================== */
.chat-img-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.5);
    font-size: 1em;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-img-btn:hover {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.85);
    transform: scale(1.08);
}

.chat-img-btn:active {
    transform: scale(0.95);
}

/* ==================== 图片消息气泡 ==================== */
.chat-msg-img-bubble {
    padding: 4px !important;
    background: transparent !important;
    overflow: hidden;
    border-radius: 12px !important;
}

.chat-msg.me .chat-msg-img-bubble {
    border-radius: 12px 4px 12px 12px !important;
}

.chat-msg.other .chat-msg-img-bubble {
    border-radius: 4px 12px 12px 12px !important;
}

.chat-msg-image {
    display: block;
    max-width: 220px;
    max-height: 260px;
    width: auto;
    height: auto;
    border-radius: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
    object-fit: cover;
}

.chat-msg-image:hover {
    opacity: 0.88;
}

/* ==================== 图片预览遮罩 ==================== */
.chat-img-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    cursor: pointer;
}

.chat-img-preview-overlay img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

/* ==================== 密码弹窗（小） ==================== */
.chat-pwd-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.55);
    z-index: 1200;
    justify-content: center;
    align-items: center;
}

.chat-pwd-overlay.active {
    display: flex;
}

.chat-pwd-box {
    background: linear-gradient(180deg, rgba(30,10,55,0.97), rgba(15,5,35,0.98));
    border-radius: 16px;
    padding: 28px 24px;
    width: 280px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.12);
}

.chat-pwd-box p {
    color: rgba(255,255,255,0.8);
    margin-bottom: 16px;
    font-size: 0.9em;
}

.chat-pwd-box input {
    width: 100%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    padding: 10px 14px;
    color: white;
    font-size: 1em;
    text-align: center;
    outline: none;
    margin-bottom: 16px;
    letter-spacing: 4px;
}

.chat-pwd-box input:focus {
    border-color: rgba(180,120,255,0.5);
}

.chat-pwd-box button {
    background: linear-gradient(135deg, rgba(130,80,200,0.8), rgba(80,45,160,0.8));
    border: none;
    color: white;
    padding: 10px 0;
    width: 100%;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9em;
    letter-spacing: 2px;
    transition: background 0.2s;
}

.chat-pwd-box button:hover {
    background: linear-gradient(135deg, rgba(150,95,220,0.85), rgba(95,55,180,0.85));
}

.chat-pwd-box .pwd-error {
    color: rgba(255,100,100,0.8);
    font-size: 0.8em;
    margin-top: 8px;
    display: none;
}

/* ==================== 响应式 ==================== */
@media (max-width: 480px) {
    .chat-window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .chat-float-btn {
        bottom: 20px;
        right: 20px;
    }
}
