/* public/css/chat.css */

/* =========================================
   1. 悬浮按钮 (Widget Button) - 下移至版权区版
   ========================================= */
.chat-widget-btn {
    position: fixed;
    /* 位置下移：从 30px 调整为 12px，使其贴近版权框 */
    bottom: 12px; 
    /* 右间距微调：从 30px 调整为 20px */
    right: 20px;
    
    /* 圆形尺寸：采用 48px 更加精致，适合放在页脚区域 */
    width: 48px;
    height: 48px;
    
    background-color: #07c160; 
    border-radius: 50%; 
    
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9990;
    
    /* 弱化投影，使其不突兀 */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 动感光波 */
.chat-widget-btn::before,
.chat-widget-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #07c160;
    z-index: -1;
    opacity: 0;
    animation: ripple-wave 2.5s infinite cubic-bezier(0, 0, 0.2, 1);
}

.chat-widget-btn::after {
    animation-delay: 1.25s;
}

/* SVG 尺寸优化：保持饱满感 */
.chat-widget-btn svg {
    width: 35px; /* 适配 48px 容器 */
    height: 35px;
    display: block;
    transform: translateY(-1px);
    overflow: visible;
}

/* 悬停反馈 */
.chat-widget-btn:hover {
    transform: translateY(-1px) scale(1.05);
    background-color: #06ad56;
}
.chat-widget-btn:active {
    transform: scale(0.92);
}

/* 圆形光波动画 */
@keyframes ripple-wave {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* 未读消息提醒 */
.chat-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #fa5151;
    color: white;
    border-radius: 9px;
    min-width: 16px;
    height: 16px;
    line-height: 12px;
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    border: 2px solid #fff;
    padding: 0 3px;
    display: none;
    z-index: 2;
}

/* 适配：当聊天窗口打开时，依然从下方弹出 */
.chat-window {
    bottom: 70px; /* 对应按钮位置调整 */
    right: 20px;
}


/* =========================================
   2. 聊天窗口主容器 (Chat Window)
   ========================================= */
.chat-window {
    position: fixed;
    /* 按钮在 12px，高度 48px，合计约 60px。将底部设为 65px 使其紧贴按钮上方 */
    bottom: 65px; 
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    z-index: 9991;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 激活显示状态 */
.chat-window.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* =========================================
   3. 头部区域 (Header)
   ========================================= */
.chat-header {
    background: #111827; /* 深色背景 */
    padding: 16px 20px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* --- 左上角图标 --- */
.chat-logo {
    width: 36px;
    height: 36px;
    background: #00bcd4; /* 湖蓝色 */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
}

.chat-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.chat-subtitle {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 状态指示灯 */
.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6b7280; /* 灰色 */
    transition: all 0.3s;
}

.chat-online .status-indicator {
    background: #10b981; /* 绿色 */
    box-shadow: 0 0 5px #10b981;
}

.chat-online .chat-subtitle {
    color: #d1d5db;
}

.chat-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    border-radius: 50%;
}

.chat-close:hover {
    background: rgba(255,255,255,0.1);
}

.chat-close svg {
    fill: #9ca3af;
    width: 24px;
    height: 24px;
}

.chat-close:hover svg {
    fill: #fff;
}

/* =========================================
   4. 消息区域 (Messages)
   ========================================= */
.chat-messages {
    flex: 1;
    background: #f9fafb;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    position: relative;
}

/* 拖拽上传覆盖层 */
.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #4f46e5;
    border: 2px dashed #4f46e5;
    margin: 10px;
    border-radius: 12px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    pointer-events: none; /* 默认不阻挡鼠标 */
}

/* 激活状态 */
.chat-window.drag-active .drag-overlay {
    opacity: 1;
    visibility: visible;
}

/* 消息气泡通用 */
.msg-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* 对方消息 (左侧) */
.msg-left {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border-bottom-left-radius: 2px;
    border: 1px solid #e5e7eb;
}

/* 我方消息 (右侧) */
.msg-right {
    align-self: flex-end;
    background: #95ec69; /* 微信标准绿 */
    color: #000;         /* 绿色背景下黑色文字更清晰 */
    border-bottom-right-radius: 2px;
}
/* 微信绿气泡内的刻度/时间颜色调整，防止看不清 */
.msg-right .msg-time {
    color: rgba(0, 0, 0, 0.5);
}
.msg-time {
    font-size: 0.7rem;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
    width: 100%;
}

/* 图片预览 */
.chat-img-preview {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 4px;
    cursor: zoom-in;
    display: block;
    border: 1px solid rgba(0,0,0,0.1);
}

/* =========================================
   5. 正在输入动画 (Typing Indicator)
   ========================================= */
.typing-indicator {
    align-self: flex-start;
    background: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    border: 1px solid #e5e7eb;
    display: none; 
    align-items: center;
    gap: 4px;
    width: fit-content;
    margin-bottom: 8px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* =========================================
   6. 底部输入区 (Input Area)
   ========================================= */
.chat-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #f3f4f6;
    display: flex;
    align-items: flex-end; 
    gap: 8px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: #f3f4f6;
    border: 1px solid transparent;
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    min-width: 0; 
}

.chat-input:focus {
    background: #fff;
    border-color: #e5e7eb;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.chat-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: #6b7280;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-icon-btn:hover {
    background: #f3f4f6;
    color: #4f46e5;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    background: #4f46e5;
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    background: #4338ca;
}

.chat-send-btn:disabled {
    background: #e5e7eb;
    cursor: not-allowed;
    transform: none;
}

.chat-send-btn:disabled svg {
    fill: #9ca3af;
}

/* =========================================
   7. 离线留言面板 (Offline Panel)
   ========================================= */
.offline-panel {
    position: absolute;
    inset: 0;
    background: #fff;
    z-index: 20;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
}

.offline-panel.active {
    display: flex;
}

.offline-icon {
    width: 64px;
    height: 64px;
    fill: #fbbf24;
    margin-bottom: 16px;
}

.offline-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.offline-desc {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 24px;
    line-height: 1.5;
}

.offline-btn {
    background: #4f46e5;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.offline-btn:hover {
    background: #4338ca;
}