/* ============================================================
 * aisearch.css
 * AI 问答对话框 + 内嵌卡片/链接样式（从 template/ds3/name/vod/search.html 抽出）
 * 依赖：search.html 中已有的 DOM 节点（#ai-chat-panel / .ai-card / .ai-link-row ...）
 * ============================================================ */

/* ============ AI 聊天面板 ============ */
.ai-chat-panel {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 540px;
    height: 680px;
    max-height: calc(100vh - 48px);
    background: #1a1b25;
    border: 1px solid #333;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    z-index: 9999;
    flex-direction: column;
    overflow: hidden;
    font-size: 14px;
    /* 拖动时禁用 transition 抖动 */
    will-change: left, top;
}
.ai-chat-panel.ai-chat-open { display: flex; }

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #21222e;
    border-bottom: 1px solid #333;
    flex: none;
    cursor: move;
    -webkit-user-select: none;
    user-select: none;
    /* 拖动时更明显的可拖感 */
    touch-action: none;
}

.ai-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 16px;
    color: #ccc;
    min-height: 0;
}

.ai-chat-input-row {
    display: flex;
    padding: 12px;
    border-top: 1px solid #333;
    flex: none;
    background: #21222e;
}
.ai-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #444;
    border-radius: 8px;
    background: #111;
    color: #fff;
    font-size: 14px;
    outline: none;
}
.ai-chat-input:focus { border-color: #6177ff; }
.ai-chat-send {
    margin-left: 10px;
    padding: 10px 20px;
    background: #6177ff;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}
.ai-chat-send:hover { background: #4f63e0; }

/* AI 聊天内 卡片/链接 通用样式 */
.ai-card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.ai-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid #333;
    border-radius: 8px;
    text-decoration: none;
    color: #e0e0e0;
    background: #1c1d28;
    min-width: 0;
}
.ai-card:hover { border-color: #6177ff; background: #232436; }
.ai-card-cover {
    width: 52px;
    height: 70px;
    flex: none;
    border-radius: 4px;
    background: #0f0f17;
    background-size: cover;
    background-position: center;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #444;
}
.ai-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ai-card-body { flex: 1; min-width: 0; }
.ai-card-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-card-meta {
    font-size: 11px;
    color: #888;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-link-list { display: flex; flex-direction: column; gap: 6px; }
.ai-link-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid #333;
    border-radius: 6px;
    text-decoration: none;
    color: #e0e0e0;
    background: #1c1d28;
    font-size: 13px;
    min-width: 0;
}
.ai-link-row:hover { border-color: #6177ff; background: #232436; }
.ai-link-row .ai-link-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-link-row .ai-link-host {
    font-size: 10px;
    color: #888;
    flex: none;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 3px;
    background: #2a2b3a;
}
.ai-section-title {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 8px;
    font-weight: 500;
}
.ai-section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #444;
}

/* ---------- 响应式：平板 ---------- */
@media (max-width: 1024px) {
    .ai-chat-panel {
        width: 460px;
        height: 600px;
        bottom: 16px;
        right: 16px;
    }
}

/* ---------- 响应式：手机 ---------- */
@media (max-width: 768px) {
    .ai-chat-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        max-height: none;
        bottom: 10px;
        right: 10px;
        left: 10px;
        border-radius: 12px;
    }
    .ai-card-grid { grid-template-columns: 1fr; gap: 8px; }
    .ai-card-cover { width: 48px; height: 64px; }
}

/* ---------- 超窄屏 (竖屏小手机) ---------- */
@media (max-width: 380px) {
    .ai-chat-panel {
        bottom: 6px;
        right: 6px;
        left: 6px;
        width: calc(100vw - 12px);
    }
    .ai-chat-header { padding: 10px 12px; }
    .ai-chat-messages { padding: 10px 12px; }
    .ai-chat-input-row { padding: 8px; }
    .ai-card-cover { width: 42px; height: 56px; }
}
/* ============================================================
 * 全站 AI 入口按钮（head.html 顶部，紧贴 .this-search 右侧）
 * add by nelson 2026-07-16
 * ============================================================ */
.ai-qa-trigger {
    position: relative; /* 供气泡定位 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: #6177ff;
    font-size: 26px;            /* iconfont i 标签会继承这个尺寸 */
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    flex: none;
    line-height: 1;
}
/* ★ 专门覆盖 i 标签：iconfont-ylfb 的尺寸由 1em 决定，需明确指定 */
.ai-qa-trigger > i {
    font-size: 30px;
    line-height: 1;
    display: inline-block;
}
.ai-qa-trigger:hover {
    background: rgba(97, 119, 255, 0.12);
    transform: scale(1.08);
    color: #4f63e0;
}
.ai-qa-trigger:active {
    transform: scale(0.96);
}

/* ============ Hover 气泡提示 ============ */
.ai-qa-trigger::after {
    content: 'AI 影视问答';
    position: absolute;
    top: calc(100% + 10px);       /* 按钮下方 */
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
    z-index: 10000;
    font-family: inherit;
}
/* 小三角 */
.ai-qa-trigger::before {
    content: '';
    position: absolute;
    top: calc(100% + 4px);        /* 贴按钮下边 */
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    border: 6px solid transparent;
    border-bottom-color: rgba(0, 0, 0, 0.85);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
    z-index: 10000;
}
/* hover 时显示 + 下滑动画 */
.ai-qa-trigger:hover::after,
.ai-qa-trigger:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
/* 主题色适配（与 footer 图标风格一致） */
.theme1 .ai-qa-trigger { color: #ff5c5c; }
.theme1 .ai-qa-trigger:hover { background: rgba(255, 92, 92, 0.12); color: #ff3838; }
.theme2 .ai-qa-trigger { color: #ff9800; }
.theme2 .ai-qa-trigger:hover { background: rgba(255, 152, 0, 0.12); color: #f57c00; }

/* 移动端微调 */
@media (max-width: 768px) {
    .ai-qa-trigger { width: 36px; height: 36px; font-size: 20px; margin-left: 4px; }
    .ai-qa-trigger > i { font-size: 20px; }
    /* 移动端用 :active 也能看到 tooltip，避免 hover 闲置 */
    .ai-qa-trigger:active::after,
    .ai-qa-trigger:active::before { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
}

/* ★ Phase 10: token streaming 视觉 */
.stage-tag { display:inline-block; padding:1px 6px; margin:1px; border-radius:8px; font-size:11px; }
.stage-tag.stage-done   { background:#e0e0e0; color:#888; }
.stage-tag.stage-active { background:#fff3cd; color:#b58900; font-weight:600;
                          animation: stagePulse 1.2s ease-in-out infinite; }
.typing-cursor { color:#b58900; animation: cursorBlink 1s steps(1) infinite; }
@keyframes stagePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,193,7,0.5); }
    50%      { opacity: 0.7; box-shadow: 0 0 0 4px rgba(255,193,7,0.0); }
}
@keyframes cursorBlink {
    0%, 50%  { opacity: 1; }
    51%, 100%{ opacity: 0; }
}
