/**
 * 以道解惑 - 加载动画样式
 * 只在对话面板使用时加载
 */

/* 加载占位区样式 */
.loading-message {
    position: relative;
    background-color: var(--button-bg-color);
    border-left: 3px solid #3b82f6;
    overflow: hidden;
    /* 确保消息不会超出聊天区域 */
    box-sizing: border-box;
    min-height: 3rem;
    margin-bottom: 1rem;
}

/* 统一子元素的盒模型 */
.loading-message * {
    box-sizing: border-box;
}

.loading-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        rgba(59, 130, 246, 0.1) 0%, 
        rgba(59, 130, 246, 0.05) 50%, 
        rgba(59, 130, 246, 0.1) 100%);
    animation: loadingShimmer 2s infinite;
    z-index: 0;
}

.loading-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
    /* 确保内容不会超出容器 */
    padding: 0.2rem 0;
}

.loading-text {
    font-size: 0.9rem;
    color: var(--text-color);
    font-style: italic;
}

.loading-animation {
    display: flex;
    gap: 0.3rem;
    align-items: center;
    margin-top: 0.3rem;
    /* 确保动画不会超出容器 */
    padding-bottom: 0.2rem;
}

.loading-dot {
    width: 0.5rem;
    height: 0.5rem;
    background-color: #3b82f6;
    border-radius: 50%;
    animation: dotPulse 1.4s infinite ease-in-out both;
    opacity: 0.7;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* 思考阶段特殊样式 */
.loading-message.thinking .loading-dot {
    background-color: #3b82f6;
}

/* 古典毛笔书写效果 */
.loading-message.writing::after {
    content: '';
    position: absolute;
    bottom: 0.5rem;
    right: 0.75rem;
    width: 1px;
    height: 0.8rem;
    background-color: var(--text-color);
    opacity: 0.7;
    animation: writingCursor 1s infinite;
}

/* 古文渐显效果 */
.loading-message.revealing .loading-text {
    background: linear-gradient(to right, 
        var(--text-color) 0%, 
        var(--text-color) 40%, 
        transparent 50%);
    background-size: 200% 100%;
    animation: textReveal 3s infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 动画定义 */
@keyframes loadingShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 0.7;
    }
}

@keyframes writingCursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes textReveal {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 输入框抖动动画 */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}