/**
 * 思悟数学 - 智能助手宵宫主题
 * 灵感来源: 原神 - 宵宫
 * 主题色: 橙红色、金黄色、火焰色
 */

/* ==================== 宵宫主题变量 ==================== */
.ai-assistant-yoimiya-theme {
    /* 主色调 */
    --ai-assistant-primary: #FF9966;
    --ai-assistant-secondary: #FFD700;
    --ai-assistant-accent: #FF6B6B;

    /* 背景色 */
    --ai-assistant-bg: #FFF5E6;
    --ai-assistant-text: #4A3728;
    --ai-assistant-border: #FFD7B5;
    --ai-assistant-shadow: rgba(255, 153, 102, 0.3);
    --ai-assistant-hover: #FFE4CC;

    /* 消息气泡 */
    --ai-assistant-user-bg: linear-gradient(135deg, #FF9966 0%, #FFD700 100%);
    --ai-assistant-user-text: #ffffff;
    --ai-assistant-bot-bg: #FFF9F0;
    --ai-assistant-bot-text: #4A3728;

    /* 发光效果 */
    --ai-assistant-glow: rgba(255, 153, 102, 0.6);
    --ai-assistant-glow-strong: rgba(255, 153, 102, 0.8);
}

/* ==================== 容器定位修正 ==================== */
/* 确保立绘面板能正确相对于容器定位 */
.ai-assistant-container.ai-assistant-yoimiya-theme {
    position: fixed;  /* 保持fixed定位 */
}

/* ==================== 浮动按钮 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-float-button {
    background: linear-gradient(135deg, #FF9966 0%, #FFD700 100%);
    box-shadow: 
        0 4px 12px rgba(255, 153, 102, 0.4),
        0 0 20px rgba(255, 153, 102, 0.3);
    animation: yoimiyaPulse 2s ease-in-out infinite;
}

@keyframes yoimiyaPulse {
    0%, 100% {
        box-shadow: 
            0 4px 12px rgba(255, 153, 102, 0.4),
            0 0 20px rgba(255, 153, 102, 0.3);
    }
    50% {
        box-shadow: 
            0 6px 16px rgba(255, 153, 102, 0.6),
            0 0 30px rgba(255, 153, 102, 0.5);
    }
}

.ai-assistant-yoimiya-theme .ai-assistant-float-button:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 
        0 8px 20px rgba(255, 153, 102, 0.6),
        0 0 40px rgba(255, 153, 102, 0.6);
}

/* ==================== 主容器 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-container {
    background: linear-gradient(135deg, #FFF5E6 0%, #FFE4CC 100%);
    border: 2px solid #FFD7B5;
    box-shadow: 
        0 8px 32px rgba(255, 153, 102, 0.3),
        0 0 60px rgba(255, 153, 102, 0.2);
    position: relative;
    overflow: hidden;
}

/* 宵宫主题背景图 */
.ai-assistant-yoimiya-theme .ai-assistant-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../images/yoimiya/宵宫主题背景.jpg');
    background-size: cover;
    background-position: center;
    opacity: 0.25;  /* ✅ 提高透明度从15%到25% */
    z-index: 1;  /* ✅ 提高z-index,确保在容器内部但在内容下方 */
    pointer-events: none;
}

/* 烟花粒子容器 */
.ai-assistant-yoimiya-theme .ai-assistant-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../images/yoimiya/烟花装饰元素.png');
    background-size: 100px;
    background-repeat: repeat;
    opacity: 0.1;
    animation: fireworksFloat 20s linear infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes fireworksFloat {
    0% {
        transform: translateY(0) rotate(0deg);
    }
    100% {
        transform: translateY(-100%) rotate(360deg);
    }
}

/* ==================== 头部 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-header {
    background: linear-gradient(135deg, #FF9966 0%, #FFD700 100%);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 10px rgba(255, 153, 102, 0.3);
    position: relative;
    z-index: 1;
}

.ai-assistant-yoimiya-theme .ai-assistant-title {
    color: #ffffff;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 0 10px rgba(255, 255, 255, 0.5);
    font-weight: 700;
}

.ai-assistant-yoimiya-theme .ai-assistant-subtitle {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ==================== 头像 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-avatar {
    border: 3px solid #FFD700;
    box-shadow: 
        0 0 20px rgba(255, 215, 0, 0.6),
        0 0 40px rgba(255, 153, 102, 0.4);
    animation: yoimiyaAvatarGlow 3s ease-in-out infinite;
}

@keyframes yoimiyaAvatarGlow {
    0%, 100% {
        box-shadow: 
            0 0 20px rgba(255, 215, 0, 0.6),
            0 0 40px rgba(255, 153, 102, 0.4);
    }
    50% {
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 0.8),
            0 0 60px rgba(255, 153, 102, 0.6);
    }
}

/* ==================== 消息气泡 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-message.user .ai-assistant-message-content {
    background: linear-gradient(135deg, #FF9966 0%, #FFD700 100%);
    color: #ffffff;
    border: none;
    box-shadow: 
        0 2px 8px rgba(255, 153, 102, 0.3),
        0 0 15px rgba(255, 153, 102, 0.2);
    position: relative;
    overflow: hidden;
}

/* 用户消息火焰效果 */
.ai-assistant-yoimiya-theme .ai-assistant-message.user .ai-assistant-message-content::before {
    content: '🔥';
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 12px;
    opacity: 0.6;
    animation: flameFlicker 1.5s ease-in-out infinite;
}

@keyframes flameFlicker {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.1); }
}

.ai-assistant-yoimiya-theme .ai-assistant-message.assistant .ai-assistant-message-content {
    background: #FFF9F0;
    color: #4A3728;
    border: 2px solid #FFE4CC;
    box-shadow: 0 2px 8px rgba(255, 153, 102, 0.15);
    position: relative;
    z-index: 1;
}

/* AI消息烟花装饰 */
.ai-assistant-yoimiya-theme .ai-assistant-message.assistant .ai-assistant-message-content::after {
    content: '✨';
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 12px;
    opacity: 0.5;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 0.5; transform: rotate(0deg); }
    50% { opacity: 0.8; transform: rotate(180deg); }
}

/* ==================== 输入框 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-input {
    background: #FFF9F0;
    border: 2px solid #FFD7B5;
    color: #4A3728;
}

.ai-assistant-yoimiya-theme .ai-assistant-input:focus {
    border-color: #FF9966;
    box-shadow: 
        0 0 0 3px rgba(255, 153, 102, 0.2),
        0 0 15px rgba(255, 153, 102, 0.3);
}

.ai-assistant-yoimiya-theme .ai-assistant-input::placeholder {
    color: #B8956A;
}

/* ==================== 按钮 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-send-button {
    background: linear-gradient(135deg, #FF9966 0%, #FFD700 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 2px 8px rgba(255, 153, 102, 0.3);
    position: relative;
    overflow: hidden;
}

.ai-assistant-yoimiya-theme .ai-assistant-send-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ai-assistant-yoimiya-theme .ai-assistant-send-button:hover::before {
    width: 300px;
    height: 300px;
}

.ai-assistant-yoimiya-theme .ai-assistant-send-button:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 4px 12px rgba(255, 153, 102, 0.5),
        0 0 20px rgba(255, 153, 102, 0.4);
}

/* ==================== 快捷按钮 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-action-button {
    background: linear-gradient(135deg, #FFE4CC 0%, #FFF9F0 100%);
    color: #FF9966;
    border: 2px solid #FFD7B5;
}

.ai-assistant-yoimiya-theme .ai-assistant-action-button:hover {
    background: linear-gradient(135deg, #FF9966 0%, #FFD700 100%);
    color: #ffffff;
    border-color: #FFD700;
    box-shadow: 0 2px 8px rgba(255, 153, 102, 0.4);
}

/* ==================== 设置面板 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-settings-panel {
    background: linear-gradient(135deg, #FFF5E6 0%, #FFE4CC 100%);
    border-left: 2px solid #FFD7B5;
}

.ai-assistant-yoimiya-theme .ai-assistant-settings-title {
    color: #FF9966;
    border-bottom: 2px solid #FFD7B5;
}

.ai-assistant-yoimiya-theme .ai-assistant-settings-item label {
    color: #4A3728;
}

/* ==================== 加载动画 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-typing-indicator span {
    background: #FF9966;
    animation: yoimiyaTyping 1.4s ease-in-out infinite;
}

@keyframes yoimiyaTyping {
    0%, 60%, 100% {
        transform: translateY(0);
        background: #FF9966;
    }
    30% {
        transform: translateY(-10px);
        background: #FFD700;
    }
}

/* ==================== 滚动条 - 宵宫主题 ==================== */
.ai-assistant-yoimiya-theme .ai-assistant-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #FF9966 0%, #FFD700 100%);
}

.ai-assistant-yoimiya-theme .ai-assistant-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #FFD700 0%, #FF9966 100%);
}

/* ==================== 特殊动画效果 ==================== */

/* 烟花爆炸动画(打开助手时) */
@keyframes fireworksExplosion {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* 火焰飞行动画(发送消息时) */
@keyframes flamefly {
    0% {
        transform: translateX(0) translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateX(-100px) translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* ==================== 宵宫角色立绘面板 ==================== */
/* 立绘包装器 - 使用fixed定位,附着在智能助手右侧 */
.ai-assistant-yoimiya-theme .yoimiya-illustration-wrapper {
    position: fixed;
    right: calc(30px - 260px);  /* 智能助手在right: 30px,立绘宽度250px,间隔10px,所以向左偏移260px */
    bottom: 100px;  /* 与智能助手容器对齐 */
    width: 250px;  /* 立绘宽度 */
    height: 600px;  /* 与智能助手容器高度一致 */
    pointer-events: none;  /* 不阻挡其他元素的交互 */
    z-index: 9997;  /* 比智能助手容器(9999)低两层 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);  /* 平滑过渡动画 */
}

/* 智能助手最小化时隐藏立绘 */
.ai-assistant-container.minimized ~ .yoimiya-illustration-wrapper {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50px);  /* 向左滑出 */
}

/* 立绘面板 */
.ai-assistant-yoimiya-theme .yoimiya-illustration-panel {
    position: absolute;
    left: 0;  /* 左对齐 */
    top: 50%;
    transform: translateY(-50%);
    width: 250px;  /* 与包装器宽度一致 */
    height: 550px;  /* 稍微小一点,留出上下边距 */
    background: linear-gradient(135deg, rgba(255, 153, 102, 0.08) 0%, rgba(255, 102, 102, 0.08) 100%);
    border-radius: 20px;  /* 四周圆角 */
    border: 2px solid rgba(255, 153, 102, 0.25);
    box-shadow:
        0 10px 40px rgba(255, 153, 102, 0.2),
        inset 0 0 60px rgba(255, 153, 102, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible;  /* 允许立绘超出边界 */
    pointer-events: all;  /* 面板本身可以交互 */
}

/* 全屏模式下调整立绘位置 */
.ai-assistant-container.fullscreen ~ .yoimiya-illustration-wrapper {
    right: calc(50% - 450px - 260px);  /* 全屏容器宽度900px,所以450px是一半,立绘在左侧,再减260px */
    bottom: 50%;
    transform: translateY(50%);
}

/* 收起状态 */
.ai-assistant-yoimiya-theme .yoimiya-illustration-panel.collapsed {
    width: 60px;
    background: rgba(255, 153, 102, 0.05);
}

/* 立绘图片 */
.ai-assistant-yoimiya-theme .yoimiya-character-illustration {
    width: auto;
    height: 100%;
    max-height: 100%;  /* 充分利用空间 */
    max-width: none;  /* 允许超出容器 */
    object-fit: contain;
    object-position: center bottom;  /* 底部对齐 */
    opacity: 1;
    animation: characterFloat 4s ease-in-out infinite, characterGlow 3s ease-in-out infinite;
    filter: drop-shadow(0 10px 30px rgba(255, 153, 102, 0.4));
    transition: all 0.3s ease;
    pointer-events: none;
    position: relative;
    z-index: 1;
}

/* 收起时隐藏立绘 */
.ai-assistant-yoimiya-theme .yoimiya-illustration-panel.collapsed .yoimiya-character-illustration {
    opacity: 0;
    transform: scale(0.5);
}

/* 切换按钮 */
.ai-assistant-yoimiya-theme .yoimiya-toggle-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #ff6666;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 10;
}

.ai-assistant-yoimiya-theme .yoimiya-toggle-btn:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* 收起时按钮位置调整 */
.ai-assistant-yoimiya-theme .yoimiya-illustration-panel.collapsed .yoimiya-toggle-btn {
    right: 8px;
}

/* 角色立绘浮动动画 */
@keyframes characterFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

/* 角色立绘发光动画 */
@keyframes characterGlow {
    0%, 100% {
        filter: drop-shadow(0 10px 30px rgba(255, 153, 102, 0.6)) brightness(1);
    }
    50% {
        filter: drop-shadow(0 15px 40px rgba(255, 165, 0, 0.8)) brightness(1.1);
    }
}

/* 装饰元素 - 烟花粒子 */
.ai-assistant-yoimiya-theme .yoimiya-illustration-panel::before {
    content: '✨';
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 24px;
    animation: sparkle 2s ease-in-out infinite;
    opacity: 0.8;
}

.ai-assistant-yoimiya-theme .yoimiya-illustration-panel::after {
    content: '🎆';
    position: absolute;
    bottom: 30px;
    right: 20px;
    font-size: 28px;
    animation: sparkle 2.5s ease-in-out infinite 0.5s;
    opacity: 0.8;
}

@keyframes sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
    }
}

/* 收起时隐藏装饰 */
.ai-assistant-yoimiya-theme .yoimiya-illustration-panel.collapsed::before,
.ai-assistant-yoimiya-theme .yoimiya-illustration-panel.collapsed::after {
    opacity: 0;
}

/* 响应式 - 移动端自动隐藏 */
@media (max-width: 768px) {
    .ai-assistant-yoimiya-theme .yoimiya-illustration-panel {
        display: none;
    }
}

/* ==================== 表情包系统 ==================== */
.ai-assistant-message-emoji {
    display: inline-block;
    width: 32px;
    height: 32px;
    margin: 0 4px;
    vertical-align: middle;
    animation: emojiPop 0.5s ease-out;
}

/* 表情包弹出动画 */
@keyframes emojiPop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* AI消息中的表情包(稍大一些) */
.ai-assistant-message.assistant .ai-assistant-message-emoji {
    width: 40px;
    height: 40px;
}

/* ==================== 消息气泡装饰图标 ==================== */
/* ✅ 消息气泡需要相对定位才能让伪元素正确定位 */
.ai-assistant-yoimiya-theme .ai-assistant-message-bubble {
    position: relative;
}

/* AI消息气泡左侧的烟花装饰 */
.ai-assistant-yoimiya-theme .ai-assistant-message.assistant .ai-assistant-message-bubble::before {
    content: '';
    position: absolute;
    left: -35px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: url('../images/yoimiya/烟花装饰元素.png') no-repeat center;
    background-size: contain;
    opacity: 0.7;
    animation: fireworkPulse 2.5s ease-in-out infinite;
}

/* 烟花脉冲动画 */
@keyframes fireworkPulse {
    0%, 100% {
        opacity: 0.5;
        transform: translateY(-50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.15);
    }
}

/* 用户消息气泡右侧的火焰装饰 */
.ai-assistant-yoimiya-theme .ai-assistant-message.user .ai-assistant-message-bubble::after {
    content: '';
    position: absolute;
    right: -35px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: url('../images/yoimiya/火焰图标.png') no-repeat center;
    background-size: contain;
    opacity: 0.8;
    animation: flameFlicker 1.5s ease-in-out infinite;
}

/* 火焰闪烁动画 */
@keyframes flameFlicker {
    0%, 100% {
        opacity: 0.6;
        transform: translateY(-50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateY(-50%) scale(1.1);
    }
}

/* ==================== 打字动画效果 ==================== */
.ai-assistant-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 153, 102, 0.1);
    border-radius: 12px;
}

.ai-assistant-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #FF9966;
    animation: typingDot 1.4s ease-in-out infinite;
}

.ai-assistant-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-assistant-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ==================== 响应式优化 ==================== */
@media (max-width: 768px) {
    .ai-assistant-yoimiya-theme .ai-assistant-container {
        border-radius: 0;
        border: none;
    }

    /* 移动端优化立绘显示 - 缩小并显示在对话框顶部 */
    body .ai-assistant-yoimiya-theme .yoimiya-illustration-wrapper,
    body .yoimiya-illustration-wrapper {
        display: block !important; /* 强制显示 */
        position: absolute !important; /* 改为absolute定位 */
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        top: 60px !important; /* 显示在对话框顶部，留出标题栏空间 */
        bottom: auto !important;
        width: 100px !important; /* 缩小宽度 */
        height: 120px !important; /* 缩小高度 */
        z-index: 1 !important;
        opacity: 0.5 !important; /* 半透明，不遮挡内容 */
        pointer-events: none !important; /* 不阻挡点击 */
    }

    body .ai-assistant-yoimiya-theme .yoimiya-character-illustration,
    body .yoimiya-character-illustration,
    body .ai-assistant-yoimiya-theme .yoimiya-illustration-wrapper img,
    body .yoimiya-illustration-wrapper img {
        display: block !important; /* 强制显示 */
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        animation: none !important; /* 移除动画，节省性能 */
        filter: drop-shadow(0 4px 12px rgba(255, 153, 102, 0.3)) !important;
    }

    /* 移动端缩小表情包 */
    .ai-assistant-message-emoji {
        width: 24px;
        height: 24px;
    }

    .ai-assistant-message.assistant .ai-assistant-message-emoji {
        width: 28px;
        height: 28px;
    }
}

