/* 家谱网聊天组件样式 v2.0 */
/* 浮动按钮 */
.chat-widget-btn {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #8B4513;
    color: #fff;
    border: none;
    cursor: grab;
    box-shadow: 0 4px 16px rgba(139,69,19,0.35);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.2s;
    /* 初始位置由 JS 设为右下角 */
}
.chat-widget-btn:hover {
    transform: scale(1.08);
}
.chat-widget-btn:active {
    cursor: grabbing;
}
.chat-widget-btn.dragging {
    opacity: 0.85;
    box-shadow: 0 8px 24px rgba(139,69,19,0.55);
}
.chat-widget-btn .dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e74c3c;
    border: 2px solid #fff;
}

/* 聊天面板 */
.chat-widget-panel {
    display: none;
    position: fixed;
    width: 340px;
    max-width: 90vw;
    height: 500px;
    max-height: 75vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    z-index: 9999;
    overflow: hidden;
    flex-direction: column;
    /* 位置由 JS 动态设置（top + left） */
}
.chat-widget-panel.open {
    display: flex;
}

/* 头部 */
.chat-header {
    background: linear-gradient(135deg, #8B4513, #A0522D);
    color: #fff;
    padding: 12px 14px;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}
.chat-header:active {
    cursor: grabbing;
}
.chat-header.dragging {
    opacity: 0.95;
}
.chat-header-title {
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-header-draghint {
    font-size: 11px;
    font-weight: normal;
    opacity: 0.75;
}
.chat-header-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}
.chat-header-close:hover { opacity: 1; }

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #fdfaf5;
}
.chat-msg {
    margin-bottom: 12px;
    max-width: 90%;
}
.chat-msg.system {
    text-align: center;
    max-width: 100%;
}
.chat-msg.system .chat-msg-bubble {
    background: #f0ebe0;
    color: #8B4513;
    font-size: 12px;
    display: inline-block;
    padding: 6px 14px;
    border-radius: 12px;
}
.chat-msg.self {
    margin-left: auto;
}
.chat-msg.self .chat-msg-bubble {
    background: #8B4513;
    color: #fff;
}
.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    background: #f5f0e8;
    word-break: break-word;
}
.chat-msg-meta {
    font-size: 11px;
    color: #999;
    margin-top: 3px;
    padding: 0 4px;
}

/* 留言图片 */
.chat-msg-image {
    margin-bottom: 4px;
}
.chat-msg-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
    cursor: pointer;
    object-fit: cover;
    transition: max-height 0.3s;
}
.chat-msg-image img.expanded {
    max-height: 500px;
    object-fit: contain;
}

/* 输入区域 */
.chat-input-area {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
.chat-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.chat-input-row input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.chat-input-row input:focus {
    border-color: #8B4513;
}
.chat-input-msg {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    resize: none;
    height: 60px;
    outline: none;
    margin-bottom: 8px;
    box-sizing: border-box;
}
.chat-input-msg:focus {
    border-color: #8B4513;
}

/* 图片预览 */
.chat-image-preview {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 6px;
    background: #f5f0e8;
    border-radius: 8px;
}
.chat-image-preview img {
    max-height: 80px;
    max-width: 120px;
    border-radius: 6px;
    object-fit: cover;
}
.chat-image-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.chat-image-remove:hover {
    background: rgba(0,0,0,0.7);
}

/* 底部按钮栏（图片+发送） */
.chat-input-bottom {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.chat-image-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 9px 12px;
    background: #f5f0e8;
    color: #8B4513;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.chat-image-btn:hover {
    background: #ede5d8;
}
.chat-image-btn svg {
    flex-shrink: 0;
}
.chat-send-btn {
    flex: 1;
    padding: 9px;
    background: #8B4513;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: bold;
}
.chat-send-btn:hover { background: #A0522D; }
.chat-send-btn:disabled { background: #ccc; cursor: not-allowed; }

.chat-error {
    color: #e74c3c;
    font-size: 12px;
    text-align: center;
    margin-top: 4px;
    display: none;
}
