/* 聊天机器人主容器 */
.rfid-chatbot-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    /* 位置完全由JavaScript控制，不设置默认位置 */
    /* 不设置固定宽高，适配移动端 */
}

/* 聊天按钮 */
.chat-button {
    width: 60px;
    height: 60px;
    background: #1890ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px #1890ff66;
    transition: all 0.3s ease;
    position: fixed;
    z-index: 10000;
    /* 位置完全由JavaScript控制 */
}
.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px #1890ff99;
}
.chat-icon {
    color: #fff;
}
.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4d4f;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* 聊天窗口 */
.chat-window {
    width: 450px;
    height: 600px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px #0000001f;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    z-index: 10001;
    /* 位置完全由JavaScript控制 */
}

/* 头部 */
.chat-header {
    background: #1890ff;
    color: #fff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}
.avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
}
.header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.connection-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #fff3;
}
.connection-status.connected {
    background: #4caf50e6;
}
.connection-status.connecting {
    background: #ff9800e6;
}
.connection-status.error,
.connection-status.disconnected {
    background: #f44336e6;
}
.header-actions {
    display: flex;
    gap: 8px;
}
.maximize-btn,
.minimize-btn,
.close-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}
.maximize-btn:hover,
.minimize-btn:hover,
.close-btn:hover {
    background: #fff3;
}
.maximize-btn img,
.minimize-btn img,
.close-btn img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

/* 消息区域 */
.messages-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.message.user {
    flex-direction: row-reverse;
}
.message .avatar {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.message .avatar img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #007bff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* 消息内容与气泡 */
.message-content {
    display: flex;
    flex-direction: row;
    max-width: 70%;
}
.bubble {
    padding: 10px 14px;
    border-radius: 16px;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.4;
}
.message.user .bubble {
    background: #007bff;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.message.bot .bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 4px;
}

/* 时间戳 */
.timestamp {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    align-self: flex-end;
    white-space: nowrap;
}
.timestamp.bot-time {
    margin-left: 8px;
    text-align: left;
}
.timestamp.user-time {
    margin-right: 8px;
    text-align: right;
}

/* 输入区域 */
.input-container {
    padding: 16px;
    background: #fff;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 8px;
}
.message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    transition: border .2s;
}
.message-input:focus {
    border-color: #1890ff;
}
.message-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}
.send-btn {
    padding: 10px 16px;
    background: #1890ff;
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background .2s;
}
.send-btn:hover:not(:disabled) {
    background: #096dd9;
}
.send-btn:disabled {
    background: #d9d9d9;
    cursor: not-allowed;
}

/* 响应式 */
@media (max-width: 480px) {
    .chat-window {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        right: 0;
        bottom: 0;
    }
    .rfid-chatbot-widget {
        right: 0;
        bottom: 0;
    }
  }