/* ============================================================
   智蝶AI · 获客助手 —— v1.3「灵动层」
   ------------------------------------------------------------
   背景：谷总反馈「不够 AI、不够灵动、色系沉暗」。
   本文件只做三件事，其余一律不碰：
     1. 让「AI 正在工作」看得见（思考可视化 + 流式输出光标）
     2. 让平面元素有景深与呼吸（柔光、渐变描边、极光辉光）
     3. 动效全部走 transform/opacity，并尊重 prefers-reduced-motion
   ⚠️ 变量在 style.css 的 :root，改色只改那里。
   ⚠️ 这个文件是叠加层，删掉即可回退到 v1.2 视觉。
   ============================================================ */

/* ============ 1. 元素景深：柔光 + 极光描边 ============ */

.panel,
.chat-container,
.auth-card,
.studio-card,
.asset-card,
.lead-card,
.auto-task,
.lp-card,
.lp-step,
.lp-plan {
    position: relative;
    box-shadow: 0 14px 44px rgba(4, 6, 20, 0.42);
    transition: box-shadow 0.32s ease, border-color 0.32s ease, transform 0.32s ease;
}

/* 顶部一道极光细边，代替原来的死板 1px 灰边 */
.panel::after,
.chat-container::after,
.auth-card::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 12%;
    right: 12%;
    height: 1px;
    border-radius: 1px;
    background: var(--accent);
    opacity: 0.5;
    pointer-events: none;
}

.panel:hover,
.studio-card:hover,
.asset-card:hover,
.lead-card:hover,
.auto-task:hover,
.lp-card:hover,
.lp-step:hover,
.lp-plan:hover {
    box-shadow: 0 18px 54px rgba(4, 6, 20, 0.5), var(--glow);
}

/* 主按钮：极光渐变 + 悬停流光扫过 */
.btn-primary {
    background: var(--accent);
    background-size: 180% 100%;
    border: none;
    color: #05122B;
    font-weight: 650;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.32);
    transition: background-position 0.5s ease, box-shadow 0.3s ease, transform 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background-position: 100% 0;
    box-shadow: 0 6px 28px rgba(45, 212, 255, 0.42);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    box-shadow: none;
}

/* 导航高亮：用极光文字代替纯色块 */
.nav-item.active {
    background: none;
    border: 1px solid var(--line-strong);
    color: var(--text);
    box-shadow: inset 0 0 22px rgba(139, 92, 246, 0.2);
}

/* 输入框聚焦：极光光环呼吸 */
#messageInput:focus,
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: rgba(45, 212, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(45, 212, 255, 0.13), 0 0 26px rgba(139, 92, 246, 0.22);
}

/* ============ 2. 「AI 正在工作」可视化 ============ */

.ai-think {
    display: flex;
    align-items: flex-start;
    gap: 13px;
}

/* 旋转的极光球：三层圆锥渐变叠加，看起来"在运转" */
.ai-think-orb {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background:
        conic-gradient(from 0deg, #2DD4FF, #8B5CF6, #F472B6, #2DD4FF);
    filter: blur(0.4px);
    animation: orbSpin 2.6s linear infinite, orbPulse 2.6s ease-in-out infinite;
    box-shadow: 0 0 18px rgba(139, 92, 246, 0.5);
    position: relative;
}

.ai-think-orb::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background: var(--bg-elevated);
}

@keyframes orbSpin {
    to { transform: rotate(360deg); }
}

@keyframes orbPulse {
    0%, 100% { box-shadow: 0 0 14px rgba(139, 92, 246, 0.42); }
    50%      { box-shadow: 0 0 26px rgba(45, 212, 255, 0.62); }
}

.ai-think-steps {
    flex: 1;
    min-width: 0;
    padding-top: 3px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ai-step {
    position: relative;
    padding-left: 16px;
    font-size: 13px;
    line-height: 1.65;
    color: var(--text-dim);
    transition: color 0.3s ease;
}

.ai-step::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--line-strong);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.ai-step.done {
    color: var(--text-muted);
}

.ai-step.done::before {
    background: var(--success);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}

.ai-step.active {
    color: var(--text);
    font-weight: 500;
}

.ai-step.active::before {
    background: var(--cyan);
    box-shadow: 0 0 10px rgba(45, 212, 255, 0.8);
    animation: stepBlink 1.1s ease-in-out infinite;
}

@keyframes stepBlink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

/* 正在生成时的那条流动光带 */
.ai-think-bar {
    margin-top: 9px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, rgba(45, 212, 255, 0.9), rgba(139, 92, 246, 0.9), transparent);
    background-size: 45% 100%;
    background-repeat: no-repeat;
    animation: barSweep 1.9s ease-in-out infinite;
}

@keyframes barSweep {
    0%   { background-position: -50% 0; }
    100% { background-position: 150% 0; }
}

/* ============ 3. 流式输出光标 ============ */

.stream-cursor {
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 1px;
    vertical-align: text-bottom;
    background: var(--cyan);
    box-shadow: 0 0 8px var(--cyan);
    animation: caretBlink 0.9s steps(1) infinite;
}

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

/* 助手气泡：左侧一道极光竖条，暗示"这是 AI 说的" */
.message.assistant .message-content {
    position: relative;
    border-left: 2px solid transparent;
    border-image: linear-gradient(180deg, #2DD4FF, #8B5CF6, #F472B6) 1;
}

/* ============ 4. 在线状态指示（"系统活着"的信号） ============ */

.ai-live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: 12px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 覆盖 .chat-header span::before 原有的装饰，避免多出一个方块 */
.chat-header .ai-live::before {
    display: none;
}

.ai-live i {
    flex: 0 0 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 9px rgba(52, 211, 153, 0.85);
    animation: livePulse 2.2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%      { opacity: 0.45; transform: scale(0.82); }
}

@media (max-width: 720px) {
    .ai-live {
        display: none;      /* 手机端标题栏太挤，直接隐藏 */
    }
}

/* ============ 5. 无障碍：用户要求减少动效时全部静止 ============ */

@media (prefers-reduced-motion: reduce) {
    body::before,
    .ai-think-orb,
    .ai-think-bar,
    .ai-live i,
    .ai-step.active::before,
    .stream-cursor {
        animation: none !important;
    }
    * {
        transition-duration: 0.01ms !important;
    }
}

/* 低端机 / 省流：关掉模糊与动画（模糊是移动端掉帧的头号原因） */
@media (max-width: 720px) {
    body::before {
        filter: blur(30px);
        animation-duration: 44s;
    }
    .ai-think-orb {
        flex: 0 0 26px;
        width: 26px;
        height: 26px;
    }
}
