/* ===========================================
   nanobot AI 助手聊天组件样式
   =========================================== */

/* 浮动聊天按钮 */
.nanobot-float-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

.nanobot-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.5);
}

.nanobot-float-btn svg {
    width: 28px;
    height: 28px;
    color: white;
}

.nanobot-float-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4757;
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    display: none;
}

.nanobot-float-btn.has-unread .badge {
    display: block;
}

/* 聊天窗口 */
.nanobot-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 600px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: nanobotSlideIn 0.3s ease;
}

.nanobot-chat-window.open {
    display: flex;
}

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

/* 聊天窗口头部 */
.nanobot-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nanobot-chat-header .title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nanobot-chat-header .title svg {
    width: 24px;
    height: 24px;
}

.nanobot-chat-header .title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.nanobot-chat-header .status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nanobot-chat-header .status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.nanobot-chat-header .close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.nanobot-chat-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nanobot-chat-header .close-btn svg {
    width: 20px;
    height: 20px;
}

/* 聊天消息区域 */
.nanobot-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.nanobot-message {
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
}

.nanobot-message.user {
    flex-direction: row-reverse;
}

.nanobot-message .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nanobot-message.user .avatar {
    background: #2ecc71;
}

.nanobot-message .avatar svg {
    width: 20px;
    height: 20px;
}

.nanobot-message .content {
    max-width: 75%;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.nanobot-message.user .content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.nanobot-message .content p {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.nanobot-message .content p:last-child {
    margin-bottom: 0;
}

.nanobot-message .content pre {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
    margin: 8px 0;
}

.nanobot-message.user .content pre {
    background: rgba(255, 255, 255, 0.2);
}

.nanobot-message .content code {
    background: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 13px;
}

.nanobot-message.user .content code {
    background: rgba(255, 255, 255, 0.3);
}

/* 工具调用提示 */
.nanobot-tool-call {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    padding: 8px 12px;
    font-size: 12px;
    color: #856404;
    margin-top: 8px;
    border-radius: 0 4px 4px 0;
}

/* 加载指示器 */
.nanobot-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    width: fit-content;
}

.nanobot-typing span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.nanobot-typing span:nth-child(1) { animation-delay: -0.32s; }
.nanobot-typing span:nth-child(2) { animation-delay: -0.16s; }
.nanobot-typing span:nth-child(3) { animation-delay: 0; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 欢迎消息 */
.nanobot-welcome {
    text-align: center;
    padding: 40px 20px;
}

.nanobot-welcome .icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nanobot-welcome .icon svg {
    width: 32px;
    height: 32px;
    color: white;
}

.nanobot-welcome h4 {
    margin: 0 0 8px 0;
    color: #333;
}

.nanobot-welcome p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* 快速操作按钮 */
.nanobot-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.nanobot-quick-actions button {
    background: #f0f0f0;
    border: none;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.nanobot-quick-actions button:hover {
    background: #667eea;
    color: white;
}

/* 聊天输入区域 */
.nanobot-chat-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #eee;
}

.nanobot-chat-input .input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.nanobot-chat-input textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 12px 16px;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    max-height: 120px;
    min-height: 44px;
}

.nanobot-chat-input textarea:focus {
    border-color: #667eea;
}

.nanobot-chat-input .send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.nanobot-chat-input .send-btn:hover {
    transform: scale(1.05);
}

.nanobot-chat-input .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nanobot-chat-input .send-btn svg {
    width: 20px;
    height: 20px;
}

/* 连接状态 */
.nanobot-connection-status {
    padding: 8px 16px;
    background: #fff3cd;
    text-align: center;
    font-size: 12px;
    color: #856404;
}

/* 错误消息 */
.nanobot-error {
    background: #f8d7da;
    color: #721c24;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 8px;
}

/* 响应式适配 */
@media (max-width: 480px) {
    .nanobot-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        right: 16px;
        bottom: 90px;
    }

    .nanobot-float-btn {
        width: 52px;
        height: 52px;
        bottom: 20px;
        right: 20px;
    }
}
