/*!
 * aiceo.hk P1 前端深度增强样式
 * 写入: 2026-05-02
 * 配套 aiceo_p1_enhance.js
 */

/* ---------- Markdown 渲染 ---------- */
.aiceo-md-body {
    line-height: 1.7;
    word-break: break-word;
}
.aiceo-md-body p { margin: 6px 0; }
.aiceo-md-body strong { color: #111827; font-weight: 600; }
.aiceo-md-body em { color: #4b5563; font-style: italic; }
.aiceo-md-body h1, .aiceo-md-body h2, .aiceo-md-body h3,
.aiceo-md-body h4, .aiceo-md-body h5, .aiceo-md-body h6 {
    margin: 14px 0 6px; font-weight: 700; line-height: 1.3; color: #111827;
}
.aiceo-md-body h1 { font-size: 1.4rem; }
.aiceo-md-body h2 { font-size: 1.25rem; }
.aiceo-md-body h3 { font-size: 1.125rem; }
.aiceo-md-body ul, .aiceo-md-body ol { margin: 6px 0 6px 22px; padding: 0; }
.aiceo-md-body li { margin: 3px 0; }
.aiceo-md-body a { color: #2563eb; text-decoration: underline; }
.aiceo-md-body a:hover { color: #1d4ed8; }
.aiceo-md-code-inline {
    background: #f3f4f6;
    color: #111827;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    border: 1px solid #e5e7eb;
}
.aiceo-md-codeblock {
    background: #1f2937 !important;
    color: #e5e7eb !important;
    padding: 12px 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
    line-height: 1.55;
    border: 1px solid #374151;
}
.aiceo-md-codeblock code {
    background: transparent !important;
    color: #e5e7eb !important;
    padding: 0;
    border: 0;
    white-space: pre;
}
/* 简易语法高亮: lang-* token 由 JS 添加, 这里仅区分关键字 / 字符串 */
.aiceo-md-code.lang-js, .aiceo-md-code.lang-javascript, .aiceo-md-code.lang-ts, .aiceo-md-code.lang-typescript {
    color: #e5e7eb;
}
.aiceo-md-table {
    border-collapse: collapse;
    margin: 8px 0;
    width: 100%;
    font-size: 0.92em;
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}
.aiceo-md-table th, .aiceo-md-table td {
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    text-align: left;
}
.aiceo-md-table thead {
    background: #f9fafb;
    color: #111827;
    font-weight: 600;
}
.aiceo-md-table tbody tr:nth-child(even) { background: #fafafa; }

/* ---------- 复制按钮 ---------- */
.aiceo-copy-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid #e5e7eb;
    background: rgba(255,255,255,0.92);
    color: #4b5563;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
    transition: all 0.15s;
    z-index: 5;
}
.aiceo-copy-btn:hover {
    background: #ffffff;
    color: #2563eb;
    border-color: #2563eb;
}

/* ---------- 时间戳 ---------- */
.aiceo-timestamp {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    color: #6b7280;
    user-select: none;
}

/* ---------- 加载动画 toast ---------- */
#aiceo-thinking-toast {
    position: fixed;
    bottom: 76px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99996;
    padding: 8px 14px;
    background: rgba(31, 41, 55, 0.92);
    color: #f3f4f6 !important;
    border-radius: 999px;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
#aiceo-thinking-toast.show {
    opacity: 1;
}
.aiceo-thinking-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 6px;
    align-items: center;
    vertical-align: middle;
}
.aiceo-thinking-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #f3f4f6;
    animation: aiceoBlinkP1 1.4s infinite both;
}
.aiceo-thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.aiceo-thinking-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes aiceoBlinkP1 {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1); }
}

/* ---------- 通用 toast ---------- */
.aiceo-toast {
    position: fixed;
    bottom: 130px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 99999;
    padding: 10px 16px;
    background: #111827;
    color: #f9fafb !important;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 92vw;
    box-shadow: 0 4px 16px rgba(0,0,0,0.22);
    opacity: 0;
    transition: all 0.3s;
}
.aiceo-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.aiceo-toast-error { background: #b91c1c; }
.aiceo-toast-warn  { background: #b45309; }
.aiceo-toast-info  { background: #1f2937; }

/* ---------- 移动端优化 ---------- */
@media (max-width: 480px) {
    .aiceo-md-codeblock { font-size: 0.82em; padding: 10px; }
    .aiceo-md-table { font-size: 0.84em; }
    .aiceo-md-table th, .aiceo-md-table td { padding: 4px 6px; }
    #aiceo-thinking-toast { bottom: 88px; font-size: 12px; }
    .aiceo-toast { bottom: 144px; font-size: 12px; padding: 8px 12px; }
}

/* 处理虚拟键盘弹起时聊天容器变形: 让外层滚动容器在键盘弹出时仍正确滚到底 */
@supports (height: 100dvh) {
    body, html { min-height: 100dvh; }
}
