/* xiaodian.css - 小电浮动聊天组件样式 v3 */

/* ── 浮动图标 ── */
.xiaodian-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 96px;
    height: 104px;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: grab;
    z-index: 99999;
    user-select: none;
    touch-action: none;
    transition: filter 0.2s, transform 0.2s;
}

.xiaodian-fab:hover {
    transform: scale(1.03);
}

.xiaodian-fab:active {
    cursor: grabbing;
}

/* ── 对话窗口 ── */
.xiaodian-window {
    position: fixed;
    width: 380px;
    height: 540px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 2147482999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 14px;
    color: #333;
}

.xiaodian-window.open {
    display: flex;
    animation: xiaodianSlideUp 0.25s ease-out;
}

@keyframes xiaodianSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── 标题栏 ── */
.xiaodian-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.xiaodian-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    font-size: 15px;
}

.xiaodian-header-icon {
    display: inline-block;
    width: 32px;
    height: 35px;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    vertical-align: middle;
    flex-shrink: 0;
}

.xiaodian-header-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}

.xiaodian-header-close:hover {
    color: white;
}

/* ── 消息列表 ── */
.xiaodian-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fc;
}

.xiaodian-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.xiaodian-message.user {
    align-self: flex-end;
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.xiaodian-message.bot {
    align-self: flex-start;
    background: white;
    color: #333;
    border: 1px solid #e8ecf1;
    border-bottom-left-radius: 4px;
}

/* 带演示卡片的回答放宽宽度，避免卡片被挤窄 */
.xiaodian-message.bot.has-demo {
    max-width: 96%;
}

.xiaodian-message .sources {
    margin-top: 8px;
    font-size: 12px;
    color: #888;
    border-top: 1px solid #eee;
    padding-top: 6px;
}

.xiaodian-message .sources span {
    display: inline-block;
    background: #f0f2f5;
    padding: 2px 8px;
    border-radius: 4px;
    margin: 2px 4px 2px 0;
    font-size: 11px;
}

.xiaodian-thinking {
    align-self: flex-start;
    background: white;
    border: 1px solid #e8ecf1;
    border-radius: 12px;
    padding: 12px 16px;
    color: #999;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom-left-radius: 4px;
}

.xiaodian-thinking::after {
    content: "...";
    animation: xiaodianDot 1.2s infinite;
}

@keyframes xiaodianDot {
    0% { content: "."; }
    33% { content: ".."; }
    66% { content: "..."; }
}

/* ── 输入框 ── */
.xiaodian-input-area {
    display: flex;
    padding: 12px 14px;
    gap: 8px;
    border-top: 1px solid #e8ecf1;
    background: white;
    flex-shrink: 0;
}

.xiaodian-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 8px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.xiaodian-input:focus {
    border-color: #667eea;
}

.xiaodian-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.xiaodian-send:hover {
    transform: scale(1.05);
}

.xiaodian-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ══════════════════════════════════════════════════════════════
   教学智能体层 —— 身份条 / 工具轨迹 / 互动演示卡片
   ══════════════════════════════════════════════════════════════ */

/* ── 身份条 ── */
.xd-idbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    font-size: 11.5px;
    color: #7a8296;
    background: #f4f6fb;
    border-bottom: 1px solid #e8ecf1;
    flex-shrink: 0;
    user-select: none;
}
.xd-idbar .xd-id-name {
    color: #5a6172;
    font-weight: bold;
}
.xd-idbar .xd-id-main {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.xd-idbar button {
    border: none;
    background: none;
    color: #667eea;
    font-size: 11.5px;
    cursor: pointer;
    padding: 0 2px;
    font-family: inherit;
}
.xd-idbar button:hover { text-decoration: underline; }

/* ── 工具调用轨迹 ── */
.xd-trace {
    margin-top: 8px;
    border: 1px solid #e6eaf2;
    border-radius: 8px;
    background: #fbfcfe;
    overflow: hidden;
}
.xd-trace-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 11.5px;
    color: #6b7280;
    cursor: pointer;
    user-select: none;
}
.xd-trace-head:hover { background: #f2f5fb; }
.xd-trace-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #667eea;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.18);
}
.xd-trace-toggle {
    margin-left: auto;
    color: #667eea;
}
.xd-trace-list {
    display: none;
    padding: 2px 10px 8px 22px;
    border-top: 1px dashed #e6eaf2;
}
.xd-trace.open .xd-trace-list { display: block; }
.xd-trace-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    color: #5b6474;
    padding: 3px 0;
}
.xd-trace-idx {
    width: 15px; height: 15px;
    border-radius: 50%;
    background: #667eea;
    color: #fff;
    font-size: 9.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.xd-trace-item.fail .xd-trace-idx { background: #d9534f; }
.xd-trace-item.fail .xd-trace-label { color: #b0453f; }

/* ── 互动演示卡片 ── */
.xd-demos {
    margin-top: 9px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.xd-demos-tip {
    font-size: 11px;
    color: #98a0b0;
    letter-spacing: 0.5px;
}
.xd-demo-card {
    display: block;
    text-decoration: none;
    border: 1px solid #e2e7f2;
    border-radius: 10px;
    padding: 9px 12px;
    background: linear-gradient(135deg, #f7f9ff 0%, #fbf7ff 100%);
    transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.xd-demo-card:hover {
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.16);
}
.xd-demo-title {
    font-size: 13px;
    font-weight: bold;
    color: #3a4152;
    margin-bottom: 2px;
}
.xd-demo-desc {
    font-size: 11.5px;
    color: #7a8296;
    line-height: 1.5;
}
.xd-demo-go {
    margin-top: 4px;
    font-size: 11.5px;
    color: #667eea;
}

/* ── 来源 ── */
.xd-sources {
    margin-top: 8px;
    font-size: 11px;
    color: #98a0b0;
    border-top: 1px solid #f0f2f5;
    padding-top: 6px;
}
.xd-sources span {
    display: inline-block;
    background: #f0f2f5;
    padding: 2px 7px;
    border-radius: 4px;
    margin: 2px 4px 2px 0;
}
