/* ============================================================
   AI 助教「小幻语」增强样式
   在原面板基础上补充：流式回答、工具调用卡片、安全拦截、思考态
   ============================================================ */

/* ---------- 思考中占位 ---------- */
.assistant-pending {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #7fb4cc;
}

.assistant-dots {
    display: inline-flex;
    gap: 3px;
}

.assistant-dots i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #2ee6ff;
    animation: assistantBlink 1.2s infinite;
}

.assistant-dots i:nth-child(2) { animation-delay: 0.15s; }
.assistant-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes assistantBlink {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ---------- 工具调用卡片 ---------- */
.assistant-tool {
    align-self: flex-start;
    max-width: 92%;
    margin: 2px 0;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 11.5px;
    color: #9fe8fa;
    background: rgba(46, 230, 255, 0.06);
    border: 1px dashed rgba(46, 230, 255, 0.35);
    animation: assistantToolIn 0.25s ease-out;
}

@keyframes assistantToolIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.assistant-tool-title {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.assistant-tool-detail {
    margin-top: 5px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 10.5px;
    line-height: 1.6;
    color: #7fb4cc;
    word-break: break-all;
}

.assistant-tool.done {
    border-style: solid;
    border-color: rgba(52, 211, 153, 0.42);
    color: #9cf0cd;
}

.assistant-tool.done .assistant-tool-detail {
    color: #86d9c0;
}

/* ---------- 知识来源卡片 ---------- */
.assistant-sources {
    align-self: flex-start;
    max-width: 92%;
    margin: 2px 0;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 11px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.32);
    animation: assistantToolIn 0.25s ease-out;
}

.assistant-sources-title {
    font-weight: 600;
    color: #c4b5fd;
    letter-spacing: 0.02em;
}

.assistant-source-item {
    margin-top: 6px;
}

.assistant-source-ref {
    color: #a5b4fc;
    font-weight: 600;
}

.assistant-source-snippet {
    margin-top: 2px;
    color: #8fa8c4;
    line-height: 1.55;
}

/* ---------- 安全拦截气泡 ---------- */
.assistant-message.blocked {
    color: #ffe1a3 !important;
    background: rgba(251, 191, 36, 0.12) !important;
    border: 1px solid rgba(251, 191, 36, 0.45) !important;
}

/* ---------- 流式输出光标 ---------- */
.assistant-message.assistant.streaming::after {
    content: "▍";
    margin-left: 2px;
    color: #2ee6ff;
    animation: assistantBlink 1s steps(2) infinite;
}

/* ============================================================
   多模态：拍照识别
   ============================================================ */

/* 相机按钮 */
.assistant-camera {
    flex: none;
    width: 38px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: #9fe8fa;
    background: rgba(46, 230, 255, 0.08);
    border: 1px solid rgba(46, 230, 255, 0.28);
    transition: all 0.2s ease;
}

.assistant-camera:hover {
    color: #eafcff;
    background: rgba(46, 230, 255, 0.2);
    border-color: rgba(46, 230, 255, 0.7);
    box-shadow: 0 0 14px rgba(46, 230, 255, 0.35);
}

.assistant-camera:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

/* 用户上传的图片缩略图 */
.assistant-thumb {
    max-width: 160px;
    max-height: 120px;
    border-radius: 8px;
    border: 1px solid rgba(46, 230, 255, 0.35);
    object-fit: cover;
    display: block;
}

/* 识别结果卡片 */
.assistant-vision {
    align-self: flex-start;
    max-width: 94%;
    padding: 12px 14px;
    border-radius: 11px;
    background: linear-gradient(180deg, rgba(12, 32, 52, 0.95), rgba(7, 20, 34, 0.95));
    border: 1px solid rgba(46, 230, 255, 0.28);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: assistantToolIn 0.25s ease-out;
}

.assistant-vision-type {
    font-size: 10.5px;
    letter-spacing: 0.12em;
    color: #6f97b0;
    margin-bottom: 7px;
}

.assistant-vision-content {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 15px;
    font-weight: 600;
    color: #9fe8fa;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
    word-break: break-word;
}

.assistant-vision-row {
    display: flex;
    gap: 7px;
    font-size: 12px;
    line-height: 1.65;
    color: #bdd7e6;
    margin-top: 5px;
}

.assistant-vision-row .label {
    flex: none;
    color: #7fb4cc;
}

.assistant-vision-balance {
    margin-top: 8px;
    padding: 7px 10px;
    border-radius: 7px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12.5px;
    color: #9cf0cd;
    background: rgba(52, 211, 153, 0.09);
    border-left: 2px solid rgba(52, 211, 153, 0.6);
}

.assistant-vision-balance.invalid {
    color: #ffc978;
    background: rgba(251, 191, 36, 0.09);
    border-left-color: rgba(251, 191, 36, 0.6);
}

.assistant-vision-safety {
    margin-top: 8px;
    padding: 7px 10px;
    border-radius: 7px;
    font-size: 11.5px;
    line-height: 1.6;
    color: #ffe1a3;
    background: rgba(251, 191, 36, 0.1);
    border-left: 2px solid rgba(251, 191, 36, 0.65);
}

.assistant-vision-low {
    margin-top: 6px;
    font-size: 11px;
    color: #ff9f9f;
}

/* 视觉链路降级提示 */
.assistant-vision-degrade {
    margin-top: 6px;
    padding: 6px 9px;
    border-radius: 7px;
    font-size: 11px;
    line-height: 1.55;
    color: #ffe1a3;
    background: rgba(251, 191, 36, 0.1);
    border: 1px dashed rgba(251, 191, 36, 0.5);
}

/* ---------- 知识来源：查看依据 ---------- */
.assistant-source-head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.assistant-source-id {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 9.5px;
    color: #8b7fd6;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 4px;
    padding: 1px 5px;
}

.assistant-source-more {
    margin-left: auto;
    font-size: 10px;
    color: #7dd3fc;
}

.assistant-source-item {
    padding: 5px 7px;
    margin: 6px -7px 0;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.18s ease;
}

.assistant-source-item:hover,
.assistant-source-item:focus-visible {
    background: rgba(139, 92, 246, 0.16);
    outline: none;
}

/* ---------- 可解释性提示（系统建议 / 降级链路） ---------- */
.assistant-notice {
    align-self: flex-start;
    max-width: 92%;
    margin: 2px 0;
    padding: 8px 11px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.6;
    animation: assistantToolIn 0.25s ease-out;
}

.assistant-notice-title {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.assistant-notice-text {
    margin-top: 3px;
}

.assistant-notice.warn {
    color: #ffe1a3;
    background: rgba(251, 191, 36, 0.09);
    border: 1px dashed rgba(251, 191, 36, 0.5);
}

.assistant-notice.hint {
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.09);
    border: 1px dashed rgba(139, 92, 246, 0.45);
}

/* ---------- 文档问答入口 ---------- */
.assistant-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 0;
}

.assistant-tool-btn {
    flex: none;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(139, 92, 246, 0.45);
    background: rgba(139, 92, 246, 0.12);
    color: #c4b5fd;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.assistant-tool-btn:hover,
.assistant-tool-btn:focus-visible {
    background: rgba(139, 92, 246, 0.26);
    color: #fff;
    outline: none;
}

.assistant-tool-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.assistant-tools-tip {
    font-size: 9.5px;
    color: #5f8499;
    line-height: 1.4;
}

/* ---------- 文档问答弹窗 ---------- */
.doc-mask {
    position: fixed;
    inset: 0;
    z-index: 320;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3, 9, 14, 0.7);
    backdrop-filter: blur(3px);
}

.doc-dialog {
    width: min(520px, 100%);
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(10, 23, 32, 0.98);
    border: 1px solid rgba(139, 92, 246, 0.42);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.doc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 9px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.doc-title {
    font-size: 13px;
    font-weight: 700;
    color: #ddd6fe;
}

.doc-close {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.doc-close:hover {
    color: #fff;
    border-color: rgba(139, 92, 246, 0.6);
    background: rgba(139, 92, 246, 0.2);
}

.doc-tip {
    margin: 9px 0 8px;
    font-size: 11px;
    line-height: 1.6;
    color: #8fa8c4;
}

.doc-upload {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.doc-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid rgba(46, 230, 255, 0.34);
    background: rgba(46, 230, 255, 0.08);
    color: #9fe8fa;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.doc-upload-btn:hover {
    background: rgba(46, 230, 255, 0.2);
    border-color: rgba(46, 230, 255, 0.65);
    color: #fff;
}

.doc-upload-tip {
    font-size: 9.5px;
    color: #5f8499;
}

.doc-textarea {
    width: 100%;
    height: 168px;
    resize: vertical;
    padding: 10px 11px;
    border-radius: 9px;
    border: 1px solid rgba(139, 92, 246, 0.26);
    background: rgba(255, 255, 255, 0.04);
    color: #e6fbff;
    font-size: 12px;
    line-height: 1.7;
    outline: none;
    font-family: inherit;
}

.doc-textarea:focus {
    border-color: rgba(139, 92, 246, 0.7);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.doc-counter {
    margin-top: 4px;
    text-align: right;
    font-size: 9.5px;
    color: #5f8499;
}

.doc-question {
    width: 100%;
    height: 36px;
    margin-top: 8px;
    padding: 0 11px;
    border-radius: 9px;
    border: 1px solid rgba(46, 230, 255, 0.22);
    background: rgba(255, 255, 255, 0.04);
    color: #e6fbff;
    font-size: 12px;
    outline: none;
}

.doc-question:focus {
    border-color: rgba(46, 230, 255, 0.65);
    box-shadow: 0 0 0 3px rgba(46, 230, 255, 0.1);
}

.doc-question::placeholder,
.doc-textarea::placeholder {
    color: #5f8499;
}

.doc-error {
    margin-top: 8px;
    padding: 6px 9px;
    border-radius: 7px;
    font-size: 11px;
    color: #fecaca;
    background: rgba(248, 113, 113, 0.1);
    border: 1px dashed rgba(248, 113, 113, 0.45);
}

.doc-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.doc-cancel,
.doc-submit {
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 11.5px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.doc-cancel {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: transparent;
    color: #a9c4d4;
}

.doc-cancel:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.doc-submit {
    border: 1px solid rgba(46, 230, 255, 0.5);
    background: linear-gradient(135deg, rgba(46, 230, 255, 0.26), rgba(139, 92, 246, 0.24));
    color: #eafcff;
}

.doc-submit:hover {
    background: linear-gradient(135deg, rgba(46, 230, 255, 0.4), rgba(139, 92, 246, 0.34));
}

.doc-submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---------- 异常状态与重试入口 ---------- */
.assistant-error {
    align-self: flex-start;
    max-width: 92%;
    margin: 2px 0;
    padding: 8px 11px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.6;
    color: #fecaca;
    background: rgba(248, 113, 113, 0.1);
    border: 1px dashed rgba(248, 113, 113, 0.5);
    animation: assistantToolIn 0.25s ease-out;
}

.assistant-error-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.assistant-retry {
    margin-top: 7px;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: #fff7e6;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.assistant-retry:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.assistant-retry:active {
    transform: translateY(0);
}

/* ---------- 查看依据弹窗 ---------- */
.evidence-mask {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3, 9, 14, 0.66);
    backdrop-filter: blur(3px);
    animation: evidenceFade 0.18s ease-out;
}

@keyframes evidenceFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.evidence-dialog {
    width: min(440px, 100%);
    max-height: 76vh;
    display: flex;
    flex-direction: column;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(10, 23, 32, 0.97);
    border: 1px solid rgba(139, 92, 246, 0.42);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    animation: evidencePop 0.2s ease-out;
}

@keyframes evidencePop {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.evidence-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.evidence-title {
    font-size: 13px;
    font-weight: 700;
    color: #ddd6fe;
}

.evidence-close {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.18s ease;
}

.evidence-close:hover {
    color: #fff;
    border-color: rgba(139, 92, 246, 0.6);
    background: rgba(139, 92, 246, 0.2);
}

.evidence-meta {
    margin-top: 10px;
    display: grid;
    gap: 4px;
}

.evidence-row {
    display: flex;
    gap: 10px;
    font-size: 11.5px;
}

.evidence-row .k {
    flex: none;
    width: 56px;
    color: #7c93aa;
}

.evidence-row .v {
    color: #bfe6f5;
    word-break: break-all;
}

.evidence-quote {
    margin-top: 12px;
    padding: 11px 13px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.75;
    color: #d7e6f2;
    background: rgba(139, 92, 246, 0.08);
    border-left: 3px solid rgba(139, 92, 246, 0.6);
    overflow-y: auto;
}

.evidence-foot {
    margin-top: 10px;
    font-size: 10.5px;
    line-height: 1.6;
    color: #6f8598;
}

/* 首屏 AI 模式入口样式已随入口按钮一起移除 */

/* AI 面板空态：给出可点的示例问题，避免打开后一片空白 */
.assistant-empty {
    padding: 14px 4px;
    text-align: left;
}

.assistant-empty-title {
    font-size: 13px;
    font-weight: 600;
    color: #eafcff;
    margin-bottom: 6px;
}

.assistant-empty-text {
    font-size: 12px;
    line-height: 1.6;
    color: #9fb6c6;
    margin-bottom: 12px;
}

.assistant-empty-chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assistant-chip {
    text-align: left;
    font-size: 12px;
    line-height: 1.5;
    color: #cfeaf5;
    background: rgba(46, 230, 255, 0.07);
    border: 1px solid rgba(46, 230, 255, 0.22);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.assistant-chip:hover,
.assistant-chip:focus-visible {
    background: rgba(46, 230, 255, 0.16);
    border-color: rgba(46, 230, 255, 0.6);
    transform: translateX(2px);
    outline: none;
}

/* ---------- 随堂小测弹窗 ---------- */
.quiz-dialog {
    width: min(560px, 100%);
}

.quiz-loading {
    padding: 26px 0;
    text-align: center;
    font-size: 12px;
    color: #8fa8c4;
}

.quiz-body {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding-right: 4px;
}

.quiz-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quiz-stem {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.65;
    color: #e6fbff;
}

.quiz-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: #c8dbe8;
    font-size: 11.5px;
    line-height: 1.6;
    text-align: left;
    cursor: pointer;
    transition: all 0.16s ease;
}

.quiz-option:hover:not(:disabled) {
    border-color: rgba(46, 230, 255, 0.5);
    background: rgba(46, 230, 255, 0.1);
    color: #fff;
}

.quiz-option:disabled {
    cursor: default;
    opacity: 0.9;
}

.quiz-option.picked {
    border-color: rgba(46, 230, 255, 0.75);
    background: rgba(46, 230, 255, 0.14);
    color: #e8fdff;
}

.quiz-option.correct {
    border-color: rgba(74, 222, 128, 0.75);
    background: rgba(74, 222, 128, 0.14);
    color: #e7ffee;
}

.quiz-option.wrong {
    border-color: rgba(248, 113, 113, 0.7);
    background: rgba(248, 113, 113, 0.12);
    color: #ffe8e8;
}

.quiz-option-key {
    flex: none;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.28);
    color: #ddd6fe;
    font-size: 10px;
    line-height: 17px;
    text-align: center;
}

.quiz-option-text {
    word-break: break-word;
}

.quiz-explain {
    margin-top: 2px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.65;
    color: #c9f7d8;
    background: rgba(74, 222, 128, 0.08);
    border-left: 3px solid rgba(74, 222, 128, 0.65);
}

.quiz-explain.wrong {
    color: #ffd9d9;
    background: rgba(248, 113, 113, 0.08);
    border-left-color: rgba(248, 113, 113, 0.65);
}

.quiz-score {
    margin-top: 10px;
    text-align: right;
    font-size: 12px;
    font-weight: 700;
    color: #9fe8fa;
}

/* ---------- 引用溯源：回答中的来源名做成可点击卡片 ---------- */
.citation-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin: 0 2px;
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid rgba(46, 230, 255, 0.45);
    background: rgba(46, 230, 255, 0.1);
    color: #9fe8fa;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.7;
    cursor: pointer;
    transition: all 0.16s ease;
    text-decoration: none;
}

.citation-chip:hover,
.citation-chip:focus-visible {
    background: rgba(46, 230, 255, 0.24);
    border-color: rgba(46, 230, 255, 0.8);
    color: #ffffff;
    outline: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(46, 230, 255, 0.25);
}

.citation-chip:active {
    transform: translateY(0);
}
