/* style.css - 阅读器样式 */

:root {
    /* Dark Theme (Default) */
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-message-user: #2563eb;
    --bg-message-assistant: #1a1a1a;
    --border-color: #2a2a2a;
    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --text-muted: #6b7280;
    --accent: #6366f1;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --code-bg: #0d0d0d;
}

[data-theme="light"] {
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e5e7eb;
    --bg-message-user: #3b82f6;
    --bg-message-assistant: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --accent: #4f46e5;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --code-bg: #f9fafb;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* 选中文本颜色 */
::selection {
    background: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}

/* 滚动条 */
.scrollbar-thin::-webkit-scrollbar { width: 5px; height: 5px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
.scrollbar-thin::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* 会话列表 */
.session-item { transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
/* .session-item:hover { background: var(--bg-tertiary); } Removed to let Tailwind handle it */
/* .session-item.active { background: var(--accent); color: white; } Removed to let Tailwind handle it */

/* 拖拽区域 */
.drop-zone { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.drop-zone.drag-over { border-color: var(--accent) !important; background: rgba(99, 102, 241, 0.15); transform: scale(1.02); }

/* 动画 */
.fade-in { animation: fadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 消息内容 */
.message-content {
    line-height: 1.7;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
.message-content p { margin-bottom: 0.75em; }
.message-content p:last-child { margin-bottom: 0; }
.message-content pre { background: #0d0d0d; border-radius: 8px; padding: 1em; overflow-x: auto; margin: 0.75em 0; }
.message-content code { font-family: 'Fira Code', 'Consolas', monospace; font-size: 0.9em; }
.message-content :not(pre) > code { background: rgba(255,255,255,0.1); padding: 0.2em 0.4em; border-radius: 4px; }
.message-content ul, .message-content ol { margin: 0.5em 0; padding-left: 1.5em; }
.message-content li { margin: 0.25em 0; }
.message-content blockquote { border-left: 3px solid var(--accent); padding-left: 1em; margin: 0.75em 0; color: var(--text-secondary); }

/* 表格样式 */
.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    background: var(--bg-secondary);
}
.message-content th, 
.message-content td {
    border: 1px solid var(--border-color);
    padding: 0.6em 0.8em;
    text-align: left;
}
.message-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

/* 图片样式 */
.message-content img {
    margin: 1em 0;
    max-width: 100%;
    border-radius: 6px;
    display: inline-block;
}

/* ========== 自定义标签样式 ========== */

/* 通用折叠块 */
.fd-think, .fd-memory, .fd-status, .fd-fold {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 0.75em 0;
    overflow: hidden;
}
.fd-think summary, .fd-memory summary, .fd-status summary, .fd-fold summary {
    padding: 0.75em 1em;
    cursor: pointer;
    font-weight: 500;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    gap: 0.5em;
}
.fd-think summary:hover, .fd-memory summary:hover, .fd-status summary:hover, .fd-fold summary:hover {
    opacity: 0.9;
}
.fd-think-content, .fd-memory-content, .fd-status-content, .fd-fold-content {
    padding: 1em;
    border-top: 1px solid var(--border-color);
}

/* 深度思考 - 特殊样式 */
.fd-think { border-left: 3px solid #8b5cf6; }
.fd-think summary { color: #8b5cf6; }
[data-theme="light"] .fd-think summary { color: #7c3aed; }
.fd-think-content { white-space: pre-wrap; font-family: monospace; font-size: 0.9em; color: var(--text-secondary); }

/* 记忆块 */
.fd-memory { border-left: 3px solid #f59e0b; }
.fd-memory summary { color: #f59e0b; }
[data-theme="light"] .fd-memory summary { color: #d97706; }

/* 状态块 */
.fd-status { border-left: 3px solid #3b82f6; }
.fd-status summary { color: #3b82f6; }
[data-theme="light"] .fd-status summary { color: #2563eb; }

/* 折叠块 - 支持自定义颜色 */
.fd-fold { border-left: 3px solid var(--text-muted); }
.fd-fold summary { color: var(--text-secondary); }
.fd-fold[style*="--fold-color"] { border-left-color: var(--fold-color); }
.fd-fold[style*="--fold-color"] summary { color: var(--fold-color); }

/* 结束块 */
.fd-endchat {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 0.75em 0;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px var(--shadow-color);
}
.fd-endchat-header {
    padding: 0.75em 1em;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5em;
    border-bottom: 1px solid var(--border-color);
}
.fd-endchat-content {
    padding: 1em;
    color: var(--text-primary);
}

/* 剧透遮罩 */
.fd-hide {
    background: var(--bg-tertiary);
    color: transparent;
    padding: 0.1em 0.3em;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.fd-hide:hover { opacity: 0.8; }
.fd-hide.revealed { background: transparent; color: inherit; }

/* 二维码占位 */
.fd-qrcode {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.5em 1em;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.9em;
}

/* ========== 论坛评论 ========== */
.fd-comment-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 0.75em 0;
    overflow: hidden;
}
.fd-comment {
    display: flex;
    gap: 0.75em;
    padding: 1em;
    border-bottom: 1px solid var(--border-color);
}
.fd-comment:last-child { border-bottom: none; }
.fd-comment-reply { padding-left: 3em; background: rgba(0,0,0,0.05); }
[data-theme="dark"] .fd-comment-reply { background: rgba(255,255,255,0.02); }
.fd-comment-avatar-wrap { flex-shrink: 0; }
.fd-comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.fd-comment-avatar-fallback {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}
.fd-comment-body { flex: 1; min-width: 0; }
.fd-comment-header {
    display: flex;
    align-items: center;
    gap: 0.75em;
    margin-bottom: 0.5em;
}
.fd-comment-author { font-weight: 500; color: var(--accent); }
.fd-comment-reply-info { color: var(--text-muted); font-size: 0.85em; }
.fd-comment-floor { color: var(--text-muted); font-size: 0.85em; margin-left: auto; }
.fd-comment-content { color: var(--text-primary); }
.fd-comment-content p { margin: 0; }

/* ========== QQ风格聊天 ========== */
.fd-chat {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 0.75em 0;
    overflow: hidden;
}
.fd-chat-title {
    padding: 0.75em 1em;
    background: var(--bg-tertiary);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.fd-chat-system {
    text-align: center;
    padding: 0.5em;
    color: var(--text-muted);
    font-size: 0.85em;
}
.fd-chat-msg {
    display: flex;
    gap: 0.5em;
    padding: 0.75em 1em;
    align-items: flex-start;
}
.fd-chat-right { flex-direction: row-reverse; }
.fd-chat-avatar-wrap { flex-shrink: 0; }
.fd-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.fd-chat-avatar-fallback {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
}
.fd-chat-bubble {
    max-width: 70%;
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 0.5em 0.75em;
    color: var(--text-primary);
}
.fd-chat-right .fd-chat-bubble { 
    background: #1e3a5f; 
    color: #fff;
}
[data-theme="light"] .fd-chat-right .fd-chat-bubble {
    background: #dbeafe;
    color: #1e3a5f;
}
.fd-chat-author {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-bottom: 0.25em;
}
.fd-chat-text {
    font-size: 0.9em;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.fd-chat-text p { margin: 0; }

/* ========== 消息列表 (chatList) ========== */
.fd-chatlist {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 0.75em 0;
    overflow: hidden;
}
.fd-chatlist-header {
    padding: 0.75em 1em;
    background: var(--bg-tertiary);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.fd-chatlist-items { }
.fd-chatlist-item {
    display: flex;
    gap: 0.75em;
    padding: 0.75em 1em;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}
.fd-chatlist-item:hover { background: var(--bg-tertiary); }
.fd-chatlist-item.active { background: var(--bg-tertiary); }
.fd-chatlist-item:last-child { border-bottom: none; }
.fd-chatlist-avatar-wrap { position: relative; flex-shrink: 0; }
.fd-chatlist-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}
.fd-chatlist-avatar-fallback {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
}
.fd-chatlist-unread {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}
.fd-chatlist-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.fd-chatlist-title { font-weight: 500; margin-bottom: 0.25em; color: var(--text-primary); }
.fd-chatlist-preview { color: var(--text-muted); font-size: 0.85em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* chatList 详情面板 */
.fd-chatlist-detail {
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}
.fd-chatlist-detail-header {
    display: flex;
    align-items: center;
    gap: 1em;
    padding: 0.75em 1em;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.fd-chatlist-detail-header span { color: var(--text-primary); font-weight: 500; }
.fd-chatlist-detail-header button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0.25em 0.5em;
    border-radius: 4px;
}
.fd-chatlist-detail-header button:hover { background: var(--bg-tertiary); }
.fd-chatlist-detail-body {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5em 0;
}

/* 内部滚动条美化 */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 图标 */
.fd-icon { font-style: normal; }
