/* --- 都市异能 - 青春校园协议 v2.1 (Rili平台适配版) --- */
/* 设计理念: 强制统一配色，适配白天黑夜模式，青春校园风 */

/* ======================================================= */
/* Part 0: 核心动画定义 */
/* ======================================================= */

/* 异能印记悬浮动画 */
@keyframes arcane-sigil-pulse {
  0%, 100% { transform: translate(45%, -55%) scale(1); filter: drop-shadow(0 0 4px #b8a3d9); opacity: 0.9; }
  50% { transform: translate(45%, -55%) scale(1.03); filter: drop-shadow(0 0 6px #b8a3d9); opacity: 1; }
}

/* 灵感火花旋转动画 */
@keyframes thought-spark-glow {
  from { transform: translate(45%, -55%) rotate(0deg); opacity: 0.8; }
  to { transform: translate(45%, -55%) rotate(360deg); opacity: 1; }
}

/* 按钮悬停光晕 */
@keyframes button-ancient-glow {
  from { box-shadow: 0 0 4px rgba(139, 69, 19, 0.6), inset 0 0 2px rgba(255,255,255,0.1); }
  to { box-shadow: 0 0 8px rgba(139, 69, 19, 0.9), inset 0 0 3px rgba(255,255,255,0.2); }
}

/* 墨迹滴落动画 */
@keyframes ink-drop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    80% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

/* 文本淡入动画 */
@keyframes text-fade-in {
    0% { opacity: 0; transform: translateY(-50%) translateX(-5px); }
    30% { opacity: 0; }
    60% { opacity: 1; transform: translateY(-50%) translateX(0); }
    100% { opacity: 0; transform: translateY(-50%) translateX(5px); }
}

/* ======================================================= */
/* Part 1: 全局背景与环境（强制统一配色） */
/* ======================================================= */

/* 全局背景：强制青春校园风渐变（覆盖黑夜模式） */
body {
    background: linear-gradient(135deg, #fef5e7 0%, #fff9f0 50%, #f0f8ff 100%) !important;
}

/* 侧边栏背景（兼容双平台可能存在的类名） */
.relative.overflow-auto.h-full.min-h-\[500px\].min-w-\[240px\].bg-white,
[class*="sidebar"] {
    background: rgba(255, 253, 245, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    border-right: 1px solid rgba(230, 220, 200, 0.6) !important;
}

/* 滚动条样式（强制浅色） */
::-webkit-scrollbar {
    width: 12px !important;
}
::-webkit-scrollbar-track {
    background: #fef9f0 !important;
    border-radius: 6px !important;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #d4c5b0, #c4b5a0) !important;
    border-radius: 6px !important;
    border: 2px solid #fef9f0 !important;
}

/* ======================================================= */
/* Part 2: 对话终端（聊天框主体 - 强制统一配色） */
/* ======================================================= */

/* 通用对话框样式 (精确定位B平台气泡本体) */
.group.is-assistant > div:first-child,
.group.is-user > div:first-child {
    position: relative !important;
    z-index: 1 !important;
    overflow: visible !important;
    border-radius: 10px !important;
    padding: 18px 22px !important;
    margin: 20px 0 !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08) !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif !important;
    line-height: 1.8 !important;
    font-size: 15.5px !important;
}

/* AI对话气泡 - 强制淡蓝紫色背景（青春校园风） */
.group.is-assistant > div:first-child {
    background: #f0f4ff !important;
    border: 1px solid #ffffff !important;
    box-shadow: 0 3px 12px rgba(100, 120, 200, 0.1) !important;
}

/* AI框的装饰符文 */
.group.is-assistant > div:first-child::after {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px !important;
    height: 26px !important;
    pointer-events: none;
    opacity: 0.3 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 5 L70 30 L95 25 L80 50 L95 75 L70 70 L50 95 L30 70 L5 75 L20 50 L5 25 L30 30 Z' fill='%23a8b8e6'/%3E%3C/svg%3E");
    background-size: contain;
    animation: arcane-sigil-pulse 5s ease-in-out infinite alternate !important;
}

/* 用户对话气泡 - 强制淡粉橙色背景（青春校园风） */
.group.is-user > div:first-child {
    background: #fff8f0 !important;
    border: 1px solid #ffffff !important;
    box-shadow: 0 3px 12px rgba(200, 150, 100, 0.08) !important;
}

/* 用户框的装饰火花 */
.group.is-user > div:first-child::after {
    content: '';
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 22px !important;
    height: 22px !important;
    pointer-events: none;
    opacity: 0.3 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 5 L60 40 L95 50 L60 60 L50 95 L40 60 L5 50 L40 40 Z' fill='%23e6c8a0'/%3E%3C/svg%3E");
    background-size: contain;
    animation: thought-spark-glow 6s linear infinite !important;
}

/* 文本内容样式（强制深色文字，适配B平台渲染器） */
.rili-markdown-renderer {
    font-size: 15.5px !important;
    line-height: 1.8 !important;
    color: #2d2d2d !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif !important;
    text-shadow: none !important;
    font-weight: 400 !important;
}

/* AI回答文本颜色（强制深色） */
.group.is-assistant .rili-markdown-renderer {
    color: #3a3a4a !important;
}

/* ======================================================= */
/* Part 3: 折叠信息栏（强制统一配色） */
/* ======================================================= */

div.rili-markdown-renderer details {
    background: #fefbf7 !important;
    border: 1.5px solid #e8dcc8 !important;
    border-radius: 8px !important;
    margin: 18px 0 !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}

div.rili-markdown-renderer details[open] {
    background: #ffffff !important;
    border-color: #d4c5b0 !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1) !important;
}

div.rili-markdown-renderer details > summary {
    padding: 12px 18px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    color: #6b5d4f !important;
    list-style-type: '📖 ' !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif !important;
}

div.rili-markdown-renderer details[open] > summary {
    color: #5a4a3a !important;
    border-bottom: 1px solid #e8dcc8 !important;
}

div.rili-markdown-renderer details > *:not(summary) {
    padding: 15px 20px !important;
    color: #3a3a3a !important;
}

/* ======================================================= */
/* Part 4: 底部附加元素（强制统一配色） */
/* ======================================================= */

/* 底部操作按钮（适配B平台的悬浮图标按钮组） */
.group.is-assistant .flex.items-center.gap-1 button,
.group.is-user .flex.items-center.gap-1 button {
    background: #f5f0e8 !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    border: 1px solid #e0d5c7 !important;
    transition: all 0.2s ease !important;
}

/* 强制修改按钮内的SVG图标颜色 */
.group.is-assistant .flex.items-center.gap-1 button svg,
.group.is-user .flex.items-center.gap-1 button svg {
    stroke: #6b5d4f !important;
}

.group.is-assistant .flex.items-center.gap-1 button:hover,
.group.is-user .flex.items-center.gap-1 button:hover {
    background: #e8dcc8 !important;
    transform: translateY(-1px) !important;
}

/* Token消耗/模型文本（适配B平台左下角信息栏） */
.group.is-assistant .flex.items-center.gap-2.text-xs.font-mono > span {
    color: #8b6f47 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif !important;
    font-weight: bold !important;
    font-size: 13px !important;
}

/* ======================================================= */
/* Part 5: 输入框区域（强制统一配色） */
/* ======================================================= */

/* 输入框容器（双平台兼容） */
.p-\[5\.5px\].max-h-\[150px\].bg-white,
#chat-input-container,
.chat-input-wrapper {
    background: rgba(255, 253, 245, 0.95) !important;
    border-top: 1px solid rgba(232, 220, 200, 0.6) !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04) !important;
    backdrop-filter: blur(10px) !important;
}

/* 输入框本身 */
#ai-chat-input,
textarea[placeholder*="输入"],
textarea {
    background: transparent !important;
    border: none !important;
    color: #2d2d2d !important;
    font-size: 15.5px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif !important;
    text-shadow: none !important;
}

#ai-chat-input:focus,
textarea:focus {
    box-shadow: none !important;
}

/* 发送按钮 */
#ai-send-button,
button[aria-label="发送"],
.send-button {
    background: linear-gradient(to bottom right, #c4b5a0, #d4c5b0) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    border-radius: 6px !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

#ai-send-button:hover,
button[aria-label="发送"]:hover,
.send-button:hover {
    background: linear-gradient(to bottom right, #b8a68d, #c4b5a0) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2) !important;
}

/* ======================================================= */
/* Part 6: 加载动画（适配B平台结构重写） */
/* ======================================================= */

/* 隐藏B平台默认的三个加载圆点 */
.flex.gap-2.w-full.h-full.items-center.justify-center > span.bg-primary {
    display: none !important;
}

/* 重构加载容器 */
.flex.gap-2.w-full.h-full.items-center.justify-center {
    position: relative !important;
    height: 30px !important;
    width: 120px !important;
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding-left: 5px !important;
    margin-left: 0 !important;
}

/* 墨迹滴落效果（左侧） */
.flex.gap-2.w-full.h-full.items-center.justify-center::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%) scale(0);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #6b5b8c;
    opacity: 0;
    animation: ink-drop 1.8s ease-out infinite;
    z-index: 2;
}

/* 加载文本（左侧，字体加大） */
.flex.gap-2.w-full.h-full.items-center.justify-center::after {
    content: '书写中...';
    position: absolute;
    top: 50%;
    left: 30px;
    transform: translateY(-50%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif !important;
    font-size: 17px !important;
    color: #6b5b8c !important;
    font-weight: 500 !important;
    opacity: 0;
    animation: text-fade-in 1.8s ease-out infinite;
    z-index: 1;
    white-space: nowrap;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .flex.gap-2.w-full.h-full.items-center.justify-center::before {
        width: 10px;
        height: 10px;
        left: 8px;
    }
    .flex.gap-2.w-full.h-full.items-center.justify-center::after {
        font-size: 15px !important;
        left: 25px;
    }
}