/**
 * AI聊天界面样式 - 完整重构版
 */

/* ==================== 1. 聊天悬浮球 (入口按钮) ==================== */
.zibll-ai-chat-button {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.zibll-ai-chat-button:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.zibll-ai-chat-button svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* 位置定义 */
.zibll-ai-position-bottom-right { bottom: 30px; right: 30px; }
.zibll-ai-position-bottom-left { bottom: 30px; left: 30px; }

/* 未读消息红点 */
.zibll-ai-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff4d4f;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid #fff;
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ==================== 2. 聊天窗口主容器 ==================== */
.zibll-ai-chat-widget {
    position: fixed;
    width: 800px; /* 宽度加宽以容纳侧边栏 */
    height: 600px;
    max-width: 90vw;
    max-height: 85vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    border: 1px solid rgba(0,0,0,0.05);
}

/* 窗口打开动画 */
.zibll-ai-chat-widget[style*="display: block"],
.zibll-ai-chat-widget[style*="display: flex"] {
    animation: slide-up-fade 0.3s ease-out forwards;
}

@keyframes slide-up-fade {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.zibll-ai-chat-widget.zibll-ai-position-bottom-right { bottom: 100px; right: 30px; }
.zibll-ai-chat-widget.zibll-ai-position-bottom-left { bottom: 100px; left: 30px; }

/* ==================== 3. 顶部标题栏 ==================== */
.zibll-ai-chat-header {
    height: 50px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.zibll-ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #333;
    font-size: 15px;
}

.zibll-ai-chat-avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
}
.zibll-ai-chat-avatar-small img { width: 100%; height: 100%; object-fit: cover; }

.zibll-ai-chat-status {
    font-size: 12px;
    color: #999;
    font-weight: normal;
    margin-left: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.zibll-ai-status-dot {
    width: 6px;
    height: 6px;
    background: #52c41a;
    border-radius: 50%;
    display: inline-block;
}

.zibll-ai-chat-action-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.zibll-ai-chat-action-btn:hover { background: #f5f5f5; color: #333; }

/* ==================== 4. 核心布局 (侧边栏 + 内容区) ==================== */
.zibll-ai-chat-container {
    flex: 1;
    display: flex !important; /* 强制 Flex */
    flex-direction: row !important;
    overflow: hidden;
    background: #fff;
    position: relative;
}

/* 4.1 左侧模型切换栏 */
.ai-model-sidebar {
    width: 68px;
    background: #f7f8fa;
    border-right: 1px solid #ebedf0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    flex-shrink: 0;
    /* overflow-y: auto; */
}

.ai-model-item {
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: #fff;
    border: 1px solid #e0e0e0;
    position: relative;
}

.ai-model-item img, .ai-model-item svg {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: contain;
}

.ai-model-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.ai-model-item.active {
    border-color: #12B7F5;
    background: #e6f7ff;
}
.ai-model-item.active::after {
    content: '';
    position: absolute;
    left: -12px;
    top: 10px;
    bottom: 10px;
    width: 4px;
    background: #12B7F5;
    border-radius: 0 4px 4px 0;
}

/* Tooltip */
.ai-model-tooltip {
    position: absolute;
    left: 55px;
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
}
.ai-model-item:hover .ai-model-tooltip { opacity: 1; }

/* 4.2 右侧内容区域 (原生聊天) */
.zibll-ai-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 0; /* 防止Flex子元素溢出 */
    height: 100%;
    position: relative;
    background: #fff;
}

/* 聊天记录区 */
.zibll-ai-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fff;
    scroll-behavior: smooth;
}

/* 消息气泡 */
.zibll-ai-chat-message {
    display: flex;
    margin-bottom: 16px;
    gap: 10px;
    animation: msg-fade-in 0.3s ease;
}
@keyframes msg-fade-in { from{opacity:0;transform:translateY(10px);} to{opacity:1;transform:translateY(0);} }

.zibll-ai-chat-message.user { flex-direction: row-reverse; }

.zibll-ai-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
}
.zibll-ai-chat-avatar img { width: 100%; height: 100%; object-fit: cover; }

.zibll-ai-chat-message-content {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.zibll-ai-chat-message.assistant .zibll-ai-chat-message-content {
    background: #f5f5f5;
    color: #333;
    border-top-left-radius: 2px;
}

.zibll-ai-chat-message.user .zibll-ai-chat-message-content {
    background: #12B7F5;
    color: #fff;
    border-top-right-radius: 2px;
}
.zibll-ai-chat-message.user .zibll-ai-chat-message-content a { color: #fff; text-decoration: underline; }

.zibll-ai-chat-message-time {
    font-size: 12px;
    color: #bbb;
    margin-top: 4px;
    text-align: center;
    width: 100%;
}

/* 4.3 底部输入区 */
.zibll-ai-chat-footer {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}

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

.zibll-ai-chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 100px;
    background: #fafafa;
    transition: all 0.2s;
}
.zibll-ai-chat-input:focus {
    background: #fff;
    border-color: #12B7F5;
    box-shadow: 0 0 0 3px rgba(18, 183, 245, 0.1);
}

.zibll-ai-chat-send-btn {
    width: 70px;
    height: 38px;
    background: #12B7F5;
    color: #fff;
    border: none;
    border-radius: 19px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}
.zibll-ai-chat-send-btn:hover { background: #0e9bd0; }
.zibll-ai-chat-send-btn:disabled { background: #ccc; cursor: not-allowed; }

/* 4.4 Iframe 网页容器 */
.ai-iframe-container {
    flex: 1;
    width: 100%;
    height: 100%;
    background: #fff;
    display: none; /* 默认隐藏 */
    position: relative;
}

.ai-iframe-container.active { display: block; }

.ai-iframe-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* 移动端适配 */
@media (max-width: 600px) {
    .zibll-ai-chat-widget {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0;
    }
    .zibll-ai-chat-widget.zibll-ai-position-bottom-right,
    .zibll-ai-chat-widget.zibll-ai-position-bottom-left { bottom: 0; left: 0; }
    
    .ai-model-sidebar { width: 50px; }
    .ai-model-item { width: 36px; height: 36px; margin-bottom: 8px; }
    .ai-model-item img { width: 20px; height: 20px; }
    .ai-model-tooltip { display: none !important; }
}


/* ==================== 5. 快速导航按钮样式 ==================== */
.zibll-ai-quick-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.zibll-ai-quick-nav-item {
    padding: 6px 12px;
    background: #f0f7ff;
    color: #12B7F5;
    border: 1px solid #d6e4ff;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.zibll-ai-quick-nav-item:hover {
    background: #12B7F5;
    color: #fff;
    border-color: #12B7F5;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(18, 183, 245, 0.2);
}

.zibll-ai-quick-nav-item:active {
    transform: translateY(0);
}